diff options
| author | user <user@clank> | 2026-08-11 20:08:23 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-11 20:08:23 +0200 |
| commit | 3418e8218d91d916b3b2a45ac81d3032c27575c6 (patch) | |
| tree | 4853d3b368d18480efe7dc4ef994e9d7e99a94e0 /zellij-utils | |
| parent | sl0p: resolve responsive layouts from current state, not a remembered position (diff) | |
| download | sl0ppij-3418e8218d91d916b3b2a45ac81d3032c27575c6.tar.gz sl0ppij-3418e8218d91d916b3b2a45ac81d3032c27575c6.tar.xz sl0ppij-3418e8218d91d916b3b2a45ac81d3032c27575c6.zip | |
sl0p: add a minimal style for the stacked-pane picker
The boxed entries read as clutter: every entry bracketed in vertical bars, and
the active one marked by a "> " that sits outside its own cell.
`stack_list_style "minimal"` drops both. The active entry is shown by
inverting it instead, which needs no glyph and no column, and the padding is
moved inside the styled run so the inverted block covers the whole cell rather
than leaving unstyled gaps at its edges. Four fewer columns of decoration per
entry, so more fit per row in grid mode.
Uses ribbon_selected rather than text_selected. Themes give ribbon_selected
real contrast because it marks the selected item elsewhere in zellij's UI --
gruber yellow here, white-on-blue in the TempleOS theme -- whereas
text_selected's background is 40,40,40 against a 24,24,24 terminal and read as
essentially no highlight when tried.
Decoration width comes from the style itself, so Tab's column arithmetic and
the renderer cannot disagree about how wide an entry is. Default stays boxed,
so nothing changes for anyone who does not ask.
Diffstat (limited to 'zellij-utils')
8 files changed, 70 insertions, 1 deletions
diff --git a/zellij-utils/src/input/config.rs b/zellij-utils/src/input/config.rs index 4cb315ca..08bfa4b0 100644 --- a/zellij-utils/src/input/config.rs +++ b/zellij-utils/src/input/config.rs @@ -1498,6 +1498,7 @@ mod config_test { responsive_layout: String::from("stacked"), stack_list_max_rows: 0, stack_list_grid: false, + stack_list_style: Default::default(), }, }; assert_eq!(config.ui, expected_ui_config, "Ui config defined in config"); diff --git a/zellij-utils/src/input/theme.rs b/zellij-utils/src/input/theme.rs index 412aaae2..646fa0ed 100644 --- a/zellij-utils/src/input/theme.rs +++ b/zellij-utils/src/input/theme.rs @@ -9,6 +9,46 @@ use std::{ use crate::data::Styling; +/// Visual treatment of the stacked-pane picker's entries. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)] +pub enum StackListStyle { + /// Each entry bracketed in vertical bars, with a "> " marker on the active + /// one. + Boxed, + /// No brackets and no marker; the active entry is shown by inverting its + /// foreground and background instead. + Minimal, +} + +impl Default for StackListStyle { + fn default() -> Self { + StackListStyle::Boxed + } +} + +impl StackListStyle { + pub fn from_str(name: &str) -> Option<Self> { + match name.trim().to_lowercase().as_str() { + "boxed" => Some(StackListStyle::Boxed), + "minimal" => Some(StackListStyle::Minimal), + _ => None, + } + } + pub fn possible_values() -> &'static str { + "\"boxed\", \"minimal\"" + } + /// Columns an entry spends on decoration. The picker's column arithmetic + /// lives in Tab and must agree with the renderer, so both read this. + pub fn decoration_cols(&self) -> usize { + match self { + // "> " marker, plus a border and a pad on each side + StackListStyle::Boxed => 6, + // one pad each side, so the inverted block has some air around it + StackListStyle::Minimal => 2, + } + } +} + #[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)] pub struct UiConfig { pub pane_frames: FrameConfig, @@ -55,6 +95,8 @@ pub struct FrameConfig { /// Pack picker entries into a grid instead of one per row. The row cap then /// becomes a space budget rather than a count. pub stack_list_grid: bool, + /// Visual treatment of picker entries. + pub stack_list_style: StackListStyle, } /// Hand-written rather than derived: `gap_aspect` must default to 2 to match @@ -76,6 +118,7 @@ impl Default for FrameConfig { responsive_layout: String::from("stacked"), stack_list_max_rows: 0, stack_list_grid: false, + stack_list_style: StackListStyle::Boxed, } } } @@ -108,6 +151,7 @@ impl FrameConfig { merged.responsive_layout = other.responsive_layout.clone(); merged.stack_list_max_rows = other.stack_list_max_rows; merged.stack_list_grid = other.stack_list_grid; + merged.stack_list_style = other.stack_list_style; merged } } diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs index dda62c87..3213b99d 100644 --- a/zellij-utils/src/kdl/mod.rs +++ b/zellij-utils/src/kdl/mod.rs @@ -15,7 +15,7 @@ use crate::input::layout::{ use crate::input::options::{Clipboard, OnForceClose, Options, PaneFrameStyle}; use crate::input::permission::{GrantedPermission, PermissionCache}; use crate::input::plugins::PluginAliases; -use crate::input::theme::{FrameConfig, Theme, Themes, UiConfig}; +use crate::input::theme::{FrameConfig, StackListStyle, Theme, Themes, UiConfig}; use crate::input::web_client::WebClientConfig; use kdl_layout_parser::KdlLayoutParser; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; @@ -5632,6 +5632,24 @@ impl UiConfig { }, None => false, }; + let stack_list_style = + match kdl_children_property_first_arg_as_string!(pane_frames, "stack_list_style") { + Some(raw) => match StackListStyle::from_str(raw) { + Some(style) => style, + None => { + return Err(ConfigError::new_kdl_error( + format!( + "Unknown stack_list_style: \"{}\". Valid values are: {}", + raw, + StackListStyle::possible_values() + ), + pane_frames.span().offset(), + pane_frames.span().len(), + )) + }, + }, + None => StackListStyle::default(), + }; let frame_config = FrameConfig { rounded_corners, hide_session_name, @@ -5645,6 +5663,7 @@ impl UiConfig { responsive_layout, stack_list_max_rows, stack_list_grid, + stack_list_style, }; ui_config.pane_frames = frame_config; } diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap index c2c29be5..ae91dafc 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap @@ -6245,6 +6245,7 @@ Config { responsive_layout: "stacked", stack_list_max_rows: 0, stack_list_grid: false, + stack_list_style: Boxed, }, }, env: {}, diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap index bc58ffff..f7f87561 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap @@ -6245,6 +6245,7 @@ Config { responsive_layout: "stacked", stack_list_max_rows: 0, stack_list_grid: false, + stack_list_style: Boxed, }, }, env: { diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap index 75cbc50e..692ffc41 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap @@ -307,6 +307,7 @@ Config { responsive_layout: "stacked", stack_list_max_rows: 0, stack_list_grid: false, + stack_list_style: Boxed, }, }, env: {}, diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap index d04f6e93..05b1553e 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap @@ -8016,6 +8016,7 @@ Config { responsive_layout: "stacked", stack_list_max_rows: 0, stack_list_grid: false, + stack_list_style: Boxed, }, }, env: {}, diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap index 966fed4e..67dade83 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap @@ -6245,6 +6245,7 @@ Config { responsive_layout: "stacked", stack_list_max_rows: 0, stack_list_grid: false, + stack_list_style: Boxed, }, }, env: {}, |
