aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-tui/src/backend/crossterm.rs8
-rw-r--r--helix-tui/src/buffer.rs7
-rw-r--r--helix-view/src/graphics.rs19
-rw-r--r--helix-view/src/theme.rs1
-rw-r--r--runtime/themes/dark_plus.toml3
5 files changed, 36 insertions, 2 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(),
}
}
diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs
index 15492119..c995f60c 100644
--- a/helix-view/src/graphics.rs
+++ b/helix-view/src/graphics.rs
@@ -440,6 +440,7 @@ impl FromStr for Modifier {
pub struct Style {
pub fg: Option<Color>,
pub bg: Option<Color>,
+ pub underline: Option<Color>,
pub add_modifier: Modifier,
pub sub_modifier: Modifier,
}
@@ -449,6 +450,7 @@ impl Default for Style {
Style {
fg: None,
bg: None,
+ underline: None,
add_modifier: Modifier::empty(),
sub_modifier: Modifier::empty(),
}
@@ -461,6 +463,7 @@ impl Style {
Style {
fg: Some(Color::Reset),
bg: Some(Color::Reset),
+ underline: Some(Color::Reset),
add_modifier: Modifier::empty(),
sub_modifier: Modifier::all(),
}
@@ -496,6 +499,21 @@ impl Style {
self
}
+ /// Changes the underline color.
+ ///
+ /// ## Examples
+ ///
+ /// ```rust
+ /// # use helix_view::graphics::{Color, Style};
+ /// let style = Style::default().underline(Color::Blue);
+ /// let diff = Style::default().underline(Color::Red);
+ /// assert_eq!(style.patch(diff), Style::default().underline(Color::Red));
+ /// ```
+ pub fn underline(mut self, color: Color) -> Style {
+ self.underline = Some(color);
+ self
+ }
+
/// Changes the text emphasis.
///
/// When applied, it adds the given modifier to the `Style` modifiers.
@@ -552,6 +570,7 @@ impl Style {
pub fn patch(mut self, other: Style) -> Style {
self.fg = other.fg.or(self.fg);
self.bg = other.bg.or(self.bg);
+ self.underline = other.underline.or(self.underline);
self.add_modifier.remove(other.sub_modifier);
self.add_modifier.insert(other.add_modifier);
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs
index fa5fa702..5ce1b2c5 100644
--- a/helix-view/src/theme.rs
+++ b/helix-view/src/theme.rs
@@ -269,6 +269,7 @@ impl ThemePalette {
match name.as_str() {
"fg" => *style = style.fg(self.parse_color(value)?),
"bg" => *style = style.bg(self.parse_color(value)?),
+ "underline" => *style = style.underline(self.parse_color(value)?),
"modifiers" => {
let modifiers = value
.as_array()
diff --git a/runtime/themes/dark_plus.toml b/runtime/themes/dark_plus.toml
index f99da4fb..d1a5756e 100644
--- a/runtime/themes/dark_plus.toml
+++ b/runtime/themes/dark_plus.toml
@@ -92,7 +92,8 @@
"info" = { fg = "light_blue" }
"hint" = { fg = "light_gray3" }
-diagnostic = { modifiers = ["underlined"] }
+"diagnostic.error" = {underline = "red", modifiers = ["undercurled"] }
+"diagnostic" = {underline = "gold", modifiers = ["undercurled"] }
[palette]
white = "#ffffff"