Add vi action to center view around vi cursor
This commit is contained in:
parent
90552e3e7f
commit
fdcf99b0c1
|
@ -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
|
- 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 set underline color (`CSI 58 : 2 : Ps : Ps : Ps m`/`CSI 58 : 5 : Ps m`)
|
||||||
- Escape sequence to reset underline color (`CSI 59 m`)
|
- Escape sequence to reset underline color (`CSI 59 m`)
|
||||||
|
- Vi mode keybinding (z) to center view around vi mode cursor
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -625,6 +625,8 @@
|
||||||
# - ToggleBlockSelection
|
# - ToggleBlockSelection
|
||||||
# - ToggleSemanticSelection
|
# - ToggleSemanticSelection
|
||||||
# Toggle semantic selection based on `selection.semantic_escape_chars`.
|
# Toggle semantic selection based on `selection.semantic_escape_chars`.
|
||||||
|
# - CenterAroundViCursor
|
||||||
|
# Center view around vi mode cursor
|
||||||
#
|
#
|
||||||
# - Vi mode exclusive cursor motion actions:
|
# - Vi mode exclusive cursor motion actions:
|
||||||
#
|
#
|
||||||
|
@ -778,6 +780,7 @@
|
||||||
#- { key: V, mods: Control, mode: Vi|~Search, action: ToggleBlockSelection }
|
#- { key: V, mods: Control, mode: Vi|~Search, action: ToggleBlockSelection }
|
||||||
#- { key: V, mods: Alt, mode: Vi|~Search, action: ToggleSemanticSelection }
|
#- { key: V, mods: Alt, mode: Vi|~Search, action: ToggleSemanticSelection }
|
||||||
#- { key: Return, mode: Vi|~Search, action: Open }
|
#- { key: Return, mode: Vi|~Search, action: Open }
|
||||||
|
#- { key: Z, mode: Vi|~Search, action: CenterAroundViCursor }
|
||||||
#- { key: K, mode: Vi|~Search, action: Up }
|
#- { key: K, mode: Vi|~Search, action: Up }
|
||||||
#- { key: J, mode: Vi|~Search, action: Down }
|
#- { key: J, mode: Vi|~Search, action: Down }
|
||||||
#- { key: H, mode: Vi|~Search, action: Left }
|
#- { key: H, mode: Vi|~Search, action: Left }
|
||||||
|
|
|
@ -275,6 +275,8 @@ pub enum ViAction {
|
||||||
SearchEnd,
|
SearchEnd,
|
||||||
/// Launch the URL below the vi mode cursor.
|
/// Launch the URL below the vi mode cursor.
|
||||||
Open,
|
Open,
|
||||||
|
/// Centers the screen around the vi mode cursor.
|
||||||
|
CenterAroundViCursor,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Search mode specific actions.
|
/// Search mode specific actions.
|
||||||
|
@ -498,6 +500,8 @@ pub fn default_key_bindings() -> Vec<KeyBinding> {
|
||||||
ViAction::SearchPrevious;
|
ViAction::SearchPrevious;
|
||||||
Return, +BindingMode::VI, ~BindingMode::SEARCH;
|
Return, +BindingMode::VI, ~BindingMode::SEARCH;
|
||||||
ViAction::Open;
|
ViAction::Open;
|
||||||
|
Z, +BindingMode::VI, ~BindingMode::SEARCH;
|
||||||
|
ViAction::CenterAroundViCursor;
|
||||||
K, +BindingMode::VI, ~BindingMode::SEARCH;
|
K, +BindingMode::VI, ~BindingMode::SEARCH;
|
||||||
ViMotion::Up;
|
ViMotion::Up;
|
||||||
J, +BindingMode::VI, ~BindingMode::SEARCH;
|
J, +BindingMode::VI, ~BindingMode::SEARCH;
|
||||||
|
|
|
@ -230,6 +230,15 @@ impl<T: EventListener> Execute<T> for Action {
|
||||||
ctx.mark_dirty();
|
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) => {
|
Action::Search(SearchAction::SearchFocusNext) => {
|
||||||
ctx.advance_search_origin(ctx.search_direction());
|
ctx.advance_search_origin(ctx.search_direction());
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue