theme.rs

   1use collections::{HashMap, IndexMap};
   2use gpui::{FontFallbacks, FontFeatures, FontStyle, FontWeight, Pixels, SharedString};
   3use schemars::{JsonSchema, JsonSchema_repr};
   4use serde::{Deserialize, Deserializer, Serialize};
   5use serde_json::Value;
   6use serde_repr::{Deserialize_repr, Serialize_repr};
   7use settings_macros::{MergeFrom, with_fallible_options};
   8use std::{fmt::Display, sync::Arc};
   9
  10use crate::serialize_f32_with_two_decimal_places;
  11
  12/// Settings for rendering text in UI and text buffers.
  13
  14#[with_fallible_options]
  15#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
  16pub struct ThemeSettingsContent {
  17    /// The default font size for text in the UI.
  18    pub ui_font_size: Option<FontSize>,
  19    /// The name of a font to use for rendering in the UI.
  20    pub ui_font_family: Option<FontFamilyName>,
  21    /// The font fallbacks to use for rendering in the UI.
  22    #[schemars(default = "default_font_fallbacks")]
  23    #[schemars(extend("uniqueItems" = true))]
  24    pub ui_font_fallbacks: Option<Vec<FontFamilyName>>,
  25    /// The OpenType features to enable for text in the UI.
  26    #[schemars(default = "default_font_features")]
  27    pub ui_font_features: Option<FontFeatures>,
  28    /// The weight of the UI font in CSS units from 100 to 900.
  29    #[schemars(default = "default_buffer_font_weight")]
  30    pub ui_font_weight: Option<FontWeight>,
  31    /// The name of a font to use for rendering in text buffers.
  32    pub buffer_font_family: Option<FontFamilyName>,
  33    /// The font fallbacks to use for rendering in text buffers.
  34    #[schemars(extend("uniqueItems" = true))]
  35    pub buffer_font_fallbacks: Option<Vec<FontFamilyName>>,
  36    /// The default font size for rendering in text buffers.
  37    pub buffer_font_size: Option<FontSize>,
  38    /// The weight of the editor font in CSS units from 100 to 900.
  39    #[schemars(default = "default_buffer_font_weight")]
  40    pub buffer_font_weight: Option<FontWeight>,
  41    /// The buffer's line height.
  42    pub buffer_line_height: Option<BufferLineHeight>,
  43    /// The OpenType features to enable for rendering in text buffers.
  44    #[schemars(default = "default_font_features")]
  45    pub buffer_font_features: Option<FontFeatures>,
  46    /// The font size for agent responses in the agent panel. Falls back to the UI font size if unset.
  47    pub agent_ui_font_size: Option<FontSize>,
  48    /// The font size for user messages in the agent panel.
  49    pub agent_buffer_font_size: Option<FontSize>,
  50    /// The name of the Zed theme to use.
  51    pub theme: Option<ThemeSelection>,
  52    /// The name of the icon theme to use.
  53    pub icon_theme: Option<IconThemeSelection>,
  54
  55    /// UNSTABLE: Expect many elements to be broken.
  56    ///
  57    // Controls the density of the UI.
  58    #[serde(rename = "unstable.ui_density")]
  59    pub ui_density: Option<UiDensity>,
  60
  61    /// How much to fade out unused code.
  62    #[schemars(range(min = 0.0, max = 0.9))]
  63    pub unnecessary_code_fade: Option<CodeFade>,
  64
  65    /// EXPERIMENTAL: Overrides for the current theme.
  66    ///
  67    /// These values will override the ones on the current theme specified in `theme`.
  68    #[serde(rename = "experimental.theme_overrides")]
  69    pub experimental_theme_overrides: Option<ThemeStyleContent>,
  70
  71    /// Overrides per theme
  72    ///
  73    /// These values will override the ones on the specified theme
  74    #[serde(default)]
  75    pub theme_overrides: HashMap<String, ThemeStyleContent>,
  76}
  77
  78/// A font size value in pixels, wrapping around `f32` for custom settings UI rendering.
  79#[derive(
  80    Clone,
  81    Copy,
  82    Debug,
  83    Serialize,
  84    Deserialize,
  85    JsonSchema,
  86    MergeFrom,
  87    PartialEq,
  88    PartialOrd,
  89    derive_more::FromStr,
  90)]
  91#[serde(transparent)]
  92pub struct FontSize(#[serde(serialize_with = "serialize_f32_with_two_decimal_places")] pub f32);
  93
  94impl Display for FontSize {
  95    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  96        write!(f, "{:.2}", self.0)
  97    }
  98}
  99
 100impl From<f32> for FontSize {
 101    fn from(value: f32) -> Self {
 102        Self(value)
 103    }
 104}
 105
 106impl From<FontSize> for Pixels {
 107    fn from(value: FontSize) -> Self {
 108        value.0.into()
 109    }
 110}
 111
 112impl From<Pixels> for FontSize {
 113    fn from(value: Pixels) -> Self {
 114        Self(value.into())
 115    }
 116}
 117
 118#[derive(
 119    Clone,
 120    Copy,
 121    Debug,
 122    Serialize,
 123    Deserialize,
 124    JsonSchema,
 125    MergeFrom,
 126    PartialEq,
 127    PartialOrd,
 128    derive_more::FromStr,
 129)]
 130#[serde(transparent)]
 131pub struct CodeFade(#[serde(serialize_with = "serialize_f32_with_two_decimal_places")] pub f32);
 132
 133impl Display for CodeFade {
 134    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 135        write!(f, "{:.2}", self.0)
 136    }
 137}
 138
 139impl From<f32> for CodeFade {
 140    fn from(x: f32) -> Self {
 141        Self(x)
 142    }
 143}
 144
 145fn default_font_features() -> Option<FontFeatures> {
 146    Some(FontFeatures::default())
 147}
 148
 149fn default_font_fallbacks() -> Option<FontFallbacks> {
 150    Some(FontFallbacks::default())
 151}
 152
 153fn default_buffer_font_weight() -> Option<FontWeight> {
 154    Some(FontWeight::default())
 155}
 156
 157/// Represents the selection of a theme, which can be either static or dynamic.
 158#[derive(
 159    Clone,
 160    Debug,
 161    Serialize,
 162    Deserialize,
 163    JsonSchema,
 164    MergeFrom,
 165    PartialEq,
 166    Eq,
 167    strum::EnumDiscriminants,
 168)]
 169#[strum_discriminants(derive(strum::VariantArray, strum::VariantNames, strum::FromRepr))]
 170#[serde(untagged)]
 171pub enum ThemeSelection {
 172    /// A static theme selection, represented by a single theme name.
 173    Static(ThemeName),
 174    /// A dynamic theme selection, which can change based the [ThemeMode].
 175    Dynamic {
 176        /// The mode used to determine which theme to use.
 177        #[serde(default)]
 178        mode: ThemeAppearanceMode,
 179        /// The theme to use for light mode.
 180        light: ThemeName,
 181        /// The theme to use for dark mode.
 182        dark: ThemeName,
 183    },
 184}
 185
 186/// Represents the selection of an icon theme, which can be either static or dynamic.
 187#[derive(
 188    Clone,
 189    Debug,
 190    Serialize,
 191    Deserialize,
 192    JsonSchema,
 193    MergeFrom,
 194    PartialEq,
 195    Eq,
 196    strum::EnumDiscriminants,
 197)]
 198#[strum_discriminants(derive(strum::VariantArray, strum::VariantNames, strum::FromRepr))]
 199#[serde(untagged)]
 200pub enum IconThemeSelection {
 201    /// A static icon theme selection, represented by a single icon theme name.
 202    Static(IconThemeName),
 203    /// A dynamic icon theme selection, which can change based on the [`ThemeMode`].
 204    Dynamic {
 205        /// The mode used to determine which theme to use.
 206        #[serde(default)]
 207        mode: ThemeAppearanceMode,
 208        /// The icon theme to use for light mode.
 209        light: IconThemeName,
 210        /// The icon theme to use for dark mode.
 211        dark: IconThemeName,
 212    },
 213}
 214
 215/// The mode use to select a theme.
 216///
 217/// `Light` and `Dark` will select their respective themes.
 218///
 219/// `System` will select the theme based on the system's appearance.
 220#[derive(
 221    Debug,
 222    PartialEq,
 223    Eq,
 224    Clone,
 225    Copy,
 226    Default,
 227    Serialize,
 228    Deserialize,
 229    JsonSchema,
 230    MergeFrom,
 231    strum::VariantArray,
 232    strum::VariantNames,
 233)]
 234#[serde(rename_all = "snake_case")]
 235pub enum ThemeAppearanceMode {
 236    /// Use the specified `light` theme.
 237    Light,
 238
 239    /// Use the specified `dark` theme.
 240    Dark,
 241
 242    /// Use the theme based on the system's appearance.
 243    #[default]
 244    System,
 245}
 246
 247/// Specifies the density of the UI.
 248/// Note: This setting is still experimental. See [this tracking issue](https://github.com/zed-industries/zed/issues/18078)
 249#[derive(
 250    Debug,
 251    Default,
 252    PartialEq,
 253    Eq,
 254    PartialOrd,
 255    Ord,
 256    Hash,
 257    Clone,
 258    Copy,
 259    Serialize,
 260    Deserialize,
 261    JsonSchema,
 262    MergeFrom,
 263)]
 264#[serde(rename_all = "snake_case")]
 265pub enum UiDensity {
 266    /// A denser UI with tighter spacing and smaller elements.
 267    #[serde(alias = "compact")]
 268    Compact,
 269    #[default]
 270    #[serde(alias = "default")]
 271    /// The default UI density.
 272    Default,
 273    #[serde(alias = "comfortable")]
 274    /// A looser UI with more spacing and larger elements.
 275    Comfortable,
 276}
 277
 278impl UiDensity {
 279    /// The spacing ratio of a given density.
 280    /// TODO: Standardize usage throughout the app or remove
 281    pub fn spacing_ratio(self) -> f32 {
 282        match self {
 283            UiDensity::Compact => 0.75,
 284            UiDensity::Default => 1.0,
 285            UiDensity::Comfortable => 1.25,
 286        }
 287    }
 288}
 289
 290/// Font family name.
 291#[with_fallible_options]
 292#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 293#[serde(transparent)]
 294pub struct FontFamilyName(pub Arc<str>);
 295
 296impl AsRef<str> for FontFamilyName {
 297    fn as_ref(&self) -> &str {
 298        &self.0
 299    }
 300}
 301
 302impl From<SharedString> for FontFamilyName {
 303    fn from(value: SharedString) -> Self {
 304        Self(Arc::from(value))
 305    }
 306}
 307
 308impl From<FontFamilyName> for SharedString {
 309    fn from(value: FontFamilyName) -> Self {
 310        SharedString::new(value.0)
 311    }
 312}
 313
 314impl From<String> for FontFamilyName {
 315    fn from(value: String) -> Self {
 316        Self(Arc::from(value))
 317    }
 318}
 319
 320impl From<FontFamilyName> for String {
 321    fn from(value: FontFamilyName) -> Self {
 322        value.0.to_string()
 323    }
 324}
 325
 326/// The buffer's line height.
 327#[derive(
 328    Clone,
 329    Copy,
 330    Debug,
 331    Serialize,
 332    Deserialize,
 333    PartialEq,
 334    JsonSchema,
 335    MergeFrom,
 336    Default,
 337    strum::EnumDiscriminants,
 338)]
 339#[strum_discriminants(derive(strum::VariantArray, strum::VariantNames, strum::FromRepr))]
 340#[serde(rename_all = "snake_case")]
 341pub enum BufferLineHeight {
 342    /// A less dense line height.
 343    #[default]
 344    Comfortable,
 345    /// The default line height.
 346    Standard,
 347    /// A custom line height, where 1.0 is the font's height. Must be at least 1.0.
 348    Custom(#[serde(deserialize_with = "deserialize_line_height")] f32),
 349}
 350
 351fn deserialize_line_height<'de, D>(deserializer: D) -> Result<f32, D::Error>
 352where
 353    D: serde::Deserializer<'de>,
 354{
 355    let value = f32::deserialize(deserializer)?;
 356    if value < 1.0 {
 357        return Err(serde::de::Error::custom(
 358            "buffer_line_height.custom must be at least 1.0",
 359        ));
 360    }
 361
 362    Ok(value)
 363}
 364
 365/// The content of a serialized theme.
 366#[with_fallible_options]
 367#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 368#[serde(default)]
 369pub struct ThemeStyleContent {
 370    #[serde(rename = "background.appearance")]
 371    pub window_background_appearance: Option<WindowBackgroundContent>,
 372
 373    #[serde(default)]
 374    pub accents: Vec<AccentContent>,
 375
 376    #[serde(flatten, default)]
 377    pub colors: ThemeColorsContent,
 378
 379    #[serde(flatten, default)]
 380    pub status: StatusColorsContent,
 381
 382    #[serde(default)]
 383    pub players: Vec<PlayerColorContent>,
 384
 385    /// The styles for syntax nodes.
 386    #[serde(default)]
 387    pub syntax: IndexMap<String, HighlightStyleContent>,
 388}
 389
 390#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 391pub struct AccentContent(pub Option<SharedString>);
 392
 393#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 394pub struct PlayerColorContent {
 395    pub cursor: Option<String>,
 396    pub background: Option<String>,
 397    pub selection: Option<String>,
 398}
 399
 400/// Theme name.
 401#[with_fallible_options]
 402#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 403#[serde(transparent)]
 404pub struct ThemeName(pub Arc<str>);
 405
 406/// Icon Theme Name
 407#[with_fallible_options]
 408#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 409#[serde(transparent)]
 410pub struct IconThemeName(pub Arc<str>);
 411
 412#[with_fallible_options]
 413#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 414#[serde(default)]
 415pub struct ThemeColorsContent {
 416    /// Border color. Used for most borders, is usually a high contrast color.
 417    #[serde(rename = "border")]
 418    pub border: Option<String>,
 419
 420    /// Border color. Used for deemphasized borders, like a visual divider between two sections
 421    #[serde(rename = "border.variant")]
 422    pub border_variant: Option<String>,
 423
 424    /// Border color. Used for focused elements, like keyboard focused list item.
 425    #[serde(rename = "border.focused")]
 426    pub border_focused: Option<String>,
 427
 428    /// Border color. Used for selected elements, like an active search filter or selected checkbox.
 429    #[serde(rename = "border.selected")]
 430    pub border_selected: Option<String>,
 431
 432    /// Border color. Used for transparent borders. Used for placeholder borders when an element gains a border on state change.
 433    #[serde(rename = "border.transparent")]
 434    pub border_transparent: Option<String>,
 435
 436    /// Border color. Used for disabled elements, like a disabled input or button.
 437    #[serde(rename = "border.disabled")]
 438    pub border_disabled: Option<String>,
 439
 440    /// Background color. Used for elevated surfaces, like a context menu, popup, or dialog.
 441    #[serde(rename = "elevated_surface.background")]
 442    pub elevated_surface_background: Option<String>,
 443
 444    /// Background Color. Used for grounded surfaces like a panel or tab.
 445    #[serde(rename = "surface.background")]
 446    pub surface_background: Option<String>,
 447
 448    /// Background Color. Used for the app background and blank panels or windows.
 449    #[serde(rename = "background")]
 450    pub background: Option<String>,
 451
 452    /// Background Color. Used for the background of an element that should have a different background than the surface it's on.
 453    ///
 454    /// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...
 455    ///
 456    /// For an element that should have the same background as the surface it's on, use `ghost_element_background`.
 457    #[serde(rename = "element.background")]
 458    pub element_background: Option<String>,
 459
 460    /// Background Color. Used for the hover state of an element that should have a different background than the surface it's on.
 461    ///
 462    /// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
 463    #[serde(rename = "element.hover")]
 464    pub element_hover: Option<String>,
 465
 466    /// Background Color. Used for the active state of an element that should have a different background than the surface it's on.
 467    ///
 468    /// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
 469    #[serde(rename = "element.active")]
 470    pub element_active: Option<String>,
 471
 472    /// Background Color. Used for the selected state of an element that should have a different background than the surface it's on.
 473    ///
 474    /// Selected states are triggered by the element being selected (or "activated") by the user.
 475    ///
 476    /// This could include a selected checkbox, a toggleable button that is toggled on, etc.
 477    #[serde(rename = "element.selected")]
 478    pub element_selected: Option<String>,
 479
 480    /// Background Color. Used for the disabled state of an element that should have a different background than the surface it's on.
 481    ///
 482    /// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
 483    #[serde(rename = "element.disabled")]
 484    pub element_disabled: Option<String>,
 485
 486    /// Background Color. Used for the background of selections in a UI element.
 487    #[serde(rename = "element.selection_background")]
 488    pub element_selection_background: Option<String>,
 489
 490    /// Background Color. Used for the area that shows where a dragged element will be dropped.
 491    #[serde(rename = "drop_target.background")]
 492    pub drop_target_background: Option<String>,
 493
 494    /// Border Color. Used for the border that shows where a dragged element will be dropped.
 495    #[serde(rename = "drop_target.border")]
 496    pub drop_target_border: Option<String>,
 497
 498    /// Used for the background of a ghost element that should have the same background as the surface it's on.
 499    ///
 500    /// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...
 501    ///
 502    /// For an element that should have a different background than the surface it's on, use `element_background`.
 503    #[serde(rename = "ghost_element.background")]
 504    pub ghost_element_background: Option<String>,
 505
 506    /// Background Color. Used for the hover state of a ghost element that should have the same background as the surface it's on.
 507    ///
 508    /// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
 509    #[serde(rename = "ghost_element.hover")]
 510    pub ghost_element_hover: Option<String>,
 511
 512    /// Background Color. Used for the active state of a ghost element that should have the same background as the surface it's on.
 513    ///
 514    /// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
 515    #[serde(rename = "ghost_element.active")]
 516    pub ghost_element_active: Option<String>,
 517
 518    /// Background Color. Used for the selected state of a ghost element that should have the same background as the surface it's on.
 519    ///
 520    /// Selected states are triggered by the element being selected (or "activated") by the user.
 521    ///
 522    /// This could include a selected checkbox, a toggleable button that is toggled on, etc.
 523    #[serde(rename = "ghost_element.selected")]
 524    pub ghost_element_selected: Option<String>,
 525
 526    /// Background Color. Used for the disabled state of a ghost element that should have the same background as the surface it's on.
 527    ///
 528    /// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
 529    #[serde(rename = "ghost_element.disabled")]
 530    pub ghost_element_disabled: Option<String>,
 531
 532    /// Text Color. Default text color used for most text.
 533    #[serde(rename = "text")]
 534    pub text: Option<String>,
 535
 536    /// Text Color. Color of muted or deemphasized text. It is a subdued version of the standard text color.
 537    #[serde(rename = "text.muted")]
 538    pub text_muted: Option<String>,
 539
 540    /// Text Color. Color of the placeholder text typically shown in input fields to guide the user to enter valid data.
 541    #[serde(rename = "text.placeholder")]
 542    pub text_placeholder: Option<String>,
 543
 544    /// Text Color. Color used for text denoting disabled elements. Typically, the color is faded or grayed out to emphasize the disabled state.
 545    #[serde(rename = "text.disabled")]
 546    pub text_disabled: Option<String>,
 547
 548    /// Text Color. Color used for emphasis or highlighting certain text, like an active filter or a matched character in a search.
 549    #[serde(rename = "text.accent")]
 550    pub text_accent: Option<String>,
 551
 552    /// Fill Color. Used for the default fill color of an icon.
 553    #[serde(rename = "icon")]
 554    pub icon: Option<String>,
 555
 556    /// Fill Color. Used for the muted or deemphasized fill color of an icon.
 557    ///
 558    /// This might be used to show an icon in an inactive pane, or to deemphasize a series of icons to give them less visual weight.
 559    #[serde(rename = "icon.muted")]
 560    pub icon_muted: Option<String>,
 561
 562    /// Fill Color. Used for the disabled fill color of an icon.
 563    ///
 564    /// Disabled states are shown when a user cannot interact with an element, like a icon button.
 565    #[serde(rename = "icon.disabled")]
 566    pub icon_disabled: Option<String>,
 567
 568    /// Fill Color. Used for the placeholder fill color of an icon.
 569    ///
 570    /// This might be used to show an icon in an input that disappears when the user enters text.
 571    #[serde(rename = "icon.placeholder")]
 572    pub icon_placeholder: Option<String>,
 573
 574    /// Fill Color. Used for the accent fill color of an icon.
 575    ///
 576    /// This might be used to show when a toggleable icon button is selected.
 577    #[serde(rename = "icon.accent")]
 578    pub icon_accent: Option<String>,
 579
 580    /// Color used to accent some of the debuggers elements
 581    /// Only accent breakpoint & breakpoint related symbols right now
 582    #[serde(rename = "debugger.accent")]
 583    pub debugger_accent: Option<String>,
 584
 585    #[serde(rename = "status_bar.background")]
 586    pub status_bar_background: Option<String>,
 587
 588    #[serde(rename = "title_bar.background")]
 589    pub title_bar_background: Option<String>,
 590
 591    #[serde(rename = "title_bar.inactive_background")]
 592    pub title_bar_inactive_background: Option<String>,
 593
 594    #[serde(rename = "toolbar.background")]
 595    pub toolbar_background: Option<String>,
 596
 597    #[serde(rename = "tab_bar.background")]
 598    pub tab_bar_background: Option<String>,
 599
 600    #[serde(rename = "tab.inactive_background")]
 601    pub tab_inactive_background: Option<String>,
 602
 603    #[serde(rename = "tab.active_background")]
 604    pub tab_active_background: Option<String>,
 605
 606    #[serde(rename = "search.match_background")]
 607    pub search_match_background: Option<String>,
 608
 609    #[serde(rename = "search.active_match_background")]
 610    pub search_active_match_background: Option<String>,
 611
 612    #[serde(rename = "panel.background")]
 613    pub panel_background: Option<String>,
 614
 615    #[serde(rename = "panel.focused_border")]
 616    pub panel_focused_border: Option<String>,
 617
 618    #[serde(rename = "panel.indent_guide")]
 619    pub panel_indent_guide: Option<String>,
 620
 621    #[serde(rename = "panel.indent_guide_hover")]
 622    pub panel_indent_guide_hover: Option<String>,
 623
 624    #[serde(rename = "panel.indent_guide_active")]
 625    pub panel_indent_guide_active: Option<String>,
 626
 627    #[serde(rename = "panel.overlay_background")]
 628    pub panel_overlay_background: Option<String>,
 629
 630    #[serde(rename = "panel.overlay_hover")]
 631    pub panel_overlay_hover: Option<String>,
 632
 633    #[serde(rename = "pane.focused_border")]
 634    pub pane_focused_border: Option<String>,
 635
 636    #[serde(rename = "pane_group.border")]
 637    pub pane_group_border: Option<String>,
 638
 639    /// The deprecated version of `scrollbar.thumb.background`.
 640    ///
 641    /// Don't use this field.
 642    #[serde(rename = "scrollbar_thumb.background", skip_serializing)]
 643    #[schemars(skip)]
 644    pub deprecated_scrollbar_thumb_background: Option<String>,
 645
 646    /// The color of the scrollbar thumb.
 647    #[serde(rename = "scrollbar.thumb.background")]
 648    pub scrollbar_thumb_background: Option<String>,
 649
 650    /// The color of the scrollbar thumb when hovered over.
 651    #[serde(rename = "scrollbar.thumb.hover_background")]
 652    pub scrollbar_thumb_hover_background: Option<String>,
 653
 654    /// The color of the scrollbar thumb whilst being actively dragged.
 655    #[serde(rename = "scrollbar.thumb.active_background")]
 656    pub scrollbar_thumb_active_background: Option<String>,
 657
 658    /// The border color of the scrollbar thumb.
 659    #[serde(rename = "scrollbar.thumb.border")]
 660    pub scrollbar_thumb_border: Option<String>,
 661
 662    /// The background color of the scrollbar track.
 663    #[serde(rename = "scrollbar.track.background")]
 664    pub scrollbar_track_background: Option<String>,
 665
 666    /// The border color of the scrollbar track.
 667    #[serde(rename = "scrollbar.track.border")]
 668    pub scrollbar_track_border: Option<String>,
 669
 670    /// The color of the minimap thumb.
 671    #[serde(rename = "minimap.thumb.background")]
 672    pub minimap_thumb_background: Option<String>,
 673
 674    /// The color of the minimap thumb when hovered over.
 675    #[serde(rename = "minimap.thumb.hover_background")]
 676    pub minimap_thumb_hover_background: Option<String>,
 677
 678    /// The color of the minimap thumb whilst being actively dragged.
 679    #[serde(rename = "minimap.thumb.active_background")]
 680    pub minimap_thumb_active_background: Option<String>,
 681
 682    /// The border color of the minimap thumb.
 683    #[serde(rename = "minimap.thumb.border")]
 684    pub minimap_thumb_border: Option<String>,
 685
 686    #[serde(rename = "editor.foreground")]
 687    pub editor_foreground: Option<String>,
 688
 689    #[serde(rename = "editor.background")]
 690    pub editor_background: Option<String>,
 691
 692    #[serde(rename = "editor.gutter.background")]
 693    pub editor_gutter_background: Option<String>,
 694
 695    #[serde(rename = "editor.subheader.background")]
 696    pub editor_subheader_background: Option<String>,
 697
 698    #[serde(rename = "editor.active_line.background")]
 699    pub editor_active_line_background: Option<String>,
 700
 701    #[serde(rename = "editor.highlighted_line.background")]
 702    pub editor_highlighted_line_background: Option<String>,
 703
 704    /// Background of active line of debugger
 705    #[serde(rename = "editor.debugger_active_line.background")]
 706    pub editor_debugger_active_line_background: Option<String>,
 707
 708    /// Text Color. Used for the text of the line number in the editor gutter.
 709    #[serde(rename = "editor.line_number")]
 710    pub editor_line_number: Option<String>,
 711
 712    /// Text Color. Used for the text of the line number in the editor gutter when the line is highlighted.
 713    #[serde(rename = "editor.active_line_number")]
 714    pub editor_active_line_number: Option<String>,
 715
 716    /// Text Color. Used for the text of the line number in the editor gutter when the line is hovered over.
 717    #[serde(rename = "editor.hover_line_number")]
 718    pub editor_hover_line_number: Option<String>,
 719
 720    /// Text Color. Used to mark invisible characters in the editor.
 721    ///
 722    /// Example: spaces, tabs, carriage returns, etc.
 723    #[serde(rename = "editor.invisible")]
 724    pub editor_invisible: Option<String>,
 725
 726    #[serde(rename = "editor.wrap_guide")]
 727    pub editor_wrap_guide: Option<String>,
 728
 729    #[serde(rename = "editor.active_wrap_guide")]
 730    pub editor_active_wrap_guide: Option<String>,
 731
 732    #[serde(rename = "editor.indent_guide")]
 733    pub editor_indent_guide: Option<String>,
 734
 735    #[serde(rename = "editor.indent_guide_active")]
 736    pub editor_indent_guide_active: Option<String>,
 737
 738    /// Read-access of a symbol, like reading a variable.
 739    ///
 740    /// A document highlight is a range inside a text document which deserves
 741    /// special attention. Usually a document highlight is visualized by changing
 742    /// the background color of its range.
 743    #[serde(rename = "editor.document_highlight.read_background")]
 744    pub editor_document_highlight_read_background: Option<String>,
 745
 746    /// Read-access of a symbol, like reading a variable.
 747    ///
 748    /// A document highlight is a range inside a text document which deserves
 749    /// special attention. Usually a document highlight is visualized by changing
 750    /// the background color of its range.
 751    #[serde(rename = "editor.document_highlight.write_background")]
 752    pub editor_document_highlight_write_background: Option<String>,
 753
 754    /// Highlighted brackets background color.
 755    ///
 756    /// Matching brackets in the cursor scope are highlighted with this background color.
 757    #[serde(rename = "editor.document_highlight.bracket_background")]
 758    pub editor_document_highlight_bracket_background: Option<String>,
 759
 760    /// Terminal background color.
 761    #[serde(rename = "terminal.background")]
 762    pub terminal_background: Option<String>,
 763
 764    /// Terminal foreground color.
 765    #[serde(rename = "terminal.foreground")]
 766    pub terminal_foreground: Option<String>,
 767
 768    /// Terminal ANSI background color.
 769    #[serde(rename = "terminal.ansi.background")]
 770    pub terminal_ansi_background: Option<String>,
 771
 772    /// Bright terminal foreground color.
 773    #[serde(rename = "terminal.bright_foreground")]
 774    pub terminal_bright_foreground: Option<String>,
 775
 776    /// Dim terminal foreground color.
 777    #[serde(rename = "terminal.dim_foreground")]
 778    pub terminal_dim_foreground: Option<String>,
 779
 780    /// Black ANSI terminal color.
 781    #[serde(rename = "terminal.ansi.black")]
 782    pub terminal_ansi_black: Option<String>,
 783
 784    /// Bright black ANSI terminal color.
 785    #[serde(rename = "terminal.ansi.bright_black")]
 786    pub terminal_ansi_bright_black: Option<String>,
 787
 788    /// Dim black ANSI terminal color.
 789    #[serde(rename = "terminal.ansi.dim_black")]
 790    pub terminal_ansi_dim_black: Option<String>,
 791
 792    /// Red ANSI terminal color.
 793    #[serde(rename = "terminal.ansi.red")]
 794    pub terminal_ansi_red: Option<String>,
 795
 796    /// Bright red ANSI terminal color.
 797    #[serde(rename = "terminal.ansi.bright_red")]
 798    pub terminal_ansi_bright_red: Option<String>,
 799
 800    /// Dim red ANSI terminal color.
 801    #[serde(rename = "terminal.ansi.dim_red")]
 802    pub terminal_ansi_dim_red: Option<String>,
 803
 804    /// Green ANSI terminal color.
 805    #[serde(rename = "terminal.ansi.green")]
 806    pub terminal_ansi_green: Option<String>,
 807
 808    /// Bright green ANSI terminal color.
 809    #[serde(rename = "terminal.ansi.bright_green")]
 810    pub terminal_ansi_bright_green: Option<String>,
 811
 812    /// Dim green ANSI terminal color.
 813    #[serde(rename = "terminal.ansi.dim_green")]
 814    pub terminal_ansi_dim_green: Option<String>,
 815
 816    /// Yellow ANSI terminal color.
 817    #[serde(rename = "terminal.ansi.yellow")]
 818    pub terminal_ansi_yellow: Option<String>,
 819
 820    /// Bright yellow ANSI terminal color.
 821    #[serde(rename = "terminal.ansi.bright_yellow")]
 822    pub terminal_ansi_bright_yellow: Option<String>,
 823
 824    /// Dim yellow ANSI terminal color.
 825    #[serde(rename = "terminal.ansi.dim_yellow")]
 826    pub terminal_ansi_dim_yellow: Option<String>,
 827
 828    /// Blue ANSI terminal color.
 829    #[serde(rename = "terminal.ansi.blue")]
 830    pub terminal_ansi_blue: Option<String>,
 831
 832    /// Bright blue ANSI terminal color.
 833    #[serde(rename = "terminal.ansi.bright_blue")]
 834    pub terminal_ansi_bright_blue: Option<String>,
 835
 836    /// Dim blue ANSI terminal color.
 837    #[serde(rename = "terminal.ansi.dim_blue")]
 838    pub terminal_ansi_dim_blue: Option<String>,
 839
 840    /// Magenta ANSI terminal color.
 841    #[serde(rename = "terminal.ansi.magenta")]
 842    pub terminal_ansi_magenta: Option<String>,
 843
 844    /// Bright magenta ANSI terminal color.
 845    #[serde(rename = "terminal.ansi.bright_magenta")]
 846    pub terminal_ansi_bright_magenta: Option<String>,
 847
 848    /// Dim magenta ANSI terminal color.
 849    #[serde(rename = "terminal.ansi.dim_magenta")]
 850    pub terminal_ansi_dim_magenta: Option<String>,
 851
 852    /// Cyan ANSI terminal color.
 853    #[serde(rename = "terminal.ansi.cyan")]
 854    pub terminal_ansi_cyan: Option<String>,
 855
 856    /// Bright cyan ANSI terminal color.
 857    #[serde(rename = "terminal.ansi.bright_cyan")]
 858    pub terminal_ansi_bright_cyan: Option<String>,
 859
 860    /// Dim cyan ANSI terminal color.
 861    #[serde(rename = "terminal.ansi.dim_cyan")]
 862    pub terminal_ansi_dim_cyan: Option<String>,
 863
 864    /// White ANSI terminal color.
 865    #[serde(rename = "terminal.ansi.white")]
 866    pub terminal_ansi_white: Option<String>,
 867
 868    /// Bright white ANSI terminal color.
 869    #[serde(rename = "terminal.ansi.bright_white")]
 870    pub terminal_ansi_bright_white: Option<String>,
 871
 872    /// Dim white ANSI terminal color.
 873    #[serde(rename = "terminal.ansi.dim_white")]
 874    pub terminal_ansi_dim_white: Option<String>,
 875
 876    #[serde(rename = "link_text.hover")]
 877    pub link_text_hover: Option<String>,
 878
 879    /// Added version control color.
 880    #[serde(rename = "version_control.added")]
 881    pub version_control_added: Option<String>,
 882
 883    /// Deleted version control color.
 884    #[serde(rename = "version_control.deleted")]
 885    pub version_control_deleted: Option<String>,
 886
 887    /// Modified version control color.
 888    #[serde(rename = "version_control.modified")]
 889    pub version_control_modified: Option<String>,
 890
 891    /// Renamed version control color.
 892    #[serde(rename = "version_control.renamed")]
 893    pub version_control_renamed: Option<String>,
 894
 895    /// Conflict version control color.
 896    #[serde(rename = "version_control.conflict")]
 897    pub version_control_conflict: Option<String>,
 898
 899    /// Ignored version control color.
 900    #[serde(rename = "version_control.ignored")]
 901    pub version_control_ignored: Option<String>,
 902
 903    /// Color for added words in word diffs.
 904    #[serde(rename = "version_control.word_added")]
 905    pub version_control_word_added: Option<String>,
 906
 907    /// Color for deleted words in word diffs.
 908    #[serde(rename = "version_control.word_deleted")]
 909    pub version_control_word_deleted: Option<String>,
 910
 911    /// Background color for row highlights of "ours" regions in merge conflicts.
 912    #[serde(rename = "version_control.conflict_marker.ours")]
 913    pub version_control_conflict_marker_ours: Option<String>,
 914
 915    /// Background color for row highlights of "theirs" regions in merge conflicts.
 916    #[serde(rename = "version_control.conflict_marker.theirs")]
 917    pub version_control_conflict_marker_theirs: Option<String>,
 918
 919    /// Deprecated in favor of `version_control_conflict_marker_ours`.
 920    #[deprecated]
 921    pub version_control_conflict_ours_background: Option<String>,
 922
 923    /// Deprecated in favor of `version_control_conflict_marker_theirs`.
 924    #[deprecated]
 925    pub version_control_conflict_theirs_background: Option<String>,
 926
 927    /// Background color for Vim Normal mode indicator.
 928    #[serde(rename = "vim.normal.background")]
 929    pub vim_normal_background: Option<String>,
 930    /// Background color for Vim Insert mode indicator.
 931    #[serde(rename = "vim.insert.background")]
 932    pub vim_insert_background: Option<String>,
 933    /// Background color for Vim Replace mode indicator.
 934    #[serde(rename = "vim.replace.background")]
 935    pub vim_replace_background: Option<String>,
 936    /// Background color for Vim Visual mode indicator.
 937    #[serde(rename = "vim.visual.background")]
 938    pub vim_visual_background: Option<String>,
 939    /// Background color for Vim Visual Line mode indicator.
 940    #[serde(rename = "vim.visual_line.background")]
 941    pub vim_visual_line_background: Option<String>,
 942    /// Background color for Vim Visual Block mode indicator.
 943    #[serde(rename = "vim.visual_block.background")]
 944    pub vim_visual_block_background: Option<String>,
 945    /// Background color for Vim Helix Normal mode indicator.
 946    #[serde(rename = "vim.helix_normal.background")]
 947    pub vim_helix_normal_background: Option<String>,
 948    /// Background color for Vim Helix Select mode indicator.
 949    #[serde(rename = "vim.helix_select.background")]
 950    pub vim_helix_select_background: Option<String>,
 951
 952    /// Text color for Vim mode indicator label.
 953    #[serde(rename = "vim.mode.text")]
 954    pub vim_mode_text: Option<String>,
 955}
 956
 957#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 958#[serde(default)]
 959pub struct HighlightStyleContent {
 960    pub color: Option<String>,
 961
 962    #[serde(
 963        skip_serializing_if = "Option::is_none",
 964        deserialize_with = "treat_error_as_none"
 965    )]
 966    pub background_color: Option<String>,
 967
 968    #[serde(
 969        skip_serializing_if = "Option::is_none",
 970        deserialize_with = "treat_error_as_none"
 971    )]
 972    pub font_style: Option<FontStyleContent>,
 973
 974    #[serde(
 975        skip_serializing_if = "Option::is_none",
 976        deserialize_with = "treat_error_as_none"
 977    )]
 978    pub font_weight: Option<FontWeightContent>,
 979}
 980
 981impl HighlightStyleContent {
 982    pub fn is_empty(&self) -> bool {
 983        self.color.is_none()
 984            && self.background_color.is_none()
 985            && self.font_style.is_none()
 986            && self.font_weight.is_none()
 987    }
 988}
 989
 990fn treat_error_as_none<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error>
 991where
 992    T: Deserialize<'de>,
 993    D: Deserializer<'de>,
 994{
 995    let value: Value = Deserialize::deserialize(deserializer)?;
 996    Ok(T::deserialize(value).ok())
 997}
 998
 999#[with_fallible_options]
