aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-15 11:39:12 +0200
committeruser <user@clank>2026-08-15 11:39:12 +0200
commit56bbd25f246f95d15dca992fa79328b37d515afe (patch)
tree3eb984a1e51c9cc30ee9bf394e14adcce049ffec /src
parentsl0ppty: modals get their own surface, and dim what is behind them (diff)
downloadslosh-56bbd25f246f95d15dca992fa79328b37d515afe.tar.gz
slosh-56bbd25f246f95d15dca992fa79328b37d515afe.tar.xz
slosh-56bbd25f246f95d15dca992fa79328b37d515afe.zip
sl0ppty: the prefix badge names the key you actually bound
The leader has been configurable since M6 -- `keys { prefix "ctrl+b" }` -- and one place had not been told. The badge in the status bar, the indicator whose entire job is to say "you are in prefix mode", was the literal string "C-a" whatever you had configured. That is worse than not having the setting. A prefix you can change and a UI that keeps naming the old one teaches you to distrust the thing telling you which mode you are in, and it is precisely the person who rebound it -- the one who wanted C-a back for start-of-line -- who gets lied to. It renders the binding now, through the same function the cheatsheet uses, so the two cannot disagree. Measured rather than assumed to be three columns wide, because `C-space` is seven and `M-\`` is three of a different width. tests/test_prefix.py holds the whole story in one place: four prefixes, each shown correctly in the badge; the rebound key running commands; the *old* key going through to the program untouched (checked with `cat -v`, so a control byte arriving is visible as ^A rather than an invisible character that would prove nothing); the double-press still sending the key itself; and the cheatsheet agreeing with the badge. Also said it out loud in the README and the config, since the way this came up was somebody reasonably assuming it was not possible.
Diffstat (limited to 'src')
-rw-r--r--src/app.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/app.c b/src/app.c
index 213dc53..297bf00 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2623,10 +2623,19 @@ static void draw_tab_strip(app_t *a, screen_t *s) {
screen_text(s, (uint16_t)(right - iw), y, info, TAB_COUNT, NO_COLOR, 0);
right = (uint16_t)(right - iw - 1);
}
- if (a->prefix && right > 5) { /* the prefix is a mode: say so */
- screen_text(s, (uint16_t)(right - 3), y, "C-a", PREFIX_FG, PREFIX_BG,
- ATTR_BOLD);
- right = (uint16_t)(right - 4);
+ if (a->prefix) { /* the prefix is a mode: say so, and say which key */
+ /* Rendered from the binding rather than written out, because it was
+ * written out: the badge said "C-a" whatever you had configured, which is
+ * the one place a rebound prefix could still lie to you. Measured too --
+ * a prefix is not always three columns wide (`C-space`, `M-\``). */
+ char pfx[24];
+ config_chord_name(CFG.prefix_key, CFG.prefix_mods, pfx, sizeof pfx);
+ uint16_t pw = cells(pfx);
+ if (right > pw + 2) {
+ screen_text(s, (uint16_t)(right - pw), y, pfx, PREFIX_FG, PREFIX_BG,
+ ATTR_BOLD);
+ right = (uint16_t)(right - pw - 1);
+ }
}
for (size_t i = 0; i < a->ntabs && x < right; i++) {