Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use `Refineable` for `ThemeStyles` (#3196)
Marshall Bowers272f85646050
diff --git a/crates/theme2/src/colors.rs b/crates/theme2/src/colors.rsindex 2a59fa41bda..02c93a2e983 100644--- a/crates/theme2/src/colors.rs+++ b/crates/theme2/src/colors.rs@@ -1,8 +1,9 @@use gpui2::Hsla;use refineable::Refineable;-use crate::{generate_struct_with_overrides, SyntaxTheme};+use crate::SyntaxTheme;+#[derive(Clone)]pub struct SystemColors {pub transparent: Hsla,pub mac_os_traffic_light_red: Hsla,@@ -17,6 +18,7 @@ pub struct PlayerColor {pub selection: Hsla,}+#[derive(Clone)]pub struct PlayerColors(pub Vec<PlayerColor>);#[derive(Refineable, Clone, Debug)]@@ -46,7 +48,7 @@ pub struct GitStatusColors {pub renamed: Hsla,}-#[derive(Refineable, Clone, Debug)]+#[derive(Refineable, Clone, Debug, Default)]#[refineable(debug)]pub struct ThemeColors {pub border: Hsla,@@ -86,15 +88,14 @@ pub struct ThemeColors {pub editor_active_line: Hsla,}-generate_struct_with_overrides! {- ThemeStyle,- ThemeStyleOverrides,- system: SystemColors,- colors: ThemeColors,- status: StatusColors,- git: GitStatusColors,- player: PlayerColors,- syntax: SyntaxTheme+#[derive(Refineable, Clone)]+pub struct ThemeStyles {+ pub system: SystemColors,+ pub colors: ThemeColors,+ pub status: StatusColors,+ pub git: GitStatusColors,+ pub player: PlayerColors,+ pub syntax: SyntaxTheme,}#[cfg(test)]diff --git a/crates/theme2/src/default_theme.rs b/crates/theme2/src/default_theme.rsindex 26a55b5e0df..d7360b6f71e 100644--- a/crates/theme2/src/default_theme.rs+++ b/crates/theme2/src/default_theme.rs@@ -1,5 +1,5 @@use crate::{- colors::{GitStatusColors, PlayerColors, StatusColors, SystemColors, ThemeColors, ThemeStyle},+ colors::{GitStatusColors, PlayerColors, StatusColors, SystemColors, ThemeColors, ThemeStyles},default_color_scales, Appearance, SyntaxTheme, ThemeFamily, ThemeVariant,};@@ -8,7 +8,7 @@ fn zed_pro_daylight() -> ThemeVariant {id: "zed_pro_daylight".to_string(),name: "Zed Pro Daylight".into(),appearance: Appearance::Light,- styles: ThemeStyle {+ styles: ThemeStyles {system: SystemColors::default(),colors: ThemeColors::default_light(),status: StatusColors::default(),@@ -24,7 +24,7 @@ pub(crate) fn zed_pro_moonlight() -> ThemeVariant {id: "zed_pro_moonlight".to_string(),name: "Zed Pro Moonlight".into(),appearance: Appearance::Dark,- styles: ThemeStyle {+ styles: ThemeStyles {system: SystemColors::default(),colors: ThemeColors::default_dark(),status: StatusColors::default(),diff --git a/crates/theme2/src/syntax.rs b/crates/theme2/src/syntax.rsindex 1cf8564bca2..a8127f0c447 100644--- a/crates/theme2/src/syntax.rs+++ b/crates/theme2/src/syntax.rs@@ -1,6 +1,6 @@use gpui2::{HighlightStyle, Hsla};-#[derive(Clone)]+#[derive(Clone, Default)]pub struct SyntaxTheme {pub highlights: Vec<(String, HighlightStyle)>,}diff --git a/crates/theme2/src/theme2.rs b/crates/theme2/src/theme2.rsindex 372e976bd31..34727eaf893 100644--- a/crates/theme2/src/theme2.rs+++ b/crates/theme2/src/theme2.rs@@ -5,7 +5,6 @@ mod registry;mod scale;mod settings;mod syntax;-mod utils;pub use colors::*;pub use default_colors::*;@@ -55,7 +54,7 @@ pub struct ThemeVariant {pub(crate) id: String,pub name: SharedString,pub appearance: Appearance,- pub styles: ThemeStyle,+ pub styles: ThemeStyles,}impl ThemeVariant {diff --git a/crates/theme2/src/utils.rs b/crates/theme2/src/utils.rsdeleted file mode 100644index ccdcde42743..00000000000--- a/crates/theme2/src/utils.rs+++ /dev/null@@ -1,43 +0,0 @@-/// This macro generates a struct and a corresponding struct with optional fields.-///-/// It takes as input the name of the struct to be generated, the name of the struct with optional fields,-/// and a list of field names along with their types.-///-/// # Example-/// ```-/// generate_struct_with_overrides!(-/// MyStruct,-/// MyStructOverride,-/// field1: i32,-/// field2: String-/// );-/// ```-/// This will generate the following structs:-/// ```-/// pub struct MyStruct {-/// pub field1: i32,-/// pub field2: String,-/// }-///-/// pub struct MyStructOverride {-/// pub field1: Option<i32>,-/// pub field2: Option<String>,-/// }-/// ```-#[macro_export]-macro_rules! generate_struct_with_overrides {- ($struct_name:ident, $struct_override_name:ident, $($field:ident: $type:ty),*) => {- pub struct $struct_name {- $(- pub $field: $type,- )*- }-- #[allow(dead_code)]- pub struct $struct_override_name {- $(- pub $field: Option<$type>,- )*- }- };-}