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