Browse code

Add pageup and pagedown

John Hawthorn authored on 20/06/2016 08:57:07
Showing 1 changed files

... ...
@@ -131,6 +131,16 @@ static void action_next(tty_interface_t *state) {
131 131
 	choices_next(state->choices);
132 132
 }
133 133
 
134
+static void action_pageup(tty_interface_t *state) {
135
+	for(size_t i = 0; i < state->options->num_lines && state->choices->selection > 0; i++)
136
+		choices_prev(state->choices);
137
+}
138
+
139
+static void action_pagedown(tty_interface_t *state) {
140
+	for(size_t i = 0; i < state->options->num_lines && state->choices->selection < state->choices->available-1; i++)
141
+		choices_next(state->choices);
142
+}
143
+
134 144
 static void action_autocomplete(tty_interface_t *state) {
135 145
 	strncpy(state->search, choices_get(state->choices, state->choices->selection), SEARCH_SIZE_MAX);
136 146
 }
... ...
@@ -200,6 +210,8 @@ static const keybinding_t keybindings[] = {{"\x7f", action_del_char},	/* DEL */
200 210
 					   {"\x1bOA", action_prev}, /* UP */
201 211
 					   {"\x1b[B", action_next}, /* DOWN */
202 212
 					   {"\x1bOB", action_next}, /* DOWN */
213
+					   {"\x1b[5~", action_pageup},
214
+					   {"\x1b[6~", action_pagedown},
203 215
 					   {NULL, NULL}};
204 216
 
205 217
 #undef KEY_CTRL