diff options
Diffstat (limited to 'alacritty/src')
-rw-r--r-- | alacritty/src/config/bindings.rs | 4 | ||||
-rw-r--r-- | alacritty/src/input.rs | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs index 4c706811..c48b2d75 100644 --- a/alacritty/src/config/bindings.rs +++ b/alacritty/src/config/bindings.rs @@ -275,6 +275,8 @@ pub enum ViAction { SearchEnd, /// Launch the URL below the vi mode cursor. Open, + /// Centers the screen around the vi mode cursor. + CenterAroundViCursor, } /// Search mode specific actions. @@ -498,6 +500,8 @@ pub fn default_key_bindings() -> Vec<KeyBinding> { ViAction::SearchPrevious; Return, +BindingMode::VI, ~BindingMode::SEARCH; ViAction::Open; + Z, +BindingMode::VI, ~BindingMode::SEARCH; + ViAction::CenterAroundViCursor; K, +BindingMode::VI, ~BindingMode::SEARCH; ViMotion::Up; J, +BindingMode::VI, ~BindingMode::SEARCH; diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index 0f389851..0441ecb4 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -230,6 +230,15 @@ impl<T: EventListener> Execute<T> for Action { ctx.mark_dirty(); } }, + Action::Vi(ViAction::CenterAroundViCursor) => { + let term = ctx.terminal(); + let display_offset = term.grid().display_offset() as i32; + let target = -display_offset + term.screen_lines() as i32 / 2 - 1; + let line = term.vi_mode_cursor.point.line; + let scroll_lines = target - line.0; + + ctx.scroll(Scroll::Delta(scroll_lines)); + }, Action::Search(SearchAction::SearchFocusNext) => { ctx.advance_search_origin(ctx.search_direction()); }, |