diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-11-10 18:16:22 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 18:16:22 +0400 |
commit | 5060f8eeb864e8c304fbad9588bdd882db942356 (patch) | |
tree | b615ded19e6ac545b495f716e2a22ecd903332af /alacritty/src/config/bindings.rs | |
parent | 3ffd6c8f26f9788466b9ba95659b8de970a10f08 (diff) | |
download | r-alacritty-5060f8eeb864e8c304fbad9588bdd882db942356.tar.gz r-alacritty-5060f8eeb864e8c304fbad9588bdd882db942356.tar.bz2 r-alacritty-5060f8eeb864e8c304fbad9588bdd882db942356.zip |
Remove `alacritty_config` from alacritty_terminal
There's no need to force alacritty's user configuration on
other users of the crate, thus provide the options actually used
by alacritty_terminal itself.
Diffstat (limited to 'alacritty/src/config/bindings.rs')
-rw-r--r-- | alacritty/src/config/bindings.rs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs index c56445f3..01e7e59c 100644 --- a/alacritty/src/config/bindings.rs +++ b/alacritty/src/config/bindings.rs @@ -14,11 +14,10 @@ use winit::platform::scancode::PhysicalKeyExtScancode; use alacritty_config_derive::{ConfigDeserialize, SerdeReplace}; -use alacritty_terminal::config::Program; use alacritty_terminal::term::TermMode; use alacritty_terminal::vi_mode::ViMotion; -use crate::config::ui_config::Hint; +use crate::config::ui_config::{Hint, Program, StringVisitor}; /// Describes a state and action to take in that state. /// @@ -1103,8 +1102,9 @@ impl<'a> Deserialize<'a> for RawBinding { action = if let Ok(vi_action) = ViAction::deserialize(value.clone()) { Some(vi_action.into()) - } else if let Ok(vi_motion) = ViMotion::deserialize(value.clone()) { - Some(vi_motion.into()) + } else if let Ok(vi_motion) = SerdeViMotion::deserialize(value.clone()) + { + Some(vi_motion.0.into()) } else if let Ok(search_action) = SearchAction::deserialize(value.clone()) { @@ -1213,6 +1213,21 @@ impl<'a> Deserialize<'a> for KeyBinding { } } +#[derive(SerdeReplace, Debug, Copy, Clone, Eq, PartialEq)] +pub struct SerdeViMotion(ViMotion); + +impl<'de> Deserialize<'de> for SerdeViMotion { + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> + where + D: Deserializer<'de>, + { + let value = deserializer.deserialize_str(StringVisitor)?; + ViMotion::deserialize(SerdeValue::String(value)) + .map(SerdeViMotion) + .map_err(de::Error::custom) + } +} + /// Newtype for implementing deserialize on winit Mods. /// /// Our deserialize impl wouldn't be covered by a derive(Deserialize); see the |