Skip to content

Commit

Permalink
add nvim scroll function to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDickie committed Aug 20, 2023
1 parent 1df3fef commit db6db3e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ impl MappableCommand {
page_down, "Move page down",
half_page_up, "Move half page up",
half_page_down, "Move half page down",
page_cursor_up, "Move page and cursor up",
page_cursor_down, "Move page and cursor down",
page_cursor_half_up, "Move page and cursor half up",
page_cursor_half_down, "Move page and cursor half down",
select_all, "Select whole document",
select_regex, "Select all regex matches inside selections",
split_selection, "Split selections on regex matches",
Expand Down Expand Up @@ -1654,6 +1658,30 @@ fn half_page_down(cx: &mut Context) {
scroll(cx, offset, Direction::Forward);
}

fn page_cursor_up(cx: &mut Context) {
let view = view!(cx.editor);
let offset = view.inner_height();
scroll_page_and_cursor(cx, offset, Direction::Backward);
}

fn page_cursor_down(cx: &mut Context) {
let view = view!(cx.editor);
let offset = view.inner_height();
scroll_page_and_cursor(cx, offset, Direction::Forward);
}

fn page_cursor_half_up(cx: &mut Context) {
let view = view!(cx.editor);
let offset = view.inner_height() / 2;
scroll_page_and_cursor(cx, offset, Direction::Backward);
}

fn page_cursor_half_down(cx: &mut Context) {
let view = view!(cx.editor);
let offset = view.inner_height() / 2;
scroll_page_and_cursor(cx, offset, Direction::Forward);
}

#[allow(deprecated)]
// currently uses the deprecated `visual_coords_at_pos`/`pos_at_visual_coords` functions
// as this function ignores softwrapping (and virtual text) and instead only cares
Expand Down

0 comments on commit db6db3e

Please sign in to comment.