aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-16 11:12:20 +0200
committeruser <user@clank>2026-08-16 11:12:20 +0200
commita4e09657ca89fe3cc553ec894e3776abfd4a3e99 (patch)
treeacc330c10f38882e139731052c7964b259a3e826 /src
parentsl0ppty: a pane can set its own shaders (diff)
downloadslosh-a4e09657ca89fe3cc553ec894e3776abfd4a3e99.tar.gz
slosh-a4e09657ca89fe3cc553ec894e3776abfd4a3e99.tar.xz
slosh-a4e09657ca89fe3cc553ec894e3776abfd4a3e99.zip
sl0ppty: a prompt with a memory
`contrib/shader-repl` imports readline, which is most of it: editing, up/down, ctrl-r, and history kept between runs in `$XDG_DATA_HOME/sl0ppty/shader-repl.history`. Chains only -- a `:` command is taken back out of the history it would otherwise fill, because pressing up four times past `:quit` and `:paste` to reach the line you were working on is the annoyance history exists to remove. Tab completes the commands, the nine shader names, the property keys, the two rects, the three channels, and the expression language's own variables and functions. `:help` prints the lot at once, which is the same list from the same place. That list is a claim about what exists, so `tests/test_shader_repl.py` checks it against `src/shader.c` and `src/expr.c` and fails if either grows a name it does not have -- verified by removing `spotlight` and watching it fail. Then it types every name it offers at a real prompt and requires `ok` from a real session, because a name that completes and does not parse is a lie with a keystroke attached. History across two runs, a tab completion, and `:help` are driven the same way, through a pty. Two things that cost me time and are now written down where they bite: keys go into a pane escaped (`\r`, `\t`, `\e[A`) because `raw` takes the rest of one command line and a literal newline ends the command instead of arriving; and Enter is CR, which is what a terminal sends and what readline waits for. Also: **a bare argument on a shader entry is now a complaint.** Every parameter is a property, so `tint color="#000000" spotlight` is not a pass with a spare word, it is a missing `;` -- KDL reads one node, the second name does nothing, and the session used to answer `ok`. It now says `unexpected argument for tint: spotlight (separate entries with ';')`. Found by watching the prompt get used.
Diffstat (limited to 'src')
-rw-r--r--src/config.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 4d75658..70667ba 100644
--- a/src/config.c
+++ b/src/config.c
@@ -252,6 +252,17 @@ static bool parse_shader_entry(const kdl_node_t *k, color_t default_color,
expr_prog_t **expr, char *why, size_t whycap) {
*expr = NULL;
+ /* Every parameter a shader takes is a property, so a bare argument is not a
+ * thing we ignore -- it is a `;` somebody left out. `tint color="#000000"
+ * spotlight` reads to a person as two passes and to KDL as one node with a
+ * spare word, and answering "ok" to that is how you spend ten minutes
+ * wondering why the second one does nothing. */
+ if (k->nargs) {
+ snprintf(why, whycap, "unexpected argument for %s: %s (separate entries with `;`)",
+ k->name, kdl_arg(k, 0, ""));
+ return false;
+ }
+
/* Where this pass runs. Dropped rather than defaulted when the word is not
* one we know, for the same reason a bad `amount` is: the entry says what it
* wants and we cannot do it, and running it over the contents because "chrom"