diff options
| author | user <user@clank> | 2026-08-14 22:26:30 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-14 22:26:30 +0200 |
| commit | 83f569c162e94609f35a33eb126af4244aa5f68f (patch) | |
| tree | f0404ecf1cfa850423a3c25036ad4f416859b78e | |
| parent | sl0ppty: shaders can be loaded from shared libraries (diff) | |
| download | slosh-83f569c162e94609f35a33eb126af4244aa5f68f.tar.gz slosh-83f569c162e94609f35a33eb126af4244aa5f68f.tar.xz slosh-83f569c162e94609f35a33eb126af4244aa5f68f.zip | |
sl0ppty: the new-tab button is a bare +, and yours to choose
It read "+tab" because of this, in the code, right above it:
Not a bare "+": the frame already has one, for splitting a pane. Two
verbs that look identical is a UI bug the fork shipped and noticed.
That was true when it was written and has not been since f2f3d67, which
removed the frame's "+" when the border became the button. The collision it
was avoiding no longer exists, and the word was left explaining itself to
nobody -- while every other affordance in this UI is a bare mark: _ # x on a
frame, and a hint under the pointer for anyone who wants the word.
So: "+", padded to three cells, because their own comment applies -- a
one-cell target is a thing you miss with a mouse.
Also configurable, as `newtab_mark`, which it should have been already: it
was the only mark here that was not (zoom_mark, zoom_on_mark, close_mark,
min_mark, bell_mark all are). Try "[+]" or "new" if you disagree; a session
picks it up on save.
Four tests were asserting the literal "+tab". Three of them only needed the
new string, but two were using it to *locate* the button -- bar.index("+tab")
-- which is exactly the mistake of asserting something incidental: what the
button says is now config, and a test that spells it out fails the day
somebody changes their mind. They look it up through the hit list now, which
is what they meant.
test_no_more_plus keeps the invariant that makes the bare mark safe, and now
says so: there is exactly one "+" in the UI, so it means one thing. If one
ever returns to a frame, that button needs its word back.
| -rw-r--r-- | DESIGN.md | 2 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | config/config.kdl | 9 | ||||
| -rw-r--r-- | src/app.c | 28 | ||||
| -rw-r--r-- | src/config.c | 3 | ||||
| -rw-r--r-- | src/config.h | 3 | ||||
| -rw-r--r-- | tests/test_config.py | 2 | ||||
| -rw-r--r-- | tests/test_finder.py | 9 | ||||
| -rw-r--r-- | tests/test_hints.py | 2 | ||||
| -rw-r--r-- | tests/test_split_ux.py | 9 | ||||
| -rw-r--r-- | tests/test_tabs.py | 2 |
11 files changed, 53 insertions, 18 deletions
@@ -189,7 +189,7 @@ reading* plus *a strip of small ones you are watching*. because a stack of headers *is* the monitored strip: ``` - 1 2 +tab 5 panes + 1 2 + 5 panes pi · ready─────────────────────────────────────────── pi · ready─────────────────────────────────────────── pi · ready─────────────────────────────────────────── @@ -66,7 +66,7 @@ connection goes away. Reattach with the same command. - **Drag a pane by its title** onto another to swap them. Everything it could land on greys out; the pane in your hand does not. - **Double-click a pane's title to rename it**, in place. -- Click a tab to switch, `+tab` to open one, a pane to focus it. +- Click a tab to switch, `+` to open one, a pane to focus it. - Hovering anything says what it does, in a word at the bottom of the screen. ### Panes do not vanish when a command ends diff --git a/config/config.kdl b/config/config.kdl index ac99e19..1bc866c 100644 --- a/config/config.kdl +++ b/config/config.kdl @@ -77,6 +77,13 @@ zoom_on_mark "*" close_mark "x" min_mark "_" +// The new-tab button at the end of the tab strip. Drawn with a space on each +// side, so a one-character mark is still a three-cell target -- a one-cell +// target is a thing you miss with a mouse. It reads as a bare "+" because +// nothing else in the UI is one: the frame's old "+" for splitting went when +// the border became the button. Try "[+]" or "new" if you prefer a word. +newtab_mark "+" + // A pane whose program exits stays where it is, keeping everything it // printed, with a line in its own backlog saying why it ended and two buttons // in its frame: [re-run] to run the same command again in the same pane and @@ -98,7 +105,7 @@ bell_indicator true // \u escape, so put the character itself here.) bell_mark "•" -// The one-row bar with tabs, the +tab button and the pane count. +// The one-row bar with tabs, the new-tab button and the pane count. status_bar true // The line along the bottom: which session and tab you are in, what the @@ -2559,14 +2559,28 @@ static void draw_tab_strip(app_t *a, screen_t *s) { x = (uint16_t)(x + w); } - /* Not a bare "+": the frame already has one, for splitting a pane. Two - * verbs that look identical is a UI bug the fork shipped and noticed. */ - if (x + 6 < right) { - uint16_t w = screen_text(s, x, y, " +tab ", TAB_IDLE, NO_COLOR, 0); - if (ptr_on(a, x, y, w, 1)) - screen_text(s, x, y, " +tab ", TAB_HOVER, NO_COLOR, ATTR_BOLD); - hit_add(&s->hits, x, y, w, 1, "newtab"); + /* A bare mark, spaced like the frame's own buttons rather than spelled out. + * It used to read "+tab", because a pane frame carried a "+" for splitting + * and two verbs that look identical is a UI bug the fork shipped. That "+" + * went when the border became the button, so the collision it was avoiding + * no longer exists and the word was left explaining itself to nobody. + * + * Padded to three cells for the same reason the frame's buttons are: a + * one-cell target is a thing you miss with a mouse. What it does is said by + * the hint under the pointer, which is where every other one-character + * affordance here says it. */ + { + char btn[24]; + snprintf(btn, sizeof btn, " %s ", CFG.newtab_mark); + uint16_t bw = (uint16_t)(cells(CFG.newtab_mark) + 2); + if (bw > 2 && x + bw <= right) { + uint16_t w = screen_text(s, x, y, btn, TAB_IDLE, NO_COLOR, 0); + if (ptr_on(a, x, y, w, 1)) + screen_text(s, x, y, btn, TAB_HOVER, NO_COLOR, ATTR_BOLD); + hit_add(&s->hits, x, y, w, 1, "newtab"); + } } + } /* The space between two of a split's children, or false if they are flush. diff --git a/src/config.c b/src/config.c index 2b80a18..80d9936 100644 --- a/src/config.c +++ b/src/config.c @@ -177,6 +177,7 @@ void config_defaults(config_t *c) { snprintf(c->zoom_on_mark, sizeof c->zoom_on_mark, "*"); snprintf(c->close_mark, sizeof c->close_mark, "x"); snprintf(c->min_mark, sizeof c->min_mark, "_"); + snprintf(c->newtab_mark, sizeof c->newtab_mark, "+"); c->bell_indicator = true; snprintf(c->bell_mark, sizeof c->bell_mark, "\u2022"); c->keep_dead = true; @@ -400,6 +401,8 @@ bool config_load(config_t *c, const char *path, char *err, size_t errcap) { if (cm) snprintf(c->close_mark, sizeof c->close_mark, "%s", cm); const char *mm = kdl_arg(kdl_child(root, "min_mark"), 0, NULL); if (mm) snprintf(c->min_mark, sizeof c->min_mark, "%s", mm); + const char *nt = kdl_arg(kdl_child(root, "newtab_mark"), 0, NULL); + if (nt) snprintf(c->newtab_mark, sizeof c->newtab_mark, "%s", nt); c->keep_dead = kdl_arg_bool(kdl_child(root, "keep_dead"), 0, c->keep_dead); c->bell_indicator = kdl_arg_bool(kdl_child(root, "bell_indicator"), 0, c->bell_indicator); diff --git a/src/config.h b/src/config.h index f8b799c..4be4ae0 100644 --- a/src/config.h +++ b/src/config.h @@ -97,6 +97,9 @@ typedef struct { * whitespace to the gap beside it and looks further away than its * neighbours, which is what an en dash did here. */ char zoom_mark[16], zoom_on_mark[16], close_mark[16], min_mark[16]; + /* The new-tab button at the end of the strip. Drawn with a space each side, + * so a one-character mark is still a three-cell target. */ + char newtab_mark[16]; bool bell_indicator; /* What to draw. A short string rather than a fixed glyph: the obvious * choice is an emoji bell, and emoji are drawn two columns wide by many diff --git a/tests/test_config.py b/tests/test_config.py index 44447e0..8e029f8 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -225,7 +225,7 @@ def test_status_line_says_what_you_are_looking_at(): # session's (see test_the_two_pane_counts_answer_different_questions). # What it must not do is restate the strip itself. check("and is not a second copy of the tab strip", - "+tab" not in bottom, repr(bottom)) + "pane 1/2" in bottom and "1:api" not in bottom, repr(bottom)) ids = [p["id"] for p in s.panes()] s.api("focus", id=ids[1]) diff --git a/tests/test_finder.py b/tests/test_finder.py index cb421e9..fa6e1d4 100644 --- a/tests/test_finder.py +++ b/tests/test_finder.py @@ -17,9 +17,12 @@ def test_status_bar(): snap = s.snapshot() bar = snap.line(1) check("the bar shows a pane count", "1 pane" in bar, repr(bar)) - check("the bar shows a new-tab button", "+tab" in bar, repr(bar)) - - x = bar.index("+tab") + # Found through the hit list rather than by its label: what the + # button says is the config's business (`newtab_mark`), and a test + # that spells it out fails the day somebody changes their mind. + btn = [h for h in snap.hits if h["action"] == "newtab"] + check("the bar shows a new-tab button", len(btn) == 1, str(snap.hits)) + x = btn[0]["x"] + 1 check("the new-tab button is clickable", snap.hit_at(x, 1) == "newtab", str(snap.hit_at(x, 1))) s.click(x, 1) diff --git a/tests/test_hints.py b/tests/test_hints.py index 4f6a5d6..e3d2dc7 100644 --- a/tests/test_hints.py +++ b/tests/test_hints.py @@ -95,7 +95,7 @@ def test_the_gap_and_the_strip_and_the_bar(): repr(bar(s))) n = hit(s, "newtab") hover(s, n["x"] + 1, n["y"]) - check("+tab offers a new one", "new tab" in bar(s), repr(bar(s))) + check("the new-tab button offers a new one", "new tab" in bar(s), repr(bar(s))) s.send(r"\x01m") s.settle(20) diff --git a/tests/test_split_ux.py b/tests/test_split_ux.py index 220a88f..e1b9942 100644 --- a/tests/test_split_ux.py +++ b/tests/test_split_ux.py @@ -48,14 +48,19 @@ def click(s, x, y): def test_no_more_plus(): + """The frame carries no `+`, which is what lets the strip's new-tab button + *be* a bare `+`: there is exactly one of them in the UI, so it means one + thing. If a `+` ever returns to a frame, that button needs its word back. + """ with Session(SH, cols=60, rows=14, config=FAST) as s: s.settle() snap = s.snapshot() p = s.pane() check("the frame has no split button any more", "+" not in snap.line(p["y"]), repr(snap.line(p["y"]))) - check("the status bar still has its own, different one", - "+tab" in snap.line(1), repr(snap.line(1))) + check("the status bar still has its own new-tab button", + any(h["action"] == "newtab" and h["y"] == 1 for h in snap.hits), + repr(snap.line(1))) # The frame does spend columns again -- six of them, on the zoom and # close buttons -- but on two verbs that a single glyph *can* encode. # The split button was removed because one glyph cannot mean four diff --git a/tests/test_tabs.py b/tests/test_tabs.py index 2b5b6d6..255d8ac 100644 --- a/tests/test_tabs.py +++ b/tests/test_tabs.py @@ -214,7 +214,7 @@ def test_hovering_the_strip_lights_what_is_under_the_pointer(): with Session(SH, cols=80, rows=14, layout=lay) as s: s.settle(20) hits = strip_hits(s.snapshot()) - check("the strip has two tabs and a +tab", len(hits) == 3, str(hits)) + check("the strip has two tabs and a new-tab button", len(hits) == 3, str(hits)) active_id = "tab:" + str(s.tabs()[0]["id"]) for target, h in hits.items(): |
