summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-09-26 15:36:24 -0400
committerpommicket <pommicket@gmail.com>2022-09-26 15:36:24 -0400
commit44c338433284b0ecb3c30cef5aae0cdb3b06901f (patch)
treec5b470bbeb487ce74486e92112320398d59e560e
parentdfde7bff94240172d3a2a037ec0b77871b71bf56 (diff)
shift+pageup/pagedown
-rw-r--r--.gitignore1
-rw-r--r--buffer.c24
-rw-r--r--command.c6
-rw-r--r--command.h6
-rw-r--r--ted.cfg2
5 files changed, 30 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index c0347a5..2873bb0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ Release
tags
TAGS
*.o
+*.out
*.obj
*.exe
*.dll
diff --git a/buffer.c b/buffer.c
index 4ee4fbd..be0c07e 100644
--- a/buffer.c
+++ b/buffer.c
@@ -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
diff --git a/command.c b/command.c
index b55260d..eda57f0 100644
--- a/command.c
+++ b/command.c
@@ -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);
diff --git a/command.h b/command.h
index 39f861d..e9faf71 100644
--- a/command.h
+++ b/command.h
@@ -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},
diff --git a/ted.cfg b/ted.cfg
index 7392494..1a006c5 100644
--- a/ted.cfg
+++ b/ted.cfg
@@ -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