diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2022-03-16 19:27:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-16 19:27:55 +0300 |
commit | f4bdf5fb36fdf3b329be8253da39050abe7238a5 (patch) | |
tree | 9b49a78b15fdd73850a7bfc279e3986af2b59683 /alacritty/src | |
parent | 589c1e9c6b8830625162af14a9a7aee32c7aade0 (diff) | |
download | r-alacritty-f4bdf5fb36fdf3b329be8253da39050abe7238a5.tar.gz r-alacritty-f4bdf5fb36fdf3b329be8253da39050abe7238a5.tar.bz2 r-alacritty-f4bdf5fb36fdf3b329be8253da39050abe7238a5.zip |
Add colored underline support
This commit adds support for colored underline and refines the dynamic
extra storage. The extra storage now is using `Arc` making cloning it way
faster compared to `Box` approach which scales really well when it comes
to cloning in `Term::write_at_cursor`, since cloning `Arc` is constant
time.
Fixes #4142.
Diffstat (limited to 'alacritty/src')
-rw-r--r-- | alacritty/src/display/content.rs | 9 | ||||
-rw-r--r-- | alacritty/src/renderer/mod.rs | 1 | ||||
-rw-r--r-- | alacritty/src/renderer/rects.rs | 7 |
3 files changed, 14 insertions, 3 deletions
diff --git a/alacritty/src/display/content.rs b/alacritty/src/display/content.rs index d2da1e81..bb3c61a8 100644 --- a/alacritty/src/display/content.rs +++ b/alacritty/src/display/content.rs @@ -186,6 +186,7 @@ pub struct RenderableCell { pub fg: Rgb, pub bg: Rgb, pub bg_alpha: f32, + pub underline: Rgb, pub flags: Flags, } @@ -251,14 +252,20 @@ impl RenderableCell { let cell_point = cell.point; let point = display::point_to_viewport(display_offset, cell_point).unwrap(); + let flags = cell.flags; + let underline = cell + .underline_color() + .map_or(fg, |underline| Self::compute_fg_rgb(content, underline, flags)); + RenderableCell { zerowidth: cell.zerowidth().map(|zerowidth| zerowidth.to_vec()), - flags: cell.flags, + flags, character, bg_alpha, point, fg, bg, + underline, } } diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs index cf9ee149..4a75416b 100644 --- a/alacritty/src/renderer/mod.rs +++ b/alacritty/src/renderer/mod.rs @@ -135,6 +135,7 @@ impl Renderer { bg_alpha: 1.0, fg, bg, + underline: fg, }); self.draw_cells(size_info, glyph_cache, cells); diff --git a/alacritty/src/renderer/rects.rs b/alacritty/src/renderer/rects.rs index a4a6bf5d..27e306be 100644 --- a/alacritty/src/renderer/rects.rs +++ b/alacritty/src/renderer/rects.rs @@ -193,6 +193,9 @@ impl RenderLines { return; } + // The underline color escape does not apply to strikeout. + let color = if flag.contains(Flags::STRIKEOUT) { cell.fg } else { cell.underline }; + // Include wide char spacer if the current cell is a wide char. let mut end = cell.point; if cell.flags.contains(Flags::WIDE_CHAR) { @@ -201,7 +204,7 @@ impl RenderLines { // Check if there's an active line. if let Some(line) = self.inner.get_mut(&flag).and_then(|lines| lines.last_mut()) { - if cell.fg == line.color + if color == line.color && cell.point.column == line.end.column + 1 && cell.point.line == line.end.line { @@ -212,7 +215,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 }; match self.inner.get_mut(&flag) { Some(lines) => lines.push(line), None => { |