Reorganize theme2 crate
This commit is contained in:
parent
7be12cb7b1
commit
889d20d046
9 changed files with 315 additions and 304 deletions
|
@ -1,243 +1,15 @@
|
|||
use gpui::{hsla, Hsla, Rgba};
|
||||
use gpui::{Hsla, Rgba};
|
||||
|
||||
use crate::colors::{SystemColors, ThemeColors};
|
||||
use crate::scale::{ColorScaleSet, ColorScales};
|
||||
use crate::syntax::SyntaxTheme;
|
||||
use crate::{ColorScale, PlayerColor, PlayerColors};
|
||||
|
||||
impl Default for PlayerColors {
|
||||
fn default() -> Self {
|
||||
Self(vec![
|
||||
PlayerColor {
|
||||
cursor: blue().dark().step_9(),
|
||||
background: blue().dark().step_5(),
|
||||
selection: blue().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: orange().dark().step_9(),
|
||||
background: orange().dark().step_5(),
|
||||
selection: orange().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: pink().dark().step_9(),
|
||||
background: pink().dark().step_5(),
|
||||
selection: pink().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: lime().dark().step_9(),
|
||||
background: lime().dark().step_5(),
|
||||
selection: lime().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: purple().dark().step_9(),
|
||||
background: purple().dark().step_5(),
|
||||
selection: purple().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: amber().dark().step_9(),
|
||||
background: amber().dark().step_5(),
|
||||
selection: amber().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: jade().dark().step_9(),
|
||||
background: jade().dark().step_5(),
|
||||
selection: jade().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: red().dark().step_9(),
|
||||
background: red().dark().step_5(),
|
||||
selection: red().dark().step_3(),
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
impl PlayerColors {
|
||||
pub fn default_light() -> Self {
|
||||
Self(vec![
|
||||
PlayerColor {
|
||||
cursor: blue().light().step_9(),
|
||||
background: blue().light().step_4(),
|
||||
selection: blue().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: orange().light().step_9(),
|
||||
background: orange().light().step_4(),
|
||||
selection: orange().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: pink().light().step_9(),
|
||||
background: pink().light().step_4(),
|
||||
selection: pink().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: lime().light().step_9(),
|
||||
background: lime().light().step_4(),
|
||||
selection: lime().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: purple().light().step_9(),
|
||||
background: purple().light().step_4(),
|
||||
selection: purple().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: amber().light().step_9(),
|
||||
background: amber().light().step_4(),
|
||||
selection: amber().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: jade().light().step_9(),
|
||||
background: jade().light().step_4(),
|
||||
selection: jade().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: red().light().step_9(),
|
||||
background: red().light().step_4(),
|
||||
selection: red().light().step_3(),
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
use crate::ColorScale;
|
||||
use crate::{SystemColors, ThemeColors};
|
||||
|
||||
pub(crate) fn neutral() -> ColorScaleSet {
|
||||
slate()
|
||||
}
|
||||
|
||||
impl Default for SystemColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
transparent: hsla(0.0, 0.0, 0.0, 0.0),
|
||||
mac_os_traffic_light_red: hsla(0.0139, 0.79, 0.65, 1.0),
|
||||
mac_os_traffic_light_yellow: hsla(0.114, 0.88, 0.63, 1.0),
|
||||
mac_os_traffic_light_green: hsla(0.313, 0.49, 0.55, 1.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SyntaxTheme {
|
||||
pub fn default_light() -> Self {
|
||||
Self {
|
||||
highlights: vec![
|
||||
("attribute".into(), cyan().light().step_11().into()),
|
||||
("boolean".into(), tomato().light().step_11().into()),
|
||||
("comment".into(), neutral().light().step_11().into()),
|
||||
("comment.doc".into(), iris().light().step_12().into()),
|
||||
("constant".into(), red().light().step_9().into()),
|
||||
("constructor".into(), red().light().step_9().into()),
|
||||
("embedded".into(), red().light().step_9().into()),
|
||||
("emphasis".into(), red().light().step_9().into()),
|
||||
("emphasis.strong".into(), red().light().step_9().into()),
|
||||
("enum".into(), red().light().step_9().into()),
|
||||
("function".into(), red().light().step_9().into()),
|
||||
("hint".into(), red().light().step_9().into()),
|
||||
("keyword".into(), orange().light().step_11().into()),
|
||||
("label".into(), red().light().step_9().into()),
|
||||
("link_text".into(), red().light().step_9().into()),
|
||||
("link_uri".into(), red().light().step_9().into()),
|
||||
("number".into(), red().light().step_9().into()),
|
||||
("operator".into(), red().light().step_9().into()),
|
||||
("predictive".into(), red().light().step_9().into()),
|
||||
("preproc".into(), red().light().step_9().into()),
|
||||
("primary".into(), red().light().step_9().into()),
|
||||
("property".into(), red().light().step_9().into()),
|
||||
("punctuation".into(), neutral().light().step_11().into()),
|
||||
(
|
||||
"punctuation.bracket".into(),
|
||||
neutral().light().step_11().into(),
|
||||
),
|
||||
(
|
||||
"punctuation.delimiter".into(),
|
||||
neutral().light().step_11().into(),
|
||||
),
|
||||
(
|
||||
"punctuation.list_marker".into(),
|
||||
blue().light().step_11().into(),
|
||||
),
|
||||
("punctuation.special".into(), red().light().step_9().into()),
|
||||
("string".into(), jade().light().step_11().into()),
|
||||
("string.escape".into(), red().light().step_9().into()),
|
||||
("string.regex".into(), tomato().light().step_11().into()),
|
||||
("string.special".into(), red().light().step_9().into()),
|
||||
(
|
||||
"string.special.symbol".into(),
|
||||
red().light().step_9().into(),
|
||||
),
|
||||
("tag".into(), red().light().step_9().into()),
|
||||
("text.literal".into(), red().light().step_9().into()),
|
||||
("title".into(), red().light().step_9().into()),
|
||||
("type".into(), red().light().step_9().into()),
|
||||
("variable".into(), red().light().step_9().into()),
|
||||
("variable.special".into(), red().light().step_9().into()),
|
||||
("variant".into(), red().light().step_9().into()),
|
||||
],
|
||||
inlay_style: tomato().light().step_1().into(), // todo!("nate: use a proper style")
|
||||
suggestion_style: orange().light().step_1().into(), // todo!("nate: use proper style")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_dark() -> Self {
|
||||
Self {
|
||||
highlights: vec![
|
||||
("attribute".into(), tomato().dark().step_11().into()),
|
||||
("boolean".into(), tomato().dark().step_11().into()),
|
||||
("comment".into(), neutral().dark().step_11().into()),
|
||||
("comment.doc".into(), iris().dark().step_12().into()),
|
||||
("constant".into(), orange().dark().step_11().into()),
|
||||
("constructor".into(), gold().dark().step_11().into()),
|
||||
("embedded".into(), red().dark().step_11().into()),
|
||||
("emphasis".into(), red().dark().step_11().into()),
|
||||
("emphasis.strong".into(), red().dark().step_11().into()),
|
||||
("enum".into(), yellow().dark().step_11().into()),
|
||||
("function".into(), blue().dark().step_11().into()),
|
||||
("hint".into(), indigo().dark().step_11().into()),
|
||||
("keyword".into(), plum().dark().step_11().into()),
|
||||
("label".into(), red().dark().step_11().into()),
|
||||
("link_text".into(), red().dark().step_11().into()),
|
||||
("link_uri".into(), red().dark().step_11().into()),
|
||||
("number".into(), red().dark().step_11().into()),
|
||||
("operator".into(), red().dark().step_11().into()),
|
||||
("predictive".into(), red().dark().step_11().into()),
|
||||
("preproc".into(), red().dark().step_11().into()),
|
||||
("primary".into(), red().dark().step_11().into()),
|
||||
("property".into(), red().dark().step_11().into()),
|
||||
("punctuation".into(), neutral().dark().step_11().into()),
|
||||
(
|
||||
"punctuation.bracket".into(),
|
||||
neutral().dark().step_11().into(),
|
||||
),
|
||||
(
|
||||
"punctuation.delimiter".into(),
|
||||
neutral().dark().step_11().into(),
|
||||
),
|
||||
(
|
||||
"punctuation.list_marker".into(),
|
||||
blue().dark().step_11().into(),
|
||||
),
|
||||
("punctuation.special".into(), red().dark().step_11().into()),
|
||||
("string".into(), lime().dark().step_11().into()),
|
||||
("string.escape".into(), orange().dark().step_11().into()),
|
||||
("string.regex".into(), tomato().dark().step_11().into()),
|
||||
("string.special".into(), red().dark().step_11().into()),
|
||||
(
|
||||
"string.special.symbol".into(),
|
||||
red().dark().step_11().into(),
|
||||
),
|
||||
("tag".into(), red().dark().step_11().into()),
|
||||
("text.literal".into(), purple().dark().step_11().into()),
|
||||
("title".into(), sky().dark().step_11().into()),
|
||||
("type".into(), mint().dark().step_11().into()),
|
||||
("variable".into(), red().dark().step_11().into()),
|
||||
("variable.special".into(), red().dark().step_11().into()),
|
||||
("variant".into(), red().dark().step_11().into()),
|
||||
],
|
||||
inlay_style: neutral().dark().step_11().into(), // todo!("nate: use a proper style")
|
||||
suggestion_style: orange().dark().step_11().into(), // todo!("nate: use a proper style")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ThemeColors {
|
||||
pub fn default_light() -> Self {
|
||||
pub fn light() -> Self {
|
||||
let system = SystemColors::default();
|
||||
|
||||
Self {
|
||||
|
@ -309,7 +81,7 @@ impl ThemeColors {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn default_dark() -> Self {
|
||||
pub fn dark() -> Self {
|
||||
let system = SystemColors::default();
|
||||
|
||||
Self {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
colors::{StatusColors, SystemColors, ThemeColors, ThemeStyles},
|
||||
default_color_scales, Appearance, PlayerColors, SyntaxTheme, Theme, ThemeFamily,
|
||||
default_color_scales, Appearance, PlayerColors, StatusColors, SyntaxTheme, SystemColors, Theme,
|
||||
ThemeColors, ThemeFamily, ThemeStyles,
|
||||
};
|
||||
|
||||
fn zed_pro_daylight() -> Theme {
|
||||
|
@ -12,10 +12,10 @@ fn zed_pro_daylight() -> Theme {
|
|||
appearance: Appearance::Light,
|
||||
styles: ThemeStyles {
|
||||
system: SystemColors::default(),
|
||||
colors: ThemeColors::default_light(),
|
||||
colors: ThemeColors::light(),
|
||||
status: StatusColors::light(),
|
||||
player: PlayerColors::default_light(),
|
||||
syntax: Arc::new(SyntaxTheme::default_light()),
|
||||
player: PlayerColors::light(),
|
||||
syntax: Arc::new(SyntaxTheme::light()),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ pub(crate) fn zed_pro_moonlight() -> Theme {
|
|||
appearance: Appearance::Dark,
|
||||
styles: ThemeStyles {
|
||||
system: SystemColors::default(),
|
||||
colors: ThemeColors::default_dark(),
|
||||
colors: ThemeColors::dark(),
|
||||
status: StatusColors::dark(),
|
||||
player: PlayerColors::default(),
|
||||
syntax: Arc::new(SyntaxTheme::default_dark()),
|
||||
player: PlayerColors::dark(),
|
||||
syntax: Arc::new(SyntaxTheme::dark()),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ impl ThemeRegistry {
|
|||
fn insert_user_themes(&mut self, themes: impl IntoIterator<Item = UserTheme>) {
|
||||
self.insert_themes(themes.into_iter().map(|user_theme| {
|
||||
let mut theme_colors = match user_theme.appearance {
|
||||
Appearance::Light => ThemeColors::default_light(),
|
||||
Appearance::Dark => ThemeColors::default_dark(),
|
||||
Appearance::Light => ThemeColors::light(),
|
||||
Appearance::Dark => ThemeColors::dark(),
|
||||
};
|
||||
theme_colors.refine(&user_theme.styles.colors);
|
||||
|
||||
|
@ -47,8 +47,8 @@ impl ThemeRegistry {
|
|||
status_colors.refine(&user_theme.styles.status);
|
||||
|
||||
let mut syntax_colors = match user_theme.appearance {
|
||||
Appearance::Light => SyntaxTheme::default_light(),
|
||||
Appearance::Dark => SyntaxTheme::default_dark(),
|
||||
Appearance::Light => SyntaxTheme::light(),
|
||||
Appearance::Dark => SyntaxTheme::dark(),
|
||||
};
|
||||
if let Some(user_syntax) = user_theme.styles.syntax {
|
||||
syntax_colors.highlights = user_syntax
|
||||
|
|
|
@ -2,54 +2,7 @@ use gpui::Hsla;
|
|||
use refineable::Refineable;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{PlayerColors, SyntaxTheme, SystemColors};
|
||||
|
||||
#[derive(Refineable, Clone, Debug)]
|
||||
#[refineable(Debug, serde::Deserialize)]
|
||||
pub struct StatusColors {
|
||||
/// Indicates some kind of conflict, like a file changed on disk while it was open, or
|
||||
/// merge conflicts in a Git repository.
|
||||
pub conflict: Hsla,
|
||||
|
||||
/// Indicates something new, like a new file added to a Git repository.
|
||||
pub created: Hsla,
|
||||
|
||||
/// Indicates that something no longer exists, like a deleted file.
|
||||
pub deleted: Hsla,
|
||||
|
||||
/// Indicates a system error, a failed operation or a diagnostic error.
|
||||
pub error: Hsla,
|
||||
|
||||
/// Represents a hidden status, such as a file being hidden in a file tree.
|
||||
pub hidden: Hsla,
|
||||
|
||||
/// Indicates a hint or some kind of additional information.
|
||||
pub hint: Hsla,
|
||||
|
||||
/// Indicates that something is deliberately ignored, such as a file or operation ignored by Git.
|
||||
pub ignored: Hsla,
|
||||
|
||||
/// Represents informational status updates or messages.
|
||||
pub info: Hsla,
|
||||
|
||||
/// Indicates a changed or altered status, like a file that has been edited.
|
||||
pub modified: Hsla,
|
||||
|
||||
/// Indicates something that is predicted, like automatic code completion, or generated code.
|
||||
pub predictive: Hsla,
|
||||
|
||||
/// Represents a renamed status, such as a file that has been renamed.
|
||||
pub renamed: Hsla,
|
||||
|
||||
/// Indicates a successful operation or task completion.
|
||||
pub success: Hsla,
|
||||
|
||||
/// Indicates some kind of unreachable status, like a block of code that can never be reached.
|
||||
pub unreachable: Hsla,
|
||||
|
||||
/// Represents a warning status, like an operation that is about to fail.
|
||||
pub warning: Hsla,
|
||||
}
|
||||
use crate::{PlayerColors, StatusColors, SyntaxTheme, SystemColors};
|
||||
|
||||
#[derive(Refineable, Clone, Debug)]
|
||||
#[refineable(Debug, serde::Deserialize)]
|
||||
|
@ -283,7 +236,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn override_a_single_theme_color() {
|
||||
let mut colors = ThemeColors::default_light();
|
||||
let mut colors = ThemeColors::light();
|
||||
|
||||
let magenta: Hsla = gpui::rgb(0xff00ff);
|
||||
|
||||
|
@ -301,7 +254,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn override_multiple_theme_colors() {
|
||||
let mut colors = ThemeColors::default_light();
|
||||
let mut colors = ThemeColors::light();
|
||||
|
||||
let magenta: Hsla = gpui::rgb(0xff00ff);
|
||||
let green: Hsla = gpui::rgb(0x00ff00);
|
||||
|
|
|
@ -16,6 +16,107 @@ pub struct PlayerColor {
|
|||
#[derive(Clone)]
|
||||
pub struct PlayerColors(pub Vec<PlayerColor>);
|
||||
|
||||
impl Default for PlayerColors {
|
||||
/// Don't use this!
|
||||
/// We have to have a default to be `[refineable::Refinable]`.
|
||||
/// todo!("Find a way to not need this for Refinable")
|
||||
fn default() -> Self {
|
||||
Self::dark()
|
||||
}
|
||||
}
|
||||
|
||||
impl PlayerColors {
|
||||
pub fn dark() -> Self {
|
||||
Self(vec![
|
||||
PlayerColor {
|
||||
cursor: blue().dark().step_9(),
|
||||
background: blue().dark().step_5(),
|
||||
selection: blue().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: orange().dark().step_9(),
|
||||
background: orange().dark().step_5(),
|
||||
selection: orange().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: pink().dark().step_9(),
|
||||
background: pink().dark().step_5(),
|
||||
selection: pink().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: lime().dark().step_9(),
|
||||
background: lime().dark().step_5(),
|
||||
selection: lime().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: purple().dark().step_9(),
|
||||
background: purple().dark().step_5(),
|
||||
selection: purple().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: amber().dark().step_9(),
|
||||
background: amber().dark().step_5(),
|
||||
selection: amber().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: jade().dark().step_9(),
|
||||
background: jade().dark().step_5(),
|
||||
selection: jade().dark().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: red().dark().step_9(),
|
||||
background: red().dark().step_5(),
|
||||
selection: red().dark().step_3(),
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
pub fn light() -> Self {
|
||||
Self(vec![
|
||||
PlayerColor {
|
||||
cursor: blue().light().step_9(),
|
||||
background: blue().light().step_4(),
|
||||
selection: blue().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: orange().light().step_9(),
|
||||
background: orange().light().step_4(),
|
||||
selection: orange().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: pink().light().step_9(),
|
||||
background: pink().light().step_4(),
|
||||
selection: pink().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: lime().light().step_9(),
|
||||
background: lime().light().step_4(),
|
||||
selection: lime().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: purple().light().step_9(),
|
||||
background: purple().light().step_4(),
|
||||
selection: purple().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: amber().light().step_9(),
|
||||
background: amber().light().step_4(),
|
||||
selection: amber().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: jade().light().step_9(),
|
||||
background: jade().light().step_4(),
|
||||
selection: jade().light().step_3(),
|
||||
},
|
||||
PlayerColor {
|
||||
cursor: red().light().step_9(),
|
||||
background: red().light().step_4(),
|
||||
selection: red().light().step_3(),
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
impl PlayerColors {
|
||||
pub fn local(&self) -> PlayerColor {
|
||||
// todo!("use a valid color");
|
||||
|
@ -36,6 +137,8 @@ impl PlayerColors {
|
|||
#[cfg(feature = "stories")]
|
||||
pub use stories::*;
|
||||
|
||||
use crate::{amber, blue, jade, lime, orange, pink, purple, red};
|
||||
|
||||
#[cfg(feature = "stories")]
|
||||
mod stories {
|
||||
use super::*;
|
||||
|
|
|
@ -1,10 +1,59 @@
|
|||
use gpui::Hsla;
|
||||
use refineable::Refineable;
|
||||
|
||||
use crate::{blue, grass, neutral, red, yellow, StatusColors};
|
||||
use crate::{blue, grass, neutral, red, yellow};
|
||||
|
||||
#[derive(Refineable, Clone, Debug)]
|
||||
#[refineable(Debug, serde::Deserialize)]
|
||||
pub struct StatusColors {
|
||||
/// Indicates some kind of conflict, like a file changed on disk while it was open, or
|
||||
/// merge conflicts in a Git repository.
|
||||
pub conflict: Hsla,
|
||||
|
||||
/// Indicates something new, like a new file added to a Git repository.
|
||||
pub created: Hsla,
|
||||
|
||||
/// Indicates that something no longer exists, like a deleted file.
|
||||
pub deleted: Hsla,
|
||||
|
||||
/// Indicates a system error, a failed operation or a diagnostic error.
|
||||
pub error: Hsla,
|
||||
|
||||
/// Represents a hidden status, such as a file being hidden in a file tree.
|
||||
pub hidden: Hsla,
|
||||
|
||||
/// Indicates a hint or some kind of additional information.
|
||||
pub hint: Hsla,
|
||||
|
||||
/// Indicates that something is deliberately ignored, such as a file or operation ignored by Git.
|
||||
pub ignored: Hsla,
|
||||
|
||||
/// Represents informational status updates or messages.
|
||||
pub info: Hsla,
|
||||
|
||||
/// Indicates a changed or altered status, like a file that has been edited.
|
||||
pub modified: Hsla,
|
||||
|
||||
/// Indicates something that is predicted, like automatic code completion, or generated code.
|
||||
pub predictive: Hsla,
|
||||
|
||||
/// Represents a renamed status, such as a file that has been renamed.
|
||||
pub renamed: Hsla,
|
||||
|
||||
/// Indicates a successful operation or task completion.
|
||||
pub success: Hsla,
|
||||
|
||||
/// Indicates some kind of unreachable status, like a block of code that can never be reached.
|
||||
pub unreachable: Hsla,
|
||||
|
||||
/// Represents a warning status, like an operation that is about to fail.
|
||||
pub warning: Hsla,
|
||||
}
|
||||
|
||||
impl Default for StatusColors {
|
||||
/// Don't use this!
|
||||
/// We have to have a default for StatusColors to be `[refineable::Refinable]`.
|
||||
/// We have to have a default to be `[refineable::Refinable]`.
|
||||
/// todo!("Find a way to not need this for Refinable")
|
||||
fn default() -> Self {
|
||||
Self::dark()
|
||||
}
|
||||
|
|
|
@ -1,13 +1,142 @@
|
|||
use gpui::{HighlightStyle, Hsla};
|
||||
|
||||
use crate::{
|
||||
blue, cyan, gold, indigo, iris, jade, lime, mint, neutral, orange, plum, purple, red, sky,
|
||||
tomato, yellow,
|
||||
};
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct SyntaxTheme {
|
||||
pub highlights: Vec<(String, HighlightStyle)>,
|
||||
// todo!("Remove this in favor of StatusColor.hint")
|
||||
// If this should be overridable we should move it to ThemeColors
|
||||
pub inlay_style: HighlightStyle,
|
||||
// todo!("Remove this in favor of StatusColor.prediction")
|
||||
// If this should be overridable we should move it to ThemeColors
|
||||
pub suggestion_style: HighlightStyle,
|
||||
}
|
||||
|
||||
impl SyntaxTheme {
|
||||
pub fn light() -> Self {
|
||||
Self {
|
||||
highlights: vec![
|
||||
("attribute".into(), cyan().light().step_11().into()),
|
||||
("boolean".into(), tomato().light().step_11().into()),
|
||||
("comment".into(), neutral().light().step_11().into()),
|
||||
("comment.doc".into(), iris().light().step_12().into()),
|
||||
("constant".into(), red().light().step_9().into()),
|
||||
("constructor".into(), red().light().step_9().into()),
|
||||
("embedded".into(), red().light().step_9().into()),
|
||||
("emphasis".into(), red().light().step_9().into()),
|
||||
("emphasis.strong".into(), red().light().step_9().into()),
|
||||
("enum".into(), red().light().step_9().into()),
|
||||
("function".into(), red().light().step_9().into()),
|
||||
("hint".into(), red().light().step_9().into()),
|
||||
("keyword".into(), orange().light().step_11().into()),
|
||||
("label".into(), red().light().step_9().into()),
|
||||
("link_text".into(), red().light().step_9().into()),
|
||||
("link_uri".into(), red().light().step_9().into()),
|
||||
("number".into(), red().light().step_9().into()),
|
||||
("operator".into(), red().light().step_9().into()),
|
||||
("predictive".into(), red().light().step_9().into()),
|
||||
("preproc".into(), red().light().step_9().into()),
|
||||
("primary".into(), red().light().step_9().into()),
|
||||
("property".into(), red().light().step_9().into()),
|
||||
("punctuation".into(), neutral().light().step_11().into()),
|
||||
(
|
||||
"punctuation.bracket".into(),
|
||||
neutral().light().step_11().into(),
|
||||
),
|
||||
(
|
||||
"punctuation.delimiter".into(),
|
||||
neutral().light().step_11().into(),
|
||||
),
|
||||
(
|
||||
"punctuation.list_marker".into(),
|
||||
blue().light().step_11().into(),
|
||||
),
|
||||
("punctuation.special".into(), red().light().step_9().into()),
|
||||
("string".into(), jade().light().step_11().into()),
|
||||
("string.escape".into(), red().light().step_9().into()),
|
||||
("string.regex".into(), tomato().light().step_11().into()),
|
||||
("string.special".into(), red().light().step_9().into()),
|
||||
(
|
||||
"string.special.symbol".into(),
|
||||
red().light().step_9().into(),
|
||||
),
|
||||
("tag".into(), red().light().step_9().into()),
|
||||
("text.literal".into(), red().light().step_9().into()),
|
||||
("title".into(), red().light().step_9().into()),
|
||||
("type".into(), red().light().step_9().into()),
|
||||
("variable".into(), red().light().step_9().into()),
|
||||
("variable.special".into(), red().light().step_9().into()),
|
||||
("variant".into(), red().light().step_9().into()),
|
||||
],
|
||||
inlay_style: tomato().light().step_1().into(), // todo!("nate: use a proper style")
|
||||
suggestion_style: orange().light().step_1().into(), // todo!("nate: use proper style")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dark() -> Self {
|
||||
Self {
|
||||
highlights: vec![
|
||||
("attribute".into(), tomato().dark().step_11().into()),
|
||||
("boolean".into(), tomato().dark().step_11().into()),
|
||||
("comment".into(), neutral().dark().step_11().into()),
|
||||
("comment.doc".into(), iris().dark().step_12().into()),
|
||||
("constant".into(), orange().dark().step_11().into()),
|
||||
("constructor".into(), gold().dark().step_11().into()),
|
||||
("embedded".into(), red().dark().step_11().into()),
|
||||
("emphasis".into(), red().dark().step_11().into()),
|
||||
("emphasis.strong".into(), red().dark().step_11().into()),
|
||||
("enum".into(), yellow().dark().step_11().into()),
|
||||
("function".into(), blue().dark().step_11().into()),
|
||||
("hint".into(), indigo().dark().step_11().into()),
|
||||
("keyword".into(), plum().dark().step_11().into()),
|
||||
("label".into(), red().dark().step_11().into()),
|
||||
("link_text".into(), red().dark().step_11().into()),
|
||||
("link_uri".into(), red().dark().step_11().into()),
|
||||
("number".into(), red().dark().step_11().into()),
|
||||
("operator".into(), red().dark().step_11().into()),
|
||||
("predictive".into(), red().dark().step_11().into()),
|
||||
("preproc".into(), red().dark().step_11().into()),
|
||||
("primary".into(), red().dark().step_11().into()),
|
||||
("property".into(), red().dark().step_11().into()),
|
||||
("punctuation".into(), neutral().dark().step_11().into()),
|
||||
(
|
||||
"punctuation.bracket".into(),
|
||||
neutral().dark().step_11().into(),
|
||||
),
|
||||
(
|
||||
"punctuation.delimiter".into(),
|
||||
neutral().dark().step_11().into(),
|
||||
),
|
||||
(
|
||||
"punctuation.list_marker".into(),
|
||||
blue().dark().step_11().into(),
|
||||
),
|
||||
("punctuation.special".into(), red().dark().step_11().into()),
|
||||
("string".into(), lime().dark().step_11().into()),
|
||||
("string.escape".into(), orange().dark().step_11().into()),
|
||||
("string.regex".into(), tomato().dark().step_11().into()),
|
||||
("string.special".into(), red().dark().step_11().into()),
|
||||
(
|
||||
"string.special.symbol".into(),
|
||||
red().dark().step_11().into(),
|
||||
),
|
||||
("tag".into(), red().dark().step_11().into()),
|
||||
("text.literal".into(), purple().dark().step_11().into()),
|
||||
("title".into(), sky().dark().step_11().into()),
|
||||
("type".into(), mint().dark().step_11().into()),
|
||||
("variable".into(), red().dark().step_11().into()),
|
||||
("variable.special".into(), red().dark().step_11().into()),
|
||||
("variant".into(), red().dark().step_11().into()),
|
||||
],
|
||||
inlay_style: neutral().dark().step_11().into(), // todo!("nate: use a proper style")
|
||||
suggestion_style: orange().dark().step_11().into(), // todo!("nate: use a proper style")
|
||||
}
|
||||
}
|
||||
|
||||
// TOOD: Get this working with `#[cfg(test)]`. Why isn't it?
|
||||
pub fn new_test(colors: impl IntoIterator<Item = (&'static str, Hsla)>) -> Self {
|
||||
SyntaxTheme {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use gpui::Hsla;
|
||||
use gpui::{hsla, Hsla};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SystemColors {
|
||||
|
@ -7,3 +7,14 @@ pub struct SystemColors {
|
|||
pub mac_os_traffic_light_yellow: Hsla,
|
||||
pub mac_os_traffic_light_green: Hsla,
|
||||
}
|
||||
|
||||
impl Default for SystemColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
transparent: hsla(0.0, 0.0, 0.0, 0.0),
|
||||
mac_os_traffic_light_red: hsla(0.0139, 0.79, 0.65, 1.0),
|
||||
mac_os_traffic_light_yellow: hsla(0.114, 0.88, 0.63, 1.0),
|
||||
mac_os_traffic_light_green: hsla(0.313, 0.49, 0.55, 1.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
mod colors;
|
||||
mod default_colors;
|
||||
mod default_theme;
|
||||
mod players;
|
||||
mod registry;
|
||||
mod scale;
|
||||
mod settings;
|
||||
mod styles;
|
||||
mod syntax;
|
||||
#[cfg(not(feature = "importing-themes"))]
|
||||
mod themes;
|
||||
mod user_theme;
|
||||
|
@ -14,15 +11,12 @@ mod user_theme;
|
|||
use std::sync::Arc;
|
||||
|
||||
use ::settings::Settings;
|
||||
pub use colors::*;
|
||||
pub use default_colors::*;
|
||||
pub use default_theme::*;
|
||||
pub use players::*;
|
||||
pub use registry::*;
|
||||
pub use scale::*;
|
||||
pub use settings::*;
|
||||
pub use styles::*;
|
||||
pub use syntax::*;
|
||||
#[cfg(not(feature = "importing-themes"))]
|
||||
pub use themes::*;
|
||||
pub use user_theme::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue