diff options
| author | user <user@clank> | 2026-08-08 20:58:17 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-08 20:58:17 +0200 |
| commit | c21f7324abdb6d83300a62b95e2af27bfcc75a1e (patch) | |
| tree | 4bf95a6a71c5c0b6e36c96d2a2d58d654b13052b /zellij-utils/src/input | |
| parent | sl0p: add fastdev build profile + SPEED.md (60x faster iteration) (diff) | |
| download | sl0ppij-c21f7324abdb6d83300a62b95e2af27bfcc75a1e.tar.gz sl0ppij-c21f7324abdb6d83300a62b95e2af27bfcc75a1e.tar.xz sl0ppij-c21f7324abdb6d83300a62b95e2af27bfcc75a1e.zip | |
sl0p: uniform pane gap + aspect-corrected horizontal gap
Two changes to how the gap is defined.
1. UNIFORM GAP. Previously every pane inset every side by `gap`, so two
neighbours each gave up a cell and the space between them was 2*gap while
the screen edge got only gap. Now a pane insets RIGHT and BOTTOM always,
and LEFT/TOP only where that edge is the viewport boundary. Two neighbours
contribute exactly one gap between them, and the outer screen edges get
the same gap. `gap 1` now means 1 everywhere.
The per-side offset is computed in tiled_panes, which is the layer that
knows the viewport, and pushed to panes via Pane::set_gap_offset before the
content-offset sweep. Floating panes keep a zero gap: they are positioned
explicitly by the user, so an inter-pane gap does not apply to them (they
still get padding).
2. ASPECT CORRECTION. Terminal cells are roughly twice as tall as they are
wide, so an equal number of rows and columns does not look like an equal
distance. `gap` and `padding` are now expressed in ROWS, and columns are
multiplied by `gap_aspect` (default 2, minimum 1). Style carries the
resolved pane_gap_x/y and pane_padding_x/y.
FrameConfig::Default is now hand-written rather than derived: gap_aspect must
default to 2 to match the KDL parser, otherwise a parsed config disagrees with
a default-constructed one and it surfaces as config round-trip diffs (this
broke can_define_ui_configuration_in_configfile and both
bare_config_from_default_assets_to_string tests).
Tests assert the actual invariants: stacked and side-by-side neighbours get
exactly one gap between them, screen edges get the same gap as between panes,
and inset_by refuses to collapse a pane too small to survive it.
Baselines held: zellij-server 1421/30, zellij-utils 433/5.
Diffstat (limited to 'zellij-utils/src/input')
| -rw-r--r-- | zellij-utils/src/input/config.rs | 1 | ||||
| -rw-r--r-- | zellij-utils/src/input/theme.rs | 43 |
2 files changed, 41 insertions, 3 deletions
diff --git a/zellij-utils/src/input/config.rs b/zellij-utils/src/input/config.rs index 546d39d0..be08adb9 100644 --- a/zellij-utils/src/input/config.rs +++ b/zellij-utils/src/input/config.rs @@ -1410,6 +1410,7 @@ mod config_test { title_alignment: Default::default(), gap: Default::default(), padding: Default::default(), + gap_aspect: 2, // parser default; see FrameConfig::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 949a8752..f4f2ec80 100644 --- a/zellij-utils/src/input/theme.rs +++ b/zellij-utils/src/input/theme.rs @@ -22,15 +22,51 @@ impl UiConfig { } } -#[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize)] pub struct FrameConfig { pub rounded_corners: bool, pub hide_session_name: bool, pub title_alignment: crate::data::PaneTitleAlignment, - /// outer gap between panes, in cells (see Style::pane_gap) + /// outer gap between panes, expressed in ROWS (see Style::pane_gap_y). + /// Columns are scaled by `gap_aspect` so the gap looks square. pub gap: usize, - /// inner padding between a pane's frame and its content (see Style::pane_padding) + /// inner padding between a pane's frame and its content, in ROWS pub padding: usize, + /// Columns per row. Terminal cells are roughly twice as tall as they are + /// wide, so 1 row of gap needs ~2 columns to look like the same distance. + /// 0 is treated as 1 (no correction). + pub gap_aspect: usize, +} + +/// Hand-written rather than derived: `gap_aspect` must default to 2 to match +/// the KDL parser's default. A derived Default would give 0, which makes a +/// parsed config disagree with a default-constructed one and shows up as +/// config round-trip diffs. +impl Default for FrameConfig { + fn default() -> Self { + FrameConfig { + rounded_corners: false, + hide_session_name: false, + title_alignment: Default::default(), + gap: 0, + padding: 0, + gap_aspect: 2, + } + } +} + +impl FrameConfig { + fn aspect(&self) -> usize { + self.gap_aspect.max(1) + } + /// (columns, rows) of outer gap + pub fn resolved_gap(&self) -> (usize, usize) { + (self.gap * self.aspect(), self.gap) + } + /// (columns, rows) of inner padding + pub fn resolved_padding(&self) -> (usize, usize) { + (self.padding * self.aspect(), self.padding) + } } impl FrameConfig { @@ -41,6 +77,7 @@ impl FrameConfig { merged.title_alignment = other.title_alignment; merged.gap = other.gap; merged.padding = other.padding; + merged.gap_aspect = other.gap_aspect; merged } } |
