1mod registry;
2mod settings;
3mod themes;
4
5pub use registry::*;
6pub use settings::*;
7
8use gpui2::{AppContext, HighlightStyle, Hsla, SharedString};
9use std::sync::Arc;
10
11pub fn init(cx: &mut AppContext) {
12 cx.set_global(ThemeRegistry::default());
13 ThemeSettings::register(cx);
14}
15
16pub fn active_theme<'a>(cx: &'a AppContext) -> &'a Arc<Theme> {
17 &ThemeSettings::get_global(cx).active_theme
18}
19
20pub struct Theme {
21 pub metadata: ThemeMetadata,
22
23 pub transparent: Hsla,
24 pub mac_os_traffic_light_red: Hsla,
25 pub mac_os_traffic_light_yellow: Hsla,
26 pub mac_os_traffic_light_green: Hsla,
27 pub border: Hsla,
28 pub border_variant: Hsla,
29 pub border_focused: Hsla,
30 pub border_transparent: Hsla,
31 /// The background color of an elevated surface, like a modal, tooltip or toast.
32 pub elevated_surface: Hsla,
33 pub surface: Hsla,
34 /// Window background color of the base app
35 pub background: Hsla,
36 /// Default background for elements like filled buttons,
37 /// text fields, checkboxes, radio buttons, etc.
38 /// - TODO: Map to step 3.
39 pub filled_element: Hsla,
40 /// The background color of a hovered element, like a button being hovered
41 /// with a mouse, or hovered on a touch screen.
42 /// - TODO: Map to step 4.
43 pub filled_element_hover: Hsla,
44 /// The background color of an active element, like a button being pressed,
45 /// or tapped on a touch screen.
46 /// - TODO: Map to step 5.
47 pub filled_element_active: Hsla,
48 /// The background color of a selected element, like a selected tab,
49 /// a button toggled on, or a checkbox that is checked.
50 pub filled_element_selected: Hsla,
51 pub filled_element_disabled: Hsla,
52 pub ghost_element: Hsla,
53 /// The background color of a hovered element with no default background,
54 /// like a ghost-style button or an interactable list item.
55 /// - TODO: Map to step 3.
56 pub ghost_element_hover: Hsla,
57 /// - TODO: Map to step 4.
58 pub ghost_element_active: Hsla,
59 pub ghost_element_selected: Hsla,
60 pub ghost_element_disabled: Hsla,
61 pub text: Hsla,
62 pub text_muted: Hsla,
63 pub text_placeholder: Hsla,
64 pub text_disabled: Hsla,
65 pub text_accent: Hsla,
66 pub icon_muted: Hsla,
67 pub syntax: SyntaxTheme,
68
69 pub status_bar: Hsla,
70 pub title_bar: Hsla,
71 pub toolbar: Hsla,
72 pub tab_bar: Hsla,
73 /// The background of the editor
74 pub editor: Hsla,
75 pub editor_subheader: Hsla,
76 pub editor_active_line: Hsla,
77 pub terminal: Hsla,
78 pub image_fallback_background: Hsla,
79
80 pub git_created: Hsla,
81 pub git_modified: Hsla,
82 pub git_deleted: Hsla,
83 pub git_conflict: Hsla,
84 pub git_ignored: Hsla,
85 pub git_renamed: Hsla,
86
87 pub players: [PlayerTheme; 8],
88}
89
90#[derive(Clone)]
91pub struct SyntaxTheme {
92 pub comment: Hsla,
93 pub string: Hsla,
94 pub function: Hsla,
95 pub keyword: Hsla,
96 pub highlights: Vec<(String, HighlightStyle)>,
97}
98
99#[derive(Clone, Copy)]
100pub struct PlayerTheme {
101 pub cursor: Hsla,
102 pub selection: Hsla,
103}
104
105#[derive(Clone)]
106pub struct ThemeMetadata {
107 pub name: SharedString,
108 pub is_light: bool,
109}
110
111pub struct Editor {
112 pub syntax: Arc<SyntaxTheme>,
113}