mirror of
https://github.com/alacritty/alacritty.git
synced 2025-04-14 17:53:03 -04:00
Add vi action to center view around vi cursor
This commit is contained in:
parent
90552e3e7f
commit
fdcf99b0c1
4 changed files with 17 additions and 0 deletions
|
@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Support for OpenGL ES 2.0
|
||||
- Escape sequence to set underline color (`CSI 58 : 2 : Ps : Ps : Ps m`/`CSI 58 : 5 : Ps m`)
|
||||
- Escape sequence to reset underline color (`CSI 59 m`)
|
||||
- Vi mode keybinding (z) to center view around vi mode cursor
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -625,6 +625,8 @@
|
|||
# - ToggleBlockSelection
|
||||
# - ToggleSemanticSelection
|
||||
# Toggle semantic selection based on `selection.semantic_escape_chars`.
|
||||
# - CenterAroundViCursor
|
||||
# Center view around vi mode cursor
|
||||
#
|
||||
# - Vi mode exclusive cursor motion actions:
|
||||
#
|
||||
|
@ -778,6 +780,7 @@
|
|||
#- { key: V, mods: Control, mode: Vi|~Search, action: ToggleBlockSelection }
|
||||
#- { key: V, mods: Alt, mode: Vi|~Search, action: ToggleSemanticSelection }
|
||||
#- { key: Return, mode: Vi|~Search, action: Open }
|
||||
#- { key: Z, mode: Vi|~Search, action: CenterAroundViCursor }
|
||||
#- { key: K, mode: Vi|~Search, action: Up }
|
||||
#- { key: J, mode: Vi|~Search, action: Down }
|
||||
#- { key: H, mode: Vi|~Search, action: Left }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue