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/display | |
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/display')
-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 |
4 files changed, 21 insertions, 18 deletions
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 { |