Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T02:56:38.367Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

fallback_themes.rs

393 lines · 19.7 KB · rust
1use std::sync::Arc;
2
3use gpui::{FontStyle, FontWeight, HighlightStyle, Hsla, WindowBackgroundAppearance, hsla};
4
5use crate::{
6    AccentColors, Appearance, DEFAULT_DARK_THEME, PlayerColors, StatusColors,
7    StatusColorsRefinement, SyntaxTheme, SystemColors, Theme, ThemeColors, ThemeColorsRefinement,
8    ThemeFamily, ThemeStyles, default_color_scales,
9};
10
11/// The default theme family for Zed.
12///
13/// This is used to construct the default theme fallback values, as well as to
14/// have a theme available at compile time for tests.
15pub fn zed_default_themes() -> ThemeFamily {
16    ThemeFamily {
17        id: "zed-default".to_string(),
18        name: "Zed Default".into(),
19        author: "".into(),
20        themes: vec![zed_default_dark()],
21        scales: default_color_scales(),
22    }
23}
24
25// If a theme customizes a foreground version of a status color, but does not
26// customize the background color, then use a partly-transparent version of the
27// foreground color for the background color.
28/// Applies default status color backgrounds from their foreground counterparts.
29pub fn apply_status_color_defaults(status: &mut StatusColorsRefinement) {
30    for (fg_color, bg_color) in [
31        (&status.deleted, &mut status.deleted_background),
32        (&status.created, &mut status.created_background),
33        (&status.modified, &mut status.modified_background),
34        (&status.conflict, &mut status.conflict_background),
35        (&status.error, &mut status.error_background),
36        (&status.hidden, &mut status.hidden_background),
37    ] {
38        if bg_color.is_none()
39            && let Some(fg_color) = fg_color
40        {
41            *bg_color = Some(fg_color.opacity(0.25));
42        }
43    }
44}
45
46/// Applies default theme color values derived from player colors.
47pub fn apply_theme_color_defaults(
48    theme_colors: &mut ThemeColorsRefinement,
49    player_colors: &PlayerColors,
50) {
51    if theme_colors.element_selection_background.is_none() {
52        let mut selection = player_colors.local().selection;
53        if selection.a == 1.0 {
54            selection.a = 0.25;
55        }
56        theme_colors.element_selection_background = Some(selection);
57    }
58}
59
60pub(crate) fn zed_default_dark() -> Theme {
61    let bg = hsla(215. / 360., 12. / 100., 15. / 100., 1.);
62    let editor = hsla(220. / 360., 12. / 100., 18. / 100., 1.);
63    let elevated_surface = hsla(225. / 360., 12. / 100., 17. / 100., 1.);
64    let hover = hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0);
65
66    let blue = hsla(207.8 / 360., 81. / 100., 66. / 100., 1.0);
67    let gray = hsla(218.8 / 360., 10. / 100., 40. / 100., 1.0);
68    let green = hsla(95. / 360., 38. / 100., 62. / 100., 1.0);
69    let orange = hsla(29. / 360., 54. / 100., 61. / 100., 1.0);
70    let purple = hsla(286. / 360., 51. / 100., 64. / 100., 1.0);
71    let red = hsla(355. / 360., 65. / 100., 65. / 100., 1.0);
72    let teal = hsla(187. / 360., 47. / 100., 55. / 100., 1.0);
73    let yellow = hsla(39. / 360., 67. / 100., 69. / 100., 1.0);
74
75    const ADDED_COLOR: Hsla = Hsla {
76        h: 134. / 360.,
77        s: 0.55,
78        l: 0.40,
79        a: 1.0,
80    };
81    const WORD_ADDED_COLOR: Hsla = Hsla {
82        h: 134. / 360.,
83        s: 0.55,
84        l: 0.40,
85        a: 0.35,
86    };
87    const MODIFIED_COLOR: Hsla = Hsla {
88        h: 48. / 360.,
89        s: 0.76,
90        l: 0.47,
91        a: 1.0,
92    };
93    const REMOVED_COLOR: Hsla = Hsla {
94        h: 350. / 360.,
95        s: 0.88,
96        l: 0.25,
97        a: 1.0,
98    };
99    const WORD_DELETED_COLOR: Hsla = Hsla {
100        h: 350. / 360.,
101        s: 0.88,
102        l: 0.25,
103        a: 0.80,
104    };
105
106    let player = PlayerColors::dark();
107    Theme {
108        id: "one_dark".to_string(),
109        name: DEFAULT_DARK_THEME.into(),
110        appearance: Appearance::Dark,
111        styles: ThemeStyles {
112            window_background_appearance: WindowBackgroundAppearance::Opaque,
113            system: SystemColors::default(),
114            accents: AccentColors(Arc::from(vec![
115                blue, orange, purple, teal, red, green, yellow,
116            ])),
117            colors: ThemeColors {
118                border: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
119                border_variant: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
120                border_focused: hsla(223. / 360., 78. / 100., 65. / 100., 1.),
121                border_selected: hsla(222.6 / 360., 77.5 / 100., 65.1 / 100., 1.0),
122                border_transparent: SystemColors::default().transparent,
123                border_disabled: hsla(222.0 / 360., 11.6 / 100., 33.7 / 100., 1.0),
124                elevated_surface_background: elevated_surface,
125                surface_background: bg,
126                background: bg,
127                element_background: hsla(223.0 / 360., 13. / 100., 21. / 100., 1.0),
128                element_hover: hover,
129                element_active: hsla(220.0 / 360., 11.8 / 100., 20.0 / 100., 1.0),
130                element_selected: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
131                element_disabled: SystemColors::default().transparent,
132                element_selection_background: player.local().selection.alpha(0.25),
133                drop_target_background: hsla(220.0 / 360., 8.3 / 100., 21.4 / 100., 1.0),
134                drop_target_border: hsla(221. / 360., 11. / 100., 86. / 100., 1.0),
135                ghost_element_background: SystemColors::default().transparent,
136                ghost_element_hover: hover,
137                ghost_element_active: hsla(220.0 / 360., 11.8 / 100., 20.0 / 100., 1.0),
138                ghost_element_selected: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
139                ghost_element_disabled: SystemColors::default().transparent,
140                text: hsla(221. / 360., 11. / 100., 86. / 100., 1.0),
141                text_muted: hsla(218.0 / 360., 7. / 100., 46. / 100., 1.0),
142                text_placeholder: hsla(220.0 / 360., 6.6 / 100., 44.5 / 100., 1.0),
143                text_disabled: hsla(220.0 / 360., 6.6 / 100., 44.5 / 100., 1.0),
144                text_accent: hsla(222.6 / 360., 77.5 / 100., 65.1 / 100., 1.0),
145                icon: hsla(222.9 / 360., 9.9 / 100., 86.1 / 100., 1.0),
146                icon_muted: hsla(220.0 / 360., 12.1 / 100., 66.1 / 100., 1.0),
147                icon_disabled: hsla(220.0 / 360., 6.4 / 100., 45.7 / 100., 1.0),
148                icon_placeholder: hsla(220.0 / 360., 6.4 / 100., 45.7 / 100., 1.0),
149                icon_accent: blue,
150                debugger_accent: red,
151                status_bar_background: bg,
152                title_bar_background: bg,
153                title_bar_inactive_background: bg,
154                toolbar_background: editor,
155                tab_bar_background: bg,
156                tab_inactive_background: bg,
157                tab_active_background: editor,
158                search_match_background: bg,
159                search_active_match_background: bg,
160
161                editor_background: editor,
162                editor_gutter_background: editor,
163                editor_subheader_background: bg,
164                editor_active_line_background: hsla(222.9 / 360., 13.5 / 100., 20.4 / 100., 1.0),
165                editor_highlighted_line_background: hsla(207.8 / 360., 81. / 100., 66. / 100., 0.1),
166                editor_debugger_active_line_background: hsla(
167                    207.8 / 360.,
168                    81. / 100.,
169                    66. / 100.,
170                    0.2,
171                ),
172                editor_line_number: hsla(222.0 / 360., 11.5 / 100., 34.1 / 100., 1.0),
173                editor_active_line_number: hsla(216.0 / 360., 5.9 / 100., 49.6 / 100., 1.0),
174                editor_hover_line_number: hsla(216.0 / 360., 5.9 / 100., 56.7 / 100., 1.0),
175                editor_invisible: hsla(222.0 / 360., 11.5 / 100., 34.1 / 100., 1.0),
176                editor_wrap_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
177                editor_active_wrap_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
178                editor_indent_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
179                editor_indent_guide_active: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
180                editor_document_highlight_read_background: hsla(
181                    207.8 / 360.,
182                    81. / 100.,
183                    66. / 100.,
184                    0.2,
185                ),
186                editor_document_highlight_write_background: gpui::red(),
187                editor_document_highlight_bracket_background: gpui::green(),
188                editor_diff_hunk_added_background: ADDED_COLOR.opacity(0.12),
189                editor_diff_hunk_added_hollow_background: ADDED_COLOR.opacity(0.06),
190                editor_diff_hunk_added_hollow_border: ADDED_COLOR.opacity(0.36),
191                editor_diff_hunk_deleted_background: REMOVED_COLOR.opacity(0.12),
192                editor_diff_hunk_deleted_hollow_background: REMOVED_COLOR.opacity(0.06),
193                editor_diff_hunk_deleted_hollow_border: REMOVED_COLOR.opacity(0.36),
194
195                terminal_background: bg,
196                // todo("Use one colors for terminal")
197                terminal_ansi_background: crate::black().dark().step_12(),
198                terminal_foreground: crate::white().dark().step_12(),
199                terminal_bright_foreground: crate::white().dark().step_11(),
200                terminal_dim_foreground: crate::white().dark().step_10(),
201                terminal_ansi_black: crate::black().dark().step_12(),
202                terminal_ansi_red: crate::red().dark().step_11(),
203                terminal_ansi_green: crate::green().dark().step_11(),
204                terminal_ansi_yellow: crate::yellow().dark().step_11(),
205                terminal_ansi_blue: crate::blue().dark().step_11(),
206                terminal_ansi_magenta: crate::violet().dark().step_11(),
207                terminal_ansi_cyan: crate::cyan().dark().step_11(),
208                terminal_ansi_white: crate::neutral().dark().step_12(),
209                terminal_ansi_bright_black: crate::black().dark().step_11(),
210                terminal_ansi_bright_red: crate::red().dark().step_10(),
211                terminal_ansi_bright_green: crate::green().dark().step_10(),
212                terminal_ansi_bright_yellow: crate::yellow().dark().step_10(),
213                terminal_ansi_bright_blue: crate::blue().dark().step_10(),
214                terminal_ansi_bright_magenta: crate::violet().dark().step_10(),
215                terminal_ansi_bright_cyan: crate::cyan().dark().step_10(),
216                terminal_ansi_bright_white: crate::neutral().dark().step_11(),
217                terminal_ansi_dim_black: crate::black().dark().step_10(),
218                terminal_ansi_dim_red: crate::red().dark().step_9(),
219                terminal_ansi_dim_green: crate::green().dark().step_9(),
220                terminal_ansi_dim_yellow: crate::yellow().dark().step_9(),
221                terminal_ansi_dim_blue: crate::blue().dark().step_9(),
222                terminal_ansi_dim_magenta: crate::violet().dark().step_9(),
223                terminal_ansi_dim_cyan: crate::cyan().dark().step_9(),
224                terminal_ansi_dim_white: crate::neutral().dark().step_10(),
225                panel_background: bg,
226                panel_focused_border: blue,
227                panel_indent_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
228                panel_indent_guide_hover: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
229                panel_indent_guide_active: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
230                panel_overlay_background: bg,
231                panel_overlay_hover: hover,
232                pane_focused_border: blue,
233                pane_group_border: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
234                scrollbar_thumb_background: gpui::transparent_black(),
235                scrollbar_thumb_hover_background: hover,
236                scrollbar_thumb_active_background: hsla(
237                    225.0 / 360.,
238                    11.8 / 100.,
239                    26.7 / 100.,
240                    1.0,
241                ),
242                scrollbar_thumb_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
243                scrollbar_track_background: gpui::transparent_black(),
244                scrollbar_track_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
245                minimap_thumb_background: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 0.7),
246                minimap_thumb_hover_background: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 0.7),
247                minimap_thumb_active_background: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 0.7),
248                minimap_thumb_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
249                editor_foreground: hsla(218. / 360., 14. / 100., 71. / 100., 1.),
250                link_text_hover: blue,
251                version_control_added: ADDED_COLOR,
252                version_control_deleted: REMOVED_COLOR,
253                version_control_modified: MODIFIED_COLOR,
254                version_control_renamed: MODIFIED_COLOR,
255                version_control_conflict: crate::orange().light().step_12(),
256                version_control_ignored: crate::gray().light().step_12(),
257                version_control_word_added: WORD_ADDED_COLOR,
258                version_control_word_deleted: WORD_DELETED_COLOR,
259                version_control_conflict_marker_ours: crate::green().light().step_12().alpha(0.5),
260                version_control_conflict_marker_theirs: crate::blue().light().step_12().alpha(0.5),
261
262                vim_normal_background: SystemColors::default().transparent,
263                vim_insert_background: SystemColors::default().transparent,
264                vim_replace_background: SystemColors::default().transparent,
265                vim_visual_background: SystemColors::default().transparent,
266                vim_visual_line_background: SystemColors::default().transparent,
267                vim_visual_block_background: SystemColors::default().transparent,
268                vim_yank_background: hsla(207.8 / 360., 81. / 100., 66. / 100., 0.2),
269                vim_helix_jump_label_foreground: red,
270                vim_helix_normal_background: SystemColors::default().transparent,
271                vim_helix_select_background: SystemColors::default().transparent,
272                vim_normal_foreground: SystemColors::default().transparent,
273                vim_insert_foreground: SystemColors::default().transparent,
274                vim_replace_foreground: SystemColors::default().transparent,
275                vim_visual_foreground: SystemColors::default().transparent,
276                vim_visual_line_foreground: SystemColors::default().transparent,
277                vim_visual_block_foreground: SystemColors::default().transparent,
278                vim_helix_normal_foreground: SystemColors::default().transparent,
279                vim_helix_select_foreground: SystemColors::default().transparent,
280            },
281            status: StatusColors {
282                conflict: yellow,
283                conflict_background: yellow,
284                conflict_border: yellow,
285                created: green,
286                created_background: green,
287                created_border: green,
288                deleted: red,
289                deleted_background: red,
290                deleted_border: red,
291                error: red,
292                error_background: red,
293                error_border: red,
294                hidden: gray,
295                hidden_background: gray,
296                hidden_border: gray,
297                hint: blue,
298                hint_background: blue,
299                hint_border: blue,
300                ignored: gray,
301                ignored_background: gray,
302                ignored_border: gray,
303                info: blue,
304                info_background: blue,
305                info_border: blue,
306                modified: yellow,
307                modified_background: yellow,
308                modified_border: yellow,
309                predictive: gray,
310                predictive_background: gray,
311                predictive_border: gray,
312                renamed: blue,
313                renamed_background: blue,
314                renamed_border: blue,
315                success: green,
316                success_background: green,
317                success_border: green,
318                unreachable: gray,
319                unreachable_background: gray,
320                unreachable_border: gray,
321                warning: yellow,
322                warning_background: yellow,
323                warning_border: yellow,
324            },
325            player,
326            syntax: Arc::new(SyntaxTheme::new(vec![
327                ("attribute".into(), purple.into()),
328                ("boolean".into(), orange.into()),
329                ("comment".into(), gray.into()),
330                ("comment.doc".into(), gray.into()),
331                ("constant".into(), yellow.into()),
332                ("constructor".into(), blue.into()),
333                ("embedded".into(), HighlightStyle::default()),
334                (
335                    "emphasis".into(),
336                    HighlightStyle {
337                        font_style: Some(FontStyle::Italic),
338                        ..HighlightStyle::default()
339                    },
340                ),
341                (
342                    "emphasis.strong".into(),
343                    HighlightStyle {
344                        font_weight: Some(FontWeight::BOLD),
345                        ..HighlightStyle::default()
346                    },
347                ),
348                ("enum".into(), teal.into()),
349                ("function".into(), blue.into()),
350                ("function.method".into(), blue.into()),
351                ("function.definition".into(), blue.into()),
352                ("hint".into(), blue.into()),
353                ("keyword".into(), purple.into()),
354                ("label".into(), HighlightStyle::default()),
355                ("link_text".into(), blue.into()),
356                (
357                    "link_uri".into(),
358                    HighlightStyle {
359                        color: Some(teal),
360                        font_style: Some(FontStyle::Italic),
361                        ..HighlightStyle::default()
362                    },
363                ),
364                ("number".into(), orange.into()),
365                ("operator".into(), HighlightStyle::default()),
366                ("predictive".into(), HighlightStyle::default()),
367                ("preproc".into(), purple.into()),
368                ("primary".into(), HighlightStyle::default()),
369                ("property".into(), red.into()),
370                ("punctuation".into(), HighlightStyle::default()),
371                ("punctuation.bracket".into(), HighlightStyle::default()),
372                ("punctuation.delimiter".into(), HighlightStyle::default()),
373                ("punctuation.list_marker".into(), HighlightStyle::default()),
374                ("punctuation.special".into(), HighlightStyle::default()),
375                ("string".into(), green.into()),
376                ("string.escape".into(), HighlightStyle::default()),
377                ("string.regex".into(), red.into()),
378                ("string.special".into(), HighlightStyle::default()),
379                ("string.special.symbol".into(), HighlightStyle::default()),
380                ("tag".into(), HighlightStyle::default()),
381                ("text.literal".into(), HighlightStyle::default()),
382                ("title".into(), HighlightStyle::default()),
383                ("type".into(), teal.into()),
384                ("variable".into(), HighlightStyle::default()),
385                ("variable.special".into(), red.into()),
386                ("variant".into(), HighlightStyle::default()),
387                ("diff.plus".into(), green.into()),
388                ("diff.minus".into(), red.into()),
389            ])),
390        },
391    }
392}
393
Served at tenant.openagents/omega Member data and write actions are omitted.