diff options
Diffstat (limited to 'alacritty_terminal/src')
-rw-r--r-- | alacritty_terminal/src/config/mod.rs | 8 | ||||
-rw-r--r-- | alacritty_terminal/src/config/scrolling.rs | 4 | ||||
-rw-r--r-- | alacritty_terminal/src/index.rs | 16 | ||||
-rw-r--r-- | alacritty_terminal/src/term/color.rs | 6 | ||||
-rw-r--r-- | alacritty_terminal/src/tty/unix.rs | 9 | ||||
-rw-r--r-- | alacritty_terminal/src/tty/windows/mod.rs | 2 |
6 files changed, 31 insertions, 14 deletions
diff --git a/alacritty_terminal/src/config/mod.rs b/alacritty_terminal/src/config/mod.rs index 5822d591..53a0eb77 100644 --- a/alacritty_terminal/src/config/mod.rs +++ b/alacritty_terminal/src/config/mod.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use serde::Deserialize; -use alacritty_config_derive::ConfigDeserialize; +use alacritty_config_derive::{ConfigDeserialize, SerdeReplace}; mod scrolling; @@ -17,7 +17,7 @@ pub const LOG_TARGET_CONFIG: &str = "alacritty_config_derive"; const MIN_BLINK_INTERVAL: u64 = 10; /// Top-level config type. -#[derive(ConfigDeserialize, Debug, PartialEq, Default)] +#[derive(ConfigDeserialize, Clone, Debug, PartialEq, Default)] pub struct Config { /// TERM env variable. pub env: HashMap<String, String>, @@ -125,7 +125,7 @@ impl Cursor { } } -#[derive(Deserialize, Debug, Copy, Clone, PartialEq, Eq)] +#[derive(SerdeReplace, Deserialize, Debug, Copy, Clone, PartialEq, Eq)] #[serde(untagged)] pub enum ConfigCursorStyle { Shape(CursorShape), @@ -222,7 +222,7 @@ impl Program { } /// Wrapper around f32 that represents a percentage value between 0.0 and 1.0. -#[derive(Deserialize, Clone, Copy, Debug, PartialEq)] +#[derive(SerdeReplace, Deserialize, Clone, Copy, Debug, PartialEq)] pub struct Percentage(f32); impl Default for Percentage { diff --git a/alacritty_terminal/src/config/scrolling.rs b/alacritty_terminal/src/config/scrolling.rs index 9a5a718c..f4e55787 100644 --- a/alacritty_terminal/src/config/scrolling.rs +++ b/alacritty_terminal/src/config/scrolling.rs @@ -1,7 +1,7 @@ use serde::de::Error as SerdeError; use serde::{Deserialize, Deserializer}; -use alacritty_config_derive::ConfigDeserialize; +use alacritty_config_derive::{ConfigDeserialize, SerdeReplace}; /// Maximum scrollback amount configurable. pub const MAX_SCROLLBACK_LINES: u32 = 100_000; @@ -31,7 +31,7 @@ impl Scrolling { } } -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(SerdeReplace, Copy, Clone, Debug, PartialEq, Eq)] struct ScrollingHistory(u32); impl Default for ScrollingHistory { diff --git a/alacritty_terminal/src/index.rs b/alacritty_terminal/src/index.rs index e672c752..9464b8d8 100644 --- a/alacritty_terminal/src/index.rs +++ b/alacritty_terminal/src/index.rs @@ -7,6 +7,8 @@ use std::ops::{Add, AddAssign, Deref, Sub, SubAssign}; use serde::{Deserialize, Serialize}; +use alacritty_config_derive::SerdeReplace; + use crate::grid::Dimensions; /// The side of a cell. @@ -222,7 +224,19 @@ impl PartialEq<usize> for Line { /// A column. /// /// Newtype to avoid passing values incorrectly. -#[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd)] +#[derive( + SerdeReplace, + Serialize, + Deserialize, + Debug, + Copy, + Clone, + Eq, + PartialEq, + Default, + Ord, + PartialOrd, +)] pub struct Column(pub usize); impl fmt::Display for Column { diff --git a/alacritty_terminal/src/term/color.rs b/alacritty_terminal/src/term/color.rs index 1cfdec6b..3c545b28 100644 --- a/alacritty_terminal/src/term/color.rs +++ b/alacritty_terminal/src/term/color.rs @@ -7,12 +7,14 @@ use serde::de::{Error as _, Visitor}; use serde::{Deserialize, Deserializer, Serialize}; use serde_yaml::Value; +use alacritty_config_derive::SerdeReplace; + use crate::ansi::NamedColor; /// Number of terminal colors. pub const COUNT: usize = 269; -#[derive(Debug, Eq, PartialEq, Copy, Clone, Default, Serialize)] +#[derive(SerdeReplace, Debug, Eq, PartialEq, Copy, Clone, Default, Serialize)] pub struct Rgb { pub r: u8, pub g: u8, @@ -170,7 +172,7 @@ impl FromStr for Rgb { } /// RGB color optionally referencing the cell's foreground or background. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(SerdeReplace, Copy, Clone, Debug, PartialEq, Eq)] pub enum CellRgb { CellForeground, CellBackground, diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs index f52f0920..63da4f9c 100644 --- a/alacritty_terminal/src/tty/unix.rs +++ b/alacritty_terminal/src/tty/unix.rs @@ -148,7 +148,7 @@ fn default_shell_command(pw: &Passwd<'_>) -> Command { } /// Create a new TTY and return a handle to interact with it. -pub fn new(config: &PtyConfig, window_size: WindowSize, window_id: Option<usize>) -> Result<Pty> { +pub fn new(config: &PtyConfig, window_size: WindowSize, window_id: u64) -> Result<Pty> { let (master, slave) = make_pty(window_size.to_winsize())?; #[cfg(any(target_os = "linux", target_os = "macos"))] @@ -178,13 +178,14 @@ pub fn new(config: &PtyConfig, window_size: WindowSize, window_id: Option<usize> builder.stdout(unsafe { Stdio::from_raw_fd(slave) }); // Setup shell environment. + let window_id = window_id.to_string(); + builder.env("ALACRITTY_WINDOW_ID", &window_id); builder.env("LOGNAME", pw.name); builder.env("USER", pw.name); builder.env("HOME", pw.dir); - if let Some(window_id) = window_id { - builder.env("WINDOWID", format!("{}", window_id)); - } + // Set Window ID for clients relying on X11 hacks. + builder.env("WINDOWID", window_id); unsafe { builder.pre_exec(move || { diff --git a/alacritty_terminal/src/tty/windows/mod.rs b/alacritty_terminal/src/tty/windows/mod.rs index aa21ce14..57925f4c 100644 --- a/alacritty_terminal/src/tty/windows/mod.rs +++ b/alacritty_terminal/src/tty/windows/mod.rs @@ -27,7 +27,7 @@ pub struct Pty { child_watcher: ChildExitWatcher, } -pub fn new(config: &PtyConfig, window_size: WindowSize, _window_id: Option<usize>) -> Result<Pty> { +pub fn new(config: &PtyConfig, window_size: WindowSize, _window_id: u64) -> Result<Pty> { conpty::new(config, window_size) .ok_or_else(|| Error::new(ErrorKind::Other, "failed to spawn conpty")) } |