aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty/src/config')
-rw-r--r--alacritty/src/config/bindings.rs41
-rw-r--r--alacritty/src/config/mouse.rs18
2 files changed, 13 insertions, 46 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
diff --git a/alacritty/src/config/mouse.rs b/alacritty/src/config/mouse.rs
index 9192aba9..1a5aec3d 100644
--- a/alacritty/src/config/mouse.rs
+++ b/alacritty/src/config/mouse.rs
@@ -4,9 +4,9 @@ use glutin::event::ModifiersState;
use log::error;
use serde::{Deserialize, Deserializer};
-use alacritty_terminal::config::{failure_default, LOG_TARGET_CONFIG};
+use alacritty_terminal::config::{failure_default, Program, LOG_TARGET_CONFIG};
-use crate::config::bindings::{CommandWrapper, ModsWrapper};
+use crate::config::bindings::ModsWrapper;
#[serde(default)]
#[derive(Default, Clone, Debug, Deserialize, PartialEq, Eq)]
@@ -26,7 +26,7 @@ pub struct Mouse {
pub struct Url {
/// Program for opening links.
#[serde(deserialize_with = "deserialize_launcher")]
- pub launcher: Option<CommandWrapper>,
+ pub launcher: Option<Program>,
/// Modifier used to open links.
#[serde(deserialize_with = "failure_default")]
@@ -39,9 +39,7 @@ impl Url {
}
}
-fn deserialize_launcher<'a, D>(
- deserializer: D,
-) -> ::std::result::Result<Option<CommandWrapper>, D::Error>
+fn deserialize_launcher<'a, D>(deserializer: D) -> std::result::Result<Option<Program>, D::Error>
where
D: Deserializer<'a>,
{
@@ -55,7 +53,7 @@ where
return Ok(None);
}
- match <Option<CommandWrapper>>::deserialize(val) {
+ match <Option<Program>>::deserialize(val) {
Ok(launcher) => Ok(launcher),
Err(err) => {
error!(
@@ -73,11 +71,11 @@ impl Default for Url {
fn default() -> Url {
Url {
#[cfg(not(any(target_os = "macos", windows)))]
- launcher: Some(CommandWrapper::Just(String::from("xdg-open"))),
+ launcher: Some(Program::Just(String::from("xdg-open"))),
#[cfg(target_os = "macos")]
- launcher: Some(CommandWrapper::Just(String::from("open"))),
+ launcher: Some(Program::Just(String::from("open"))),
#[cfg(windows)]
- launcher: Some(CommandWrapper::Just(String::from("explorer"))),
+ launcher: Some(Program::Just(String::from("explorer"))),
modifiers: Default::default(),
}
}