summaryrefslogtreecommitdiff
path: root/editor.c
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2023-01-12 12:19:08 -0700
committercflip <cflip@cflip.net>2023-01-12 12:21:03 -0700
commit4c150aab138f5733d29ad4548d66764fe19ffc44 (patch)
tree6559f4cfafb7abb9a10b4a12be0ec79ee5b93df7 /editor.c
parentab00e1e288743496e75c5e54c0e6abdecf439642 (diff)
Make the editor modal and refactor keyboard events
This makes the editor behave more like vi, with a seperate insert mode. This also refactors the keyboard input code to pass the SDL_Keysym structure to input.c and to use the SDL_TEXTINPUT event for editing text. SDL's text input event already fixes typing capital letters with shift, and should make it possible to enter text using an IME, however most unicode characters aren't properly rendered.
Diffstat (limited to 'editor.c')
-rw-r--r--editor.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/editor.c b/editor.c
index 58f18c9..d52d553 100644
--- a/editor.c
+++ b/editor.c
@@ -26,6 +26,7 @@ void init_editor(struct editor_state* editor)
editor->status_message[0] = '\0';
editor->status_message_time = 0;
editor->syntax = NULL;
+ editor->mode = EDITOR_MODE_NORMAL;
window_get_size(&editor->screen_rows, &editor->screen_cols);
@@ -153,6 +154,7 @@ static void editor_find_callback(struct editor_state* editor, char* query, int k
saved_highlight = NULL;
}
+ /* TODO:
if (key == '\r' || key == '\x1b') {
last_match = -1;
direction = 1;
@@ -165,6 +167,7 @@ static void editor_find_callback(struct editor_state* editor, char* query, int k
last_match = -1;
direction = 1;
}
+ */
if (last_match == -1)
direction = 1;