From bd4906722a1a026b01f06c94c33b13ff63a7e044 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Mon, 12 Jun 2023 02:23:41 +0200 Subject: 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. --- alacritty/src/config/mouse.rs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'alacritty/src/config/mouse.rs') 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, + 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); + +impl Default for MouseBindings { + fn default() -> Self { + Self(bindings::default_mouse_bindings()) + } +} + +impl<'de> Deserialize<'de> for MouseBindings { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + Ok(Self(ui_config::deserialize_bindings(deserializer, Self::default().0)?)) + } +} -- cgit