diff options
author | Joshua Ortiz <53029739+sophrosyne97@users.noreply.github.com> | 2021-06-19 15:58:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-19 22:58:15 +0000 |
commit | 7e4325796d6a5179873dac1b72e3286cc68aa85a (patch) | |
tree | 5eecd0da3be486ff6471b22eb563258388ad68a5 | |
parent | 0be25c5e22ddd71a3335026b4853792512df141a (diff) | |
download | alacritty-7e4325796d6a5179873dac1b72e3286cc68aa85a.tar.gz alacritty-7e4325796d6a5179873dac1b72e3286cc68aa85a.zip |
Add modes to regex hint bindings
Fixes #5154.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty.yml | 4 | ||||
-rw-r--r-- | alacritty/src/config/bindings.rs | 9 | ||||
-rw-r--r-- | alacritty/src/config/ui_config.rs | 9 |
4 files changed, 17 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2be62dd3..373530ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Support for `ipfs`/`ipns` URLs +- Mode field for regex hint bindings ### Fixed diff --git a/alacritty.yml b/alacritty.yml index 8f4f5218..21f06fd0 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -458,8 +458,8 @@ # Each hint must have a `regex` and either an `action` or a `command` field. # The fields `mouse`, `binding` and `post_processing` are optional. # - # The fields `command`, `binding.key`, `binding.mods` and `mouse.mods` accept - # the same values as they do in the `key_bindings` section. + # The fields `command`, `binding.key`, `binding.mods`, `binding.mode` and + # `mouse.mods` accept the same values as they do in the `key_bindings` section. # # The `mouse.enabled` field controls if the hint should be underlined while # the mouse with all `mouse.mods` keys held or the vi mode cursor is above it. diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs index 4e7c2fcb..12349639 100644 --- a/alacritty/src/config/bindings.rs +++ b/alacritty/src/config/bindings.rs @@ -726,7 +726,8 @@ impl<'a> Deserialize<'a> for Key { } } -struct ModeWrapper { +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct ModeWrapper { pub mode: BindingMode, pub not_mode: BindingMode, } @@ -754,6 +755,12 @@ impl BindingMode { } } +impl Default for ModeWrapper { + fn default() -> Self { + Self { mode: BindingMode::empty(), not_mode: BindingMode::empty() } + } +} + impl<'a> Deserialize<'a> for ModeWrapper { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where diff --git a/alacritty/src/config/ui_config.rs b/alacritty/src/config/ui_config.rs index 460eebb0..a58c1fd3 100644 --- a/alacritty/src/config/ui_config.rs +++ b/alacritty/src/config/ui_config.rs @@ -14,7 +14,7 @@ use alacritty_terminal::term::search::RegexSearch; use crate::config::bell::BellConfig; use crate::config::bindings::{ - self, Action, Binding, BindingMode, Key, KeyBinding, ModsWrapper, MouseBinding, + self, Action, Binding, Key, KeyBinding, ModeWrapper, ModsWrapper, MouseBinding, }; use crate::config::color::Colors; use crate::config::debug::Debug; @@ -105,8 +105,8 @@ impl UiConfig { let binding = KeyBinding { trigger: binding.key, mods: binding.mods.0, - mode: BindingMode::empty(), - notmode: BindingMode::empty(), + mode: binding.mode.mode, + notmode: binding.mode.not_mode, action: Action::Hint(hint.clone()), }; @@ -242,6 +242,7 @@ impl Default for Hints { binding: Some(HintBinding { key: Key::Keycode(VirtualKeyCode::U), mods: ModsWrapper(ModifiersState::SHIFT | ModifiersState::CTRL), + mode: Default::default(), }), }], alphabet: Default::default(), @@ -340,6 +341,8 @@ pub struct HintBinding { pub key: Key, #[serde(default)] pub mods: ModsWrapper, + #[serde(default)] + pub mode: ModeWrapper, } /// Hint mouse highlighting. |