aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-15 15:21:24 +0200
committeruser <user@clank>2026-08-15 15:21:24 +0200
commit8379c0e7e92eb31a351e5023a1364ec8e95b402c (patch)
tree4e2628719f15123b93fe036fdf830e77d71c70d6 /src/config.c
parentsl0ppty: dim the panes you are not in, and a knob to say how much (diff)
downloadslosh-8379c0e7e92eb31a351e5023a1364ec8e95b402c.tar.gz
slosh-8379c0e7e92eb31a351e5023a1364ec8e95b402c.tar.xz
slosh-8379c0e7e92eb31a351e5023a1364ec8e95b402c.zip
sl0ppty: only panes that were given a command keep their corpse
Keeping every dead pane was too much. Split off a shell, do something in it, type `exit` -- and you are left with a corpse to dismiss, which is fussiness rather than information. You know what happened. You did it. So the policy has a line now, and the line is the *command*, not who made the pane. A pane told to run `npm run dev` is part of the session's shape: when it dies you want the error it left and the button that runs it again. A pane that is a shell is finished when you say so. Not provenance, because a shell is a shell whether a layout file made it or C-a \ did -- and that also means a session restored from dump-layout behaves like the one it was dumped from, since the dump writes `command=` only for panes that had one. The distinguishing mark turned out to need no new state: pane_label() already holds the command a layout gave it and is empty for a plain shell, so this is a policy over something already recorded. `keep_dead` is now `commands` (default), `all` or `none`, and still reads `true`/`false` as `all`/`none` -- that was the shipped spelling and a config saying it should keep working rather than quietly changing behaviour. Most of the diff is tests. The dead-pane suite had been written against the session's own pane, which is a shell under the new rule, so it was testing the half of the policy that now says "reap it". They run commanded panes from layouts instead, and the pair of cases -- a shell you split off goes, a commanded pane stays -- sits together in one place so the rule is legible in the test file too. One of those layouts wanted an escape sequence, which has to be written `\\033` so KDL's unescaping hands `\033` to the shell. Written singly the shell prints `033[38;2;...` and the test reads as "the colour stopped working".
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c
index 71dbb49..f4076b7 100644
--- a/src/config.c
+++ b/src/config.c
@@ -234,7 +234,7 @@ void config_defaults(config_t *c) {
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;
+ c->keep_dead = KEEP_DEAD_COMMANDS;
/* Gentle: an unfocused pane is one you are still reading half the time.
* At 60 white text lands on #c3c3c3, which reads as "not this one" without
* reading as "not available". */
@@ -654,7 +654,21 @@ bool config_load(config_t *c, const char *path, char *err, size_t errcap) {
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);
+ {
+ /* `commands` (the default), `all`, or `none`. `true`/`false` are taken as
+ * `all`/`none`, because that is what they used to mean here and a config
+ * that still says so should keep working rather than silently changing
+ * behaviour. */
+ const char *kd = kdl_arg(kdl_child(root, "keep_dead"), 0, NULL);
+ if (kd) {
+ if (!strcmp(kd, "all") || !strcmp(kd, "true")) c->keep_dead = KEEP_DEAD_ALL;
+ else if (!strcmp(kd, "none") || !strcmp(kd, "false"))
+ c->keep_dead = KEEP_DEAD_NONE;
+ else if (!strcmp(kd, "commands")) c->keep_dead = KEEP_DEAD_COMMANDS;
+ else if (err && !err[0])
+ snprintf(err, errcap, "keep_dead: %s (want commands, all or none)", kd);
+ }
+ }
{
long v = kdl_arg_int(kdl_child(root, "dim_unfocused"), 0, c->dim_unfocused);
c->dim_unfocused = (uint8_t)(v < 0 ? 0 : v > 255 ? 255 : v);