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