From ac64b1236bb85cb693b71a0d3552bff1d298da22 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Fri, 22 May 2020 15:21:10 -0400 Subject: Use new Style struct, wrapping ansi_term::Style --- src/style.rs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/style.rs') diff --git a/src/style.rs b/src/style.rs index ede5d3da..17a265f3 100644 --- a/src/style.rs +++ b/src/style.rs @@ -1,4 +1,19 @@ -use ansi_term::{Color, Style}; +use ansi_term::{self, Color}; + +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Style { + pub ansi_term_style: ansi_term::Style, + pub is_syntax_highlighted: bool, +} + +impl Style { + pub fn new() -> Self { + Self { + ansi_term_style: ansi_term::Style::new(), + is_syntax_highlighted: false, + } + } +} pub const LIGHT_THEMES: [&str; 5] = [ "GitHub", @@ -86,17 +101,3 @@ const DARK_THEME_PLUS_COLOR_256: Color = Color::Fixed(22); const DARK_THEME_PLUS_EMPH_COLOR: Color = Color::RGB(0x00, 0x60, 0x00); const DARK_THEME_PLUS_EMPH_COLOR_256: Color = Color::Fixed(28); - -/// A special color value to signify that the foreground color of a style should be derived from -/// syntax highlighting. -pub const SYNTAX_HIGHLIGHTING_COLOR: Color = Color::White; // TODO - -pub trait SyntaxHighlightable { - fn is_syntax_highlighted(&self) -> bool; -} - -impl SyntaxHighlightable for Style { - fn is_syntax_highlighted(&self) -> bool { - self.foreground == Some(SYNTAX_HIGHLIGHTING_COLOR) - } -} -- cgit v1.2.3