theme.rs

  1mod theme_registry;
  2
  3use gpui::{
  4    color::Color,
  5    elements::{ContainerStyle, ImageStyle, LabelStyle, Shadow, TooltipStyle},
  6    fonts::{HighlightStyle, TextStyle},
  7    Border, MouseState,
  8};
  9use serde::{de::DeserializeOwned, Deserialize};
 10use serde_json::Value;
 11use std::{collections::HashMap, sync::Arc};
 12
 13pub use theme_registry::*;
 14
 15#[derive(Deserialize, Default)]
 16pub struct Theme {
 17    #[serde(default)]
 18    pub meta: ThemeMeta,
 19    pub workspace: Workspace,
 20    pub context_menu: ContextMenu,
 21    pub contacts_popover: ContactsPopover,
 22    pub contact_list: ContactList,
 23    pub contact_finder: ContactFinder,
 24    pub project_panel: ProjectPanel,
 25    pub command_palette: CommandPalette,
 26    pub picker: Picker,
 27    pub editor: Editor,
 28    pub search: Search,
 29    pub project_diagnostics: ProjectDiagnostics,
 30    pub breadcrumbs: ContainedText,
 31    pub shared_screen: ContainerStyle,
 32    pub contact_notification: ContactNotification,
 33    pub update_notification: UpdateNotification,
 34    pub simple_message_notification: MessageNotification,
 35    pub project_shared_notification: ProjectSharedNotification,
 36    pub incoming_call_notification: IncomingCallNotification,
 37    pub tooltip: TooltipStyle,
 38    pub terminal: TerminalStyle,
 39    pub feedback: FeedbackStyle,
 40    pub color_scheme: ColorScheme,
 41}
 42
 43#[derive(Deserialize, Default, Clone)]
 44pub struct ThemeMeta {
 45    pub name: String,
 46    pub is_light: bool,
 47}
 48
 49#[derive(Deserialize, Default)]
 50pub struct Workspace {
 51    pub background: Color,
 52    pub titlebar: Titlebar,
 53    pub tab_bar: TabBar,
 54    pub pane_divider: Border,
 55    pub leader_border_opacity: f32,
 56    pub leader_border_width: f32,
 57    pub sidebar: Sidebar,
 58    pub status_bar: StatusBar,
 59    pub toolbar: Toolbar,
 60    pub disconnected_overlay: ContainedText,
 61    pub modal: ContainerStyle,
 62    pub notification: ContainerStyle,
 63    pub notifications: Notifications,
 64    pub joining_project_avatar: ImageStyle,
 65    pub joining_project_message: ContainedText,
 66    pub external_location_message: ContainedText,
 67    pub dock: Dock,
 68    pub drop_target_overlay_color: Color,
 69}
 70
 71#[derive(Clone, Deserialize, Default)]
 72pub struct Titlebar {
 73    #[serde(flatten)]
 74    pub container: ContainerStyle,
 75    pub height: f32,
 76    pub title: TextStyle,
 77    pub avatar_width: f32,
 78    pub avatar_margin: f32,
 79    pub avatar_ribbon: AvatarRibbon,
 80    pub offline_icon: OfflineIcon,
 81    pub avatar: ImageStyle,
 82    pub inactive_avatar: ImageStyle,
 83    pub sign_in_prompt: Interactive<ContainedText>,
 84    pub outdated_warning: ContainedText,
 85    pub share_button: Interactive<ContainedText>,
 86    pub call_control: Interactive<IconButton>,
 87    pub toggle_contacts_button: Interactive<IconButton>,
 88    pub toggle_contacts_badge: ContainerStyle,
 89}
 90
 91#[derive(Deserialize, Default)]
 92pub struct ContactsPopover {
 93    #[serde(flatten)]
 94    pub container: ContainerStyle,
 95    pub height: f32,
 96    pub width: f32,
 97    pub invite_row_height: f32,
 98    pub invite_row: Interactive<ContainedLabel>,
 99}
