From f6bfae31034095b80ffce8a22c2be2179fe42d2f Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 23 Dec 2025 17:07:56 -0800 Subject: [PATCH] docs(schema): avoid duplicating display format enums in bar This commit also addresses some clippy warnings. --- komorebi-bar/src/widgets/applications.rs | 14 +++---- komorebi/src/workspace.rs | 14 +++---- schema.bar.json | 52 ++++++++++++------------ 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/komorebi-bar/src/widgets/applications.rs b/komorebi-bar/src/widgets/applications.rs index 2bdbae1e..4a01fe48 100644 --- a/komorebi-bar/src/widgets/applications.rs +++ b/komorebi-bar/src/widgets/applications.rs @@ -41,7 +41,7 @@ pub struct ApplicationsConfig { pub spacing: Option, /// Default display format for all applications (optional). /// Could be overridden per application. Defaults to `Icon`. - pub display: Option, + pub display: Option, /// List of configured applications to display. pub items: Vec, } @@ -64,12 +64,12 @@ pub struct AppConfig { /// Command to execute (e.g. path to the application or shell command). pub command: String, /// Display format for this application button (optional). Overrides global format if set. - pub display: Option, + pub display: Option, } #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Default)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -pub enum DisplayFormat { +pub enum ApplicationsDisplayFormat { /// Show only the application icon. #[default] Icon, @@ -165,7 +165,7 @@ pub struct App { /// Command to execute when the application is launched. pub command: UserCommand, /// Display format (icon, text, or both). - pub display: DisplayFormat, + pub display: ApplicationsDisplayFormat, /// Whether to show the launch command on hover. pub show_command_on_hover: bool, } @@ -180,9 +180,9 @@ impl App { ui.spacing_mut().item_spacing = Vec2::splat(4.0); match self.display { - DisplayFormat::Icon => self.draw_icon(ctx, ui, icon_config), - DisplayFormat::Text => self.draw_name(ui), - DisplayFormat::IconAndText => { + ApplicationsDisplayFormat::Icon => self.draw_icon(ctx, ui, icon_config), + ApplicationsDisplayFormat::Text => self.draw_name(ui), + ApplicationsDisplayFormat::IconAndText => { self.draw_icon(ctx, ui, icon_config); self.draw_name(ui); } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index cfd4d59c..246e4481 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1497,7 +1497,7 @@ impl Workspace { 0 | 1 => self.enforce_no_resize(), _ => { // Zero is actually on the left - if let Some(mut left) = resize_dimensions[0] { + if let Some(left) = resize_dimensions[0].as_mut() { left.top = 0; left.bottom = 0; left.left = 0; @@ -1530,7 +1530,7 @@ impl Workspace { 0 | 1 => self.enforce_no_resize(), _ => { // Zero is actually on the right - if let Some(mut left) = resize_dimensions[1] { + if let Some(left) = resize_dimensions[1].as_mut() { left.top = 0; left.bottom = 0; left.right = 0; @@ -1561,7 +1561,7 @@ impl Workspace { match resize_dimensions.len() { 0 | 1 => self.enforce_no_resize(), _ => { - if let Some(mut left) = resize_dimensions[0] { + if let Some(left) = resize_dimensions[0].as_mut() { left.top = 0; left.left = 0; left.right = 0; @@ -1592,14 +1592,14 @@ impl Workspace { // Two windows can only be resized in the middle 2 => { // Zero is actually on the right - if let Some(mut right) = resize_dimensions[0] { + if let Some(right) = resize_dimensions[0].as_mut() { right.top = 0; right.bottom = 0; right.right = 0; } // One is on the left - if let Some(mut left) = resize_dimensions[1] { + if let Some(left) = resize_dimensions[1].as_mut() { left.top = 0; left.bottom = 0; left.left = 0; @@ -1609,13 +1609,13 @@ impl Workspace { // stack on the right _ => { // Central can be resized left or right - if let Some(mut right) = resize_dimensions[0] { + if let Some(right) = resize_dimensions[0].as_mut() { right.top = 0; right.bottom = 0; } // Left one can only be resized to the right - if let Some(mut left) = resize_dimensions[1] { + if let Some(left) = resize_dimensions[1].as_mut() { left.top = 0; left.bottom = 0; left.left = 0; diff --git a/schema.bar.json b/schema.bar.json index f702adbe..7f066088 100644 --- a/schema.bar.json +++ b/schema.bar.json @@ -173,7 +173,7 @@ "description": "Display format for this application button (optional). Overrides global format if set.", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat" + "$ref": "#/$defs/ApplicationsDisplayFormat" }, { "type": "null" @@ -218,7 +218,7 @@ "description": "Default display format for all applications (optional).\nCould be overridden per application. Defaults to `Icon`.", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat" + "$ref": "#/$defs/ApplicationsDisplayFormat" }, { "type": "null" @@ -257,6 +257,25 @@ "items" ] }, + "ApplicationsDisplayFormat": { + "oneOf": [ + { + "description": "Show only the application icon.", + "type": "string", + "const": "Icon" + }, + { + "description": "Show only the application name as text.", + "type": "string", + "const": "Text" + }, + { + "description": "Show both the application icon and name.", + "type": "string", + "const": "IconAndText" + } + ] + }, "Base16": { "type": "string", "enum": [ @@ -888,25 +907,6 @@ ] }, "DisplayFormat": { - "oneOf": [ - { - "description": "Show only the application icon.", - "type": "string", - "const": "Icon" - }, - { - "description": "Show only the application name as text.", - "type": "string", - "const": "Text" - }, - { - "description": "Show both the application icon and name.", - "type": "string", - "const": "IconAndText" - } - ] - }, - "DisplayFormat2": { "oneOf": [ { "description": "Show only icon", @@ -1408,7 +1408,7 @@ "description": "Display format of the currently focused container", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" }, { "type": "null" @@ -1457,7 +1457,7 @@ "description": "Display format of the current layout", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" }, { "type": "null" @@ -1490,7 +1490,7 @@ "description": "Display format of the current locked state", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" }, { "type": "null" @@ -1520,7 +1520,7 @@ "description": "Display format of the current layer", "anyOf": [ { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" }, { "type": "null" @@ -2249,7 +2249,7 @@ "const": "AllIconsAndTextOnSelected" }, { - "$ref": "#/$defs/DisplayFormat2" + "$ref": "#/$defs/DisplayFormat" } ] }