|
|
@ -1,29 +1,14 @@
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use druid_shell::piet::Color;
|
|
|
|
use skia_safe::Color4f;
|
|
|
|
|
|
|
|
use skia_safe::colors::*;
|
|
|
|
|
|
|
|
|
|
|
|
use neovim_lib::{Neovim, NeovimApi};
|
|
|
|
use neovim_lib::{Neovim, NeovimApi};
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(new, Debug, Clone)]
|
|
|
|
#[derive(new, PartialEq, Debug, Clone)]
|
|
|
|
pub struct Colors {
|
|
|
|
pub struct Colors {
|
|
|
|
pub foreground: Option<Color>,
|
|
|
|
pub foreground: Option<Color4f>,
|
|
|
|
pub background: Option<Color>,
|
|
|
|
pub background: Option<Color4f>,
|
|
|
|
pub special: Option<Color>
|
|
|
|
pub special: Option<Color4f>
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl PartialEq for Colors {
|
|
|
|
|
|
|
|
fn eq(&self, other: &Colors) -> bool {
|
|
|
|
|
|
|
|
fn compare_options(a: &Option<Color>, b: &Option<Color>) -> bool {
|
|
|
|
|
|
|
|
match (a, b) {
|
|
|
|
|
|
|
|
(Some(a), Some(b)) => a.as_rgba_u32() == b.as_rgba_u32(),
|
|
|
|
|
|
|
|
(None, None) => true,
|
|
|
|
|
|
|
|
_ => false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
compare_options(&self.foreground, &other.foreground) &&
|
|
|
|
|
|
|
|
compare_options(&self.background, &other.background) &&
|
|
|
|
|
|
|
|
compare_options(&self.special, &other.special)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(new, Debug, Clone, PartialEq)]
|
|
|
|
#[derive(new, Debug, Clone, PartialEq)]
|
|
|
@ -81,7 +66,7 @@ impl Editor {
|
|
|
|
grid: Vec::new(),
|
|
|
|
grid: Vec::new(),
|
|
|
|
cursor_pos: (0, 0),
|
|
|
|
cursor_pos: (0, 0),
|
|
|
|
size: (width, height),
|
|
|
|
size: (width, height),
|
|
|
|
default_colors: Colors::new(Some(Color::rgb(0xff, 0xff, 0xff)), Some(Color::rgb(0x00, 0x00, 0x00)), Some(Color::rgb(0x88, 0x88, 0x88))),
|
|
|
|
default_colors: Colors::new(Some(colors::WHITE), Some(colors::BLACK), Some(colors::GREY)),
|
|
|
|
defined_styles: HashMap::new(),
|
|
|
|
defined_styles: HashMap::new(),
|
|
|
|
previous_style: None
|
|
|
|
previous_style: None
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -174,7 +159,7 @@ impl Editor {
|
|
|
|
self.defined_styles.insert(id, style);
|
|
|
|
self.defined_styles.insert(id, style);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn set_default_colors(&mut self, foreground: Color, background: Color, special: Color) {
|
|
|
|
pub fn set_default_colors(&mut self, foreground: Color4f, background: Color4f, special: Color4f) {
|
|
|
|
self.default_colors = Colors::new(Some(foreground), Some(background), Some(special));
|
|
|
|
self.default_colors = Colors::new(Some(foreground), Some(background), Some(special));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|