summaryrefslogtreecommitdiff
path: root/editor.h
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.h
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.h')
-rw-r--r--editor.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/editor.h b/editor.h
index 63f6c76..7df152a 100644
--- a/editor.h
+++ b/editor.h
@@ -4,6 +4,12 @@
#include <time.h>
#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);