aboutsummaryrefslogtreecommitdiff
path: root/keybind.c
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2025-11-04 17:29:52 -0500
committerJack Jamison <jackqjamison@gmail.com>2025-11-06 19:45:03 -0500
commit95fb3cad63941466e913775a3c080b310d45d13a (patch)
tree555cbaf4d5fd7454efbe6ab200e268c04b53ed49 /keybind.c
parent38d43004656a2d00960484e5e5a5ece46bde840b (diff)
refactor onfig file and delete word backward
Diffstat (limited to 'keybind.c')
-rw-r--r--keybind.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/keybind.c b/keybind.c
index 17baad1..910fd95 100644
--- a/keybind.c
+++ b/keybind.c
@@ -100,6 +100,27 @@ key_repeat_t delete_word(client_state* state) {
return KEY_REPEAT;
}
+key_repeat_t delete_word_backward(client_state* state) {
+ if (state->cursor_index) {
+ size_t startidx = state->cursor_index - 1;
+ bool hit_non_white = false;
+ for (; startidx > 0; startidx--) {
+ if (state->input_buffer[startidx] == ' ') {
+ if (hit_non_white) {
+ ++startidx;
+ break;
+ }
+ } else {
+ hit_non_white = true;
+ }
+ }
+ array_erase_range(state->input_buffer, startidx, state->cursor_index - 1);
+ state->cursor_index = startidx;
+ update_text_buffer(state);
+ }
+ return KEY_REPEAT;
+}
+
key_repeat_t delete_char(client_state* state) {
if (state->cursor_index != array_size(state->input_buffer)) {
array_erase(state->input_buffer, state->cursor_index);