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