1use gpui::{FontWeight, Hsla};
2use refineable::Refineable;
3use serde::Deserialize;
4
5use crate::{Appearance, StatusColors, StatusColorsRefinement, ThemeColors, ThemeColorsRefinement};
6
7#[derive(Deserialize)]
8pub struct UserThemeFamily {
9 pub name: String,
10 pub author: String,
11 pub themes: Vec<UserTheme>,
12}
13
14#[derive(Deserialize)]
15pub struct UserTheme {
16 pub name: String,
17 pub appearance: Appearance,
18 pub styles: UserThemeStylesRefinement,
19}
20
21#[derive(Refineable, Clone)]
22#[refineable(deserialize)]
23pub struct UserThemeStyles {
24 #[refineable]
25 pub colors: ThemeColors,
26 #[refineable]
27 pub status: StatusColors,
28 pub syntax: UserSyntaxTheme,
29}
30
31#[derive(Clone, Default, Deserialize)]
32pub struct UserSyntaxTheme {
33 pub highlights: Vec<(String, UserHighlightStyle)>,
34}
35
36#[derive(Clone, Default, Deserialize)]
37pub struct UserHighlightStyle {
38 pub color: Option<Hsla>,
39 pub font_style: Option<UserFontStyle>,
40 pub font_weight: Option<UserFontWeight>,
41}
42
43#[derive(Clone, Default, Deserialize)]
44pub struct UserFontWeight(pub f32);
45
46impl UserFontWeight {
47 /// Thin weight (100), the thinnest value.
48 pub const THIN: Self = Self(FontWeight::THIN.0);
49 /// Extra light weight (200).
50 pub const EXTRA_LIGHT: Self = Self(FontWeight::EXTRA_LIGHT.0);
51 /// Light weight (300).
52 pub const LIGHT: Self = Self(FontWeight::LIGHT.0);
53 /// Normal (400).
54 pub const NORMAL: Self = Self(FontWeight::NORMAL.0);
55 /// Medium weight (500, higher than normal).
56 pub const MEDIUM: Self = Self(FontWeight::MEDIUM.0);
57 /// Semibold weight (600).
58 pub const SEMIBOLD: Self = Self(FontWeight::SEMIBOLD.0);
59 /// Bold weight (700).
60 pub const BOLD: Self = Self(FontWeight::BOLD.0);
61 /// Extra-bold weight (800).
62 pub const EXTRA_BOLD: Self = Self(FontWeight::EXTRA_BOLD.0);
63 /// Black weight (900), the thickest value.
64 pub const BLACK: Self = Self(FontWeight::BLACK.0);
65}
66
67#[derive(Debug, Clone, Copy, Deserialize)]
68pub enum UserFontStyle {
69 Normal,
70 Italic,
71 Oblique,
72}
73
74impl UserHighlightStyle {
75 pub fn is_empty(&self) -> bool {
76 self.color.is_none()
77 }
78}