100
101#[derive(Deserialize, Default)]
102pub struct ContactList {
103    pub user_query_editor: FieldEditor,
104    pub user_query_editor_height: f32,
105    pub add_contact_button: IconButton,
106    pub header_row: Interactive<ContainedText>,
107    pub leave_call: Interactive<ContainedText>,
108    pub contact_row: Interactive<ContainerStyle>,
109    pub row_height: f32,
110    pub project_row: Interactive<ProjectRow>,
111    pub tree_branch: Interactive<TreeBranch>,
112    pub contact_avatar: ImageStyle,
113    pub contact_status_free: ContainerStyle,
114    pub contact_status_busy: ContainerStyle,
115    pub contact_username: ContainedText,
116    pub contact_button: Interactive<IconButton>,
117    pub contact_button_spacing: f32,
118    pub disabled_button: IconButton,
119    pub section_icon_size: f32,
120    pub calling_indicator: ContainedText,
121}
122
123#[derive(Deserialize, Default)]
124pub struct ProjectRow {
125    #[serde(flatten)]
126    pub container: ContainerStyle,
127    pub icon: Icon,
128    pub name: ContainedText,
129}
130
131#[derive(Deserialize, Default, Clone, Copy)]
132pub struct TreeBranch {
133    pub width: f32,
134    pub color: Color,
135}
136
137#[derive(Deserialize, Default)]
138pub struct ContactFinder {
139    pub picker: Picker,
140    pub row_height: f32,
141    pub contact_avatar: ImageStyle,
142    pub contact_username: ContainerStyle,
143    pub contact_button: IconButton,
144    pub disabled_contact_button: IconButton,
145}
146
147#[derive(Clone, Deserialize, Default)]
148pub struct TabBar {
149    #[serde(flatten)]
150    pub container: ContainerStyle,
151    pub pane_button: Interactive<IconButton>,
152    pub pane_button_container: ContainerStyle,
153    pub active_pane: TabStyles,
154    pub inactive_pane: TabStyles,
155    pub dragged_tab: Tab,
156    pub height: f32,
157}
158
159impl TabBar {
160    pub fn tab_style(&self, pane_active: bool, tab_active: bool) -> &Tab {
161        let tabs = if pane_active {
162            &self.active_pane
163        } else {
164            &self.inactive_pane
165        };
166
167        if tab_active {
168            &tabs.active_tab
169        } else {
170            &tabs.inactive_tab
171        }
172    }
173}
174
175#[derive(Clone, Deserialize, Default)]
176pub struct TabStyles {
177    pub active_tab: Tab,
178    pub inactive_tab: Tab,
179}
180
181#[derive(Clone, Deserialize, Default)]
182pub struct AvatarRibbon {
183    #[serde(flatten)]
184    pub container: ContainerStyle,
185    pub width: f32,
186    pub height: f32,
187}
188
189#[derive(Clone, Deserialize, Default)]
190pub struct OfflineIcon {
191    #[serde(flatten)]
192    pub container: ContainerStyle,
193    pub width: f32,
194    pub color: Color,
195}
196
197#[derive(Clone, Deserialize, Default)]
198pub struct Tab {
199    pub height: f32,
200    #[serde(flatten)]
201    pub container: ContainerStyle,
202    #[serde(flatten)]
203    pub label: LabelStyle,
204    pub description: ContainedText,
205    pub spacing: f32,
206    pub icon_width: f32,
207    pub icon_close: Color,
208    pub icon_close_active: Color,
209    pub icon_dirty: Color,
210    pub icon_conflict: Color,
211}
212
213#[derive(Clone, Deserialize, Default)]
214pub struct Toolbar {
215    #[serde(flatten)]
216    pub container: ContainerStyle,
217    pub height: f32,
218    pub item_spacing: f32,
219    pub nav_button: Interactive<IconButton>,
220}
221
222#[derive(Clone, Deserialize, Default)]
223pub struct Dock {
224    pub initial_size_right: f32,
225    pub initial_size_bottom: f32,
226    pub wash_color: Color,
227    pub panel: ContainerStyle,
228    pub maximized: ContainerStyle,
229}
230
231#[derive(Clone, Deserialize, Default)]
232pub struct Notifications {
233    #[serde(flatten)]
234    pub container: ContainerStyle,
235    pub width: f32,
236}
237
238#[derive(Clone, Deserialize, Default)]
239pub struct Search {
240    #[serde(flatten)]
241    pub container: ContainerStyle,
242    pub editor: FindEditor,
243    pub invalid_editor: ContainerStyle,
244    pub option_button_group: ContainerStyle,
245    pub option_button: Interactive<ContainedText>,
246    pub match_background: Color,
247    pub match_index: ContainedText,
248    pub results_status: TextStyle,
249    pub tab_icon_width: f32,
250    pub tab_icon_spacing: f32,
251    pub dismiss_button: Interactive<IconButton>,
252}
253
254#[derive(Clone, Deserialize, Default)]
255pub struct FindEditor {
256    #[serde(flatten)]
257    pub input: FieldEditor,
258    pub min_width: f32,
259    pub max_width: f32,
260}
261
262#[derive(Deserialize, Default)]
263pub struct StatusBar {
264    #[serde(flatten)]
265    pub container: ContainerStyle,
266    pub height: f32,
267    pub item_spacing: f32,
268    pub cursor_position: TextStyle,
269    pub auto_update_progress_message: TextStyle,
270    pub auto_update_done_message: TextStyle,
271    pub lsp_status: Interactive<StatusBarLspStatus>,
272    pub feedback: Interactive<TextStyle>,
273    pub sidebar_buttons: StatusBarSidebarButtons,
274    pub diagnostic_summary: Interactive<StatusBarDiagnosticSummary>,
275    pub diagnostic_message: Interactive<ContainedText>,
276}
277
278#[derive(Deserialize, Default)]
279pub struct StatusBarSidebarButtons {
280    pub group_left: ContainerStyle,
281    pub group_right: ContainerStyle,
282    pub item: Interactive<SidebarItem>,
283    pub badge: ContainerStyle,
284}
285
286#[derive(Deserialize, Default)]
287pub struct StatusBarDiagnosticSummary {
288    pub container_ok: ContainerStyle,
289    pub container_warning: ContainerStyle,
290    pub container_error: ContainerStyle,
291    pub text: TextStyle,
292    pub icon_color_ok: Color,
293    pub icon_color_warning: Color,
294    pub icon_color_error: Color,
295    pub height: f32,
296    pub icon_width: f32,
297    pub icon_spacing: f32,
298    pub summary_spacing: f32,
299}
300
301#[derive(Deserialize, Default)]
302pub struct StatusBarLspStatus {
303    #[serde(flatten)]
304    pub container: ContainerStyle,
305    pub height: f32,
306    pub icon_spacing: f32,
307    pub icon_color: Color,
308    pub icon_width: f32,
309    pub message: TextStyle,
310}
311
312#[derive(Deserialize, Default)]
313pub struct Sidebar {
314    pub initial_size: f32,
315    #[serde(flatten)]
316    pub container: ContainerStyle,
317}
318
319#[derive(Clone, Copy, Deserialize, Default)]
320pub struct SidebarItem {
321    #[serde(flatten)]
322    pub container: ContainerStyle,
323    pub icon_color: Color,
324    pub icon_size: f32,
325}
326
327#[derive(Deserialize, Default)]
328pub struct ProjectPanel {
329    #[serde(flatten)]
330    pub container: ContainerStyle,
331    pub entry: Interactive<ProjectPanelEntry>,
332    pub dragged_entry: ProjectPanelEntry,
333    pub ignored_entry: Interactive<ProjectPanelEntry>,
334    pub cut_entry: Interactive<ProjectPanelEntry>,
335    pub filename_editor: FieldEditor,
336    pub indent_width: f32,
337}
338
339#[derive(Clone, Debug, Deserialize, Default)]
340pub struct ProjectPanelEntry {
341    pub height: f32,
342    #[serde(flatten)]
343    pub container: ContainerStyle,
344    pub text: TextStyle,
345    pub icon_color: Color,
346    pub icon_size: f32,
347    pub icon_spacing: f32,
348}
349
350#[derive(Clone, Debug, Deserialize, Default)]
351pub struct ContextMenu {
352    #[serde(flatten)]
353    pub container: ContainerStyle,
354    pub item: Interactive<ContextMenuItem>,
355    pub keystroke_margin: f32,
356    pub separator: ContainerStyle,
357}
358
359#[derive(Clone, Debug, Deserialize, Default)]
360pub struct ContextMenuItem {
361    #[serde(flatten)]
362    pub container: ContainerStyle,
363    pub label: TextStyle,
364    pub keystroke: ContainedText,
365    pub icon_width: f32,
366    pub icon_spacing: f32,
367}
368
369#[derive(Debug, Deserialize, Default)]
370pub struct CommandPalette {
371    pub key: Interactive<ContainedLabel>,
372    pub keystroke_spacing: f32,
373}
374
375#[derive(Deserialize, Default)]
376pub struct InviteLink {
377    #[serde(flatten)]
378    pub container: ContainerStyle,
379    #[serde(flatten)]
380    pub label: LabelStyle,
381    pub icon: Icon,
382}
383
384#[derive(Deserialize, Default)]
385pub struct Icon {
386    #[serde(flatten)]
387    pub container: ContainerStyle,
388    pub color: Color,
389    pub width: f32,
390}
391
392#[derive(Deserialize, Clone, Copy, Default)]
393pub struct IconButton {
394    #[serde(flatten)]
395    pub container: ContainerStyle,
396    pub color: Color,
397    pub icon_width: f32,
398    pub button_width: f32,
399}
400
401#[derive(Deserialize, Default)]
402pub struct ChatMessage {
403    #[serde(flatten)]
404    pub container: ContainerStyle,
405    pub body: TextStyle,
406    pub sender: ContainedText,
407    pub timestamp: ContainedText,
408}
409
410#[derive(Deserialize, Default)]
411pub struct ChannelSelect {
412    #[serde(flatten)]
413    pub container: ContainerStyle,
414    pub header: ChannelName,
415    pub item: ChannelName,
416    pub active_item: ChannelName,
417    pub hovered_item: ChannelName,
418    pub hovered_active_item: ChannelName,
419    pub menu: ContainerStyle,
420}
421
422#[derive(Deserialize, Default)]
423pub struct ChannelName {
424    #[serde(flatten)]
425    pub container: ContainerStyle,
426    pub hash: ContainedText,
427    pub name: TextStyle,
428}
429
430#[derive(Clone, Deserialize, Default)]
431pub struct Picker {
432    #[serde(flatten)]
433    pub container: ContainerStyle,
434    pub empty_container: ContainerStyle,
435    pub input_editor: FieldEditor,
436    pub empty_input_editor: FieldEditor,
437    pub no_matches: ContainedLabel,
438    pub item: Interactive<ContainedLabel>,
439}
440
441#[derive(Clone, Debug, Deserialize, Default)]
442pub struct ContainedText {
443    #[serde(flatten)]
444    pub container: ContainerStyle,
445    #[serde(flatten)]
446    pub text: TextStyle,
447}
448
449#[derive(Clone, Debug, Deserialize, Default)]
450pub struct ContainedLabel {
451    #[serde(flatten)]
452    pub container: ContainerStyle,
453    #[serde(flatten)]
454    pub label: LabelStyle,
455}
456
457#[derive(Clone, Deserialize, Default)]
458pub struct ProjectDiagnostics {
459    #[serde(flatten)]
460    pub container: ContainerStyle,
461    pub empty_message: TextStyle,
462    pub tab_icon_width: f32,
463    pub tab_icon_spacing: f32,
464    pub tab_summary_spacing: f32,
465}
466
467#[derive(Deserialize, Default)]
468pub struct ContactNotification {
469    pub header_avatar: ImageStyle,
470    pub header_message: ContainedText,
471    pub header_height: f32,
472    pub body_message: ContainedText,
473    pub button: Interactive<ContainedText>,
474    pub dismiss_button: Interactive<IconButton>,
475}
476
477#[derive(Deserialize, Default)]
478pub struct UpdateNotification {
479    pub message: ContainedText,
480    pub action_message: Interactive<ContainedText>,
481    pub dismiss_button: Interactive<IconButton>,
482}
483
484#[derive(Deserialize, Default)]
485pub struct MessageNotification {
486    pub message: ContainedText,
487    pub action_message: Interactive<ContainedText>,
488    pub dismiss_button: Interactive<IconButton>,
489}
490
491#[derive(Deserialize, Default)]
492pub struct ProjectSharedNotification {
493    pub window_height: f32,
494    pub window_width: f32,
495    #[serde(default)]
496    pub background: Color,
497    pub owner_container: ContainerStyle,
498    pub owner_avatar: ImageStyle,
499    pub owner_metadata: ContainerStyle,
500    pub owner_username: ContainedText,
501    pub message: ContainedText,
502    pub worktree_roots: ContainedText,
503    pub button_width: f32,
504    pub open_button: ContainedText,
505    pub dismiss_button: ContainedText,
506}
507
508#[derive(Deserialize, Default)]
509pub struct IncomingCallNotification {
510    pub window_height: f32,
511    pub window_width: f32,
512    #[serde(default)]
513    pub background: Color,
514    pub caller_container: ContainerStyle,
515    pub caller_avatar: ImageStyle,
516    pub caller_metadata: ContainerStyle,
517    pub caller_username: ContainedText,
518    pub caller_message: ContainedText,
519    pub worktree_roots: ContainedText,
520    pub button_width: f32,
521    pub accept_button: ContainedText,
522    pub decline_button: ContainedText,
523}
524
525#[derive(Clone, Deserialize, Default)]
526pub struct Editor {
527    pub text_color: Color,
528    #[serde(default)]
529    pub background: Color,
530    pub selection: SelectionStyle,
531    pub gutter_background: Color,
532    pub gutter_padding_factor: f32,
533    pub active_line_background: Color,
534    pub highlighted_line_background: Color,
535    pub rename_fade: f32,
536    pub document_highlight_read_background: Color,
537    pub document_highlight_write_background: Color,
538    pub diff: DiffStyle,
539    pub line_number: Color,
540    pub line_number_active: Color,
541    pub guest_selections: Vec<SelectionStyle>,
542    pub syntax: Arc<SyntaxTheme>,
543    pub diagnostic_path_header: DiagnosticPathHeader,
544    pub diagnostic_header: DiagnosticHeader,
545    pub error_diagnostic: DiagnosticStyle,
546    pub invalid_error_diagnostic: DiagnosticStyle,
547    pub warning_diagnostic: DiagnosticStyle,
548    pub invalid_warning_diagnostic: DiagnosticStyle,
549    pub information_diagnostic: DiagnosticStyle,
550    pub invalid_information_diagnostic: DiagnosticStyle,
551    pub hint_diagnostic: DiagnosticStyle,
552    pub invalid_hint_diagnostic: DiagnosticStyle,
553    pub autocomplete: AutocompleteStyle,
554    pub code_actions: CodeActions,
555    pub unnecessary_code_fade: f32,
556    pub hover_popover: HoverPopover,
557    pub link_definition: HighlightStyle,
558    pub composition_mark: HighlightStyle,
559    pub jump_icon: Interactive<IconButton>,
560    pub scrollbar: Scrollbar,
561}
562
563#[derive(Clone, Deserialize, Default)]
564pub struct Scrollbar {
565    pub track: ContainerStyle,
566    pub thumb: ContainerStyle,
567    pub width: f32,
568    pub min_height_factor: f32,
569}
570
571#[derive(Clone, Deserialize, Default)]
572pub struct DiagnosticPathHeader {
573    #[serde(flatten)]
574    pub container: ContainerStyle,
575    pub filename: ContainedText,
576    pub path: ContainedText,
577    pub text_scale_factor: f32,
578}
579
580#[derive(Clone, Deserialize, Default)]
581pub struct DiagnosticHeader {
582    #[serde(flatten)]
583    pub container: ContainerStyle,
584    pub message: ContainedLabel,
585    pub code: ContainedText,
586    pub text_scale_factor: f32,
587    pub icon_width_factor: f32,
588}
589
590#[derive(Clone, Deserialize, Default)]
591pub struct DiagnosticStyle {
592    pub message: LabelStyle,
593    #[serde(default)]
594    pub header: ContainerStyle,
595    pub text_scale_factor: f32,
596}
597
598#[derive(Clone, Deserialize, Default)]
599pub struct AutocompleteStyle {
600    #[serde(flatten)]
601    pub container: ContainerStyle,
602    pub item: ContainerStyle,
603    pub selected_item: ContainerStyle,
604    pub hovered_item: ContainerStyle,
605    pub match_highlight: HighlightStyle,
606}
607
608#[derive(Clone, Copy, Default, Deserialize)]
609pub struct SelectionStyle {
610    pub cursor: Color,
611    pub selection: Color,
612}
613
614#[derive(Clone, Deserialize, Default)]
615pub struct FieldEditor {
616    #[serde(flatten)]
617    pub container: ContainerStyle,
618    pub text: TextStyle,
619    #[serde(default)]
620    pub placeholder_text: Option<TextStyle>,
621    pub selection: SelectionStyle,
622}
623
624#[derive(Clone, Deserialize, Default)]
625pub struct CodeActions {
626    #[serde(default)]
627    pub indicator: Color,
628    pub vertical_scale: f32,
629}
630
631#[derive(Clone, Deserialize, Default)]
632pub struct DiffStyle {
633    pub inserted: Color,
634    pub modified: Color,
635    pub deleted: Color,
636    pub removed_width_em: f32,
637    pub width_em: f32,
638    pub corner_radius: f32,
639}
640
641#[derive(Debug, Default, Clone, Copy)]
642pub struct Interactive<T> {
643    pub default: T,
644    pub hover: Option<T>,
645    pub clicked: Option<T>,
646    pub active: Option<T>,
647    pub disabled: Option<T>,
648}
649
650impl<T> Interactive<T> {
651    pub fn style_for(&self, state: &mut MouseState, active: bool) -> &T {
652        if active {
653            self.active.as_ref().unwrap_or(&self.default)
654        } else if state.clicked() == Some(gpui::MouseButton::Left) && self.clicked.is_some() {
655            self.clicked.as_ref().unwrap()
656        } else if state.hovered() {
657            self.hover.as_ref().unwrap_or(&self.default)
658        } else {
659            &self.default
660        }
661    }
662
663    pub fn disabled_style(&self) -> &T {
664        self.disabled.as_ref().unwrap_or(&self.default)
665    }
666}
667
668impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive<T> {
669    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
670    where
671        D: serde::Deserializer<'de>,
672    {
673        #[derive(Deserialize)]
674        struct Helper {
675            #[serde(flatten)]
676            default: Value,
677            hover: Option<Value>,
678            clicked: Option<Value>,
679            active: Option<Value>,
680            disabled: Option<Value>,
681        }
682
683        let json = Helper::deserialize(deserializer)?;
684
685        let deserialize_state = |state_json: Option<Value>| -> Result<Option<T>, D::Error> {
686            if let Some(mut state_json) = state_json {
687                if let Value::Object(state_json) = &mut state_json {
688                    if let Value::Object(default) = &json.default {
689                        for (key, value) in default {
690                            if !state_json.contains_key(key) {
691                                state_json.insert(key.clone(), value.clone());
692                            }
693                        }
694                    }
695                }
696                Ok(Some(
697                    serde_json::from_value::<T>(state_json).map_err(serde::de::Error::custom)?,
698                ))
699            } else {
700                Ok(None)
701            }
702        };
703
704        let hover = deserialize_state(json.hover)?;
705        let clicked = deserialize_state(json.clicked)?;
706        let active = deserialize_state(json.active)?;
707        let disabled = deserialize_state(json.disabled)?;
708        let default = serde_json::from_value(json.default).map_err(serde::de::Error::custom)?;
709
710        Ok(Interactive {
711            default,
712            hover,
713            clicked,
714            active,
715            disabled,
716        })
717    }
718}
719
720impl Editor {
721    pub fn replica_selection_style(&self, replica_id: u16) -> &SelectionStyle {
722        let style_ix = replica_id as usize % (self.guest_selections.len() + 1);
723        if style_ix == 0 {
724            &self.selection
725        } else {
726            &self.guest_selections[style_ix - 1]
727        }
728    }
729}
730
731#[derive(Default)]
732pub struct SyntaxTheme {
733    pub highlights: Vec<(String, HighlightStyle)>,
734}
735
736impl SyntaxTheme {
737    pub fn new(highlights: Vec<(String, HighlightStyle)>) -> Self {
738        Self { highlights }
739    }
740}
741
742impl<'de> Deserialize<'de> for SyntaxTheme {
743    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
744    where
745        D: serde::Deserializer<'de>,
746    {
747        let syntax_data: HashMap<String, HighlightStyle> = Deserialize::deserialize(deserializer)?;
748
749        let mut result = Self::new(Vec::new());
750        for (key, style) in syntax_data {
751            match result
752                .highlights
753                .binary_search_by(|(needle, _)| needle.cmp(&key))
754            {
755                Ok(i) | Err(i) => {
756                    result.highlights.insert(i, (key, style));
757                }
758            }
759        }
760
761        Ok(result)
762    }
763}
764
765#[derive(Clone, Deserialize, Default)]
766pub struct HoverPopover {
767    pub container: ContainerStyle,
768    pub info_container: ContainerStyle,
769    pub warning_container: ContainerStyle,
770    pub error_container: ContainerStyle,
771    pub block_style: ContainerStyle,
772    pub prose: TextStyle,
773    pub highlight: Color,
774}
775
776#[derive(Clone, Deserialize, Default)]
777pub struct TerminalStyle {
778    pub black: Color,
779    pub red: Color,
780    pub green: Color,
781    pub yellow: Color,
782    pub blue: Color,
783    pub magenta: Color,
784    pub cyan: Color,
785    pub white: Color,
786    pub bright_black: Color,
787    pub bright_red: Color,
788    pub bright_green: Color,
789    pub bright_yellow: Color,
790    pub bright_blue: Color,
791    pub bright_magenta: Color,
792    pub bright_cyan: Color,
793    pub bright_white: Color,
794    pub foreground: Color,
795    pub background: Color,
796    pub modal_background: Color,
797    pub cursor: Color,
798    pub dim_black: Color,
799    pub dim_red: Color,
800    pub dim_green: Color,
801    pub dim_yellow: Color,
802    pub dim_blue: Color,
803    pub dim_magenta: Color,
804    pub dim_cyan: Color,
805    pub dim_white: Color,
806    pub bright_foreground: Color,
807    pub dim_foreground: Color,
808}
809
810#[derive(Clone, Deserialize, Default)]
811pub struct FeedbackStyle {
812    pub submit_button: Interactive<ContainedText>,
813    pub button_margin: f32,
814}
815
816#[derive(Clone, Deserialize, Default)]
817pub struct ColorScheme {
818    pub name: String,
819    pub is_light: bool,
820
821    pub ramps: RampSet,
822
823    pub lowest: Layer,
824    pub middle: Layer,
825    pub highest: Layer,
826
827    pub popover_shadow: Shadow,
828    pub modal_shadow: Shadow,
829
830    pub players: Vec<Player>,
831}
832
833#[derive(Clone, Deserialize, Default)]
834pub struct Player {
835    pub cursor: Color,
836    pub selection: Color,
837}
838
839#[derive(Clone, Deserialize, Default)]
840pub struct RampSet {
841    pub neutral: Vec<Color>,
842    pub red: Vec<Color>,
843    pub orange: Vec<Color>,
844    pub yellow: Vec<Color>,
845    pub green: Vec<Color>,
846    pub cyan: Vec<Color>,
847    pub blue: Vec<Color>,
848    pub violet: Vec<Color>,
849    pub magenta: Vec<Color>,
850}
851
852#[derive(Clone, Deserialize, Default)]
853pub struct Layer {
854    pub base: StyleSet,
855    pub variant: StyleSet,
856    pub on: StyleSet,
857    pub accent: StyleSet,
858    pub positive: StyleSet,
859    pub warning: StyleSet,
860    pub negative: StyleSet,
861}
862
863#[derive(Clone, Deserialize, Default)]
864pub struct StyleSet {
865    pub default: Style,
866    pub active: Style,
867    pub disabled: Style,
868    pub hovered: Style,
869    pub pressed: Style,
870    pub inverted: Style,
871}
872
873#[derive(Clone, Deserialize, Default)]
874pub struct Style {
875    pub background: Color,
876    pub border: Color,
877    pub foreground: Color,
878}