suggestion picker: a persistent layer to complement virtual keyboards like wvkbd
suggestion: take from stdin
Zach DeCook 2022-01-21
parent 24f516a · commit da3ce83
-rw-r--r--main.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/main.c b/main.c
index 62b80e9..5ffb772 100644
--- a/main.c
+++ b/main.c
@@ -380,13 +380,29 @@ show(int sigint) {
}
void
-handle_input(FILE *fd) {
+handle_input(FILE *fd, struct key *sugg) {
char *line;
line = malloc(1024);
if (fgets(line, 1024, fd) != NULL) {
fprintf(stderr, "Retrieved line: %s", line);
-
+ int i;
+ struct key *key = sugg;
+ char *l = line;
+ for (i = 0; l[i+1]; i++) {
+ if (l[i] == '\t') {
+ // free label?
+ key->label = strndup(l,i);
+ l += i + 1;
+ i = 0;
+ key++;
+ } else if (l[i] == '\n') {
+ break;
+ }
+ }
+ key->label = strndup(l,i);
+ key+=sizeof(struct key*);
+ key->label = NULL;
}
free(line);
@@ -506,7 +522,7 @@ main(int argc, char **argv) {
while (run_display) {
while(layer_surface && poll(fds, 2, -1) != -1) {
if (fds[0].revents & POLLIN) {
- handle_input(stdin);
+ handle_input(stdin, keyboard.suggs);
}
if (wl_display_dispatch(display) == -1) {
break;