From 1bfe5bde0398b25fa90816725b808cce93f56413 Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Fri, 13 Dec 2019 15:05:17 -0800 Subject: [PATCH] mouse support, terminal handling, and underlines --- src/editor.rs | 46 ++++++++++++++++ src/events.rs | 9 +++- src/main.rs | 10 +++- src/window.rs | 143 +++++++++++++++++++++++++++++++++++++------------- 4 files changed, 167 insertions(+), 41 deletions(-) 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