diff options
author | Josh Rahm <rahm@google.com> | 2021-09-15 01:08:10 -0600 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2021-09-15 01:18:33 -0600 |
commit | 2ded77656793f340440fe0efb54119697bb22a1a (patch) | |
tree | db9e584a2882f2137ff029800cf35a61a7502e65 | |
parent | d2b578e011d62311125033d895060986a96d3c88 (diff) | |
download | r-alacritty-2ded77656793f340440fe0efb54119697bb22a1a.tar.gz r-alacritty-2ded77656793f340440fe0efb54119697bb22a1a.tar.bz2 r-alacritty-2ded77656793f340440fe0efb54119697bb22a1a.zip |
Added ability to set the special color for the undercur and underlines using the standard ANSI code 59
-rw-r--r-- | alacritty/src/display/content.rs | 7 | ||||
-rw-r--r-- | alacritty/src/renderer/mod.rs | 2 | ||||
-rw-r--r-- | alacritty/src/renderer/rects.rs | 2 | ||||
-rw-r--r-- | alacritty_terminal/src/term/cell.rs | 3 | ||||
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 4 |
5 files changed, 17 insertions, 1 deletions
diff --git a/alacritty/src/display/content.rs b/alacritty/src/display/content.rs index 09116508..9f52e74e 100644 --- a/alacritty/src/display/content.rs +++ b/alacritty/src/display/content.rs @@ -189,6 +189,7 @@ pub struct RenderableCell { pub point: Point<usize>, pub fg: Rgb, pub bg: Rgb, + pub sp: Rgb, // Special pub bg_alpha: f32, pub flags: Flags, } @@ -198,6 +199,11 @@ impl RenderableCell { // Lookup RGB values. let mut fg = Self::compute_fg_rgb(content, cell.fg, cell.flags); let mut bg = Self::compute_bg_rgb(content, cell.bg); + let mut sp = if cell.sp == Color::Named(NamedColor::Foreground) { + fg + } else { + Self::compute_bg_rgb(content, cell.sp) + }; let mut bg_alpha = if cell.flags.contains(Flags::INVERSE) { mem::swap(&mut fg, &mut bg); @@ -263,6 +269,7 @@ impl RenderableCell { point, fg, bg, + sp, } } diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs index 11ccfc63..0173769c 100644 --- a/alacritty/src/renderer/mod.rs +++ b/alacritty/src/renderer/mod.rs @@ -835,6 +835,7 @@ impl<'a> RenderApi<'a> { bg: Rgb, string: &str, ) { + let sp = Rgb { b: 0, g: 0, r: 0 }; let cells = string .chars() .enumerate() @@ -846,6 +847,7 @@ impl<'a> RenderApi<'a> { bg_alpha: 1.0, fg, bg, + sp, }) .collect::<Vec<_>>(); diff --git a/alacritty/src/renderer/rects.rs b/alacritty/src/renderer/rects.rs index 91a67c22..2640b645 100644 --- a/alacritty/src/renderer/rects.rs +++ b/alacritty/src/renderer/rects.rs @@ -260,7 +260,7 @@ impl RenderLines { } // Start new line if there currently is none. - let line = RenderLine { start: cell.point, end, color: cell.fg }; + let line = RenderLine { start: cell.point, end, color: cell.sp }; match self.inner.get_mut(&flag) { Some(lines) => lines.push(line), None => { diff --git a/alacritty_terminal/src/term/cell.rs b/alacritty_terminal/src/term/cell.rs index 2191ced2..467d955a 100644 --- a/alacritty_terminal/src/term/cell.rs +++ b/alacritty_terminal/src/term/cell.rs @@ -62,6 +62,7 @@ pub struct Cell { pub c: char, pub fg: Color, pub bg: Color, + pub sp: Color, pub flags: Flags, #[serde(default)] extra: Option<Box<CellExtra>>, @@ -74,6 +75,7 @@ impl Default for Cell { c: ' ', bg: Color::Named(NamedColor::Background), fg: Color::Named(NamedColor::Foreground), + sp: Color::Named(NamedColor::Foreground), flags: Flags::empty(), extra: None, } @@ -116,6 +118,7 @@ impl GridCell for Cell { (self.c == ' ' || self.c == '\t') && self.bg == Color::Named(NamedColor::Background) && self.fg == Color::Named(NamedColor::Foreground) + && self.sp == Color::Named(NamedColor::Foreground) && !self.flags.intersects( Flags::INVERSE | Flags::UNDERLINE diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 367f39f9..85b76937 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -783,6 +783,7 @@ impl<T> Term<T> { let c = self.grid.cursor.charsets[self.active_charset].map(c); let fg = self.grid.cursor.template.fg; let bg = self.grid.cursor.template.bg; + let sp = self.grid.cursor.template.sp; let flags = self.grid.cursor.template.flags; let mut cursor_cell = self.grid.cursor_cell(); @@ -812,6 +813,7 @@ impl<T> Term<T> { cursor_cell.c = c; cursor_cell.fg = fg; cursor_cell.bg = bg; + cursor_cell.sp = sp; cursor_cell.flags = flags; } } @@ -1494,9 +1496,11 @@ impl<T: EventListener> Handler for Term<T> { match attr { Attr::Foreground(color) => cursor.template.fg = color, Attr::Background(color) => cursor.template.bg = color, + Attr::Special(color) => cursor.template.sp = color, Attr::Reset => { cursor.template.fg = Color::Named(NamedColor::Foreground); cursor.template.bg = Color::Named(NamedColor::Background); + cursor.template.sp = Color::Named(NamedColor::Foreground); cursor.template.flags = Flags::empty(); }, Attr::Reverse => cursor.template.flags.insert(Flags::INVERSE), |