diff options
| author | user <user@clank> | 2026-08-17 14:22:38 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-17 14:22:38 +0200 |
| commit | ec91ccffe631ae34b111bf6161fd0e3c487f684c (patch) | |
| tree | 4a9fdbb720d9bf03edd5f538d1d87afd2bf51bfb /src/cmd.c | |
| parent | sl0ppty: clang-format, and a hook that runs it on what you staged (diff) | |
| download | slosh-ec91ccffe631ae34b111bf6161fd0e3c487f684c.tar.gz slosh-ec91ccffe631ae34b111bf6161fd0e3c487f684c.tar.xz slosh-ec91ccffe631ae34b111bf6161fd0e3c487f684c.zip | |
sl0ppty: clang-format the tree
The bumpy one. `make fmt` over every `.c` and `.h` outside `vendor/`: 32 files,
1,843 lines rewritten, no behaviour changed. Nothing here is worth reading -- the
next commit adds it to `.git-blame-ignore-revs` so `git blame` walks past it.
Two thirds of it is alignment the formatter now owns: trailing comments in a
struct, continuation lines under a signature. The rest is the hand-packed tables
opening up to one entry per line -- `ACTIONS`, `NAMED_KEYS`, `ACTION_HELP`. That
is a real loss of density and a real gain in diffs: adding an action was a reflow
of the block and is now one line. Anything worth keeping packed can be fenced with
`// clang-format off`; nothing was, on the grounds that a table is the thing a
formatter is for.
**One change is not formatting.** `src/config.h` had three trailing comments glued
onto one field:
uint16_t hover_delay_ms; /* how long the pointer must rest to arm a guide */
/* how long an announcement stays up */ /* rows per wheel notch */
-- `toast_ms`'s and `scroll_lines`' comments, landed on their neighbour by an
earlier edit, documenting the wrong things ever since. It is in this commit
because it is what caught it: clang-format could not settle on that line, wrapping
it one way and then re-indenting the wrap on a second pass, so `make fmt` was not
idempotent. The comments are back where they belong and it is.
Verified after the reformat, not before: `make clean && make all` is
warning-free, `make retest` is 1801 checks green, and `make fmt` twice in a row
changes nothing the second time. A formatter that alters behaviour would be worse
than none, so the gate was the whole suite rather than a reading of the diff.
Diffstat (limited to 'src/cmd.c')
| -rw-r--r-- | src/cmd.c | 53 |
1 files changed, 28 insertions, 25 deletions
@@ -21,21 +21,21 @@ size_t cmd_unescape(const char *in, uint8_t *out, size_t cap) { } p++; switch (*p) { - case 'e': out[n++] = 0x1b; break; - case 'n': out[n++] = '\n'; break; - case 'r': out[n++] = '\r'; break; - case 't': out[n++] = '\t'; break; - case '0': out[n++] = 0; break; - case '\\': out[n++] = '\\'; break; - case 'x': { - int hi = 0, lo = 0; - sscanf(p + 1, "%1x%1x", &hi, &lo); - out[n++] = (uint8_t)(hi * 16 + lo); - p += 2; - break; - } - case 0: return n; - default: out[n++] = (uint8_t)*p; break; + case 'e': out[n++] = 0x1b; break; + case 'n': out[n++] = '\n'; break; + case 'r': out[n++] = '\r'; break; + case 't': out[n++] = '\t'; break; + case '0': out[n++] = 0; break; + case '\\': out[n++] = '\\'; break; + case 'x': { + int hi = 0, lo = 0; + sscanf(p + 1, "%1x%1x", &hi, &lo); + out[n++] = (uint8_t)(hi * 16 + lo); + p += 2; + break; + } + case 0: return n; + default: out[n++] = (uint8_t)*p; break; } } return n; @@ -195,7 +195,8 @@ static char *cmd_json(app_t *a, screen_t *s, input_parser_t *in, uint32_t tid = (uint32_t)jv_geti(req, "tab", 0); bool rows = strcmp(jv_gets(req, "dir", "cols"), "rows") == 0; if (!tid) { - uint32_t made = app_move_pane_to_new_tab(a, pid, jv_gets(req, "name", "")); + uint32_t made = + app_move_pane_to_new_tab(a, pid, jv_gets(req, "name", "")); if (!made) return jerr("cannot move it to a tab of its own"); return jok_int("tab", (long long)made); } @@ -238,8 +239,8 @@ static char *cmd_json(app_t *a, screen_t *s, input_parser_t *in, uint32_t id = (uint32_t)jv_geti(req, "id", 0); const char *name = jv_gets(req, "name", ""); bool pane = strcmp(target, "pane") == 0; - bool ok = pane ? app_set_pane_name(a, id, name) - : app_set_tab_name(a, id, name); + bool ok = + pane ? app_set_pane_name(a, id, name) : app_set_tab_name(a, id, name); return ok ? jok_int(NULL, 0) : jerr(pane ? "no such pane" : "no such tab"); } if (strcmp(cmd, "set-purpose") == 0) { @@ -257,7 +258,8 @@ static char *cmd_json(app_t *a, screen_t *s, input_parser_t *in, if (strcmp(cmd, "dump-layout") == 0) { dump_layout_t o = {.tab = (uint32_t)jv_geti(req, "tab", 0), .base = jv_gets(req, "relative_to", NULL)}; - o.suspend = suspend_policy(jv_gets(req, "suspend", NULL), DUMP_SUSPEND_ASIS); + o.suspend = + suspend_policy(jv_gets(req, "suspend", NULL), DUMP_SUSPEND_ASIS); if (o.suspend < 0) return jerr("suspend is as-is, none, commands or all"); char *kdl = app_dump_layout(a, &o); if (o.tab && !o.tabs) { @@ -280,9 +282,9 @@ static char *cmd_json(app_t *a, screen_t *s, input_parser_t *in, const char *text = jv_gets(req, "kdl", NULL); bool replace = jv_getb(req, "replace", false); char err[256] = {0}; - bool ok = text ? app_apply_layout_text(a, text, replace, err, sizeof err) - : path ? app_apply_layout_file(a, path, replace, err, sizeof err) - : false; + bool ok = text ? app_apply_layout_text(a, text, replace, err, sizeof err) + : path ? app_apply_layout_file(a, path, replace, err, sizeof err) + : false; if (!ok) return jerr(err[0] ? err : "need a path or kdl"); app_resize(a, s->cols, s->rows); s->force_full = true; @@ -368,8 +370,8 @@ static char *cmd_json(app_t *a, screen_t *s, input_parser_t *in, return jok_int("closed", (long long)n); } if (strcmp(cmd, "save-workspace") == 0) { - int suspend = suspend_policy(jv_gets(req, "suspend", NULL), - DUMP_SUSPEND_COMMANDS); + int suspend = + suspend_policy(jv_gets(req, "suspend", NULL), DUMP_SUSPEND_COMMANDS); if (suspend < 0) return jerr("suspend is as-is, none, commands or all"); app_workspace_save_t w; char err[256] = {0}; @@ -523,7 +525,8 @@ char *cmd_exec(app_t *a, screen_t *s, input_parser_t *in, const char *line, return app_tabs_json(a); } if (strcmp(verb, "dump-layout") == 0) { - app_compose(a, s); /* the layout is a function of the frame: compose first */ + app_compose(a, + s); /* the layout is a function of the frame: compose first */ return app_dump_layout(a, NULL); } /* The bare forms the harness and a person at a shell use. Same functions, so |
