diff options
author | pommicket <pommicket@gmail.com> | 2022-09-26 15:36:24 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-09-26 15:36:24 -0400 |
commit | 44c338433284b0ecb3c30cef5aae0cdb3b06901f (patch) | |
tree | c5b470bbeb487ce74486e92112320398d59e560e | |
parent | dfde7bff94240172d3a2a037ec0b77871b71bf56 (diff) |
shift+pageup/pagedown
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | buffer.c | 24 | ||||
-rw-r--r-- | command.c | 6 | ||||
-rw-r--r-- | command.h | 6 | ||||
-rw-r--r-- | ted.cfg | 2 |
5 files changed, 30 insertions, 9 deletions
@@ -8,6 +8,7 @@ Release tags TAGS *.o +*.out *.obj *.exe *.dll @@ -842,14 +842,6 @@ 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; @@ -1555,6 +1547,22 @@ void buffer_disable_selection(TextBuffer *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)); +} + +void buffer_select_page_up(TextBuffer *buffer, i64 npages) { + buffer_select_up(buffer, npages * (i64)buffer_display_lines(buffer)); +} + +void buffer_select_page_down(TextBuffer *buffer, i64 npages) { + buffer_select_down(buffer, npages * (i64)buffer_display_lines(buffer)); +} + static void buffer_shorten_line(Line *line, u32 new_len) { assert(line->len >= new_len); line->len = new_len; // @OPTIMIZE(memory): decrease line capacity @@ -182,6 +182,12 @@ void command_execute(Ted *ted, Command c, i64 argument) { case CMD_PAGE_UP: if (buffer) buffer_page_up(buffer, argument); break; + case CMD_SELECT_PAGE_DOWN: + if (buffer) buffer_select_page_down(buffer, argument); + break; + case CMD_SELECT_PAGE_UP: + if (buffer) buffer_select_page_up(buffer, argument); + break; case CMD_OPEN: menu_open(ted, MENU_OPEN); @@ -26,7 +26,9 @@ ENUM_U16 { CMD_SELECT_START_OF_FILE, CMD_SELECT_END_OF_FILE, CMD_SELECT_ALL, // select entire buffer - + CMD_SELECT_PAGE_UP, + CMD_SELECT_PAGE_DOWN, + // insertion CMD_TAB, // insert '\t' CMD_BACKTAB, @@ -125,6 +127,8 @@ static CommandName const command_names[] = { {"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}, + {"select-page-up", CMD_SELECT_PAGE_UP}, + {"select-page-down", CMD_SELECT_PAGE_DOWN}, {"select-all", CMD_SELECT_ALL}, {"page-up", CMD_PAGE_UP}, {"page-down", CMD_PAGE_DOWN}, @@ -88,6 +88,8 @@ Ctrl+Shift+Backspace = :backspace-word # scrolling PageUp = :page-up PageDown = :page-down +Shift+PageUp = :select-page-up +Shift+PageDown = :select-page-down Ctrl+o = :open Ctrl+n = :new |