From 4c150aab138f5733d29ad4548d66764fe19ffc44 Mon Sep 17 00:00:00 2001 From: cflip Date: Thu, 12 Jan 2023 12:19:08 -0700 Subject: 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. --- editor.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'editor.h') diff --git a/editor.h b/editor.h index 63f6c76..7df152a 100644 --- a/editor.h +++ b/editor.h @@ -4,6 +4,12 @@ #include #include "buffer.h" +enum editor_mode { + EDITOR_MODE_NORMAL, + EDITOR_MODE_INSERT, + EDITOR_MODE_COMMAND +}; + struct editor_state { int cursor_x, cursor_y; int cursor_display_x; @@ -18,6 +24,7 @@ struct editor_state { char status_message[80]; time_t status_message_time; struct editor_syntax* syntax; + int mode; }; void init_editor(struct editor_state* editor); -- cgit v1.2.3