Highlighter now handles highlighting visual mode selections instead of LineBuf

This commit is contained in:
2026-02-20 14:03:42 -05:00
parent 6aa5521562
commit 3b515c42a6
4 changed files with 84 additions and 16 deletions

View File

@@ -15,6 +15,8 @@ impl<T: Display> Styled for T {}
pub enum Style {
// Undoes all styles
Reset,
ResetFg,
ResetBg,
// Foreground Colors
Black,
Red,
@@ -66,6 +68,8 @@ impl Display for Style {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Style::Reset => write!(f, "\x1b[0m"),
Style::ResetFg => write!(f, "\x1b[39m"),
Style::ResetBg => write!(f, "\x1b[49m"),
// Foreground colors
Style::Black => write!(f, "\x1b[30m"),
@@ -127,6 +131,14 @@ impl StyleSet {
Self { styles: vec![] }
}
pub fn styles(&self) -> &[Style] {
&self.styles
}
pub fn styles_mut(&mut self) -> &mut Vec<Style> {
&mut self.styles
}
pub fn add_style(mut self, style: Style) -> Self {
if !self.styles.contains(&style) {
self.styles.push(style);