aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.c
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-15 13:21:35 +0200
committeruser <user@clank>2026-08-15 13:21:35 +0200
commitd24a07a6048e6d6416e97a26483739bdd879e01b (patch)
tree764a08f255aeaa71fa8fbdc6bad7fa1b9835171f /src/app.c
parentsl0ppty: write the session back out as a layout, and a loop that uses it (diff)
downloadslosh-d24a07a6048e6d6416e97a26483739bdd879e01b.tar.gz
slosh-d24a07a6048e6d6416e97a26483739bdd879e01b.tar.xz
slosh-d24a07a6048e6d6416e97a26483739bdd879e01b.zip
sl0ppty: say which build you are talking to
The middle of the status line is empty unless the pointer is on something, which is most of the time. It says which sl0ppty this is now. That reads as decoration and is not. A session keeps the binary it started with, so after a rebuild there are two versions in play: the one on disk and the one you are attached to. This session has been dogfooding sl0ppty for a while, and "which build is this?" has already been the answer to two bugs that looked like something else -- once when a config reload appeared to do nothing, and once when kitty graphics were fixed and still broken on screen. The banner answers it without asking, and `sl0ppty --version` answers for the binary, from the same string. The version is baked in by the Makefile from `git describe --always --dirty`, into a generated header that is only rewritten when the value changes -- so a commit rebuilds and a second `make` does nothing. It takes the hint's slot and yields to it: a hint is about what you are doing right now, the banner is about always, and it comes back the moment the pointer moves off. Both give way to the ends of the line, which was already the rule for hints and is why a narrow terminal loses the middle rather than its session name. `version_banner false` for anyone who finds it noisy; it is a separate knob from `hints`, and the tests hold both directions of that.
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/app.c b/src/app.c
index c9ba927..5c6d7f4 100644
--- a/src/app.c
+++ b/src/app.c
@@ -12,6 +12,7 @@
#include <string.h>
#include "json.h"
+#include "version.h"
#include "graphics.h"
#include "kdl.h"
@@ -610,22 +611,34 @@ static void draw_status_line(app_t *a, screen_t *s) {
if (n > (size_t)(right - x)) line[right - x] = 0;
if (n) screen_text(s, x, y, line, STATUS_C, NO_COLOR, 0);
- /* The hint sits in what is left between the two ends, centred there rather
- * than in the row: centring it in the row would put it under the session
- * name on a narrow screen, and a hint that overwrites what it is explaining
- * is worse than no hint. It is simply not drawn when it does not fit. */
- if (!CFG.hints || !a->painted) return;
- const char *hint = hint_for(a, hit_test(&s->hits, a->ptr_x, a->ptr_y));
- if (!hint || !a->ptr_valid) return;
+ /* What goes between the two ends: the hint for whatever the pointer is on,
+ * and when there is none, which sl0ppty this is. The hint wins because it is
+ * about right now and the banner is about always; the banner takes the slot
+ * back the moment the pointer moves off, which is most of the time.
+ *
+ * Centred in what is *left* rather than in the row: centring it in the row
+ * would put it under the session name on a narrow screen, and either of
+ * these overwriting what it sits next to is worse than not being drawn. */
+ const char *middle = NULL;
+ color_t middle_fg = HINT_C;
+ if (CFG.hints && a->painted && a->ptr_valid)
+ middle = hint_for(a, hit_test(&s->hits, a->ptr_x, a->ptr_y));
+ if (!middle && CFG.version_banner) {
+ /* Quieter than a hint: this is ambient, and a hint is an answer to
+ * something you are doing. */
+ middle = "sl0ppty " SL0PPTY_VERSION;
+ middle_fg = STATUS_C;
+ }
+ if (!middle) return;
uint16_t used = (uint16_t)(x + cells(line));
uint16_t from = (uint16_t)(used + 2);
if (right <= from) return;
uint16_t span = (uint16_t)(right - from);
- uint16_t hw = cells(hint);
+ uint16_t hw = cells(middle);
if (hw + 2 > span) return;
- screen_text(s, (uint16_t)(from + (span - hw) / 2), y, hint, HINT_C, NO_COLOR,
- 0);
+ screen_text(s, (uint16_t)(from + (span - hw) / 2), y, middle, middle_fg,
+ NO_COLOR, 0);
}
static void draw_toasts(app_t *a, screen_t *s) {