Skip to repository content686 lines · 31.4 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T05:04:22.489Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
colors.rs
1#![allow(missing_docs)]
2
3use gpui::{App, Hsla, SharedString, WindowBackgroundAppearance};
4use refineable::Refineable;
5use std::sync::Arc;
6use strum::{AsRefStr, EnumIter, IntoEnumIterator};
7
8use crate::{
9 AccentColors, ActiveTheme, PlayerColors, StatusColors, StatusColorsRefinement, SyntaxTheme,
10 SystemColors,
11};
12
13#[derive(Refineable, Clone, Debug, PartialEq)]
14#[refineable(Debug, serde::Deserialize)]
15pub struct ThemeColors {
16 /// Border color. Used for most borders, is usually a high contrast color.
17 pub border: Hsla,
18 /// Border color. Used for deemphasized borders, like a visual divider between two sections
19 pub border_variant: Hsla,
20 /// Border color. Used for focused elements, like keyboard focused list item.
21 pub border_focused: Hsla,
22 /// Border color. Used for selected elements, like an active search filter or selected checkbox.
23 pub border_selected: Hsla,
24 /// Border color. Used for transparent borders. Used for placeholder borders when an element gains a border on state change.
25 pub border_transparent: Hsla,
26 /// Border color. Used for disabled elements, like a disabled input or button.
27 pub border_disabled: Hsla,
28 /// Border color. Used for elevated surfaces, like a context menu, popup, or dialog.
29 pub elevated_surface_background: Hsla,
30 /// Background Color. Used for grounded surfaces like a panel or tab.
31 pub surface_background: Hsla,
32 /// Background Color. Used for the app background and blank panels or windows.
33 pub background: Hsla,
34 /// Background Color. Used for the background of an element that should have a different background than the surface it's on.
35 ///
36 /// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...
37 ///
38 /// For an element that should have the same background as the surface it's on, use `ghost_element_background`.
39 pub element_background: Hsla,
40 /// Background Color. Used for the hover state of an element that should have a different background than the surface it's on.
41 ///
42 /// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
43 pub element_hover: Hsla,
44 /// Background Color. Used for the active state of an element that should have a different background than the surface it's on.
45 ///
46 /// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
47 pub element_active: Hsla,
48 /// Background Color. Used for the selected state of an element that should have a different background than the surface it's on.
49 ///
50 /// Selected states are triggered by the element being selected (or "activated") by the user.
51 ///
52 /// This could include a selected checkbox, a toggleable button that is toggled on, etc.
53 pub element_selected: Hsla,
54 /// Background Color. Used for the background of selections in a UI element.
55 pub element_selection_background: Hsla,
56 /// Background Color. Used for the disabled state of an element that should have a different background than the surface it's on.
57 ///
58 /// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
59 pub element_disabled: Hsla,
60 /// Background Color. Used for the area that shows where a dragged element will be dropped.
61 pub drop_target_background: Hsla,
62 /// Border Color. Used for the border that shows where a dragged element will be dropped.
63 pub drop_target_border: Hsla,
64 /// Used for the background of a ghost element that should have the same background as the surface it's on.
65 ///
66 /// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...
67 ///
68 /// For an element that should have a different background than the surface it's on, use `element_background`.
69 pub ghost_element_background: Hsla,
70 /// Background Color. Used for the hover state of a ghost element that should have the same background as the surface it's on.
71 ///
72 /// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
73 pub ghost_element_hover: Hsla,
74 /// Background Color. Used for the active state of a ghost element that should have the same background as the surface it's on.
75 ///
76 /// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
77 pub ghost_element_active: Hsla,
78 /// Background Color. Used for the selected state of a ghost element that should have the same background as the surface it's on.
79 ///
80 /// Selected states are triggered by the element being selected (or "activated") by the user.
81 ///
82 /// This could include a selected checkbox, a toggleable button that is toggled on, etc.
83 pub ghost_element_selected: Hsla,
84 /// Background Color. Used for the disabled state of a ghost element that should have the same background as the surface it's on.
85 ///
86 /// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
87 pub ghost_element_disabled: Hsla,
88 /// Text Color. Default text color used for most text.
89 pub text: Hsla,
90 /// Text Color. Color of muted or deemphasized text. It is a subdued version of the standard text color.
91 pub text_muted: Hsla,
92 /// Text Color. Color of the placeholder text typically shown in input fields to guide the user to enter valid data.
93 pub text_placeholder: Hsla,
94 /// Text Color. Color used for text denoting disabled elements. Typically, the color is faded or grayed out to emphasize the disabled state.
95 pub text_disabled: Hsla,
96 /// Text Color. Color used for emphasis or highlighting certain text, like an active filter or a matched character in a search.
97 pub text_accent: Hsla,
98 /// Fill Color. Used for the default fill color of an icon.
99 pub icon: Hsla,
100 /// Fill Color. Used for the muted or deemphasized fill color of an icon.
101 ///
102 /// This might be used to show an icon in an inactive pane, or to deemphasize a series of icons to give them less visual weight.
103 pub icon_muted: Hsla,
104 /// Fill Color. Used for the disabled fill color of an icon.
105 ///
106 /// Disabled states are shown when a user cannot interact with an element, like a icon button.
107 pub icon_disabled: Hsla,
108 /// Fill Color. Used for the placeholder fill color of an icon.
109 ///
110 /// This might be used to show an icon in an input that disappears when the user enters text.
111 pub icon_placeholder: Hsla,
112 /// Fill Color. Used for the accent fill color of an icon.
113 ///
114 /// This might be used to show when a toggleable icon button is selected.
115 pub icon_accent: Hsla,
116 /// Color used to accent some debugger elements
117 /// Is used by breakpoints
118 pub debugger_accent: Hsla,
119
120 // ===
121 // UI Elements
122 // ===
123 pub status_bar_background: Hsla,
124 pub title_bar_background: Hsla,
125 pub title_bar_inactive_background: Hsla,
126 pub toolbar_background: Hsla,
127 pub tab_bar_background: Hsla,
128 pub tab_inactive_background: Hsla,
129 pub tab_active_background: Hsla,
130 pub search_match_background: Hsla,
131 pub search_active_match_background: Hsla,
132 pub panel_background: Hsla,
133 pub panel_focused_border: Hsla,
134 pub panel_indent_guide: Hsla,
135 pub panel_indent_guide_hover: Hsla,
136 pub panel_indent_guide_active: Hsla,
137
138 /// The color of the overlay surface on top of panel.
139 pub panel_overlay_background: Hsla,
140 /// The color of the overlay surface on top of panel when hovered over.
141 pub panel_overlay_hover: Hsla,
142
143 pub pane_focused_border: Hsla,
144 pub pane_group_border: Hsla,
145 /// The color of the scrollbar thumb.
146 pub scrollbar_thumb_background: Hsla,
147 /// The color of the scrollbar thumb when hovered over.
148 pub scrollbar_thumb_hover_background: Hsla,
149 /// The color of the scrollbar thumb whilst being actively dragged.
150 pub scrollbar_thumb_active_background: Hsla,
151 /// The border color of the scrollbar thumb.
152 pub scrollbar_thumb_border: Hsla,
153 /// The background color of the scrollbar track.
154 pub scrollbar_track_background: Hsla,
155 /// The border color of the scrollbar track.
156 pub scrollbar_track_border: Hsla,
157 /// The color of the minimap thumb.
158 pub minimap_thumb_background: Hsla,
159 /// The color of the minimap thumb when hovered over.
160 pub minimap_thumb_hover_background: Hsla,
161 /// The color of the minimap thumb whilst being actively dragged.
162 pub minimap_thumb_active_background: Hsla,
163 /// The border color of the minimap thumb.
164 pub minimap_thumb_border: Hsla,
165
166 /// Background color for Vim Normal mode indicator.
167 pub vim_normal_background: Hsla,
168 /// Background color for Vim Insert mode indicator.
169 pub vim_insert_background: Hsla,
170 /// Background color for Vim Replace mode indicator.
171 pub vim_replace_background: Hsla,
172 /// Background color for Vim Visual mode indicator.
173 pub vim_visual_background: Hsla,
174 /// Background color for Vim Visual Line mode indicator.
175 pub vim_visual_line_background: Hsla,
176 /// Background color for Vim Visual Block mode indicator.
177 pub vim_visual_block_background: Hsla,
178 /// Background color for Vim yank highlight.
179 pub vim_yank_background: Hsla,
180 /// Foreground color for Helix jump labels.
181 pub vim_helix_jump_label_foreground: Hsla,
182 /// Background color for Vim Helix Normal mode indicator.
183 pub vim_helix_normal_background: Hsla,
184 /// Background color for Vim Helix Select mode indicator.
185 pub vim_helix_select_background: Hsla,
186 /// Foreground color for Vim Normal mode indicator.
187 pub vim_normal_foreground: Hsla,
188 /// Foreground color for Vim Insert mode indicator.
189 pub vim_insert_foreground: Hsla,
190 /// Foreground color for Vim Replace mode indicator.
191 pub vim_replace_foreground: Hsla,
192 /// Foreground color for Vim Visual mode indicator.
193 pub vim_visual_foreground: Hsla,
194 /// Foreground color for Vim Visual Line mode indicator.
195 pub vim_visual_line_foreground: Hsla,
196 /// Foreground color for Vim Visual Block mode indicator.
197 pub vim_visual_block_foreground: Hsla,
198 /// Foreground color for Vim Helix Normal mode indicator.
199 pub vim_helix_normal_foreground: Hsla,
200 /// Foreground color for Vim Helix Select mode indicator.
201 pub vim_helix_select_foreground: Hsla,
202
203 // ===
204 // Editor
205 // ===
206 pub editor_foreground: Hsla,
207 pub editor_background: Hsla,
208 pub editor_gutter_background: Hsla,
209 pub editor_subheader_background: Hsla,
210 pub editor_active_line_background: Hsla,
211 pub editor_highlighted_line_background: Hsla,
212 /// Line color of the line a debugger is currently stopped at
213 pub editor_debugger_active_line_background: Hsla,
214 /// Text Color. Used for the text of the line number in the editor gutter.
215 pub editor_line_number: Hsla,
216 /// Text Color. Used for the text of the line number in the editor gutter when the line is highlighted.
217 pub editor_active_line_number: Hsla,
218 /// Text Color. Used for the text of the line number in the editor gutter when the line is hovered over.
219 pub editor_hover_line_number: Hsla,
220 /// Text Color. Used to mark invisible characters in the editor.
221 ///
222 /// Example: spaces, tabs, carriage returns, etc.
223 pub editor_invisible: Hsla,
224 pub editor_wrap_guide: Hsla,
225 pub editor_active_wrap_guide: Hsla,
226 pub editor_indent_guide: Hsla,
227 pub editor_indent_guide_active: Hsla,
228 /// Read-access of a symbol, like reading a variable.
229 ///
230 /// A document highlight is a range inside a text document which deserves
231 /// special attention. Usually a document highlight is visualized by changing
232 /// the background color of its range.
233 pub editor_document_highlight_read_background: Hsla,
234 /// Read-access of a symbol, like reading a variable.
235 ///
236 /// A document highlight is a range inside a text document which deserves
237 /// special attention. Usually a document highlight is visualized by changing
238 /// the background color of its range.
239 pub editor_document_highlight_write_background: Hsla,
240 /// Highlighted brackets background color.
241 ///
242 /// Matching brackets in the cursor scope are highlighted with this background color.
243 pub editor_document_highlight_bracket_background: Hsla,
244 /// Filled background color for added diff hunk row highlights in the editor.
245 pub editor_diff_hunk_added_background: Hsla,
246 /// Hollow background color for added diff hunk row highlights in the editor.
247 pub editor_diff_hunk_added_hollow_background: Hsla,
248 /// Hollow border color for added diff hunk row highlights in the editor.
249 pub editor_diff_hunk_added_hollow_border: Hsla,
250 /// Filled background color for deleted diff hunk row highlights in the editor.
251 pub editor_diff_hunk_deleted_background: Hsla,
252 /// Hollow background color for deleted diff hunk row highlights in the editor.
253 pub editor_diff_hunk_deleted_hollow_background: Hsla,
254 /// Hollow border color for deleted diff hunk row highlights in the editor.
255 pub editor_diff_hunk_deleted_hollow_border: Hsla,
256
257 // ===
258 // Terminal
259 // ===
260 /// Terminal layout background color.
261 pub terminal_background: Hsla,
262 /// Terminal foreground color.
263 pub terminal_foreground: Hsla,
264 /// Bright terminal foreground color.
265 pub terminal_bright_foreground: Hsla,
266 /// Dim terminal foreground color.
267 pub terminal_dim_foreground: Hsla,
268 /// Terminal ANSI background color.
269 pub terminal_ansi_background: Hsla,
270 /// Black ANSI terminal color.
271 pub terminal_ansi_black: Hsla,
272 /// Bright black ANSI terminal color.
273 pub terminal_ansi_bright_black: Hsla,
274 /// Dim black ANSI terminal color.
275 pub terminal_ansi_dim_black: Hsla,
276 /// Red ANSI terminal color.
277 pub terminal_ansi_red: Hsla,
278 /// Bright red ANSI terminal color.
279 pub terminal_ansi_bright_red: Hsla,
280 /// Dim red ANSI terminal color.
281 pub terminal_ansi_dim_red: Hsla,
282 /// Green ANSI terminal color.
283 pub terminal_ansi_green: Hsla,
284 /// Bright green ANSI terminal color.
285 pub terminal_ansi_bright_green: Hsla,
286 /// Dim green ANSI terminal color.
287 pub terminal_ansi_dim_green: Hsla,
288 /// Yellow ANSI terminal color.
289 pub terminal_ansi_yellow: Hsla,
290 /// Bright yellow ANSI terminal color.
291 pub terminal_ansi_bright_yellow: Hsla,
292 /// Dim yellow ANSI terminal color.
293 pub terminal_ansi_dim_yellow: Hsla,
294 /// Blue ANSI terminal color.
295 pub terminal_ansi_blue: Hsla,
296 /// Bright blue ANSI terminal color.
297 pub terminal_ansi_bright_blue: Hsla,
298 /// Dim blue ANSI terminal color.
299 pub terminal_ansi_dim_blue: Hsla,
300 /// Magenta ANSI terminal color.
301 pub terminal_ansi_magenta: Hsla,
302 /// Bright magenta ANSI terminal color.
303 pub terminal_ansi_bright_magenta: Hsla,
304 /// Dim magenta ANSI terminal color.
305 pub terminal_ansi_dim_magenta: Hsla,
306 /// Cyan ANSI terminal color.
307 pub terminal_ansi_cyan: Hsla,
308 /// Bright cyan ANSI terminal color.
309 pub terminal_ansi_bright_cyan: Hsla,
310 /// Dim cyan ANSI terminal color.
311 pub terminal_ansi_dim_cyan: Hsla,
312 /// White ANSI terminal color.
313 pub terminal_ansi_white: Hsla,
314 /// Bright white ANSI terminal color.
315 pub terminal_ansi_bright_white: Hsla,
316 /// Dim white ANSI terminal color.
317 pub terminal_ansi_dim_white: Hsla,
318
319 /// Represents a link text hover color.
320 pub link_text_hover: Hsla,
321
322 /// Represents an added entry or hunk in vcs, like git.
323 pub version_control_added: Hsla,
324 /// Represents a deleted entry in version control systems.
325 pub version_control_deleted: Hsla,
326 /// Represents a modified entry in version control systems.
327 pub version_control_modified: Hsla,
328 /// Represents a renamed entry in version control systems.
329 pub version_control_renamed: Hsla,
330 /// Represents a conflicting entry in version control systems.
331 pub version_control_conflict: Hsla,
332 /// Represents an ignored entry in version control systems.
333 pub version_control_ignored: Hsla,
334 /// Represents an added word in a word diff.
335 pub version_control_word_added: Hsla,
336 /// Represents a deleted word in a word diff.
337 pub version_control_word_deleted: Hsla,
338 /// Represents the "ours" region of a merge conflict.
339 pub version_control_conflict_marker_ours: Hsla,
340 /// Represents the "theirs" region of a merge conflict.
341 pub version_control_conflict_marker_theirs: Hsla,
342}
343
344#[derive(EnumIter, Debug, Clone, Copy, AsRefStr)]
345#[strum(serialize_all = "snake_case")]
346pub enum ThemeColorField {
347 Border,
348 BorderVariant,
349 BorderFocused,
350 BorderSelected,
351 BorderTransparent,
352 BorderDisabled,
353 ElevatedSurfaceBackground,
354 SurfaceBackground,
355 Background,
356 ElementBackground,
357 ElementHover,
358 ElementActive,
359 ElementSelected,
360 ElementDisabled,
361 DropTargetBackground,
362 DropTargetBorder,
363 GhostElementBackground,
364 GhostElementHover,
365 GhostElementActive,
366 GhostElementSelected,
367 GhostElementDisabled,
368 Text,
369 TextMuted,
370 TextPlaceholder,
371 TextDisabled,
372 TextAccent,
373 Icon,
374 IconMuted,
375 IconDisabled,
376 IconPlaceholder,
377 IconAccent,
378 StatusBarBackground,
379 TitleBarBackground,
380 TitleBarInactiveBackground,
381 ToolbarBackground,
382 TabBarBackground,
383 TabInactiveBackground,
384 TabActiveBackground,
385 SearchMatchBackground,
386 SearchActiveMatchBackground,
387 PanelBackground,
388 PanelFocusedBorder,
389 PanelIndentGuide,
390 PanelIndentGuideHover,
391 PanelIndentGuideActive,
392 PanelOverlayBackground,
393 PanelOverlayHover,
394 PaneFocusedBorder,
395 PaneGroupBorder,
396 ScrollbarThumbBackground,
397 ScrollbarThumbHoverBackground,
398 ScrollbarThumbActiveBackground,
399 ScrollbarThumbBorder,
400 ScrollbarTrackBackground,
401 ScrollbarTrackBorder,
402 MinimapThumbBackground,
403 MinimapThumbHoverBackground,
404 MinimapThumbActiveBackground,
405 MinimapThumbBorder,
406 EditorForeground,
407 EditorBackground,
408 EditorGutterBackground,
409 EditorSubheaderBackground,
410 EditorActiveLineBackground,
411 EditorHighlightedLineBackground,
412 EditorLineNumber,
413 EditorActiveLineNumber,
414 EditorInvisible,
415 EditorWrapGuide,
416 EditorActiveWrapGuide,
417 EditorIndentGuide,
418 EditorIndentGuideActive,
419 EditorDocumentHighlightReadBackground,
420 EditorDocumentHighlightWriteBackground,
421 EditorDocumentHighlightBracketBackground,
422 TerminalBackground,
423 TerminalForeground,
424 TerminalBrightForeground,
425 TerminalDimForeground,
426 TerminalAnsiBackground,
427 TerminalAnsiBlack,
428 TerminalAnsiBrightBlack,
429 TerminalAnsiDimBlack,
430 TerminalAnsiRed,
431 TerminalAnsiBrightRed,
432 TerminalAnsiDimRed,
433 TerminalAnsiGreen,
434 TerminalAnsiBrightGreen,
435 TerminalAnsiDimGreen,
436 TerminalAnsiYellow,
437 TerminalAnsiBrightYellow,
438 TerminalAnsiDimYellow,
439 TerminalAnsiBlue,
440 TerminalAnsiBrightBlue,
441 TerminalAnsiDimBlue,
442 TerminalAnsiMagenta,
443 TerminalAnsiBrightMagenta,
444 TerminalAnsiDimMagenta,
445 TerminalAnsiCyan,
446 TerminalAnsiBrightCyan,
447 TerminalAnsiDimCyan,
448 TerminalAnsiWhite,
449 TerminalAnsiBrightWhite,
450 TerminalAnsiDimWhite,
451 LinkTextHover,
452 VersionControlAdded,
453 VersionControlDeleted,
454 VersionControlModified,
455 VersionControlRenamed,
456 VersionControlConflict,
457 VersionControlIgnored,
458}
459
460impl ThemeColors {
461 pub fn color(&self, field: ThemeColorField) -> Hsla {
462 match field {
463 ThemeColorField::Border => self.border,
464 ThemeColorField::BorderVariant => self.border_variant,
465 ThemeColorField::BorderFocused => self.border_focused,
466 ThemeColorField::BorderSelected => self.border_selected,
467 ThemeColorField::BorderTransparent => self.border_transparent,
468 ThemeColorField::BorderDisabled => self.border_disabled,
469 ThemeColorField::ElevatedSurfaceBackground => self.elevated_surface_background,
470 ThemeColorField::SurfaceBackground => self.surface_background,
471 ThemeColorField::Background => self.background,
472 ThemeColorField::ElementBackground => self.element_background,
473 ThemeColorField::ElementHover => self.element_hover,
474 ThemeColorField::ElementActive => self.element_active,
475 ThemeColorField::ElementSelected => self.element_selected,
476 ThemeColorField::ElementDisabled => self.element_disabled,
477 ThemeColorField::DropTargetBackground => self.drop_target_background,
478 ThemeColorField::DropTargetBorder => self.drop_target_border,
479 ThemeColorField::GhostElementBackground => self.ghost_element_background,
480 ThemeColorField::GhostElementHover => self.ghost_element_hover,
481 ThemeColorField::GhostElementActive => self.ghost_element_active,
482 ThemeColorField::GhostElementSelected => self.ghost_element_selected,
483 ThemeColorField::GhostElementDisabled => self.ghost_element_disabled,
484 ThemeColorField::Text => self.text,
485 ThemeColorField::TextMuted => self.text_muted,
486 ThemeColorField::TextPlaceholder => self.text_placeholder,
487 ThemeColorField::TextDisabled => self.text_disabled,
488 ThemeColorField::TextAccent => self.text_accent,
489 ThemeColorField::Icon => self.icon,
490 ThemeColorField::IconMuted => self.icon_muted,
491 ThemeColorField::IconDisabled => self.icon_disabled,
492 ThemeColorField::IconPlaceholder => self.icon_placeholder,
493 ThemeColorField::IconAccent => self.icon_accent,
494 ThemeColorField::StatusBarBackground => self.status_bar_background,
495 ThemeColorField::TitleBarBackground => self.title_bar_background,
496 ThemeColorField::TitleBarInactiveBackground => self.title_bar_inactive_background,
497 ThemeColorField::ToolbarBackground => self.toolbar_background,
498 ThemeColorField::TabBarBackground => self.tab_bar_background,
499 ThemeColorField::TabInactiveBackground => self.tab_inactive_background,
500 ThemeColorField::TabActiveBackground => self.tab_active_background,
501 ThemeColorField::SearchMatchBackground => self.search_match_background,
502 ThemeColorField::SearchActiveMatchBackground => self.search_active_match_background,
503 ThemeColorField::PanelBackground => self.panel_background,
504 ThemeColorField::PanelFocusedBorder => self.panel_focused_border,
505 ThemeColorField::PanelIndentGuide => self.panel_indent_guide,
506 ThemeColorField::PanelIndentGuideHover => self.panel_indent_guide_hover,
507 ThemeColorField::PanelIndentGuideActive => self.panel_indent_guide_active,
508 ThemeColorField::PanelOverlayBackground => self.panel_overlay_background,
509 ThemeColorField::PanelOverlayHover => self.panel_overlay_hover,
510 ThemeColorField::PaneFocusedBorder => self.pane_focused_border,
511 ThemeColorField::PaneGroupBorder => self.pane_group_border,
512 ThemeColorField::ScrollbarThumbBackground => self.scrollbar_thumb_background,
513 ThemeColorField::ScrollbarThumbHoverBackground => self.scrollbar_thumb_hover_background,
514 ThemeColorField::ScrollbarThumbActiveBackground => {
515 self.scrollbar_thumb_active_background
516 }
517 ThemeColorField::ScrollbarThumbBorder => self.scrollbar_thumb_border,
518 ThemeColorField::ScrollbarTrackBackground => self.scrollbar_track_background,
519 ThemeColorField::ScrollbarTrackBorder => self.scrollbar_track_border,
520 ThemeColorField::MinimapThumbBackground => self.minimap_thumb_background,
521 ThemeColorField::MinimapThumbHoverBackground => self.minimap_thumb_hover_background,
522 ThemeColorField::MinimapThumbActiveBackground => self.minimap_thumb_active_background,
523 ThemeColorField::MinimapThumbBorder => self.minimap_thumb_border,
524 ThemeColorField::EditorForeground => self.editor_foreground,
525 ThemeColorField::EditorBackground => self.editor_background,
526 ThemeColorField::EditorGutterBackground => self.editor_gutter_background,
527 ThemeColorField::EditorSubheaderBackground => self.editor_subheader_background,
528 ThemeColorField::EditorActiveLineBackground => self.editor_active_line_background,
529 ThemeColorField::EditorHighlightedLineBackground => {
530 self.editor_highlighted_line_background
531 }
532 ThemeColorField::EditorLineNumber => self.editor_line_number,
533 ThemeColorField::EditorActiveLineNumber => self.editor_active_line_number,
534 ThemeColorField::EditorInvisible => self.editor_invisible,
535 ThemeColorField::EditorWrapGuide => self.editor_wrap_guide,
536 ThemeColorField::EditorActiveWrapGuide => self.editor_active_wrap_guide,
537 ThemeColorField::EditorIndentGuide => self.editor_indent_guide,
538 ThemeColorField::EditorIndentGuideActive => self.editor_indent_guide_active,
539 ThemeColorField::EditorDocumentHighlightReadBackground => {
540 self.editor_document_highlight_read_background
541 }
542 ThemeColorField::EditorDocumentHighlightWriteBackground => {
543 self.editor_document_highlight_write_background
544 }
545 ThemeColorField::EditorDocumentHighlightBracketBackground => {
546 self.editor_document_highlight_bracket_background
547 }
548 ThemeColorField::TerminalBackground => self.terminal_background,
549 ThemeColorField::TerminalForeground => self.terminal_foreground,
550 ThemeColorField::TerminalBrightForeground => self.terminal_bright_foreground,
551 ThemeColorField::TerminalDimForeground => self.terminal_dim_foreground,
552 ThemeColorField::TerminalAnsiBackground => self.terminal_ansi_background,
553 ThemeColorField::TerminalAnsiBlack => self.terminal_ansi_black,
554 ThemeColorField::TerminalAnsiBrightBlack => self.terminal_ansi_bright_black,
555 ThemeColorField::TerminalAnsiDimBlack => self.terminal_ansi_dim_black,
556 ThemeColorField::TerminalAnsiRed => self.terminal_ansi_red,
557 ThemeColorField::TerminalAnsiBrightRed => self.terminal_ansi_bright_red,
558 ThemeColorField::TerminalAnsiDimRed => self.terminal_ansi_dim_red,
559 ThemeColorField::TerminalAnsiGreen => self.terminal_ansi_green,
560 ThemeColorField::TerminalAnsiBrightGreen => self.terminal_ansi_bright_green,
561 ThemeColorField::TerminalAnsiDimGreen => self.terminal_ansi_dim_green,
562 ThemeColorField::TerminalAnsiYellow => self.terminal_ansi_yellow,
563 ThemeColorField::TerminalAnsiBrightYellow => self.terminal_ansi_bright_yellow,
564 ThemeColorField::TerminalAnsiDimYellow => self.terminal_ansi_dim_yellow,
565 ThemeColorField::TerminalAnsiBlue => self.terminal_ansi_blue,
566 ThemeColorField::TerminalAnsiBrightBlue => self.terminal_ansi_bright_blue,
567 ThemeColorField::TerminalAnsiDimBlue => self.terminal_ansi_dim_blue,
568 ThemeColorField::TerminalAnsiMagenta => self.terminal_ansi_magenta,
569 ThemeColorField::TerminalAnsiBrightMagenta => self.terminal_ansi_bright_magenta,
570 ThemeColorField::TerminalAnsiDimMagenta => self.terminal_ansi_dim_magenta,
571 ThemeColorField::TerminalAnsiCyan => self.terminal_ansi_cyan,
572 ThemeColorField::TerminalAnsiBrightCyan => self.terminal_ansi_bright_cyan,
573 ThemeColorField::TerminalAnsiDimCyan => self.terminal_ansi_dim_cyan,
574 ThemeColorField::TerminalAnsiWhite => self.terminal_ansi_white,
575 ThemeColorField::TerminalAnsiBrightWhite => self.terminal_ansi_bright_white,
576 ThemeColorField::TerminalAnsiDimWhite => self.terminal_ansi_dim_white,
577 ThemeColorField::LinkTextHover => self.link_text_hover,
578 ThemeColorField::VersionControlAdded => self.version_control_added,
579 ThemeColorField::VersionControlDeleted => self.version_control_deleted,
580 ThemeColorField::VersionControlModified => self.version_control_modified,
581 ThemeColorField::VersionControlRenamed => self.version_control_renamed,
582 ThemeColorField::VersionControlConflict => self.version_control_conflict,
583 ThemeColorField::VersionControlIgnored => self.version_control_ignored,
584 }
585 }
586
587 pub fn iter(&self) -> impl Iterator<Item = (ThemeColorField, Hsla)> + '_ {
588 ThemeColorField::iter().map(move |field| (field, self.color(field)))
589 }
590
591 pub fn to_vec(&self) -> Vec<(ThemeColorField, Hsla)> {
592 self.iter().collect()
593 }
594}
595
596pub fn all_theme_colors(cx: &mut App) -> Vec<(Hsla, SharedString)> {
597 let theme = cx.theme();
598 ThemeColorField::iter()
599 .map(|field| {
600 let color = theme.colors().color(field);
601 let name = field.as_ref().to_string();
602 (color, SharedString::from(name))
603 })
604 .collect()
605}
606
607#[derive(Refineable, Clone, Debug, PartialEq)]
608pub struct ThemeStyles {
609 /// The background appearance of the window.
610 pub window_background_appearance: WindowBackgroundAppearance,
611 pub system: SystemColors,
612 /// An array of colors used for theme elements that iterate through a series of colors.
613 ///
614 /// Example: Player colors, rainbow brackets and indent guides, etc.
615 pub accents: AccentColors,
616
617 #[refineable]
618 pub colors: ThemeColors,
619
620 #[refineable]
621 pub status: StatusColors,
622
623 pub player: PlayerColors,
624
625 pub syntax: Arc<SyntaxTheme>,
626}
627
628#[cfg(test)]
629mod tests {
630 use serde_json::json;
631
632 use super::*;
633
634 #[test]
635 fn override_a_single_theme_color() {
636 let mut colors = ThemeColors::light();
637
638 let magenta: Hsla = gpui::rgb(0xff00ff).into();
639
640 assert_ne!(colors.text, magenta);
641
642 let overrides = ThemeColorsRefinement {
643 text: Some(magenta),
644 ..Default::default()
645 };
646
647 colors.refine(&overrides);
648
649 assert_eq!(colors.text, magenta);
650 }
651
652 #[test]
653 fn override_multiple_theme_colors() {
654 let mut colors = ThemeColors::light();
655
656 let magenta: Hsla = gpui::rgb(0xff00ff).into();
657 let green: Hsla = gpui::rgb(0x00ff00).into();
658
659 assert_ne!(colors.text, magenta);
660 assert_ne!(colors.background, green);
661
662 let overrides = ThemeColorsRefinement {
663 text: Some(magenta),
664 background: Some(green),
665 ..Default::default()
666 };
667
668 colors.refine(&overrides);
669
670 assert_eq!(colors.text, magenta);
671 assert_eq!(colors.background, green);
672 }
673
674 #[test]
675 fn deserialize_theme_colors_refinement_from_json() {
676 let colors: ThemeColorsRefinement = serde_json::from_value(json!({
677 "background": "#ff00ff",
678 "text": "#ff0000"
679 }))
680 .unwrap();
681
682 assert_eq!(colors.background, Some(gpui::rgb(0xff00ff).into()));
683 assert_eq!(colors.text, Some(gpui::rgb(0xff0000).into()));
684 }
685}
686