diff options
author | Anhad Singh <62820092+Andy-Python-Programmer@users.noreply.github.com> | 2023-05-24 06:35:58 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-23 20:35:58 +0000 |
commit | cb7ad5b7e6893787c2006cc8cb09fbbc4711c0f7 (patch) | |
tree | e8c5315bb620e6d4e1564dfd6825303b498a3d6d /alacritty/src | |
parent | f0379f2da751e81ba05bbf65ecb5e59590f39be4 (diff) | |
download | r-alacritty-cb7ad5b7e6893787c2006cc8cb09fbbc4711c0f7.tar.gz r-alacritty-cb7ad5b7e6893787c2006cc8cb09fbbc4711c0f7.tar.bz2 r-alacritty-cb7ad5b7e6893787c2006cc8cb09fbbc4711c0f7.zip |
Switch to VTE's built-in ansi feature
Co-authored-by: Christian Duerr <contact@christianduerr.com>
Diffstat (limited to 'alacritty/src')
-rw-r--r-- | alacritty/src/config/bell.rs | 11 | ||||
-rw-r--r-- | alacritty/src/config/color.rs | 68 | ||||
-rw-r--r-- | alacritty/src/config/window.rs | 18 | ||||
-rw-r--r-- | alacritty/src/display/color.rs | 12 | ||||
-rw-r--r-- | alacritty/src/display/content.rs | 11 | ||||
-rw-r--r-- | alacritty/src/display/hint.rs | 14 | ||||
-rw-r--r-- | alacritty/src/display/mod.rs | 2 | ||||
-rw-r--r-- | alacritty/src/renderer/rects.rs | 2 |
8 files changed, 63 insertions, 75 deletions
diff --git a/alacritty/src/config/bell.rs b/alacritty/src/config/bell.rs index 2516e2b3..fbf5be2f 100644 --- a/alacritty/src/config/bell.rs +++ b/alacritty/src/config/bell.rs @@ -23,7 +23,7 @@ pub struct BellConfig { impl Default for BellConfig { fn default() -> Self { Self { - color: Rgb { r: 255, g: 255, b: 255 }, + color: Rgb::new(255, 255, 255), animation: Default::default(), command: Default::default(), duration: Default::default(), @@ -39,7 +39,7 @@ impl BellConfig { /// `VisualBellAnimations` are modeled after a subset of CSS transitions and Robert /// Penner's Easing Functions. -#[derive(ConfigDeserialize, Clone, Copy, Debug, PartialEq, Eq)] +#[derive(ConfigDeserialize, Default, Clone, Copy, Debug, PartialEq, Eq)] pub enum BellAnimation { // CSS animation. Ease, @@ -56,15 +56,10 @@ pub enum BellAnimation { // Penner animation. EaseOutQuint, // Penner animation. + #[default] EaseOutExpo, // Penner animation. EaseOutCirc, // Penner animation. Linear, } - -impl Default for BellAnimation { - fn default() -> Self { - BellAnimation::EaseOutExpo - } -} diff --git a/alacritty/src/config/color.rs b/alacritty/src/config/color.rs index 5028347c..23c18e50 100644 --- a/alacritty/src/config/color.rs +++ b/alacritty/src/config/color.rs @@ -52,8 +52,8 @@ pub struct HintStartColors { impl Default for HintStartColors { fn default() -> Self { Self { - foreground: CellRgb::Rgb(Rgb { r: 0x1d, g: 0x1f, b: 0x21 }), - background: CellRgb::Rgb(Rgb { r: 0xe9, g: 0xff, b: 0x5e }), + foreground: CellRgb::Rgb(Rgb::new(0x1d, 0x1f, 0x21)), + background: CellRgb::Rgb(Rgb::new(0xe9, 0xff, 0x5e)), } } } @@ -67,8 +67,8 @@ pub struct HintEndColors { impl Default for HintEndColors { fn default() -> Self { Self { - foreground: CellRgb::Rgb(Rgb { r: 0xe9, g: 0xff, b: 0x5e }), - background: CellRgb::Rgb(Rgb { r: 0x1d, g: 0x1f, b: 0x21 }), + foreground: CellRgb::Rgb(Rgb::new(0xe9, 0xff, 0x5e)), + background: CellRgb::Rgb(Rgb::new(0x1d, 0x1f, 0x21)), } } } @@ -139,8 +139,8 @@ pub struct FocusedMatchColors { impl Default for FocusedMatchColors { fn default() -> Self { Self { - background: CellRgb::Rgb(Rgb { r: 0x00, g: 0x00, b: 0x00 }), - foreground: CellRgb::Rgb(Rgb { r: 0xff, g: 0xff, b: 0xff }), + background: CellRgb::Rgb(Rgb::new(0x00, 0x00, 0x00)), + foreground: CellRgb::Rgb(Rgb::new(0xff, 0xff, 0xff)), } } } @@ -154,8 +154,8 @@ pub struct MatchColors { impl Default for MatchColors { fn default() -> Self { Self { - background: CellRgb::Rgb(Rgb { r: 0xff, g: 0xff, b: 0xff }), - foreground: CellRgb::Rgb(Rgb { r: 0x00, g: 0x00, b: 0x00 }), + background: CellRgb::Rgb(Rgb::new(0xff, 0xff, 0xff)), + foreground: CellRgb::Rgb(Rgb::new(0x00, 0x00, 0x00)), } } } @@ -177,8 +177,8 @@ pub struct PrimaryColors { impl Default for PrimaryColors { fn default() -> Self { PrimaryColors { - background: Rgb { r: 0x1d, g: 0x1f, b: 0x21 }, - foreground: Rgb { r: 0xc5, g: 0xc8, b: 0xc6 }, + background: Rgb::new(0x1d, 0x1f, 0x21), + foreground: Rgb::new(0xc5, 0xc8, 0xc6), bright_foreground: Default::default(), dim_foreground: Default::default(), } @@ -200,14 +200,14 @@ pub struct NormalColors { impl Default for NormalColors { fn default() -> Self { NormalColors { - black: Rgb { r: 0x1d, g: 0x1f, b: 0x21 }, - red: Rgb { r: 0xcc, g: 0x66, b: 0x66 }, - green: Rgb { r: 0xb5, g: 0xbd, b: 0x68 }, - yellow: Rgb { r: 0xf0, g: 0xc6, b: 0x74 }, - blue: Rgb { r: 0x81, g: 0xa2, b: 0xbe }, - magenta: Rgb { r: 0xb2, g: 0x94, b: 0xbb }, - cyan: Rgb { r: 0x8a, g: 0xbe, b: 0xb7 }, - white: Rgb { r: 0xc5, g: 0xc8, b: 0xc6 }, + black: Rgb::new(0x1d, 0x1f, 0x21), + red: Rgb::new(0xcc, 0x66, 0x66), + green: Rgb::new(0xb5, 0xbd, 0x68), + yellow: Rgb::new(0xf0, 0xc6, 0x74), + blue: Rgb::new(0x81, 0xa2, 0xbe), + magenta: Rgb::new(0xb2, 0x94, 0xbb), + cyan: Rgb::new(0x8a, 0xbe, 0xb7), + white: Rgb::new(0xc5, 0xc8, 0xc6), } } } @@ -227,14 +227,14 @@ pub struct BrightColors { impl Default for BrightColors { fn default() -> Self { BrightColors { - black: Rgb { r: 0x66, g: 0x66, b: 0x66 }, - red: Rgb { r: 0xd5, g: 0x4e, b: 0x53 }, - green: Rgb { r: 0xb9, g: 0xca, b: 0x4a }, - yellow: Rgb { r: 0xe7, g: 0xc5, b: 0x47 }, - blue: Rgb { r: 0x7a, g: 0xa6, b: 0xda }, - magenta: Rgb { r: 0xc3, g: 0x97, b: 0xd8 }, - cyan: Rgb { r: 0x70, g: 0xc0, b: 0xb1 }, - white: Rgb { r: 0xea, g: 0xea, b: 0xea }, + black: Rgb::new(0x66, 0x66, 0x66), + red: Rgb::new(0xd5, 0x4e, 0x53), + green: Rgb::new(0xb9, 0xca, 0x4a), + yellow: Rgb::new(0xe7, 0xc5, 0x47), + blue: Rgb::new(0x7a, 0xa6, 0xda), + magenta: Rgb::new(0xc3, 0x97, 0xd8), + cyan: Rgb::new(0x70, 0xc0, 0xb1), + white: Rgb::new(0xea, 0xea, 0xea), } } } @@ -254,14 +254,14 @@ pub struct DimColors { impl Default for DimColors { fn default() -> Self { DimColors { - black: Rgb { r: 0x13, g: 0x14, b: 0x15 }, - red: Rgb { r: 0x86, g: 0x43, b: 0x43 }, - green: Rgb { r: 0x77, g: 0x7c, b: 0x44 }, - yellow: Rgb { r: 0x9e, g: 0x82, b: 0x4c }, - blue: Rgb { r: 0x55, g: 0x6a, b: 0x7d }, - magenta: Rgb { r: 0x75, g: 0x61, b: 0x7b }, - cyan: Rgb { r: 0x5b, g: 0x7d, b: 0x78 }, - white: Rgb { r: 0x82, g: 0x84, b: 0x82 }, + black: Rgb::new(0x13, 0x14, 0x15), + red: Rgb::new(0x86, 0x43, 0x43), + green: Rgb::new(0x77, 0x7c, 0x44), + yellow: Rgb::new(0x9e, 0x82, 0x4c), + blue: Rgb::new(0x55, 0x6a, 0x7d), + magenta: Rgb::new(0x75, 0x61, 0x7b), + cyan: Rgb::new(0x5b, 0x7d, 0x78), + white: Rgb::new(0x82, 0x84, 0x82), } } } diff --git a/alacritty/src/config/window.rs b/alacritty/src/config/window.rs index 98bc18b6..db29fd85 100644 --- a/alacritty/src/config/window.rs +++ b/alacritty/src/config/window.rs @@ -154,8 +154,9 @@ impl Default for Identity { } } -#[derive(ConfigDeserialize, Debug, Copy, Clone, PartialEq, Eq)] +#[derive(ConfigDeserialize, Default, Debug, Copy, Clone, PartialEq, Eq)] pub enum StartupMode { + #[default] Windowed, Maximized, Fullscreen, @@ -163,14 +164,9 @@ pub enum StartupMode { SimpleFullscreen, } -impl Default for StartupMode { - fn default() -> StartupMode { - StartupMode::Windowed - } -} - -#[derive(ConfigDeserialize, Debug, Copy, Clone, PartialEq, Eq)] +#[derive(ConfigDeserialize, Default, Debug, Copy, Clone, PartialEq, Eq)] pub enum Decorations { + #[default] Full, #[cfg(target_os = "macos")] Transparent, @@ -179,12 +175,6 @@ pub enum Decorations { None, } -impl Default for Decorations { - fn default() -> Decorations { - Decorations::Full - } -} - /// Window Dimensions. /// /// Newtype to avoid passing values incorrectly. diff --git a/alacritty/src/display/color.rs b/alacritty/src/display/color.rs index 6e0de048..054ca314 100644 --- a/alacritty/src/display/color.rs +++ b/alacritty/src/display/color.rs @@ -95,11 +95,11 @@ impl List { { self[index] = indexed_color.color; } else { - self[index] = Rgb { - r: if r == 0 { 0 } else { r * 40 + 55 }, - b: if b == 0 { 0 } else { b * 40 + 55 }, - g: if g == 0 { 0 } else { g * 40 + 55 }, - }; + self[index] = Rgb::new( + if r == 0 { 0 } else { r * 40 + 55 }, + if b == 0 { 0 } else { b * 40 + 55 }, + if g == 0 { 0 } else { g * 40 + 55 }, + ); } index += 1; } @@ -126,7 +126,7 @@ impl List { } let value = i * 10 + 8; - self[index] = Rgb { r: value, g: value, b: value }; + self[index] = Rgb::new(value, value, value); index += 1; } diff --git a/alacritty/src/display/content.rs b/alacritty/src/display/content.rs index ca49c01a..da211094 100644 --- a/alacritty/src/display/content.rs +++ b/alacritty/src/display/content.rs @@ -121,7 +121,7 @@ impl<'a> RenderableContent<'a> { let insufficient_contrast = (!matches!(cursor_color, CellRgb::Rgb(_)) || !matches!(text_color, CellRgb::Rgb(_))) - && cell.fg.contrast(cell.bg) < MIN_CURSOR_CONTRAST; + && cell.fg.contrast(*cell.bg) < MIN_CURSOR_CONTRAST; // Convert from cell colors to RGB. let mut text_color = text_color.color(cell.fg, cell.bg); @@ -307,8 +307,11 @@ impl RenderableCell { let config = &content.config; match fg { Color::Spec(rgb) => match flags & Flags::DIM { - Flags::DIM => rgb * DIM_FACTOR, - _ => rgb, + Flags::DIM => { + let rgb: Rgb = rgb.into(); + rgb * DIM_FACTOR + }, + _ => rgb.into(), }, Color::Named(ansi) => { match (config.draw_bold_text_with_bright_colors, flags & Flags::DIM_BOLD) { @@ -350,7 +353,7 @@ impl RenderableCell { #[inline] fn compute_bg_rgb(content: &mut RenderableContent<'_>, bg: Color) -> Rgb { match bg { - Color::Spec(rgb) => rgb, + Color::Spec(rgb) => rgb.into(), Color::Named(ansi) => content.color(ansi as usize), Color::Indexed(idx) => content.color(idx as usize), } diff --git a/alacritty/src/display/hint.rs b/alacritty/src/display/hint.rs index 12047011..c30a88c5 100644 --- a/alacritty/src/display/hint.rs +++ b/alacritty/src/display/hint.rs @@ -647,25 +647,25 @@ mod tests { #[test] fn collect_unique_hyperlinks() { let mut term = mock_term("000\r\n111"); - term.goto(Line(0), Column(0)); + term.goto(0, 0); let hyperlink_foo = Hyperlink::new(Some("1"), String::from("foo")); let hyperlink_bar = Hyperlink::new(Some("2"), String::from("bar")); // Create 2 hyperlinks on the first line. - term.set_hyperlink(Some(hyperlink_foo.clone())); + term.set_hyperlink(Some(hyperlink_foo.clone().into())); term.input('b'); term.input('a'); - term.set_hyperlink(Some(hyperlink_bar.clone())); + term.set_hyperlink(Some(hyperlink_bar.clone().into())); term.input('r'); - term.set_hyperlink(Some(hyperlink_foo.clone())); - term.goto(Line(1), Column(0)); + term.set_hyperlink(Some(hyperlink_foo.clone().into())); + term.goto(1, 0); // Ditto for the second line. - term.set_hyperlink(Some(hyperlink_foo)); + term.set_hyperlink(Some(hyperlink_foo.into())); term.input('b'); term.input('a'); - term.set_hyperlink(Some(hyperlink_bar)); + term.set_hyperlink(Some(hyperlink_bar.into())); term.input('r'); term.set_hyperlink(None); diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs index 4d9c1540..b575b1a8 100644 --- a/alacritty/src/display/mod.rs +++ b/alacritty/src/display/mod.rs @@ -73,7 +73,7 @@ const BACKWARD_SEARCH_LABEL: &str = "Backward Search: "; const SHORTENER: char = '…'; /// Color which is used to highlight damaged rects when debugging. -const DAMAGE_RECT_COLOR: Rgb = Rgb { r: 255, g: 0, b: 255 }; +const DAMAGE_RECT_COLOR: Rgb = Rgb::new(255, 0, 255); #[derive(Debug)] pub enum Error { diff --git a/alacritty/src/renderer/rects.rs b/alacritty/src/renderer/rects.rs index 31818f60..8f6204c2 100644 --- a/alacritty/src/renderer/rects.rs +++ b/alacritty/src/renderer/rects.rs @@ -366,7 +366,7 @@ impl RectRenderer { let y = -rect.y / half_height + 1.0; let width = rect.width / half_width; let height = rect.height / half_height; - let Rgb { r, g, b } = rect.color; + let (r, g, b) = rect.color.as_tuple(); let a = (rect.alpha * 255.) as u8; // Make quad vertices. |