aboutsummaryrefslogtreecommitdiff
path: root/helix-tui
diff options
context:
space:
mode:
authorA-Walrus2022-08-11 11:10:29 +0000
committerPascal Kuthe2022-10-01 15:00:34 +0000
commit3ad7d543ca17963f0839b1a6cd8abacdb5c60cf7 (patch)
tree8b754434eb9d3d21732c92bab64228efe2d283f4 /helix-tui
parent999b45b28c157418c20a9a8cd9219db6ce0beac7 (diff)
Add separate color for underlines
Diffstat (limited to 'helix-tui')
-rw-r--r--helix-tui/src/backend/crossterm.rs8
-rw-r--r--helix-tui/src/buffer.rs7
2 files changed, 14 insertions, 1 deletions
diff --git a/helix-tui/src/backend/crossterm.rs b/helix-tui/src/backend/crossterm.rs
index 252036f3..fe9da919 100644
--- a/helix-tui/src/backend/crossterm.rs
+++ b/helix-tui/src/backend/crossterm.rs
@@ -4,7 +4,7 @@ use crossterm::{
execute, queue,
style::{
Attribute as CAttribute, Color as CColor, Print, SetAttribute, SetBackgroundColor,
- SetForegroundColor,
+ SetForegroundColor, SetUnderlineColor,
},
terminal::{self, Clear, ClearType},
};
@@ -47,6 +47,7 @@ where
{
let mut fg = Color::Reset;
let mut bg = Color::Reset;
+ let mut underline = Color::Reset;
let mut modifier = Modifier::empty();
let mut last_pos: Option<(u16, u16)> = None;
for (x, y, cell) in content {
@@ -73,6 +74,11 @@ where
map_error(queue!(self.buffer, SetBackgroundColor(color)))?;
bg = cell.bg;
}
+ if cell.underline != underline {
+ let color = CColor::from(cell.underline);
+ map_error(queue!(self.buffer, SetUnderlineColor(color)))?;
+ underline = cell.underline;
+ }
map_error(queue!(self.buffer, Print(&cell.symbol)))?;
}
diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs
index 21c53aad..14f3ecaf 100644
--- a/helix-tui/src/buffer.rs
+++ b/helix-tui/src/buffer.rs
@@ -11,6 +11,7 @@ pub struct Cell {
pub symbol: String,
pub fg: Color,
pub bg: Color,
+ pub underline: Color,
pub modifier: Modifier,
}
@@ -44,6 +45,9 @@ impl Cell {
if let Some(c) = style.bg {
self.bg = c;
}
+ if let Some(c) = style.underline {
+ self.underline = c;
+ }
self.modifier.insert(style.add_modifier);
self.modifier.remove(style.sub_modifier);
self
@@ -53,6 +57,7 @@ impl Cell {
Style::default()
.fg(self.fg)
.bg(self.bg)
+ .underline(self.bg)
.add_modifier(self.modifier)
}
@@ -61,6 +66,7 @@ impl Cell {
self.symbol.push(' ');
self.fg = Color::Reset;
self.bg = Color::Reset;
+ self.underline = Color::Reset;
self.modifier = Modifier::empty();
}
}
@@ -71,6 +77,7 @@ impl Default for Cell {
symbol: " ".into(),
fg: Color::Reset,
bg: Color::Reset,
+ underline: Color::Reset,
modifier: Modifier::empty(),
}
}