diff --git a/src/editor.rs b/src/editor.rs index 94a5a5e..d681c56 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -31,6 +31,28 @@ pub struct Style { pub blend: u8 } +impl Style { + pub fn foreground(&self, default_colors: &Colors) -> Color4f { + if self.reverse { + self.colors.background.clone().unwrap_or(default_colors.background.clone().unwrap()) + } else { + self.colors.foreground.clone().unwrap_or(default_colors.foreground.clone().unwrap()) + } + } + + pub fn background(&self, default_colors: &Colors) -> Color4f { + if self.reverse { + self.colors.foreground.clone().unwrap_or(default_colors.foreground.clone().unwrap()) + } else { + self.colors.background.clone().unwrap_or(default_colors.background.clone().unwrap()) + } + } + + pub fn special(&self, default_colors: &Colors) -> Color4f { + self.colors.special.clone().unwrap_or(default_colors.special.clone().unwrap()) + } +} + #[derive(new, Debug, Clone, PartialEq)] pub struct ModeInfo { #[new(default)] @@ -73,6 +95,7 @@ pub struct Editor { pub cursor_pos: (u64, u64), pub cursor_type: CursorType, pub cursor_style: Option