1use std::fmt::Display;
2use std::num;
3
4use collections::HashMap;
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7use serde_with::skip_serializing_none;
8use settings_macros::MergeFrom;
9
10use crate::{
11 DelayMs, DiagnosticSeverityContent, ShowScrollbar, serialize_f32_with_two_decimal_places,
12};
13
14#[skip_serializing_none]
15#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
16pub struct EditorSettingsContent {
17 /// Whether the cursor blinks in the editor.
18 ///
19 /// Default: true
20 pub cursor_blink: Option<bool>,
21 /// Cursor shape for the default editor.
22 /// Can be "bar", "block", "underline", or "hollow".
23 ///
24 /// Default: bar
25 pub cursor_shape: Option<CursorShape>,
26 /// Determines when the mouse cursor should be hidden in an editor or input box.
27 ///
28 /// Default: on_typing_and_movement
29 pub hide_mouse: Option<HideMouseMode>,
30 /// Determines how snippets are sorted relative to other completion items.
31 ///
32 /// Default: inline
33 pub snippet_sort_order: Option<SnippetSortOrder>,
34 /// How to highlight the current line in the editor.
35 ///
36 /// Default: all
37 pub current_line_highlight: Option<CurrentLineHighlight>,
38 /// Whether to highlight all occurrences of the selected text in an editor.
39 ///
40 /// Default: true
41 pub selection_highlight: Option<bool>,
42 /// Whether the text selection should have rounded corners.
43 ///
44 /// Default: true
45 pub rounded_selection: Option<bool>,
46 /// The debounce delay before querying highlights from the language
47 /// server based on the current cursor location.
48 ///
49 /// Default: 75
50 pub lsp_highlight_debounce: Option<DelayMs>,
51 /// Whether to show the informational hover box when moving the mouse
52 /// over symbols in the editor.
53 ///
54 /// Default: true
55 pub hover_popover_enabled: Option<bool>,
56 /// Time to wait in milliseconds before showing the informational hover box.
57 ///
58 /// Default: 300
59 pub hover_popover_delay: Option<DelayMs>,
60 /// Toolbar related settings
61 pub toolbar: Option<ToolbarContent>,
62 /// Scrollbar related settings
63 pub scrollbar: Option<ScrollbarContent>,
64 /// Minimap related settings
65 pub minimap: Option<MinimapContent>,
66 /// Gutter related settings
67 pub gutter: Option<GutterContent>,
68 /// Whether the editor will scroll beyond the last line.
69 ///
70 /// Default: one_page
71 pub scroll_beyond_last_line: Option<ScrollBeyondLastLine>,
72 /// The number of lines to keep above/below the cursor when auto-scrolling.
73 ///
74 /// Default: 3.
75 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
76 pub vertical_scroll_margin: Option<f32>,
77 /// Whether to scroll when clicking near the edge of the visible text area.
78 ///
79 /// Default: false
80 pub autoscroll_on_clicks: Option<bool>,
81 /// The number of characters to keep on either side when scrolling with the mouse.
82 ///
83 /// Default: 5.
84 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
85 pub horizontal_scroll_margin: Option<f32>,
86 /// Scroll sensitivity multiplier. This multiplier is applied
87 /// to both the horizontal and vertical delta values while scrolling.
88 ///
89 /// Default: 1.0
90 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
91 pub scroll_sensitivity: Option<f32>,
92 /// Scroll sensitivity multiplier for fast scrolling. This multiplier is applied
93 /// to both the horizontal and vertical delta values while scrolling. Fast scrolling
94 /// happens when a user holds the alt or option key while scrolling.
95 ///
96 /// Default: 4.0
97 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
98 pub fast_scroll_sensitivity: Option<f32>,
99 /// Whether the line numbers on editors gutter are relative or not.
100 ///
101 /// Default: false
102 pub relative_line_numbers: Option<bool>,
103 /// When to populate a new search's query based on the text under the cursor.
104 ///
105 /// Default: always
106 pub seed_search_query_from_cursor: Option<SeedQuerySetting>,
107 pub use_smartcase_search: Option<bool>,
108 /// Determines the modifier to be used to add multiple cursors with the mouse. The open hover link mouse gestures will adapt such that it do not conflict with the multicursor modifier.
109 ///
110 /// Default: alt
111 pub multi_cursor_modifier: Option<MultiCursorModifier>,
112 /// Hide the values of variables in `private` files, as defined by the
113 /// private_files setting. This only changes the visual representation,
114 /// the values are still present in the file and can be selected / copied / pasted
115 ///
116 /// Default: false
117 pub redact_private_values: Option<bool>,
118
119 /// How many lines to expand the multibuffer excerpts by default
120 ///
121 /// Default: 3
122 pub expand_excerpt_lines: Option<u32>,
123
124 /// How many lines of context to provide in multibuffer excerpts by default
125 ///
126 /// Default: 2
127 pub excerpt_context_lines: Option<u32>,
128
129 /// Whether to enable middle-click paste on Linux
130 ///
131 /// Default: true
132 pub middle_click_paste: Option<bool>,
133
134 /// What to do when multibuffer is double clicked in some of its excerpts
135 /// (parts of singleton buffers).
136 ///
137 /// Default: select
138 pub double_click_in_multibuffer: Option<DoubleClickInMultibuffer>,
139 /// Whether the editor search results will loop
140 ///
141 /// Default: true
142 pub search_wrap: Option<bool>,
143
144 /// Defaults to use when opening a new buffer and project search items.
145 ///
146 /// Default: nothing is enabled
147 pub search: Option<SearchSettingsContent>,
148
149 /// Whether to automatically show a signature help pop-up or not.
150 ///
151 /// Default: false
152 pub auto_signature_help: Option<bool>,
153
154 /// Whether to show the signature help pop-up after completions or bracket pairs inserted.
155 ///
156 /// Default: false
157 pub show_signature_help_after_edits: Option<bool>,
158 /// The minimum APCA perceptual contrast to maintain when
159 /// rendering text over highlight backgrounds in the editor.
160 ///
161 /// Values range from 0 to 106. Set to 0 to disable adjustments.
162 /// Default: 45
163 #[schemars(range(min = 0, max = 106))]
164 pub minimum_contrast_for_highlights: Option<MinimumContrast>,
165
166 /// Whether to follow-up empty go to definition responses from the language server or not.
167 /// `FindAllReferences` allows to look up references of the same symbol instead.
168 /// `None` disables the fallback.
169 ///
170 /// Default: FindAllReferences
171 pub go_to_definition_fallback: Option<GoToDefinitionFallback>,
172
173 /// Jupyter REPL settings.
174 pub jupyter: Option<JupyterContent>,
175
176 /// Which level to use to filter out diagnostics displayed in the editor.
177 ///
178 /// Affects the editor rendering only, and does not interrupt
179 /// the functionality of diagnostics fetching and project diagnostics editor.
180 /// Which files containing diagnostic errors/warnings to mark in the tabs.
181 /// Diagnostics are only shown when file icons are also active.
182 ///
183 /// Shows all diagnostics if not specified.
184 ///
185 /// Default: warning
186 pub diagnostics_max_severity: Option<DiagnosticSeverityContent>,
187
188 /// Whether to show code action button at start of buffer line.
189 ///
190 /// Default: true
191 pub inline_code_actions: Option<bool>,
192
193 /// Drag and drop related settings
194 pub drag_and_drop_selection: Option<DragAndDropSelectionContent>,
195
196 /// How to render LSP `textDocument/documentColor` colors in the editor.
197 ///
198 /// Default: [`DocumentColorsRenderMode::Inlay`]
199 pub lsp_document_colors: Option<DocumentColorsRenderMode>,
200}
201
202// Toolbar related settings
203#[skip_serializing_none]
204#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
205pub struct ToolbarContent {
206 /// Whether to display breadcrumbs in the editor toolbar.
207 ///
208 /// Default: true
209 pub breadcrumbs: Option<bool>,
210 /// Whether to display quick action buttons in the editor toolbar.
211 ///
212 /// Default: true
213 pub quick_actions: Option<bool>,
214 /// Whether to show the selections menu in the editor toolbar.
215 ///
216 /// Default: true
217 pub selections_menu: Option<bool>,
218 /// Whether to display Agent review buttons in the editor toolbar.
219 /// Only applicable while reviewing a file edited by the Agent.
220 ///
221 /// Default: true
222 pub agent_review: Option<bool>,
223 /// Whether to display code action buttons in the editor toolbar.
224 ///
225 /// Default: false
226 pub code_actions: Option<bool>,
227}
228
229/// Scrollbar related settings
230#[skip_serializing_none]
231#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
232pub struct ScrollbarContent {
233 /// When to show the scrollbar in the editor.
234 ///
235 /// Default: auto
236 pub show: Option<ShowScrollbar>,
237 /// Whether to show git diff indicators in the scrollbar.
238 ///
239 /// Default: true
240 pub git_diff: Option<bool>,
241 /// Whether to show buffer search result indicators in the scrollbar.
242 ///
243 /// Default: true
244 pub search_results: Option<bool>,
245 /// Whether to show selected text occurrences in the scrollbar.
246 ///
247 /// Default: true
248 pub selected_text: Option<bool>,
249 /// Whether to show selected symbol occurrences in the scrollbar.
250 ///
251 /// Default: true
252 pub selected_symbol: Option<bool>,
253 /// Which diagnostic indicators to show in the scrollbar:
254 ///
255 /// Default: all
256 pub diagnostics: Option<ScrollbarDiagnostics>,
257 /// Whether to show cursor positions in the scrollbar.
258 ///
259 /// Default: true
260 pub cursors: Option<bool>,
261 /// Forcefully enable or disable the scrollbar for each axis
262 pub axes: Option<ScrollbarAxesContent>,
263}
264
265/// Minimap related settings
266#[skip_serializing_none]
267#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
268pub struct MinimapContent {
269 /// When to show the minimap in the editor.
270 ///
271 /// Default: never
272 pub show: Option<ShowMinimap>,
273
274 /// Where to show the minimap in the editor.
275 ///
276 /// Default: [`DisplayIn::ActiveEditor`]
277 pub display_in: Option<DisplayIn>,
278
279 /// When to show the minimap thumb.
280 ///
281 /// Default: always
282 pub thumb: Option<MinimapThumb>,
283
284 /// Defines the border style for the minimap's scrollbar thumb.
285 ///
286 /// Default: left_open
287 pub thumb_border: Option<MinimapThumbBorder>,
288
289 /// How to highlight the current line in the minimap.
290 ///
291 /// Default: inherits editor line highlights setting
292 pub current_line_highlight: Option<CurrentLineHighlight>,
293
294 /// Maximum number of columns to display in the minimap.
295 ///
296 /// Default: 80
297 pub max_width_columns: Option<num::NonZeroU32>,
298}
299
300/// Forcefully enable or disable the scrollbar for each axis
301#[skip_serializing_none]
302#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
303pub struct ScrollbarAxesContent {
304 /// When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings.
305 ///
306 /// Default: true
307 pub horizontal: Option<bool>,
308
309 /// When false, forcefully disables the vertical scrollbar. Otherwise, obey other settings.
310 ///
311 /// Default: true
312 pub vertical: Option<bool>,
313}
314
315/// Gutter related settings
316#[skip_serializing_none]
317#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
318pub struct GutterContent {
319 /// Whether to show line numbers in the gutter.
320 ///
321 /// Default: true
322 pub line_numbers: Option<bool>,
323 /// Minimum number of characters to reserve space for in the gutter.
324 ///
325 /// Default: 4
326 pub min_line_number_digits: Option<usize>,
327 /// Whether to show runnable buttons in the gutter.
328 ///
329 /// Default: true
330 pub runnables: Option<bool>,
331 /// Whether to show breakpoints in the gutter.
332 ///
333 /// Default: true
334 pub breakpoints: Option<bool>,
335 /// Whether to show fold buttons in the gutter.
336 ///
337 /// Default: true
338 pub folds: Option<bool>,
339}
340
341/// How to render LSP `textDocument/documentColor` colors in the editor.
342#[derive(
343 Copy,
344 Clone,
345 Debug,
346 Default,
347 Serialize,
348 Deserialize,
349 PartialEq,
350 Eq,
351 JsonSchema,
352 MergeFrom,
353 strum::VariantArray,
354 strum::VariantNames,
355)]
356#[serde(rename_all = "snake_case")]
357pub enum DocumentColorsRenderMode {
358 /// Do not query and render document colors.
359 None,
360 /// Render document colors as inlay hints near the color text.
361 #[default]
362 Inlay,
363 /// Draw a border around the color text.
364 Border,
365 /// Draw a background behind the color text.
366 Background,
367}
368
369#[derive(
370 Copy,
371 Clone,
372 Debug,
373 Serialize,
374 Deserialize,
375 PartialEq,
376 Eq,
377 JsonSchema,
378 MergeFrom,
379 strum::VariantArray,
380 strum::VariantNames,
381)]
382#[serde(rename_all = "snake_case")]
383pub enum CurrentLineHighlight {
384 // Don't highlight the current line.
385 None,
386 // Highlight the gutter area.
387 Gutter,
388 // Highlight the editor area.
389 Line,
390 // Highlight the full line.
391 All,
392}
393
394/// When to populate a new search's query based on the text under the cursor.
395#[derive(
396 Copy,
397 Clone,
398 Debug,
399 Serialize,
400 Deserialize,
401 PartialEq,
402 Eq,
403 JsonSchema,
404 MergeFrom,
405 strum::VariantArray,
406 strum::VariantNames,
407)]
408#[serde(rename_all = "snake_case")]
409pub enum SeedQuerySetting {
410 /// Always populate the search query with the word under the cursor.
411 Always,
412 /// Only populate the search query when there is text selected.
413 Selection,
414 /// Never populate the search query
415 Never,
416}
417
418/// What to do when multibuffer is double clicked in some of its excerpts (parts of singleton buffers).
419#[derive(
420 Default,
421 Copy,
422 Clone,
423 Debug,
424 Serialize,
425 Deserialize,
426 PartialEq,
427 Eq,
428 JsonSchema,
429 MergeFrom,
430 strum::VariantArray,
431 strum::VariantNames,
432)]
433#[serde(rename_all = "snake_case")]
434pub enum DoubleClickInMultibuffer {
435 /// Behave as a regular buffer and select the whole word.
436 #[default]
437 Select,
438 /// Open the excerpt clicked as a new buffer in the new tab, if no `alt` modifier was pressed during double click.
439 /// Otherwise, behave as a regular buffer and select the whole word.
440 Open,
441}
442
443/// When to show the minimap thumb.
444///
445/// Default: always
446#[derive(
447 Copy,
448 Clone,
449 Debug,
450 Default,
451 Serialize,
452 Deserialize,
453 JsonSchema,
454 MergeFrom,
455 PartialEq,
456 Eq,
457 strum::VariantArray,
458 strum::VariantNames,
459)]
460#[serde(rename_all = "snake_case")]
461pub enum MinimapThumb {
462 /// Show the minimap thumb only when the mouse is hovering over the minimap.
463 Hover,
464 /// Always show the minimap thumb.
465 #[default]
466 Always,
467}
468
469/// Defines the border style for the minimap's scrollbar thumb.
470///
471/// Default: left_open
472#[derive(
473 Copy,
474 Clone,
475 Debug,
476 Default,
477 Serialize,
478 Deserialize,
479 JsonSchema,
480 MergeFrom,
481 PartialEq,
482 Eq,
483 strum::VariantArray,
484 strum::VariantNames,
485)]
486#[serde(rename_all = "snake_case")]
487pub enum MinimapThumbBorder {
488 /// Displays a border on all sides of the thumb.
489 Full,
490 /// Displays a border on all sides except the left side of the thumb.
491 #[default]
492 LeftOpen,
493 /// Displays a border on all sides except the right side of the thumb.
494 RightOpen,
495 /// Displays a border only on the left side of the thumb.
496 LeftOnly,
497 /// Displays the thumb without any border.
498 None,
499}
500
501/// Which diagnostic indicators to show in the scrollbar.
502///
503/// Default: all
504#[derive(
505 Copy,
506 Clone,
507 Debug,
508 Serialize,
509 Deserialize,
510 JsonSchema,
511 MergeFrom,
512 PartialEq,
513 Eq,
514 strum::VariantArray,
515 strum::VariantNames,
516)]
517#[serde(rename_all = "lowercase")]
518pub enum ScrollbarDiagnostics {
519 /// Show all diagnostic levels: hint, information, warnings, error.
520 All,
521 /// Show only the following diagnostic levels: information, warning, error.
522 Information,
523 /// Show only the following diagnostic levels: warning, error.
524 Warning,
525 /// Show only the following diagnostic level: error.
526 Error,
527 /// Do not show diagnostics.
528 None,
529}
530
531/// The key to use for adding multiple cursors
532///
533/// Default: alt
534#[derive(
535 Copy,
536 Clone,
537 Debug,
538 Serialize,
539 Deserialize,
540 JsonSchema,
541 MergeFrom,
542 PartialEq,
543 Eq,
544 strum::VariantArray,
545 strum::VariantNames,
546)]
547#[serde(rename_all = "snake_case")]
548pub enum MultiCursorModifier {
549 Alt,
550 #[serde(alias = "cmd", alias = "ctrl")]
551 CmdOrCtrl,
552}
553
554/// Whether the editor will scroll beyond the last line.
555///
556/// Default: one_page
557#[derive(
558 Copy,
559 Clone,
560 Debug,
561 Serialize,
562 Deserialize,
563 JsonSchema,
564 MergeFrom,
565 PartialEq,
566 Eq,
567 strum::VariantArray,
568 strum::VariantNames,
569)]
570#[serde(rename_all = "snake_case")]
571pub enum ScrollBeyondLastLine {
572 /// The editor will not scroll beyond the last line.
573 Off,
574
575 /// The editor will scroll beyond the last line by one page.
576 OnePage,
577
578 /// The editor will scroll beyond the last line by the same number of lines as vertical_scroll_margin.
579 VerticalScrollMargin,
580}
581
582/// The shape of a selection cursor.
583#[derive(
584 Copy,
585 Clone,
586 Debug,
587 Default,
588 Serialize,
589 Deserialize,
590 PartialEq,
591 Eq,
592 JsonSchema,
593 MergeFrom,
594 strum::VariantArray,
595 strum::VariantNames,
596)]
597#[serde(rename_all = "snake_case")]
598pub enum CursorShape {
599 /// A vertical bar
600 #[default]
601 Bar,
602 /// A block that surrounds the following character
603 Block,
604 /// An underline that runs along the following character
605 Underline,
606 /// A box drawn around the following character
607 Hollow,
608}
609
610/// What to do when go to definition yields no results.
611#[derive(
612 Copy,
613 Clone,
614 Debug,
615 Default,
616 Serialize,
617 Deserialize,
618 PartialEq,
619 Eq,
620 JsonSchema,
621 MergeFrom,
622 strum::VariantArray,
623 strum::VariantNames,
624)]
625#[serde(rename_all = "snake_case")]
626pub enum GoToDefinitionFallback {
627 /// Disables the fallback.
628 None,
629 /// Looks up references of the same symbol instead.
630 #[default]
631 FindAllReferences,
632}
633
634/// Determines when the mouse cursor should be hidden in an editor or input box.
635///
636/// Default: on_typing_and_movement
637#[derive(
638 Copy,
639 Clone,
640 Debug,
641 Default,
642 Serialize,
643 Deserialize,
644 PartialEq,
645 Eq,
646 JsonSchema,
647 MergeFrom,
648 strum::VariantArray,
649 strum::VariantNames,
650)]
651#[serde(rename_all = "snake_case")]
652pub enum HideMouseMode {
653 /// Never hide the mouse cursor
654 Never,
655 /// Hide only when typing
656 OnTyping,
657 /// Hide on both typing and cursor movement
658 #[default]
659 OnTypingAndMovement,
660}
661
662/// Determines how snippets are sorted relative to other completion items.
663///
664/// Default: inline
665#[derive(
666 Copy,
667 Clone,
668 Debug,
669 Default,
670 Serialize,
671 Deserialize,
672 PartialEq,
673 Eq,
674 JsonSchema,
675 MergeFrom,
676 strum::VariantArray,
677 strum::VariantNames,
678)]
679#[serde(rename_all = "snake_case")]
680pub enum SnippetSortOrder {
681 /// Place snippets at the top of the completion list
682 Top,
683 /// Sort snippets normally using the default comparison logic
684 #[default]
685 Inline,
686 /// Place snippets at the bottom of the completion list
687 Bottom,
688 /// Do not show snippets in the completion list
689 None,
690}
691
692/// Default options for buffer and project search items.
693#[skip_serializing_none]
694#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
695pub struct SearchSettingsContent {
696 /// Whether to show the project search button in the status bar.
697 pub button: Option<bool>,
698 pub whole_word: Option<bool>,
699 pub case_sensitive: Option<bool>,
700 pub include_ignored: Option<bool>,
701 pub regex: Option<bool>,
702}
703
704#[skip_serializing_none]
705#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
706#[serde(rename_all = "snake_case")]
707pub struct JupyterContent {
708 /// Whether the Jupyter feature is enabled.
709 ///
710 /// Default: true
711 pub enabled: Option<bool>,
712
713 /// Default kernels to select for each language.
714 ///
715 /// Default: `{}`
716 pub kernel_selections: Option<HashMap<String, String>>,
717}
718
719/// Whether to allow drag and drop text selection in buffer.
720#[skip_serializing_none]
721#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
722pub struct DragAndDropSelectionContent {
723 /// When true, enables drag and drop text selection in buffer.
724 ///
725 /// Default: true
726 pub enabled: Option<bool>,
727
728 /// The delay in milliseconds that must elapse before drag and drop is allowed. Otherwise, a new text selection is created.
729 ///
730 /// Default: 300
731 pub delay: Option<DelayMs>,
732}
733
734/// When to show the minimap in the editor.
735///
736/// Default: never
737#[derive(
738 Copy,
739 Clone,
740 Debug,
741 Default,
742 Serialize,
743 Deserialize,
744 JsonSchema,
745 MergeFrom,
746 PartialEq,
747 Eq,
748 strum::VariantArray,
749 strum::VariantNames,
750)]
751#[serde(rename_all = "snake_case")]
752pub enum ShowMinimap {
753 /// Follow the visibility of the scrollbar.
754 Auto,
755 /// Always show the minimap.
756 Always,
757 /// Never show the minimap.
758 #[default]
759 Never,
760}
761
762/// Where to show the minimap in the editor.
763///
764/// Default: all_editors
765#[derive(
766 Copy,
767 Clone,
768 Debug,
769 Default,
770 Serialize,
771 Deserialize,
772 JsonSchema,
773 MergeFrom,
774 PartialEq,
775 Eq,
776 strum::VariantArray,
777 strum::VariantNames,
778)]
779#[serde(rename_all = "snake_case")]
780pub enum DisplayIn {
781 /// Show on all open editors.
782 AllEditors,
783 /// Show the minimap on the active editor only.
784 #[default]
785 ActiveEditor,
786}
787
788/// Minimum APCA perceptual contrast for text over highlight backgrounds.
789///
790/// Valid range: 0.0 to 106.0
791/// Default: 45.0
792#[derive(
793 Clone,
794 Copy,
795 Debug,
796 Serialize,
797 Deserialize,
798 JsonSchema,
799 MergeFrom,
800 PartialEq,
801 PartialOrd,
802 derive_more::FromStr,
803)]
804#[serde(transparent)]
805pub struct MinimumContrast(
806 #[serde(serialize_with = "crate::serialize_f32_with_two_decimal_places")] pub f32,
807);
808
809impl Display for MinimumContrast {
810 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
811 write!(f, "{:.1}", self.0)
812 }
813}
814
815impl From<f32> for MinimumContrast {
816 fn from(x: f32) -> Self {
817 Self(x)
818 }
819}
820
821/// Opacity of the inactive panes. 0 means transparent, 1 means opaque.
822///
823/// Valid range: 0.0 to 1.0
824/// Default: 1.0
825#[derive(
826 Clone,
827 Copy,
828 Debug,
829 Serialize,
830 Deserialize,
831 JsonSchema,
832 MergeFrom,
833 PartialEq,
834 PartialOrd,
835 derive_more::FromStr,
836)]
837#[serde(transparent)]
838pub struct InactiveOpacity(
839 #[serde(serialize_with = "serialize_f32_with_two_decimal_places")] pub f32,
840);
841
842impl Display for InactiveOpacity {
843 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
844 write!(f, "{:.1}", self.0)
845 }
846}
847
848impl From<f32> for InactiveOpacity {
849 fn from(x: f32) -> Self {
850 Self(x)
851 }
852}
853
854/// Centered layout related setting (left/right).
855///
856/// Valid range: 0.0 to 0.4
857/// Default: 2.0
858#[derive(
859 Clone,
860 Copy,
861 Debug,
862 Serialize,
863 Deserialize,
864 MergeFrom,
865 PartialEq,
866 PartialOrd,
867 derive_more::FromStr,
868)]
869#[serde(transparent)]
870pub struct CenteredPaddingSettings(
871 #[serde(serialize_with = "serialize_f32_with_two_decimal_places")] pub f32,
872);
873
874impl CenteredPaddingSettings {
875 pub const MIN_PADDING: f32 = 0.0;
876 // This is an f64 so serde_json can give a type hint without random numbers in the back
877 pub const DEFAULT_PADDING: f64 = 0.2;
878 pub const MAX_PADDING: f32 = 0.4;
879}
880
881impl Display for CenteredPaddingSettings {
882 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
883 write!(f, "{:.2}", self.0)
884 }
885}
886
887impl From<f32> for CenteredPaddingSettings {
888 fn from(x: f32) -> Self {
889 Self(x)
890 }
891}
892
893impl Default for CenteredPaddingSettings {
894 fn default() -> Self {
895 Self(Self::DEFAULT_PADDING as f32)
896 }
897}
898
899impl schemars::JsonSchema for CenteredPaddingSettings {
900 fn schema_name() -> std::borrow::Cow<'static, str> {
901 "CenteredPaddingSettings".into()
902 }
903
904 fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
905 use schemars::json_schema;
906 json_schema!({
907 "type": "number",
908 "minimum": Self::MIN_PADDING,
909 "maximum": Self::MAX_PADDING,
910 "default": Self::DEFAULT_PADDING,
911 "description": "Centered layout related setting (left/right)."
912 })
913 }
914}