diff options
-rw-r--r-- | buffer.c | 8 | ||||
-rw-r--r-- | command.c | 7 | ||||
-rw-r--r-- | command.h | 9 | ||||
-rw-r--r-- | ted.cfg | 7 |
4 files changed, 29 insertions, 2 deletions
@@ -695,6 +695,14 @@ void buffer_scroll(TextBuffer *buffer, double dx, double dy) { buffer_correct_scroll(buffer); } +void buffer_page_up(TextBuffer *buffer, i64 npages) { + buffer_scroll(buffer, 0, (double)(-npages * buffer_display_lines(buffer))); +} + +void buffer_page_down(TextBuffer *buffer, i64 npages) { + buffer_scroll(buffer, 0, (double)(+npages * buffer_display_lines(buffer))); +} + // returns the position of the character at the given position in the buffer. v2 buffer_pos_to_pixels(TextBuffer *buffer, BufferPos pos) { u32 line = pos.line, index = pos.index; @@ -100,6 +100,13 @@ void command_execute(Ted *ted, Command c, i64 argument) { case CMD_DELETE_WORD: buffer_delete_words_at_cursor(buffer, argument); break; + + case CMD_PAGE_DOWN: + buffer_page_down(buffer, argument); + break; + case CMD_PAGE_UP: + buffer_page_up(buffer, argument); + break; case CMD_SAVE: buffer_save(buffer); @@ -23,6 +23,10 @@ ENUM_U16 { CMD_SELECT_START_OF_FILE, CMD_SELECT_END_OF_FILE, + // scrolling + CMD_PAGE_UP, + CMD_PAGE_DOWN, + // deletion CMD_BACKSPACE, CMD_DELETE, @@ -40,7 +44,6 @@ typedef struct { char const *name; Command cmd; } CommandName; - static CommandName const command_names[CMD_COUNT] = { {"unknown", CMD_UNKNOWN}, {"noop", CMD_NOOP}, @@ -64,12 +67,14 @@ static CommandName const command_names[CMD_COUNT] = { {"end-of-file", CMD_END_OF_FILE}, {"select-start-of-file", CMD_SELECT_START_OF_FILE}, {"select-end-of-file", CMD_SELECT_END_OF_FILE}, + {"page-up", CMD_PAGE_UP}, + {"page-down", CMD_PAGE_DOWN}, {"backspace", CMD_BACKSPACE}, {"delete", CMD_DELETE}, {"backspace-word", CMD_BACKSPACE_WORD}, {"delete-word", CMD_DELETE_WORD}, {"save", CMD_SAVE}, {"undo", CMD_UNDO}, - {"redo", CMD_REDO} + {"redo", CMD_REDO}, }; @@ -31,6 +31,13 @@ Ctrl+Delete = :delete-word Backspace = :backspace Ctrl+Backspace = :backspace-word +# scrolling +PageUp = :page-up +PageDown = :page-down +Ctrl+PageUp = 10 :page-up +Ctrl+PageDown = 10 :page-down + Ctrl+s = :save Ctrl+z = :undo Ctrl+Shift+z = :redo + |