aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.c
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-14 16:42:38 +0200
committeruser <user@clank>2026-08-14 16:42:38 +0200
commit93d9ed9863cd509950fb8beae66d40d37288004d (patch)
treede0b21eb503693aa01079129a543d536962538d2 /src/app.c
parentsl0ppty: a status line along the bottom (diff)
downloadslosh-93d9ed9863cd509950fb8beae66d40d37288004d.tar.gz
slosh-93d9ed9863cd509950fb8beae66d40d37288004d.tar.xz
slosh-93d9ed9863cd509950fb8beae66d40d37288004d.zip
sl0ppty: the status line counts this tab's panes
The strip along the top counts every pane in the session, which is the right number for a strip that lists every tab. It is the wrong number for "how big is the thing I am working in", and nothing answered that. So the line along the bottom carries its own count, of this tab only. The two disagree as soon as there is more than one tab, which is the point of having both — and the test says so directly rather than checking each in isolation. It sits hard against the right edge with the pane's state inboard of it, which is the order the strip above already uses for its own pair: the number is always there, the mode only sometimes, and a thing that comes and goes should not shove a thing that does not. Both counts now say "1 pane" rather than "1 panes". The top has been ungrammatical since it was written and a test had faithfully pinned it that way; adding a second place to say it made that worth fixing rather than copying. One of my own tests had to go: it asserted the bottom line contained no pane count at all, on the reasoning that the top already had one. That was right when it was written and is exactly what this change reverses, so it now checks the thing that is still true — the bottom line is not a second copy of the tab strip.
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/app.c b/src/app.c
index 7daa7cc..c013ed2 100644
--- a/src/app.c
+++ b/src/app.c
@@ -270,6 +270,8 @@ size_t app_toast_count(app_t *a) {
return a->ntoasts;
}
+static size_t count_leaves(node_t *n); /* defined with the layout */
+
/* The line along the bottom: what you are looking at, rather than what you
* could switch to. The strip along the top already answers "which tab" and
* "how many panes"; repeating that here would spend a row saying it twice.
@@ -288,7 +290,24 @@ static void draw_status_line(app_t *a, screen_t *s) {
node_t *f = a->ntabs ? cur(a)->focus : NULL;
/* Right side first, so a long name can never push the state off the end —
- * the same budgeting rule the tab strip and the pane frame both use. */
+ * the same budgeting rule the tab strip and the pane frame both use.
+ *
+ * The count goes hard against the edge with the state inboard of it, which
+ * is how the strip above orders its own pair: the number is always there,
+ * the mode only sometimes, and a thing that comes and goes should not move
+ * a thing that does not. This count is *this tab's*; the strip above counts
+ * the whole session, which is why they can disagree. */
+ if (a->ntabs && cur(a)->root) {
+ char cnt[32];
+ size_t np = count_leaves(cur(a)->root);
+ snprintf(cnt, sizeof cnt, "%zu pane%s", np, np == 1 ? "" : "s");
+ uint16_t cw = (uint16_t)strlen(cnt);
+ if (right > x + cw + 2) {
+ screen_text(s, (uint16_t)(right - cw), y, cnt, FRAME_IDLE, NO_COLOR, 0);
+ right = (uint16_t)(right - cw - 1);
+ }
+ }
+
char ind[64] = {0};
if (f) {
if (pane_suspended(f->pane)) {
@@ -1864,7 +1883,8 @@ static void draw_tab_strip(app_t *a, screen_t *s) {
* same budgeting rule as the split button and the OSC buttons. */
uint16_t right = (uint16_t)(s->cols - CFG.gap * CFG.gap_aspect);
char info[64];
- snprintf(info, sizeof info, "%zu panes", app_pane_count(a));
+ size_t np = app_pane_count(a);
+ snprintf(info, sizeof info, "%zu pane%s", np, np == 1 ? "" : "s");
uint16_t iw = (uint16_t)strlen(info);
if (right > iw + 4) {
screen_text(s, (uint16_t)(right - iw), y, info, FRAME_IDLE, NO_COLOR, 0);