Add a with_style method to Editor

This commit is contained in:
Max Brunsfeld
2021-09-01 17:15:21 -07:00
parent 6821c47e3d
commit 007d6f5eca
4 changed files with 51 additions and 22 deletions
+17 -4
View File
@@ -22,7 +22,7 @@ pub struct Theme {
pub workspace: Workspace,
pub chat_panel: ChatPanel,
pub selector: Selector,
pub editor: Editor,
pub editor: EditorStyle,
pub syntax: SyntaxTheme,
}
@@ -127,8 +127,8 @@ pub struct ContainedLabel {
pub label: LabelStyle,
}
#[derive(Deserialize)]
pub struct Editor {
#[derive(Clone, Deserialize)]
pub struct EditorStyle {
pub background: Color,
pub gutter_background: Color,
pub active_line_background: Color,
@@ -137,7 +137,7 @@ pub struct Editor {
pub replicas: Vec<Replica>,
}
#[derive(Clone, Copy, Deserialize)]
#[derive(Clone, Copy, Default, Deserialize)]
pub struct Replica {
pub cursor: Color,
pub selection: Color,
@@ -164,6 +164,19 @@ impl SyntaxTheme {
}
}
impl Default for EditorStyle {
fn default() -> Self {
Self {
background: Default::default(),
gutter_background: Default::default(),
active_line_background: Default::default(),
line_number: Default::default(),
line_number_active: Default::default(),
replicas: vec![Default::default()],
}
}
}
impl<'de> Deserialize<'de> for SyntaxTheme {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where