feat: simple overlay and window modes with intention setting
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#include "window_state.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
struct state *s = NULL;
|
||||
|
||||
#define INTENTION_MAX_SIZE 2048
|
||||
|
||||
struct state {
|
||||
Mode mode;
|
||||
char intention[INTENTION_MAX_SIZE];
|
||||
};
|
||||
|
||||
void init_window_state() {
|
||||
s = malloc(sizeof(struct state));
|
||||
s->mode = WINDOW;
|
||||
|
||||
memset(s->intention, 0, sizeof(s->intention));
|
||||
}
|
||||
|
||||
void cleanup_window_state() {
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
free(s);
|
||||
s = NULL;
|
||||
}
|
||||
|
||||
void set_intention(char *intention) {
|
||||
assert(s);
|
||||
|
||||
strncpy(s->intention, intention, sizeof(s->intention));
|
||||
s->intention[sizeof(s->intention) - 1] = '\0';
|
||||
}
|
||||
|
||||
char *get_intention() {
|
||||
assert(s);
|
||||
return s->intention;
|
||||
}
|
||||
|
||||
size_t get_intention_size() {
|
||||
assert(s);
|
||||
return sizeof(s->intention);
|
||||
}
|
||||
|
||||
Mode get_mode() {
|
||||
assert(s);
|
||||
return s->mode;
|
||||
}
|
||||
|
||||
void set_mode(Mode new_mode) {
|
||||
s->mode = new_mode;
|
||||
}
|
||||
Reference in New Issue
Block a user