diff options
author | Christian Duerr <contact@christianduerr.com> | 2021-04-15 21:25:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-15 21:25:49 +0000 |
commit | 1f46bb7b925e5a6ce2dc4e5eeb88449d4cb8ebc5 (patch) | |
tree | 1ee1b4939b452dd18cc9b7832efd7ce44dc04089 | |
parent | 05917b27405f797bca817fa68305c08b74897997 (diff) | |
download | alacritty-1f46bb7b925e5a6ce2dc4e5eeb88449d4cb8ebc5.tar.gz alacritty-1f46bb7b925e5a6ce2dc4e5eeb88449d4cb8ebc5.zip |
Add hint action for moving the vi cursor
Fixes #4319.
-rw-r--r-- | alacritty.yml | 2 | ||||
-rw-r--r-- | alacritty/src/config/ui_config.rs | 2 | ||||
-rw-r--r-- | alacritty/src/event.rs | 9 |
3 files changed, 13 insertions, 0 deletions
diff --git a/alacritty.yml b/alacritty.yml index 840c4ed9..8c3a1ab0 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -475,6 +475,8 @@ # Paste the hint's text to the terminal or search. # - Select # Select the hint's text. + # - MoveViModeCursor + # Move the vi mode cursor to the beginning of the hint. #enabled: # - regex: "(mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)\ # [^\u0000-\u001F\u007F-\u009F<>\" {-}\\^⟨⟩`]+" diff --git a/alacritty/src/config/ui_config.rs b/alacritty/src/config/ui_config.rs index ff013d57..135d12c8 100644 --- a/alacritty/src/config/ui_config.rs +++ b/alacritty/src/config/ui_config.rs @@ -293,6 +293,8 @@ pub enum HintInternalAction { Paste, /// Select the text matching the hint. Select, + /// Move the vi mode cursor to the beginning of the hint. + MoveViModeCursor, } /// Actions for hint bindings. diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 33b15928..3b24de0f 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -657,6 +657,15 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon self.start_selection(SelectionType::Simple, *hint.bounds.start(), Side::Left); self.update_selection(*hint.bounds.end(), Side::Right); }, + // Move the vi mode cursor. + HintAction::Action(HintInternalAction::MoveViModeCursor) => { + // Enter vi mode if we're not in it already. + if !self.terminal.mode().contains(TermMode::VI) { + self.terminal.toggle_vi_mode(); + } + + self.terminal.vi_goto_point(*hint.bounds.start()); + }, } } |