aboutsummaryrefslogtreecommitdiff
path: root/input_field.c
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2025-10-16 11:53:16 -0400
committerJack Jamison <jackqjamison@gmail.com>2025-10-16 11:53:16 -0400
commit46efa1936ec44ece2167480ccf4fa1b3af1218bc (patch)
tree8c6363e1050a80f51361bf70a4e03906eebcdfd9 /input_field.c
parent7f2c79d77de931d38d5359ba836f5b6dd77fdcc2 (diff)
you can type
Diffstat (limited to 'input_field.c')
-rw-r--r--input_field.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/input_field.c b/input_field.c
index 114019a..4bd09bb 100644
--- a/input_field.c
+++ b/input_field.c
@@ -2,6 +2,12 @@
#include "input_field.h"
#include "array.h"
+#include "graphics.h"
+
+void regenerate_text_buffer(client_state* state) {
+ destroy_text_buffer(&state->input_buffer_text);
+ init_text_buffer(state, &state->input_buffer_text, state->input_buffer, array_size(state->input_buffer));
+}
bool type_key(client_state* state, xkb_keysym_t keysym) {
bool ctrl = xkb_state_mod_name_is_active(state->xkb_state, XKB_MOD_NAME_CTRL, XKB_STATE_MODS_EFFECTIVE);
@@ -18,6 +24,7 @@ bool type_key(client_state* state, xkb_keysym_t keysym) {
// submit line
if (keysym == XKB_KEY_Return || keysym == XKB_KEY_KP_Enter) {
submit_line(state);
+ regenerate_text_buffer(state);
return false;
}
@@ -28,6 +35,7 @@ bool type_key(client_state* state, xkb_keysym_t keysym) {
} else {
array_pop(state->input_buffer);
}
+ regenerate_text_buffer(state);
return true;
}
@@ -36,8 +44,9 @@ bool type_key(client_state* state, xkb_keysym_t keysym) {
int len = xkb_keysym_to_utf8(keysym, buf, sizeof(buf));
if (len > 0) {
for (int i = 0; i < strlen(buf); i++) {
- array_add(state->input_buffer, buf[i]);
+ array_add(state->input_buffer, buf[i]);
}
+ regenerate_text_buffer(state);
return true;
}