diff options
| author | Christian Duerr <contact@christianduerr.com> | 2025-05-29 18:55:34 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-29 18:55:34 +0000 |
| commit | a63c770befd3aa8be916ef9cfadd7e541f5377f0 (patch) | |
| tree | ddf720e1834f101175f6ac3a8d11120dcca861a7 /alacritty/src/display | |
| parent | 9eb68039dcb3edf9c87d253532a3ddd6c3cb8c4e (diff) | |
| download | r-alacritty-a63c770befd3aa8be916ef9cfadd7e541f5377f0.tar.gz r-alacritty-a63c770befd3aa8be916ef9cfadd7e541f5377f0.tar.bz2 r-alacritty-a63c770befd3aa8be916ef9cfadd7e541f5377f0.zip | |
Add IPC config retrieval subcommand
This patch adds a new `alacritty msg get-config` subcommand which can
retrieve the current config from any Alacritty window using the IPC
socket.
The command will always print the full configuration file in JSON,
without the ability to filter which values are returned, leaning on
tools like `jq` instead of adding this complexity to Alacritty.
Contrary to deserialization, this relies heavily on the default
serialization implementations to reduce the necessary changes. Key and
Mouse bindings are omitted entirely since their structure is very
complex and they tend to just bloat the message size without having an
obvious usecase.
Diffstat (limited to 'alacritty/src/display')
| -rw-r--r-- | alacritty/src/display/color.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/alacritty/src/display/color.rs b/alacritty/src/display/color.rs index 2e854a3f..a825aff8 100644 --- a/alacritty/src/display/color.rs +++ b/alacritty/src/display/color.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use log::trace; use serde::de::{Error as SerdeError, Visitor}; -use serde::{Deserialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; use alacritty_config_derive::SerdeReplace; use alacritty_terminal::term::color::COUNT; @@ -216,10 +216,7 @@ impl Add<Rgb> for Rgb { } } -/// Deserialize an Rgb from a hex string. -/// -/// This is *not* the deserialize impl for Rgb since we want a symmetric -/// serialize/deserialize impl for ref tests. +/// Deserialize Rgb color from a hex string. impl<'de> Deserialize<'de> for Rgb { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where @@ -267,6 +264,16 @@ impl<'de> Deserialize<'de> for Rgb { } } +/// Serialize Rgb color to a hex string. +impl Serialize for Rgb { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: Serializer, + { + serializer.serialize_str(&self.to_string()) + } +} + impl Display for Rgb { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "#{:02x}{:02x}{:02x}", self.r, self.g, self.b) @@ -300,10 +307,11 @@ impl FromStr for Rgb { } /// RGB color optionally referencing the cell's foreground or background. -#[derive(SerdeReplace, Copy, Clone, Debug, PartialEq, Eq)] +#[derive(SerdeReplace, Serialize, Copy, Clone, Debug, PartialEq, Eq)] pub enum CellRgb { CellForeground, CellBackground, + #[serde(untagged)] Rgb(Rgb), } |