1000#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
1001#[serde(default)]
1002pub struct StatusColorsContent {
1003    /// Indicates some kind of conflict, like a file changed on disk while it was open, or
1004    /// merge conflicts in a Git repository.
1005    #[serde(rename = "conflict")]
1006    pub conflict: Option<String>,
1007
1008    #[serde(rename = "conflict.background")]
1009    pub conflict_background: Option<String>,
1010
1011    #[serde(rename = "conflict.border")]
1012    pub conflict_border: Option<String>,
1013
1014    /// Indicates something new, like a new file added to a Git repository.
1015    #[serde(rename = "created")]
1016    pub created: Option<String>,
1017
1018    #[serde(rename = "created.background")]
1019    pub created_background: Option<String>,
1020
1021    #[serde(rename = "created.border")]
1022    pub created_border: Option<String>,
1023
1024    /// Indicates that something no longer exists, like a deleted file.
1025    #[serde(rename = "deleted")]
1026    pub deleted: Option<String>,
1027
1028    #[serde(rename = "deleted.background")]
1029    pub deleted_background: Option<String>,
1030
1031    #[serde(rename = "deleted.border")]
1032    pub deleted_border: Option<String>,
1033
1034    /// Indicates a system error, a failed operation or a diagnostic error.
1035    #[serde(rename = "error")]
1036    pub error: Option<String>,
1037
1038    #[serde(rename = "error.background")]
1039    pub error_background: Option<String>,
1040
1041    #[serde(rename = "error.border")]
1042    pub error_border: Option<String>,
1043
1044    /// Represents a hidden status, such as a file being hidden in a file tree.
1045    #[serde(rename = "hidden")]
1046    pub hidden: Option<String>,
1047
1048    #[serde(rename = "hidden.background")]
1049    pub hidden_background: Option<String>,
1050
1051    #[serde(rename = "hidden.border")]
1052    pub hidden_border: Option<String>,
1053
1054    /// Indicates a hint or some kind of additional information.
1055    #[serde(rename = "hint")]
1056    pub hint: Option<String>,
1057
1058    #[serde(rename = "hint.background")]
1059    pub hint_background: Option<String>,
1060
1061    #[serde(rename = "hint.border")]
1062    pub hint_border: Option<String>,
1063
1064    /// Indicates that something is deliberately ignored, such as a file or operation ignored by Git.
1065    #[serde(rename = "ignored")]
1066    pub ignored: Option<String>,
1067
1068    #[serde(rename = "ignored.background")]
1069    pub ignored_background: Option<String>,
1070
1071    #[serde(rename = "ignored.border")]
1072    pub ignored_border: Option<String>,
1073
1074    /// Represents informational status updates or messages.
1075    #[serde(rename = "info")]
1076    pub info: Option<String>,
1077
1078    #[serde(rename = "info.background")]
1079    pub info_background: Option<String>,
1080
1081    #[serde(rename = "info.border")]
1082    pub info_border: Option<String>,
1083
1084    /// Indicates a changed or altered status, like a file that has been edited.
1085    #[serde(rename = "modified")]
1086    pub modified: Option<String>,
1087
1088    #[serde(rename = "modified.background")]
1089    pub modified_background: Option<String>,
1090
1091    #[serde(rename = "modified.border")]
1092    pub modified_border: Option<String>,
1093
1094    /// Indicates something that is predicted, like automatic code completion, or generated code.
1095    #[serde(rename = "predictive")]
1096    pub predictive: Option<String>,
1097
1098    #[serde(rename = "predictive.background")]
1099    pub predictive_background: Option<String>,
1100
1101    #[serde(rename = "predictive.border")]
1102    pub predictive_border: Option<String>,
1103
1104    /// Represents a renamed status, such as a file that has been renamed.
1105    #[serde(rename = "renamed")]
1106    pub renamed: Option<String>,
1107
1108    #[serde(rename = "renamed.background")]
1109    pub renamed_background: Option<String>,
1110
1111    #[serde(rename = "renamed.border")]
1112    pub renamed_border: Option<String>,
1113
1114    /// Indicates a successful operation or task completion.
1115    #[serde(rename = "success")]
1116    pub success: Option<String>,
1117
1118    #[serde(rename = "success.background")]
1119    pub success_background: Option<String>,
1120
1121    #[serde(rename = "success.border")]
1122    pub success_border: Option<String>,
1123
1124    /// Indicates some kind of unreachable status, like a block of code that can never be reached.
1125    #[serde(rename = "unreachable")]
1126    pub unreachable: Option<String>,
1127
1128    #[serde(rename = "unreachable.background")]
1129    pub unreachable_background: Option<String>,
1130
1131    #[serde(rename = "unreachable.border")]
1132    pub unreachable_border: Option<String>,
1133
1134    /// Represents a warning status, like an operation that is about to fail.
1135    #[serde(rename = "warning")]
1136    pub warning: Option<String>,
1137
1138    #[serde(rename = "warning.background")]
1139    pub warning_background: Option<String>,
1140
1141    #[serde(rename = "warning.border")]
1142    pub warning_border: Option<String>,
1143}
1144
1145/// The background appearance of the window.
1146#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, JsonSchema, MergeFrom)]
1147#[serde(rename_all = "snake_case")]
1148pub enum WindowBackgroundContent {
1149    Opaque,
1150    Transparent,
1151    Blurred,
1152}
1153
1154impl Into<gpui::WindowBackgroundAppearance> for WindowBackgroundContent {
1155    fn into(self) -> gpui::WindowBackgroundAppearance {
1156        match self {
1157            WindowBackgroundContent::Opaque => gpui::WindowBackgroundAppearance::Opaque,
1158            WindowBackgroundContent::Transparent => gpui::WindowBackgroundAppearance::Transparent,
1159            WindowBackgroundContent::Blurred => gpui::WindowBackgroundAppearance::Blurred,
1160        }
1161    }
1162}
1163
1164#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
1165#[serde(rename_all = "snake_case")]
1166pub enum FontStyleContent {
1167    Normal,
1168    Italic,
1169    Oblique,
1170}
1171
1172impl From<FontStyleContent> for FontStyle {
1173    fn from(value: FontStyleContent) -> Self {
1174        match value {
1175            FontStyleContent::Normal => FontStyle::Normal,
1176            FontStyleContent::Italic => FontStyle::Italic,
1177            FontStyleContent::Oblique => FontStyle::Oblique,
1178        }
1179    }
1180}
1181
1182#[derive(
1183    Debug, Clone, Copy, Serialize_repr, Deserialize_repr, JsonSchema_repr, PartialEq, MergeFrom,
1184)]
1185#[repr(u16)]
1186pub enum FontWeightContent {
1187    Thin = 100,
1188    ExtraLight = 200,
1189    Light = 300,
1190    Normal = 400,
1191    Medium = 500,
1192    Semibold = 600,
1193    Bold = 700,
1194    ExtraBold = 800,
1195    Black = 900,
1196}
1197
1198impl From<FontWeightContent> for FontWeight {
1199    fn from(value: FontWeightContent) -> Self {
1200        match value {
1201            FontWeightContent::Thin => FontWeight::THIN,
1202            FontWeightContent::ExtraLight => FontWeight::EXTRA_LIGHT,
1203            FontWeightContent::Light => FontWeight::LIGHT,
1204            FontWeightContent::Normal => FontWeight::NORMAL,
1205            FontWeightContent::Medium => FontWeight::MEDIUM,
1206            FontWeightContent::Semibold => FontWeight::SEMIBOLD,
1207            FontWeightContent::Bold => FontWeight::BOLD,
1208            FontWeightContent::ExtraBold => FontWeight::EXTRA_BOLD,
1209            FontWeightContent::Black => FontWeight::BLACK,
1210        }
1211    }
1212}
1213
1214#[cfg(test)]
1215mod tests {
1216    use super::*;
1217    use serde_json::json;
1218
1219    #[test]
1220    fn test_buffer_line_height_deserialize_valid() {
1221        assert_eq!(
1222            serde_json::from_value::<BufferLineHeight>(json!("comfortable")).unwrap(),
1223            BufferLineHeight::Comfortable
1224        );
1225        assert_eq!(
1226            serde_json::from_value::<BufferLineHeight>(json!("standard")).unwrap(),
1227            BufferLineHeight::Standard
1228        );
1229        assert_eq!(
1230            serde_json::from_value::<BufferLineHeight>(json!({"custom": 1.0})).unwrap(),
1231            BufferLineHeight::Custom(1.0)
1232        );
1233        assert_eq!(
1234            serde_json::from_value::<BufferLineHeight>(json!({"custom": 1.5})).unwrap(),
1235            BufferLineHeight::Custom(1.5)
1236        );
1237    }
1238
1239    #[test]
1240    fn test_buffer_line_height_deserialize_invalid() {
1241        assert!(
1242            serde_json::from_value::<BufferLineHeight>(json!({"custom": 0.99}))
1243                .err()
1244                .unwrap()
1245                .to_string()
1246                .contains("buffer_line_height.custom must be at least 1.0")
1247        );
1248        assert!(
1249            serde_json::from_value::<BufferLineHeight>(json!({"custom": 0.0}))
1250                .err()
1251                .unwrap()
1252                .to_string()
1253                .contains("buffer_line_height.custom must be at least 1.0")
1254        );
1255        assert!(
1256            serde_json::from_value::<BufferLineHeight>(json!({"custom": -1.0}))
1257                .err()
1258                .unwrap()
1259                .to_string()
1260                .contains("buffer_line_height.custom must be at least 1.0")
1261        );
1262    }
1263
1264    #[test]
1265    fn test_buffer_font_weight_schema_has_default() {
1266        use schemars::schema_for;
1267
1268        let schema = schema_for!(ThemeSettingsContent);
1269        let schema_value = serde_json::to_value(&schema).unwrap();
1270
1271        let properties = &schema_value["properties"];
1272        let buffer_font_weight = &properties["buffer_font_weight"];
1273
1274        assert!(
1275            buffer_font_weight.get("default").is_some(),
1276            "buffer_font_weight should have a default value in the schema"
1277        );
1278
1279        let default_value = &buffer_font_weight["default"];
1280        assert_eq!(
1281            default_value.as_f64(),
1282            Some(FontWeight::NORMAL.0 as f64),
1283            "buffer_font_weight default should be 400.0 (FontWeight::NORMAL)"
1284        );
1285
1286        let defs = &schema_value["$defs"];
1287        let font_weight_def = &defs["FontWeight"];
1288
1289        assert_eq!(
1290            font_weight_def["minimum"].as_f64(),
1291            Some(FontWeight::THIN.0 as f64),
1292            "FontWeight should have minimum of 100.0"
1293        );
1294        assert_eq!(
1295            font_weight_def["maximum"].as_f64(),
1296            Some(FontWeight::BLACK.0 as f64),
1297            "FontWeight should have maximum of 900.0"
1298        );
1299        assert_eq!(
1300            font_weight_def["default"].as_f64(),
1301            Some(FontWeight::NORMAL.0 as f64),
1302            "FontWeight should have default of 400.0"
1303        );
1304    }
1305}