-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
schema.rs
1265 lines (1107 loc) · 46.7 KB
/
schema.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
use anyhow::Result;
use gpui::{FontStyle, FontWeight, HighlightStyle, Hsla};
use indexmap::IndexMap;
use palette::FromColor;
use schemars::gen::SchemaGenerator;
use schemars::schema::{Schema, SchemaObject};
use schemars::JsonSchema;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;
use serde_repr::{Deserialize_repr, Serialize_repr};
use crate::{StatusColorsRefinement, ThemeColorsRefinement};
pub(crate) fn try_parse_color(color: &str) -> Result<Hsla> {
let rgba = gpui::Rgba::try_from(color)?;
let rgba = palette::rgb::Srgba::from_components((rgba.r, rgba.g, rgba.b, rgba.a));
let hsla = palette::Hsla::from_color(rgba);
let hsla = gpui::hsla(
hsla.hue.into_positive_degrees() / 360.,
hsla.saturation,
hsla.lightness,
hsla.alpha,
);
Ok(hsla)
}
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum AppearanceContent {
Light,
Dark,
}
/// The content of a serialized theme family.
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct ThemeFamilyContent {
pub name: String,
pub author: String,
pub themes: Vec<ThemeContent>,
}
/// The content of a serialized theme.
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct ThemeContent {
pub name: String,
pub appearance: AppearanceContent,
pub style: ThemeStyleContent,
}
/// The content of a serialized theme.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
#[serde(default)]
pub struct ThemeStyleContent {
#[serde(flatten, default)]
pub colors: ThemeColorsContent,
#[serde(flatten, default)]
pub status: StatusColorsContent,
#[serde(default)]
pub players: Vec<PlayerColorContent>,
/// The styles for syntax nodes.
#[serde(default)]
pub syntax: IndexMap<String, HighlightStyleContent>,
}
impl ThemeStyleContent {
/// Returns a [`ThemeColorsRefinement`] based on the colors in the [`ThemeContent`].
#[inline(always)]
pub fn theme_colors_refinement(&self) -> ThemeColorsRefinement {
self.colors.theme_colors_refinement()
}
/// Returns a [`StatusColorsRefinement`] based on the colors in the [`ThemeContent`].
#[inline(always)]
pub fn status_colors_refinement(&self) -> StatusColorsRefinement {
self.status.status_colors_refinement()
}
/// Returns the syntax style overrides in the [`ThemeContent`].
pub fn syntax_overrides(&self) -> Vec<(String, HighlightStyle)> {
self.syntax
.iter()
.map(|(key, style)| {
(
key.clone(),
HighlightStyle {
color: style
.color
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
..Default::default()
},
)
})
.collect()
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
#[serde(default)]
pub struct ThemeColorsContent {
/// Border color. Used for most borders, is usually a high contrast color.
#[serde(rename = "border")]
pub border: Option<String>,
/// Border color. Used for deemphasized borders, like a visual divider between two sections
#[serde(rename = "border.variant")]
pub border_variant: Option<String>,
/// Border color. Used for focused elements, like keyboard focused list item.
#[serde(rename = "border.focused")]
pub border_focused: Option<String>,
/// Border color. Used for selected elements, like an active search filter or selected checkbox.
#[serde(rename = "border.selected")]
pub border_selected: Option<String>,
/// Border color. Used for transparent borders. Used for placeholder borders when an element gains a border on state change.
#[serde(rename = "border.transparent")]
pub border_transparent: Option<String>,
/// Border color. Used for disabled elements, like a disabled input or button.
#[serde(rename = "border.disabled")]
pub border_disabled: Option<String>,
/// Border color. Used for elevated surfaces, like a context menu, popup, or dialog.
#[serde(rename = "elevated_surface.background")]
pub elevated_surface_background: Option<String>,
/// Background Color. Used for grounded surfaces like a panel or tab.
#[serde(rename = "surface.background")]
pub surface_background: Option<String>,
/// Background Color. Used for the app background and blank panels or windows.
#[serde(rename = "background")]
pub background: Option<String>,
/// Background Color. Used for the background of an element that should have a different background than the surface it's on.
///
/// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...
///
/// For an element that should have the same background as the surface it's on, use `ghost_element_background`.
#[serde(rename = "element.background")]
pub element_background: Option<String>,
/// Background Color. Used for the hover state of an element that should have a different background than the surface it's on.
///
/// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
#[serde(rename = "element.hover")]
pub element_hover: Option<String>,
/// Background Color. Used for the active state of an element that should have a different background than the surface it's on.
///
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressd.
#[serde(rename = "element.active")]
pub element_active: Option<String>,
/// Background Color. Used for the selected state of an element that should have a different background than the surface it's on.
///
/// Selected states are triggered by the element being selected (or "activated") by the user.
///
/// This could include a selected checkbox, a toggleable button that is toggled on, etc.
#[serde(rename = "element.selected")]
pub element_selected: Option<String>,
/// Background Color. Used for the disabled state of an element that should have a different background than the surface it's on.
///
/// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
#[serde(rename = "element.disabled")]
pub element_disabled: Option<String>,
/// Background Color. Used for the area that shows where a dragged element will be dropped.
#[serde(rename = "drop_target.background")]
pub drop_target_background: Option<String>,
/// Used for the background of a ghost element that should have the same background as the surface it's on.
///
/// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...
///
/// For an element that should have a different background than the surface it's on, use `element_background`.
#[serde(rename = "ghost_element.background")]
pub ghost_element_background: Option<String>,
/// Background Color. Used for the hover state of a ghost element that should have the same background as the surface it's on.
///
/// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
#[serde(rename = "ghost_element.hover")]
pub ghost_element_hover: Option<String>,
/// Background Color. Used for the active state of a ghost element that should have the same background as the surface it's on.
///
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressd.
#[serde(rename = "ghost_element.active")]
pub ghost_element_active: Option<String>,
/// Background Color. Used for the selected state of a ghost element that should have the same background as the surface it's on.
///
/// Selected states are triggered by the element being selected (or "activated") by the user.
///
/// This could include a selected checkbox, a toggleable button that is toggled on, etc.
#[serde(rename = "ghost_element.selected")]
pub ghost_element_selected: Option<String>,
/// Background Color. Used for the disabled state of a ghost element that should have the same background as the surface it's on.
///
/// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
#[serde(rename = "ghost_element.disabled")]
pub ghost_element_disabled: Option<String>,
/// Text Color. Default text color used for most text.
#[serde(rename = "text")]
pub text: Option<String>,
/// Text Color. Color of muted or deemphasized text. It is a subdued version of the standard text color.
#[serde(rename = "text.muted")]
pub text_muted: Option<String>,
/// Text Color. Color of the placeholder text typically shown in input fields to guide the user to enter valid data.
#[serde(rename = "text.placeholder")]
pub text_placeholder: Option<String>,
/// Text Color. Color used for text denoting disabled elements. Typically, the color is faded or grayed out to emphasize the disabled state.
#[serde(rename = "text.disabled")]
pub text_disabled: Option<String>,
/// Text Color. Color used for emphasis or highlighting certain text, like an active filter or a matched character in a search.
#[serde(rename = "text.accent")]
pub text_accent: Option<String>,
/// Fill Color. Used for the default fill color of an icon.
#[serde(rename = "icon")]
pub icon: Option<String>,
/// Fill Color. Used for the muted or deemphasized fill color of an icon.
///
/// This might be used to show an icon in an inactive pane, or to demphasize a series of icons to give them less visual weight.
#[serde(rename = "icon.muted")]
pub icon_muted: Option<String>,
/// Fill Color. Used for the disabled fill color of an icon.
///
/// Disabled states are shown when a user cannot interact with an element, like a icon button.
#[serde(rename = "icon.disabled")]
pub icon_disabled: Option<String>,
/// Fill Color. Used for the placeholder fill color of an icon.
///
/// This might be used to show an icon in an input that disappears when the user enters text.
#[serde(rename = "icon.placeholder")]
pub icon_placeholder: Option<String>,
/// Fill Color. Used for the accent fill color of an icon.
///
/// This might be used to show when a toggleable icon button is selected.
#[serde(rename = "icon.accent")]
pub icon_accent: Option<String>,
#[serde(rename = "status_bar.background")]
pub status_bar_background: Option<String>,
#[serde(rename = "title_bar.background")]
pub title_bar_background: Option<String>,
#[serde(rename = "toolbar.background")]
pub toolbar_background: Option<String>,
#[serde(rename = "tab_bar.background")]
pub tab_bar_background: Option<String>,
#[serde(rename = "tab.inactive_background")]
pub tab_inactive_background: Option<String>,
#[serde(rename = "tab.active_background")]
pub tab_active_background: Option<String>,
#[serde(rename = "search.match_background")]
pub search_match_background: Option<String>,
#[serde(rename = "panel.background")]
pub panel_background: Option<String>,
#[serde(rename = "panel.focused_border")]
pub panel_focused_border: Option<String>,
#[serde(rename = "pane.focused_border")]
pub pane_focused_border: Option<String>,
/// The color of the scrollbar thumb.
#[serde(rename = "scrollbar_thumb.background")]
pub scrollbar_thumb_background: Option<String>,
/// The color of the scrollbar thumb when hovered over.
#[serde(rename = "scrollbar.thumb.hover_background")]
pub scrollbar_thumb_hover_background: Option<String>,
/// The border color of the scrollbar thumb.
#[serde(rename = "scrollbar.thumb.border")]
pub scrollbar_thumb_border: Option<String>,
/// The background color of the scrollbar track.
#[serde(rename = "scrollbar.track.background")]
pub scrollbar_track_background: Option<String>,
/// The border color of the scrollbar track.
#[serde(rename = "scrollbar.track.border")]
pub scrollbar_track_border: Option<String>,
#[serde(rename = "editor.foreground")]
pub editor_foreground: Option<String>,
#[serde(rename = "editor.background")]
pub editor_background: Option<String>,
#[serde(rename = "editor.gutter.background")]
pub editor_gutter_background: Option<String>,
#[serde(rename = "editor.subheader.background")]
pub editor_subheader_background: Option<String>,
#[serde(rename = "editor.active_line.background")]
pub editor_active_line_background: Option<String>,
#[serde(rename = "editor.highlighted_line.background")]
pub editor_highlighted_line_background: Option<String>,
/// Text Color. Used for the text of the line number in the editor gutter.
#[serde(rename = "editor.line_number")]
pub editor_line_number: Option<String>,
/// Text Color. Used for the text of the line number in the editor gutter when the line is highlighted.
#[serde(rename = "editor.active_line_number")]
pub editor_active_line_number: Option<String>,
/// Text Color. Used to mark invisible characters in the editor.
///
/// Example: spaces, tabs, carriage returns, etc.
#[serde(rename = "editor.invisible")]
pub editor_invisible: Option<String>,
#[serde(rename = "editor.wrap_guide")]
pub editor_wrap_guide: Option<String>,
#[serde(rename = "editor.active_wrap_guide")]
pub editor_active_wrap_guide: Option<String>,
/// Read-access of a symbol, like reading a variable.
///
/// A document highlight is a range inside a text document which deserves
/// special attention. Usually a document highlight is visualized by changing
/// the background color of its range.
#[serde(rename = "editor.document_highlight.read_background")]
pub editor_document_highlight_read_background: Option<String>,
/// Read-access of a symbol, like reading a variable.
///
/// A document highlight is a range inside a text document which deserves
/// special attention. Usually a document highlight is visualized by changing
/// the background color of its range.
#[serde(rename = "editor.document_highlight.write_background")]
pub editor_document_highlight_write_background: Option<String>,
/// Terminal background color.
#[serde(rename = "terminal.background")]
pub terminal_background: Option<String>,
/// Terminal foreground color.
#[serde(rename = "terminal.foreground")]
pub terminal_foreground: Option<String>,
/// Bright terminal foreground color.
#[serde(rename = "terminal.bright_foreground")]
pub terminal_bright_foreground: Option<String>,
/// Dim terminal foreground color.
#[serde(rename = "terminal.dim_foreground")]
pub terminal_dim_foreground: Option<String>,
/// Black ANSI terminal color.
#[serde(rename = "terminal.ansi.black")]
pub terminal_ansi_black: Option<String>,
/// Bright black ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_black")]
pub terminal_ansi_bright_black: Option<String>,
/// Dim black ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_black")]
pub terminal_ansi_dim_black: Option<String>,
/// Red ANSI terminal color.
#[serde(rename = "terminal.ansi.red")]
pub terminal_ansi_red: Option<String>,
/// Bright red ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_red")]
pub terminal_ansi_bright_red: Option<String>,
/// Dim red ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_red")]
pub terminal_ansi_dim_red: Option<String>,
/// Green ANSI terminal color.
#[serde(rename = "terminal.ansi.green")]
pub terminal_ansi_green: Option<String>,
/// Bright green ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_green")]
pub terminal_ansi_bright_green: Option<String>,
/// Dim green ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_green")]
pub terminal_ansi_dim_green: Option<String>,
/// Yellow ANSI terminal color.
#[serde(rename = "terminal.ansi.yellow")]
pub terminal_ansi_yellow: Option<String>,
/// Bright yellow ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_yellow")]
pub terminal_ansi_bright_yellow: Option<String>,
/// Dim yellow ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_yellow")]
pub terminal_ansi_dim_yellow: Option<String>,
/// Blue ANSI terminal color.
#[serde(rename = "terminal.ansi.blue")]
pub terminal_ansi_blue: Option<String>,
/// Bright blue ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_blue")]
pub terminal_ansi_bright_blue: Option<String>,
/// Dim blue ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_blue")]
pub terminal_ansi_dim_blue: Option<String>,
/// Magenta ANSI terminal color.
#[serde(rename = "terminal.ansi.magenta")]
pub terminal_ansi_magenta: Option<String>,
/// Bright magenta ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_magenta")]
pub terminal_ansi_bright_magenta: Option<String>,
/// Dim magenta ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_magenta")]
pub terminal_ansi_dim_magenta: Option<String>,
/// Cyan ANSI terminal color.
#[serde(rename = "terminal.ansi.cyan")]
pub terminal_ansi_cyan: Option<String>,
/// Bright cyan ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_cyan")]
pub terminal_ansi_bright_cyan: Option<String>,
/// Dim cyan ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_cyan")]
pub terminal_ansi_dim_cyan: Option<String>,
/// White ANSI terminal color.
#[serde(rename = "terminal.ansi.white")]
pub terminal_ansi_white: Option<String>,
/// Bright white ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_white")]
pub terminal_ansi_bright_white: Option<String>,
/// Dim white ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_white")]
pub terminal_ansi_dim_white: Option<String>,
#[serde(rename = "link_text.hover")]
pub link_text_hover: Option<String>,
}
impl ThemeColorsContent {
/// Returns a [`ThemeColorsRefinement`] based on the colors in the [`ThemeColorsContent`].
pub fn theme_colors_refinement(&self) -> ThemeColorsRefinement {
ThemeColorsRefinement {
border: self
.border
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
border_variant: self
.border_variant
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
border_focused: self
.border_focused
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
border_selected: self
.border_selected
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
border_transparent: self
.border_transparent
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
border_disabled: self
.border_disabled
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
elevated_surface_background: self
.elevated_surface_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
surface_background: self
.surface_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
background: self
.background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
element_background: self
.element_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
element_hover: self
.element_hover
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
element_active: self
.element_active
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
element_selected: self
.element_selected
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
element_disabled: self
.element_disabled
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
drop_target_background: self
.drop_target_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
ghost_element_background: self
.ghost_element_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
ghost_element_hover: self
.ghost_element_hover
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
ghost_element_active: self
.ghost_element_active
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
ghost_element_selected: self
.ghost_element_selected
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
ghost_element_disabled: self
.ghost_element_disabled
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
text: self
.text
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
text_muted: self
.text_muted
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
text_placeholder: self
.text_placeholder
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
text_disabled: self
.text_disabled
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
text_accent: self
.text_accent
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
icon: self
.icon
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
icon_muted: self
.icon_muted
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
icon_disabled: self
.icon_disabled
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
icon_placeholder: self
.icon_placeholder
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
icon_accent: self
.icon_accent
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
status_bar_background: self
.status_bar_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
title_bar_background: self
.title_bar_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
toolbar_background: self
.toolbar_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
tab_bar_background: self
.tab_bar_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
tab_inactive_background: self
.tab_inactive_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
tab_active_background: self
.tab_active_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
search_match_background: self
.search_match_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
panel_background: self
.panel_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
panel_focused_border: self
.panel_focused_border
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
pane_focused_border: self
.pane_focused_border
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
scrollbar_thumb_background: self
.scrollbar_thumb_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
scrollbar_thumb_hover_background: self
.scrollbar_thumb_hover_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
scrollbar_thumb_border: self
.scrollbar_thumb_border
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
scrollbar_track_background: self
.scrollbar_track_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
scrollbar_track_border: self
.scrollbar_track_border
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_foreground: self
.editor_foreground
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_background: self
.editor_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_gutter_background: self
.editor_gutter_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_subheader_background: self
.editor_subheader_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_active_line_background: self
.editor_active_line_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_highlighted_line_background: self
.editor_highlighted_line_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_line_number: self
.editor_line_number
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_active_line_number: self
.editor_active_line_number
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_invisible: self
.editor_invisible
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_wrap_guide: self
.editor_wrap_guide
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_active_wrap_guide: self
.editor_active_wrap_guide
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_document_highlight_read_background: self
.editor_document_highlight_read_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
editor_document_highlight_write_background: self
.editor_document_highlight_write_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_background: self
.terminal_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_foreground: self
.terminal_foreground
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_bright_foreground: self
.terminal_bright_foreground
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_dim_foreground: self
.terminal_dim_foreground
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_black: self
.terminal_ansi_black
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_bright_black: self
.terminal_ansi_bright_black
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_dim_black: self
.terminal_ansi_dim_black
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_red: self
.terminal_ansi_red
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_bright_red: self
.terminal_ansi_bright_red
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_dim_red: self
.terminal_ansi_dim_red
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_green: self
.terminal_ansi_green
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_bright_green: self
.terminal_ansi_bright_green
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_dim_green: self
.terminal_ansi_dim_green
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_yellow: self
.terminal_ansi_yellow
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_bright_yellow: self
.terminal_ansi_bright_yellow
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_dim_yellow: self
.terminal_ansi_dim_yellow
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_blue: self
.terminal_ansi_blue
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_bright_blue: self
.terminal_ansi_bright_blue
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_dim_blue: self
.terminal_ansi_dim_blue
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_magenta: self
.terminal_ansi_magenta
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_bright_magenta: self
.terminal_ansi_bright_magenta
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_dim_magenta: self
.terminal_ansi_dim_magenta
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_cyan: self
.terminal_ansi_cyan
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_bright_cyan: self
.terminal_ansi_bright_cyan
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_dim_cyan: self
.terminal_ansi_dim_cyan
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_white: self
.terminal_ansi_white
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_bright_white: self
.terminal_ansi_bright_white
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
terminal_ansi_dim_white: self
.terminal_ansi_dim_white
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
link_text_hover: self
.link_text_hover
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
}
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
#[serde(default)]
pub struct StatusColorsContent {
/// Indicates some kind of conflict, like a file changed on disk while it was open, or
/// merge conflicts in a Git repository.
#[serde(rename = "conflict")]
pub conflict: Option<String>,
#[serde(rename = "conflict.background")]
pub conflict_background: Option<String>,
#[serde(rename = "conflict.border")]
pub conflict_border: Option<String>,
/// Indicates something new, like a new file added to a Git repository.
#[serde(rename = "created")]
pub created: Option<String>,
#[serde(rename = "created.background")]
pub created_background: Option<String>,
#[serde(rename = "created.border")]
pub created_border: Option<String>,
/// Indicates that something no longer exists, like a deleted file.
#[serde(rename = "deleted")]
pub deleted: Option<String>,
#[serde(rename = "deleted.background")]
pub deleted_background: Option<String>,
#[serde(rename = "deleted.border")]
pub deleted_border: Option<String>,
/// Indicates a system error, a failed operation or a diagnostic error.
#[serde(rename = "error")]
pub error: Option<String>,
#[serde(rename = "error.background")]
pub error_background: Option<String>,
#[serde(rename = "error.border")]
pub error_border: Option<String>,
/// Represents a hidden status, such as a file being hidden in a file tree.
#[serde(rename = "hidden")]
pub hidden: Option<String>,
#[serde(rename = "hidden.background")]
pub hidden_background: Option<String>,
#[serde(rename = "hidden.border")]
pub hidden_border: Option<String>,
/// Indicates a hint or some kind of additional information.
#[serde(rename = "hint")]
pub hint: Option<String>,
#[serde(rename = "hint.background")]
pub hint_background: Option<String>,
#[serde(rename = "hint.border")]
pub hint_border: Option<String>,
/// Indicates that something is deliberately ignored, such as a file or operation ignored by Git.
#[serde(rename = "ignored")]
pub ignored: Option<String>,
#[serde(rename = "ignored.background")]
pub ignored_background: Option<String>,
#[serde(rename = "ignored.border")]
pub ignored_border: Option<String>,
/// Represents informational status updates or messages.
#[serde(rename = "info")]
pub info: Option<String>,
#[serde(rename = "info.background")]
pub info_background: Option<String>,
#[serde(rename = "info.border")]
pub info_border: Option<String>,
/// Indicates a changed or altered status, like a file that has been edited.
#[serde(rename = "modified")]
pub modified: Option<String>,
#[serde(rename = "modified.background")]
pub modified_background: Option<String>,
#[serde(rename = "modified.border")]
pub modified_border: Option<String>,
/// Indicates something that is predicted, like automatic code completion, or generated code.
#[serde(rename = "predictive")]
pub predictive: Option<String>,
#[serde(rename = "predictive.background")]
pub predictive_background: Option<String>,
#[serde(rename = "predictive.border")]
pub predictive_border: Option<String>,
/// Represents a renamed status, such as a file that has been renamed.
#[serde(rename = "renamed")]
pub renamed: Option<String>,
#[serde(rename = "renamed.background")]
pub renamed_background: Option<String>,
#[serde(rename = "renamed.border")]
pub renamed_border: Option<String>,
/// Indicates a successful operation or task completion.
#[serde(rename = "success")]
pub success: Option<String>,
#[serde(rename = "success.background")]
pub success_background: Option<String>,
#[serde(rename = "success.border")]
pub success_border: Option<String>,
/// Indicates some kind of unreachable status, like a block of code that can never be reached.
#[serde(rename = "unreachable")]
pub unreachable: Option<String>,
#[serde(rename = "unreachable.background")]
pub unreachable_background: Option<String>,
#[serde(rename = "unreachable.border")]
pub unreachable_border: Option<String>,
/// Represents a warning status, like an operation that is about to fail.
#[serde(rename = "warning")]
pub warning: Option<String>,
#[serde(rename = "warning.background")]
pub warning_background: Option<String>,
#[serde(rename = "warning.border")]
pub warning_border: Option<String>,
}
impl StatusColorsContent {
/// Returns a [`StatusColorsRefinement`] based on the colors in the [`StatusColorsContent`].
pub fn status_colors_refinement(&self) -> StatusColorsRefinement {
StatusColorsRefinement {
conflict: self
.conflict
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
conflict_background: self
.conflict_background
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
conflict_border: self
.conflict_border
.as_ref()
.and_then(|color| try_parse_color(&color).ok()),
created: self
.created