diff options
| author | cflip <cflip@cflip.net> | 2023-01-31 10:46:21 -0700 |
|---|---|---|
| committer | cflip <cflip@cflip.net> | 2023-01-31 12:20:03 -0700 |
| commit | 757efb85045408e2601da0f53547941a40d2e960 (patch) | |
| tree | 0ab46da5222222971d3dd4bd7319262c6842be8a /window.c | |
| parent | c3da108c2d41853beb49a90a1f43a2a9a158c385 (diff) | |
Start implementing editor commands
This first step allows you to press the semicolon key to enter command
mode, where you can type into a command line. Currently, pressing enter
when in command mode will clear the command line but since there are no
commands implemented it doesn't matter what you type in there.
Diffstat (limited to 'window.c')
| -rw-r--r-- | window.c | 24 |
1 files changed, 11 insertions, 13 deletions
@@ -52,17 +52,7 @@ int window_handle_event(struct editor_state *editor) editor_process_keypress(editor, &e.key.keysym); break; case SDL_TEXTINPUT: - if (editor->mode == EDITOR_MODE_NORMAL) - break; - /* - * Ignore the first letter after entering insert mode, because it - * usually is just 'i'. - */ - if (editor->pressed_insert_key) { - editor->pressed_insert_key = 0; - break; - } - editor_insert_char(editor, *e.text.text); + input_process_textinput(editor, e.text.text); break; case SDL_WINDOWEVENT: if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { @@ -164,9 +154,17 @@ void window_redraw(struct editor_state *editor) editor_scroll(editor); draw_editor(editor); + int cursor_x = (editor->cursor_display_x - editor->col_offset); + int cursor_y = (editor->cursor_y - editor->line_offset); + + if (editor->mode == EDITOR_MODE_COMMAND) { + cursor_x = editor->cmdline.length; + cursor_y = editor->screen_rows + 1; + } + SDL_Rect cursor_rect; - cursor_rect.x = (editor->cursor_display_x - editor->col_offset) * font.width; - cursor_rect.y = (editor->cursor_y - editor->line_offset) * font.height; + cursor_rect.x = cursor_x * font.width; + cursor_rect.y = cursor_y * font.height; cursor_rect.w = font.width; cursor_rect.h = font.height; |
