Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-view/src/graphics.rs')
| -rw-r--r-- | helix-view/src/graphics.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index 7625e8b5..3a4eee3d 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -315,6 +315,34 @@ impl From<Color> for termina::style::ColorSpec { } } +#[cfg(all(feature = "term", windows))] +impl From<Color> for crossterm::style::Color { + fn from(color: Color) -> Self { + use crossterm::style::Color as CColor; + + match color { + Color::Reset => CColor::Reset, + Color::Black => CColor::Black, + Color::Red => CColor::DarkRed, + Color::Green => CColor::DarkGreen, + Color::Yellow => CColor::DarkYellow, + Color::Blue => CColor::DarkBlue, + Color::Magenta => CColor::DarkMagenta, + Color::Cyan => CColor::DarkCyan, + Color::Gray => CColor::DarkGrey, + Color::LightRed => CColor::Red, + Color::LightGreen => CColor::Green, + Color::LightBlue => CColor::Blue, + Color::LightYellow => CColor::Yellow, + Color::LightMagenta => CColor::Magenta, + Color::LightCyan => CColor::Cyan, + Color::LightGray => CColor::Grey, + Color::White => CColor::White, + Color::Indexed(i) => CColor::AnsiValue(i), + Color::Rgb(r, g, b) => CColor::Rgb { r, g, b }, + } + } +} #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum UnderlineStyle { Reset, @@ -354,6 +382,20 @@ impl From<UnderlineStyle> for termina::style::Underline { } } +#[cfg(all(feature = "term", windows))] +impl From<UnderlineStyle> for crossterm::style::Attribute { + fn from(style: UnderlineStyle) -> Self { + match style { + UnderlineStyle::Line => crossterm::style::Attribute::Underlined, + UnderlineStyle::Curl => crossterm::style::Attribute::Undercurled, + UnderlineStyle::Dotted => crossterm::style::Attribute::Underdotted, + UnderlineStyle::Dashed => crossterm::style::Attribute::Underdashed, + UnderlineStyle::DoubleLine => crossterm::style::Attribute::DoubleUnderlined, + UnderlineStyle::Reset => crossterm::style::Attribute::NoUnderline, + } + } +} + bitflags! { /// Modifier changes the way a piece of text is displayed. /// |