summaryrefslogtreecommitdiff
path: root/src/host/state_files.zig
Commit message (Collapse)AuthorAge
* The tree describes itself: README and commands from the tables; ctl takes ↵Gabriel Schneider6 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | input live README is made at each open from the tables (pinned per open, as the traces are): a line a file from control.zig's `files`, ctl's verbs indented under ctl (ctl's own, the script's input verbs, the console's, each with its args and doc from its row), and a line per State file under state/, from the layout (its path with <n> for an index, its type, an enum's tags, a row's length), in the shape cloud9's `help` reads: `help ctl` prints the verbs, `help state/tracker` the state/ line and every file under it. `commands` is the verb lines alone, unindented, the sketch's own words (App.commands) last. A ctl read points at both. ctl takes the script's input verbs live: click, move, down, up, wheel, wheel-x, cancel, key, hold, release, type route their events at the wall clock through script.input, the same code a script runs, with no frame of their own: the next frame feeds them to update. Order: ctl's own words, then the input verbs, then a console line (and through it the sketch's); so a sketch command named like an input verb is shadowed over ctl (none is today). Tests: test-control, a new test: ctl's click and hold reach the pending events, a short click is refused (ExpectedPoint), README and commands read the rows and the layout: 40/40 steps, 10/10 tests. Live with the replay fixture: README read over 9P, `down 5 5` written to ctl moved state/pressing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* The State as files: state/ in the 9P tree, a directory per struct and arrayGabriel Schneider6 hours
state/ serves the running sketch's State nested: a directory per struct and per array, a file per value, state/tracker/songs/3/bpm. A read is the value as get shows it, and a newline; a write is the console's set with the file's path (control.zig builds `set tracker.songs[3].bpm 90` and runs it through runLine, so it stops a replay, logs, marks a jump and notes the line like any set). Numbers, bools and enums are written; optionals, unions and the like read as `<N bytes>` and refuse writes. An array of scalars (a vector's lanes, talk.text) is one file of its values, blank-separated; an array of arrays is a directory of such rows (grid/1 for grid[1] of a [2][3]i16). So a file is one value or one row, the run of values one set names, and stays the size of a row however large the array; and paths keep the State's own shape. An array of structs is a directory of indices: drat-meout's patterns, 8x16x16x4 of {pitch, velocity}, are state/tracker/songs/<n>/patterns/<n>/<n>/<n>/ pitch, reached by walking, listed a dimension at a time. state_files.zig does the walking from a (Layout, bytes) alone: lookup, readdir, read, the set path and a README line per file, so the save's newest State and a sketch's defaults can be served the same way. A node is the layout's first leaf under it, its depth and the element's offset, with bit 62 set (bit 63 stays the sketch's). A node a reload made stale is refused, "StateLayoutChangedWalkAgain". fields.setRow sets a row from its words, all or none, and the console's set takes it: `set talk.text 104 105 0`. The engine keeps names up to 64 bytes (from 28), for long field names. Tests: test-control (now also "the State as files" and "a row of scalars"): 40/40 steps, 9/9 tests. Live, headless, the replay fixture over plan9port 9p: ls state, read and write dots/buffer/3/kind and the position vector, a bad value refused as InvalidValue. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T