on master help sign in
Support ctrl-f and ctrl-b to page up/down, fixes #41
cbb3ebaBlaž Hrastnik
helix-term/src/commands.rs+4−4
@@ -473,10 +473,10 @@ fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
473 let last_line = view.last_line(doc);
473 let last_line = view.last_line(doc);
474
474
475 // clamp into viewport
475 // clamp into viewport
476− let line = cursor.row.clamp(
476+ let line = cursor
477+ .row
477− view.first_line + scrolloff,
478+ .min(view.first_line + scrolloff)
478− last_line.saturating_sub(scrolloff),
479+ .max(last_line.saturating_sub(scrolloff));
479− );
480
480
481 let text = doc.text().slice(..);
481 let text = doc.text().slice(..);
482 let pos = pos_at_coords(text, Position::new(line, cursor.col)); // this func will properly truncate to line end
482 let pos = pos_at_coords(text, Position::new(line, cursor.col)); // this func will properly truncate to line end
helix-term/src/keymap.rs+2
@@ -240,10 +240,12 @@ pub fn default() -> Keymaps {
240 code: KeyCode::PageUp,
240 code: KeyCode::PageUp,
241 modifiers: KeyModifiers::NONE
241 modifiers: KeyModifiers::NONE
242 } => commands::page_up,
242 } => commands::page_up,
243+ ctrl!('b') => commands::page_up,
243 KeyEvent {
244 KeyEvent {
244 code: KeyCode::PageDown,
245 code: KeyCode::PageDown,
245 modifiers: KeyModifiers::NONE
246 modifiers: KeyModifiers::NONE
246 } => commands::page_down,
247 } => commands::page_down,
248+ ctrl!('f') => commands::page_down,
247 ctrl!('u') => commands::half_page_up,
249 ctrl!('u') => commands::half_page_up,
248 ctrl!('d') => commands::half_page_down,
250 ctrl!('d') => commands::half_page_down,
249
251