diff options
Diffstat (limited to 'alacritty/src/config/bindings.rs')
-rw-r--r-- | alacritty/src/config/bindings.rs | 41 |
1 files changed, 5 insertions, 36 deletions
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs index 41a0b1db..c74a0c2c 100644 --- a/alacritty/src/config/bindings.rs +++ b/alacritty/src/config/bindings.rs @@ -22,6 +22,7 @@ use serde::de::{self, MapAccess, Unexpected, Visitor}; use serde::{Deserialize, Deserializer}; use serde_yaml::Value as SerdeValue; +use alacritty_terminal::config::Program; use alacritty_terminal::term::TermMode; use alacritty_terminal::vi_mode::ViMotion; @@ -94,7 +95,7 @@ pub enum Action { /// Run given command. #[serde(skip)] - Command(String, Vec<String>), + Command(Program), /// Move vi mode cursor. #[serde(skip)] @@ -763,7 +764,7 @@ impl<'a> Deserialize<'a> for RawBinding { let mut mode: Option<TermMode> = None; let mut not_mode: Option<TermMode> = None; let mut mouse: Option<MouseButton> = None; - let mut command: Option<CommandWrapper> = None; + let mut command: Option<Program> = None; use de::Error; @@ -860,7 +861,7 @@ impl<'a> Deserialize<'a> for RawBinding { return Err(<V::Error as Error>::duplicate_field("command")); } - command = Some(map.next_value::<CommandWrapper>()?); + command = Some(map.next_value::<Program>()?); }, } } @@ -882,12 +883,7 @@ impl<'a> Deserialize<'a> for RawBinding { }, (Some(action), None, None) => action, (None, Some(chars), None) => Action::Esc(chars), - (None, None, Some(cmd)) => match cmd { - CommandWrapper::Just(program) => Action::Command(program, vec![]), - CommandWrapper::WithArgs { program, args } => { - Action::Command(program, args) - }, - }, + (None, None, Some(cmd)) => Action::Command(cmd), _ => { return Err(V::Error::custom( "must specify exactly one of chars, action or command", @@ -929,33 +925,6 @@ impl<'a> Deserialize<'a> for KeyBinding { } } -#[serde(untagged)] -#[derive(Debug, Deserialize, Clone, PartialEq, Eq)] -pub enum CommandWrapper { - Just(String), - WithArgs { - program: String, - #[serde(default)] - args: Vec<String>, - }, -} - -impl CommandWrapper { - pub fn program(&self) -> &str { - match self { - CommandWrapper::Just(program) => program, - CommandWrapper::WithArgs { program, .. } => program, - } - } - - pub fn args(&self) -> &[String] { - match self { - CommandWrapper::Just(_) => &[], - CommandWrapper::WithArgs { args, .. } => args, - } - } -} - /// Newtype for implementing deserialize on glutin Mods. /// /// Our deserialize impl wouldn't be covered by a derive(Deserialize); see the |