aboutsummaryrefslogtreecommitdiff
path: root/helix-tui/src/buffer.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-10-19 04:51:13 +0000
committerGitHub2022-10-19 04:51:13 +0000
commit418a622db9d957d09e10ccbc3897d8ac9268dc8e (patch)
tree6e69857287580ab24c1e60ac199138ac23dc37df /helix-tui/src/buffer.rs
parentfaf0c521d15c314f411cc6178024c5d3310212da (diff)
parent66a49080bc7e492c37f9cd10ed36a696de1787a3 (diff)
Merge pull request #4061 from pascalkuthe/undercurl-modifier
Support different kinds of underline rendering (updated)
Diffstat (limited to 'helix-tui/src/buffer.rs')
-rw-r--r--helix-tui/src/buffer.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs
index 21c53aad..424e6d32 100644
--- a/helix-tui/src/buffer.rs
+++ b/helix-tui/src/buffer.rs
@@ -3,7 +3,7 @@ use helix_core::unicode::width::UnicodeWidthStr;
use std::cmp::min;
use unicode_segmentation::UnicodeSegmentation;
-use helix_view::graphics::{Color, Modifier, Rect, Style};
+use helix_view::graphics::{Color, Modifier, Rect, Style, UnderlineStyle};
/// A buffer cell
#[derive(Debug, Clone, PartialEq)]
@@ -11,6 +11,8 @@ pub struct Cell {
pub symbol: String,
pub fg: Color,
pub bg: Color,
+ pub underline_color: Color,
+ pub underline_style: UnderlineStyle,
pub modifier: Modifier,
}
@@ -44,6 +46,13 @@ impl Cell {
if let Some(c) = style.bg {
self.bg = c;
}
+ if let Some(c) = style.underline_color {
+ self.underline_color = c;
+ }
+ if let Some(style) = style.underline_style {
+ self.underline_style = style;
+ }
+
self.modifier.insert(style.add_modifier);
self.modifier.remove(style.sub_modifier);
self
@@ -53,6 +62,8 @@ impl Cell {
Style::default()
.fg(self.fg)
.bg(self.bg)
+ .underline_color(self.underline_color)
+ .underline_style(self.underline_style)
.add_modifier(self.modifier)
}
@@ -61,6 +72,8 @@ impl Cell {
self.symbol.push(' ');
self.fg = Color::Reset;
self.bg = Color::Reset;
+ self.underline_color = Color::Reset;
+ self.underline_style = UnderlineStyle::Reset;
self.modifier = Modifier::empty();
}
}
@@ -71,6 +84,8 @@ impl Default for Cell {
symbol: " ".into(),
fg: Color::Reset,
bg: Color::Reset,
+ underline_color: Color::Reset,
+ underline_style: UnderlineStyle::Reset,
modifier: Modifier::empty(),
}
}
@@ -87,7 +102,7 @@ impl Default for Cell {
///
/// ```
/// use helix_tui::buffer::{Buffer, Cell};
-/// use helix_view::graphics::{Rect, Color, Style, Modifier};
+/// use helix_view::graphics::{Rect, Color, UnderlineStyle, Style, Modifier};
///
/// let mut buf = Buffer::empty(Rect{x: 0, y: 0, width: 10, height: 5});
/// buf[(0, 2)].set_symbol("x");
@@ -97,7 +112,9 @@ impl Default for Cell {
/// symbol: String::from("r"),
/// fg: Color::Red,
/// bg: Color::White,
-/// modifier: Modifier::empty()
+/// underline_color: Color::Reset,
+/// underline_style: UnderlineStyle::Reset,
+/// modifier: Modifier::empty(),
/// });
/// buf[(5, 0)].set_char('x');
/// assert_eq!(buf[(5, 0)].symbol, "x");