aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruser <user@clank>2026-11-22 13:41:45 +0100
committeruser <user@clank>2026-11-22 13:41:45 +0100
commit76bbb171d2ad5f6298443ca055b6625e00f7ec22 (patch)
tree66475f6fd51d4b7db262b9132b289d37dc653353
parentfix: commands naming a background pane do not move the human's view (diff)
downloadslosh-76bbb171d2ad5f6298443ca055b6625e00f7ec22.tar.gz
slosh-76bbb171d2ad5f6298443ca055b6625e00f7ec22.tar.xz
slosh-76bbb171d2ad5f6298443ca055b6625e00f7ec22.zip
tab bar: tab_bar_collapse, the sidebar's cutoff as one number
The automatic fallback to the top row is derived from tab_bar_width, min_pane, a third of the screen and TAB_BAR_FIT -- 42 columns with the defaults, but nothing you could write down in a config. tab_bar_collapse N says it outright: the sidebar is tab_bar_width wide while at least N columns are left beside it, and the top row the moment there are fewer, with no narrowing in between. 0 (the default) keeps the automatic behaviour. The too-short fallback is untouched: that one is about tabs staying reachable.
-rw-r--r--docs/config.md2
-rw-r--r--docs/panes.md10
-rw-r--r--docs/slosh.59
-rw-r--r--include/config.h7
-rw-r--r--src/app_layout.c7
-rw-r--r--src/config.c8
-rw-r--r--tests/test_tab_bar.py40
7 files changed, 81 insertions, 2 deletions
diff --git a/docs/config.md b/docs/config.md
index 0c6b817..37bdf14 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -134,7 +134,7 @@ whatever the file says.
| group | what is in it |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| geometry | `gap` `gap_aspect` `padding` `compact` `rounded` `title_align` `title_inset` `min_pane` `min_split` |
-| chrome | `status_bar` `status_line` `status_pad` `tab_bar_side` `tab_bar_index` `tab_bar_width` `tab_bar_padding` `tab_bar_pad` `tab_gap` `tab_bar_status` `tab_bar_status_lines` `tab_bar_chrome` `hints` `version_banner` `pane_buttons` `bell_indicator` `newtab_button` `newtab_pad` and the marks (`zoom_mark` `zoom_on_mark` `close_mark` `min_mark` `newtab_mark` `bell_mark` `busy_mark` `busy_ms`) |
+| chrome | `status_bar` `status_line` `status_pad` `tab_bar_side` `tab_bar_index` `tab_bar_width` `tab_bar_collapse` `tab_bar_padding` `tab_bar_pad` `tab_gap` `tab_bar_status` `tab_bar_status_lines` `tab_bar_chrome` `hints` `version_banner` `pane_buttons` `bell_indicator` `newtab_button` `newtab_pad` and the marks (`zoom_mark` `zoom_on_mark` `close_mark` `min_mark` `newtab_mark` `bell_mark` `busy_mark` `busy_ms`) |
| behaviour | `focus_follows_mouse` `ctrl_d_exits` `scroll_lines` `scrollback` `scrollback_bytes` `toast_ms` `splash_ms` `hover_delay_ms` `double_click_ms` `word_separators` `anim_ms` `modal_scrim` `dim_unfocused` `float_shadow` `keep_dead` `in_band_shaders` `multi_attach` `attach_indicator` `size_follows` `shell` `editor` `open_click` `open_hover` `open_in` `open_command` (see [opening a path](panes.md#opening-a-path)) |
| projects | `project_roots` `project_layout` (see [workspaces](workspaces.md)) |
| colour | `theme { }` |
diff --git a/docs/panes.md b/docs/panes.md
index a88360a..775e53c 100644
--- a/docs/panes.md
+++ b/docs/panes.md
@@ -55,6 +55,7 @@ The strip of tabs sits along the top by default. It does not have to:
```kdl
tab_bar_side "left" // or "right"; "top" is the default
tab_bar_width 18 // columns the sidebar takes, at most
+tab_bar_collapse 0 // top row when fewer columns are left beside it; 0 = auto
tab_bar_index "right" // the tab number at the far end; "prefix" is 1:name
tab_bar_padding 0 1 0 2 // air inside it, in cells: top right bottom left
tab_bar_pad 0 // ...or just the top of that, the older name
@@ -86,7 +87,14 @@ held to a third of the screen, so 18 columns is a margin beside a 90-column
terminal and narrows to 16 beside a 50-column one, with the panes keeping the
rest and never dropping below the width they collapse at. Only when even a
legible sidebar (14 columns, or whatever narrower width you asked for) will not
-fit does the strip go back to the top row.
+fit does the strip go back to the top row. With the defaults that is a
+42-column terminal.
+
+If you would rather pick the line yourself, `tab_bar_collapse 60` says it
+outright: the sidebar stays exactly `tab_bar_width` wide while at least 60
+columns are left beside it, and goes to the top row the moment there are
+fewer. No narrowing, no third-of-the-screen rule — one number. 0 (the default)
+is the automatic behaviour above.
Height counts too: a sidebar spends a
row per tab, so a wide but short terminal runs out of list before it runs out
diff --git a/docs/slosh.5 b/docs/slosh.5
index 558b08f..39ec23b 100644
--- a/docs/slosh.5
+++ b/docs/slosh.5
@@ -141,6 +141,15 @@ narrow to read a name in, or when the terminal is too short to give every tab
a row (unless the top strip could not seat them either, where nothing is
gained by moving them). Re-derived per frame, so a resize moves the bar.
.TP
+.BI tab_bar_collapse\ n
+The sidebar's cutoff, as one number: the strip goes to \fBtop\fR whenever
+fewer than \fIn\fR columns would be left beside a sidebar of
+\fBtab_bar_width\fR, and the sidebar is exactly that width otherwise \(em it
+does not narrow first.
+\fB0\fR (the default) is the automatic behaviour under
+\fBtab_bar_width\fR.
+The too-short fallback still applies either way.
+.TP
.BI tab_bar_padding\ n\ ...
Air inside a sidebar, between its frame and the list, per side and in
cells: 1, 2 or 4 values in CSS order, like
diff --git a/include/config.h b/include/config.h
index 91def5e..4ac5fa0 100644
--- a/include/config.h
+++ b/include/config.h
@@ -373,6 +373,13 @@ typedef struct {
* untouched and keeps the full width either way. */
int tab_bar_side; /* TAB_BAR_* */
uint16_t tab_bar_width; /* columns a sidebar takes; ignored for top */
+ /* The one-number answer to "when does the sidebar give up its edge": the
+ * top row as soon as fewer than this many columns would be left beside a
+ * sidebar of tab_bar_width. 0 is automatic -- narrow first, then fall back
+ * on min_pane and a third of the screen (app_tab_bar_cols). Set, it takes
+ * over the width question entirely: the sidebar is tab_bar_width or it is
+ * on top, nothing in between, so the cutoff is exactly where you put it. */
+ uint16_t tab_bar_collapse;
/* Where a tab's number goes (TAB_INDEX_*). A sidebar row is wider than the
* name on it, and `1:api` spends the start of every row on a number nobody
* reads until they want to press it -- against the right edge the names all
diff --git a/src/app_layout.c b/src/app_layout.c
index d156941..d39dd87 100644
--- a/src/app_layout.c
+++ b/src/app_layout.c
@@ -355,6 +355,13 @@ uint16_t app_tab_bar_cols(const app_t *a) {
if (w > TAB_BAR_MAX) w = TAB_BAR_MAX;
if (!a) return w;
+ /* tab_bar_collapse: the cutoff, said outright. No narrowing and no third
+ * of the screen -- the sidebar is the width you asked for until fewer
+ * than N columns would be left beside it, then it is the top row. One
+ * number you can predict beats an arithmetic you have to reproduce. */
+ if (CFG.tab_bar_collapse)
+ return (unsigned)a->cols >= (unsigned)w + CFG.tab_bar_collapse ? w : 0;
+
uint16_t spare = a->cols > (uint16_t)(CFG.min_pane_cols + 4)
? (uint16_t)(a->cols - CFG.min_pane_cols - 4)
: 0;
diff --git a/src/config.c b/src/config.c
index e405ee8..76669ab 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1038,6 +1038,7 @@ void config_defaults(config_t *c) {
* than a reservation -- app_tab_bar_cols narrows it to fit a smaller
* screen, so this is the width you get when there is room for it. */
c->tab_bar_width = 18;
+ c->tab_bar_collapse = 0; /* automatic */
/* None by default: tab_bar_chrome's top line is the separation the air was
* standing in for, and a blank row inside the frame on top of it reads as
* a gap nobody asked for. Still there for a bare sidebar, or for anyone
@@ -1815,6 +1816,10 @@ char *config_render(const config_t *c) {
c->tab_bar_index == TAB_INDEX_RIGHT ? "right" : "prefix");
cb_add(&b, "tab_bar_width %u // columns a sidebar takes, at most\n",
c->tab_bar_width);
+ cb_add(&b,
+ "tab_bar_collapse %u // top row when fewer columns are left beside "
+ "it, 0 = auto\n",
+ c->tab_bar_collapse);
if (c->tab_pad_top == c->tab_pad_right &&
c->tab_pad_top == c->tab_pad_bottom && c->tab_pad_top == c->tab_pad_left)
cb_add(&b, "tab_bar_padding %u // air inside a sidebar, in cells\n",
@@ -2347,6 +2352,7 @@ static const char *const KNOWN_TOP[] = {
"status_line",
"status_pad",
"tab_bar_chrome",
+ "tab_bar_collapse",
"tab_bar_pad",
"tab_bar_padding",
"tab_bar_index",
@@ -2762,6 +2768,8 @@ static bool load_into(config_t *c, const char *path, int depth, char *err,
}
c->tab_bar_width = (uint16_t)kdl_arg_int(kdl_child(root, "tab_bar_width"), 0,
c->tab_bar_width);
+ c->tab_bar_collapse = (uint16_t)kdl_arg_int(
+ kdl_child(root, "tab_bar_collapse"), 0, c->tab_bar_collapse);
c->tab_gap = (uint16_t)kdl_arg_int(kdl_child(root, "tab_gap"), 0, c->tab_gap);
c->tab_bar_status = (uint16_t)kdl_arg_int(kdl_child(root, "tab_bar_status"),
0, c->tab_bar_status);
diff --git a/tests/test_tab_bar.py b/tests/test_tab_bar.py
index af5e37e..8778fc8 100644
--- a/tests/test_tab_bar.py
+++ b/tests/test_tab_bar.py
@@ -1406,6 +1406,45 @@ def test_growing_back_restores_the_sidebar():
check("and the panes give the columns back", p["x"] >= W, str(p["x"]))
+def test_tab_bar_collapse_is_the_cutoff_said_outright():
+ """One number instead of an arithmetic: the sidebar is tab_bar_width wide
+ while at least N columns are left beside it, and the top row the moment
+ there are fewer -- no narrowing first, no third-of-the-screen rule."""
+ cut = _cfg(f'tab_bar_side "left"\ntab_bar_width {W}\ntab_bar_collapse 60\n')
+ with Session(SH, cols=W + 60, rows=20, config=cut) as s:
+ s.settle(30)
+ check(
+ "exactly N left: the sidebar keeps its edge",
+ s.snapshot().hit_at(CX, Y0) == "tab:1",
+ str(s.snapshot().hit_at(CX, Y0)),
+ )
+ check("...at the full width", s.pane(0)["x"] - 2 == W, str(s.pane(0)["x"]))
+ s.resize(W + 59, 20)
+ s.until(lambda snap: snap.hit_at(5, 1) == "tab:1")
+ check(
+ "one fewer: the top row",
+ s.snapshot().hit_at(5, 1) == "tab:1",
+ str(s.snapshot().hit_at(5, 1)),
+ )
+ check("and the panes get the columns", s.pane(0)["x"] < W, str(s.pane(0)["x"]))
+ # 50 columns: the automatic rule would narrow and keep the edge here
+ # (test_a_small_screen_narrows_the_sidebar_first); the knob does not.
+ s.resize(50, 20)
+ s.settle(30)
+ check(
+ "no narrowing in between",
+ s.snapshot().hit_at(5, 1) == "tab:1",
+ str(s.snapshot().hit_at(5, 1)),
+ )
+ s.resize(W + 60, 20)
+ s.until(lambda snap: snap.hit_at(CX, Y0) == "tab:1")
+ check(
+ "and back again",
+ s.pane(0)["x"] - 2 == W,
+ str(s.pane(0)["x"]),
+ )
+
+
if __name__ == "__main__":
test_left_sidebar_reserves_columns()
test_sidebar_rows_click_like_the_strip()
@@ -1466,4 +1505,5 @@ if __name__ == "__main__":
test_a_strip_that_could_not_hold_them_either_changes_nothing()
test_narrow_terminal_falls_back_to_top()
test_growing_back_restores_the_sidebar()
+ test_tab_bar_collapse_is_the_cutoff_said_outright()
sys.exit(report())