diff options
author | Christian Duerr <contact@christianduerr.com> | 2023-06-12 02:23:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-12 00:23:41 +0000 |
commit | bd4906722a1a026b01f06c94c33b13ff63a7e044 (patch) | |
tree | a2713a7b0a5fa23ec8b9055d7ed06f1cede62447 /alacritty/src/config/mouse.rs | |
parent | ea2c39e65d21728e0f04b0eafcec7153e4447cd5 (diff) | |
download | r-alacritty-bd4906722a1a026b01f06c94c33b13ff63a7e044.tar.gz r-alacritty-bd4906722a1a026b01f06c94c33b13ff63a7e044.tar.bz2 r-alacritty-bd4906722a1a026b01f06c94c33b13ff63a7e044.zip |
Switch to TOML configuration format
This switches Alacritty's default configuration format from yaml to
toml. While yaml is still supported, it is done by converting it to toml
and should be removed entirely in the future.
All existing features were persisted based on my testing. Behavior
should not change much, though `--option` might have slightly different
behavior since the entire line is not interpreted as one line of toml.
A new `alacritty migrate` subcommand has been added which allows
automatic migration from yaml to toml. This also could be used as a
facility to automatically fix configuration file changes in the future.
Closes #6592.
Diffstat (limited to 'alacritty/src/config/mouse.rs')
-rw-r--r-- | alacritty/src/config/mouse.rs | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/alacritty/src/config/mouse.rs b/alacritty/src/config/mouse.rs index 291e4c61..b6556a2c 100644 --- a/alacritty/src/config/mouse.rs +++ b/alacritty/src/config/mouse.rs @@ -1,14 +1,18 @@ use std::time::Duration; -use alacritty_config_derive::ConfigDeserialize; +use serde::{Deserialize, Deserializer}; + +use alacritty_config_derive::{ConfigDeserialize, SerdeReplace}; + +use crate::config::bindings::{self, MouseBinding}; +use crate::config::ui_config; #[derive(ConfigDeserialize, Default, Clone, Debug, PartialEq, Eq)] pub struct Mouse { pub double_click: ClickHandler, pub triple_click: ClickHandler, pub hide_when_typing: bool, - #[config(deprecated = "use `hints` section instead")] - pub url: Option<serde_yaml::Value>, + pub bindings: MouseBindings, } #[derive(ConfigDeserialize, Clone, Debug, PartialEq, Eq)] @@ -27,3 +31,21 @@ impl ClickHandler { Duration::from_millis(self.threshold as u64) } } + +#[derive(SerdeReplace, Clone, Debug, PartialEq, Eq)] +pub struct MouseBindings(pub Vec<MouseBinding>); + +impl Default for MouseBindings { + fn default() -> Self { + Self(bindings::default_mouse_bindings()) + } +} + +impl<'de> Deserialize<'de> for MouseBindings { + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> + where + D: Deserializer<'de>, + { + Ok(Self(ui_config::deserialize_bindings(deserializer, Self::default().0)?)) + } +} |