Skip to content

Commit

Permalink
Support ctrl-f and ctrl-b to page up/down, fixes #41
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Jun 2, 2021
1 parent 0851110 commit cbb3eba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions helix-term/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down

0 comments on commit cbb3eba

Please sign in to comment.