From cbb3ebafdc6f2473264ad7cde99ddfff5a80a832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 2 Jun 2021 13:19:21 +0900 Subject: [PATCH] Support ctrl-f and ctrl-b to page up/down, fixes #41 --- helix-term/src/commands.rs | 8 ++++---- helix-term/src/keymap.rs | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 6465241f..7b30168a 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -473,10 +473,10 @@ fn scroll(cx: &mut Context, offset: usize, direction: Direction) { let last_line = view.last_line(doc); // clamp into viewport - let line = cursor.row.clamp( - view.first_line + scrolloff, - last_line.saturating_sub(scrolloff), - ); + let line = cursor + .row + .min(view.first_line + scrolloff) + .max(last_line.saturating_sub(scrolloff)); let text = doc.text().slice(..); let pos = pos_at_coords(text, Position::new(line, cursor.col)); // this func will properly truncate to line end diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 044d97eb..fc7bb86e 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -240,10 +240,12 @@ pub fn default() -> Keymaps { code: KeyCode::PageUp, modifiers: KeyModifiers::NONE } => commands::page_up, + ctrl!('b') => commands::page_up, KeyEvent { code: KeyCode::PageDown, modifiers: KeyModifiers::NONE } => commands::page_down, + ctrl!('f') => commands::page_down, ctrl!('u') => commands::half_page_up, ctrl!('d') => commands::half_page_down,