diff options
| author | user <user@clank> | 2026-08-11 00:12:10 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-11 00:12:10 +0200 |
| commit | 393748bb2fb0ad741f2d51cfe0f8db75cf2ad7c3 (patch) | |
| tree | 09a651d4640e18398df90cdac0857e8602bcd5a0 /README.md | |
| parent | sl0p: refresh snapshots for the compact scroll indicator (diff) | |
| download | sl0ppij-393748bb2fb0ad741f2d51cfe0f8db75cf2ad7c3.tar.gz sl0ppij-393748bb2fb0ad741f2d51cfe0f8db75cf2ad7c3.tar.xz sl0ppij-393748bb2fb0ad741f2d51cfe0f8db75cf2ad7c3.zip | |
sl0p: collapse to a swap layout when the terminal gets narrow
Splitting a window into thirds is great until the window is 70 columns wide
and each pane gets 23. `responsive_min_cols` collapses the tab into the swap
layout named by `responsive_layout` when it gets narrower than that, and
restores the previously active layout when it grows back.
Selects a swap layout BY NAME rather than adding a size-aware
LayoutConstraint: that type crosses both the plugin protobuf API and the
client/server contract, and the committed prost assets cannot be regenerated
here (no protoc).
Restoring uses a 10-column hysteresis band. Without a dead band, dragging a
window edge that lands exactly on the threshold flips the layout on every
motion event, and every flip resizes every PTY in the tab.
"Did the user rearrange panes by hand" is judged from the damaged flag as
sampled BEFORE each resize, not the live one: resize_whole_tab's own
auto-layout pass sets that flag itself and clears it again only if it found a
layout that fits, so on a terminal too narrow for any of them it latches true
although nothing was rearranged. And once collapsed, restore stays reachable
regardless of the flag, so damage occurring while collapsed cannot strand the
tab in the narrow layout.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 85 |
1 files changed, 82 insertions, 3 deletions
@@ -57,10 +57,80 @@ ui { // Applies to `gap`, and to the 1-value form of `padding`. The 2- and // 4-value padding forms are taken literally. Set to 1 to disable. gap_aspect 2 // default: 2 + + // Collapse to a named swap layout when the terminal gets narrow, and + // restore the previous one when it grows back. 0 disables (default). + // See "Responsive layouts" below -- this one needs swap layouts in your + // layout file to do anything. + responsive_min_cols 90 // default: 0 (off) + responsive_layout "stacked" // default: "stacked" + } +} +``` + +### Responsive layouts + +When the terminal is narrower than `responsive_min_cols`, the tab switches to the +swap layout named by `responsive_layout`; when it grows back, the layout that was +active before the collapse is restored. Splitting a wide window into thirds is great +until the window is 70 columns wide and each pane gets 23. + +This selects a swap layout **by name**, so it only does something if your layout +file defines one with that name: + +```kdl +layout { + pane split_direction="vertical" { + pane + pane + pane + } + swap_tiled_layout name="tiled" { + tab { + pane split_direction="vertical" { + pane + pane + pane + } + } + } + swap_tiled_layout name="stacked" { + tab min_panes=2 { + pane stacked=true { + children + } + } } } ``` +(One node per line: zellij's KDL parser rejects the `{ pane; pane; }` one-liner form.) + +Name-based rather than a new size-aware `LayoutConstraint` on purpose: that type +crosses both the plugin protobuf API and the client/server contract, and the +committed prost assets cannot be regenerated without `protoc`. + +Two deliberate behaviours: + +- **Hysteresis.** Collapse happens below `responsive_min_cols`, but restore only + above `responsive_min_cols + 10`. Without that dead band, dragging a window edge + that lands exactly on the threshold flips the layout on every motion event, and + every flip resizes every PTY in the tab. +- **Manual arrangement wins.** Once you have rearranged panes yourself (what zellij + calls a *damaged* swap layout), the responsive switch stops acting, on the same + principle as upstream's `auto_layout`. An explicit arrangement outranks an + automatic one. Note this includes opening a pane with an explicit direction + (`NewPane "Right"`, `zellij action new-pane -d right`): that is an explicit + arrangement, so a tab built that way will not collapse. A plain `NewPane` is + not, and will. +- **Escaping the collapse is always possible.** "Damaged" is judged as of *before* + each resize, because `resize_whole_tab`'s own auto-layout pass sets that flag + itself and only clears it again if it found a layout that fits — on a very + narrow terminal it may find none, which would otherwise look like a manual + rearrangement that never happened. And once collapsed, restore stays reachable + regardless, so damage occurring while collapsed cannot strand the tab in the + narrow layout. + ### Drag a pane title to rearrange it Dragging a tiled pane by its title bar and dropping it on another pane swaps the @@ -107,6 +177,7 @@ Also in the fork, not configurable: | change | applies | |---|---| | `title_alignment`, `gap`, `padding`, `gap_aspect` | **live**, no restart | +| `responsive_min_cols`, `responsive_layout` | **live**, applies on the next resize | | `rounded_corners`, and other stock options | **live** (upstream behaviour) | | anything requiring a new binary | **new session** — a running server keeps its old inode | @@ -121,9 +192,14 @@ cargo build --profile fastdev -p zellij # ~3s incremental -> target/fastdev cargo build --release -p zellij # ~3min -> ship this one ``` -See `.fastfeedback/SPEED.md` for narrow test commands, measured timings, and the -pre-existing test-failure baselines (this tree has failures that are **not** caused by -the fork — check against `upstream/main` before chasing one). +See `.fastfeedback/SPEED.md` for narrow test commands and measured timings. + +The test suite is **green** (`cargo test -p zellij-server -p zellij-utils`), so any +failure is a real one. It was not always: the fork carried 35 failing snapshot tests +from its first commit until 5f2c28ab, because `aa51848d` changed the frame rendering +without refreshing the `insta` snapshots. If you change anything about how frames or +pane titles render, expect to regenerate snapshots — and read the diffs before +accepting them. ## Known rough edges @@ -138,6 +214,9 @@ the fork — check against `upstream/main` before chasing one). inter-pane gap does not apply. - **Stacked panes** apply the gap uniformly; stack header spacing may look slightly off at larger gaps. +- **Responsive layouts need a swap layout with a matching name.** `responsive_layout` + selects by name; if no swap layout has that name the tab silently stays as it is, + with nothing logged. It is also column-only — there is no `responsive_min_rows`. - The fork's options are **not** exposed over the plugin protobuf API. Plugins have no use for them and adding proto fields would mean regenerating the committed prost assets in `zellij-utils/assets/prost/`. |
