diff options
-rw-r--r-- | editor.c | 13 | ||||
-rw-r--r-- | editor.h | 3 | ||||
-rw-r--r-- | input.c | 14 |
3 files changed, 30 insertions, 0 deletions
@@ -140,6 +140,19 @@ void editor_delete_char(struct editor_state* editor) } } +void editor_add_line_above(struct editor_state* editor) +{ + insert_row(editor, editor->cursor_y, "", 0); + editor->cursor_x = 0; +} + +void editor_add_line_below(struct editor_state* editor) +{ + insert_row(editor, editor->cursor_y + 1, "", 0); + editor->cursor_y++; + editor->cursor_x = 0; +} + static void editor_find_callback(struct editor_state* editor, char* query, int key) { static int last_match = -1; @@ -40,6 +40,9 @@ void editor_move_down(struct editor_state *); void editor_insert_char(struct editor_state* editor, int c); void editor_insert_newline(struct editor_state* editor); void editor_delete_char(struct editor_state* editor); +void editor_add_line_above(struct editor_state* editor); +void editor_add_line_below(struct editor_state* editor); + void editor_find(struct editor_state* editor); void editor_scroll(struct editor_state* editor); void editor_draw_rows(struct editor_state* editor, struct append_buffer* buffer); @@ -62,6 +62,20 @@ void editor_process_keypress(struct editor_state *editor, SDL_Keysym *keysym) case SDLK_i: editor->mode = EDITOR_MODE_INSERT; break; + case SDLK_a: + if (keysym->mod & KMOD_SHIFT) + editor->cursor_x = editor->rows[editor->cursor_y].size; + else + editor_move_right(editor); + editor->mode = EDITOR_MODE_INSERT; + break; + case SDLK_o: + if (keysym->mod & KMOD_SHIFT) + editor_add_line_above(editor); + else + editor_add_line_below(editor); + editor->mode = EDITOR_MODE_INSERT; + break; case SDLK_k: editor_move_up(editor); break; |