summaryrefslogtreecommitdiff
path: root/src/host/script.zig
Commit message (Collapse)AuthorAge
* script: a key carries the modifiers `hold` has down, as a window's doesGabriel Schneider7 hours
| | | | | | | | | | | | | A window's key event carries the modifiers held as it happened in its `value` (Host.zig, `modifiers(event.key.mod)`), and a sketch reads chords from there (examples/live: Alt-o, helix's node walk). A script's `key` (and a 9P ctl's `input key`) left `value` 0, so `hold left_alt` then `key o` was a plain o to the sketch: the chord could not be scripted. `key` now carries what `hold` has down, as `click` and the other pointer verbs already did in their `flags`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* One verb table: the flags, the console's, the script's and ctl's words are rowsGabriel Schneider7 hours
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Six hand-kept lists said one vocabulary: root.zig's parser, its usage and its header; the console's completion list, its help strings and the execute chain; Host.zig's list of lines that do not move State; the script's header comment and its step chain; control.zig's names and its magic node numbers. Now each is a table, and the parser, the help, the completion and the dispatch read it. - root.zig: `Flag`, an enum, and `flags`, a row each (arg, doc): the loop looks the word up, takes its argument when the row names one, and a switch sets what it means; `usage` is made from the rows at compile time (the same text, and a line for --help). Errors say the flag and what it needs. - Console.zig: `Verb` and `verbs`, a row each (args, doc, moves_state): execute is a switch on the verb, a line whose first word is none goes to the sketch as before; Tab completes from the rows (a verb, and with each lowercase word its first argument may be: `seek start`); `help` prints the rows wrapped to the log's width, `help VERB` its line. - Host.zig: movesState asks the row; a sketch's command moves State. - script.zig: `Verb` and `verbs` (args, doc, frame, input): step is a switch, a row with `frame` is followed by one; the input verbs are `input`, which a 9P ctl will call live. - control.zig: `File` and `files` (mode, doc), a node being its number (the same numbers); `Verb` and `verbs` for ctl's own two words. Behaviour is unchanged but for help's text, completion's list (the same words, and `timing`, `play`, `seek`... alone) and errors' words. The diff adds more than it deletes (+630 -521): the rows carry a line of doc for every verb, which nothing had before. Tests: test-control, test-timing, test-setup, test-same, test-kill, test-past, test-import, test-paths: 70/70 steps, 29/29 tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* host.newSound: samples a sketch made become a sound, played by voicesGabriel Schneider7 hours
| | | | | | | | | | | | | | | | | | | | | | | A sketch that synthesised a one-shot had to stream it (and keep a replay from re-firing it by hand) or encode a WAV for decodeSound. host.newSound (samples) copies mono samples at in.sample_rate into the host and gives an Audio like a loaded one, so the one-shot is a voice: reconciled by key and serial, mixed, faded and limited by the host. It is kept for the life of the host like every sound, and .none if a sample is not finite. The vtable entry is C callconv (pointer and length), as anything new in abi.zig is, for a second host; the web host keeps the copy for samples() (its voices are silent). Tests: a unit test that the sound is a copy and that NaN and infinity are refused; test/voices.zig makes a 1000-sample blip in setup and declares it under a serial space bumps, and test/voices.script checks it sounds once, stays silent through a recording of it played, stepped and seeked, and sounds again for a new serial. For that, expect-audio KEY also passes when voice KEY was mixed since it was last asked, and expect-no-audio KEY says it was not. zig build test-audio runs the script too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* Make snapshots named marks and recordings named clips of sessionsGabriel Schneider7 hours
| | | | | | | | | | | | | | | | | | | | | The state file keeps live state only (SKETCH03, one slot). save NAME is a keyframe and a mark in the sessions database, synced to disk; load, diff, snapshot and expect-snapshot take mark names, through the keyframe's own layout migrated to today's, compared over the leaves migration kept. A file from before (SKETCH01/02) has its used snapshot slots imported as marks "1".."7" at open, then drops them; a run that records nothing leaves them alone. record NAME, stop and play NAME make and play clips: a frame range of a session and its start keyframe, nothing overwritten, nothing invalidated by a later save, no capacity. The 64 MiB .inputs file, its --fresh memset and Timeline's Bank are gone; numbers still work as names, so every existing script runs unchanged. Event times in a clip are the session's, not restarted at record. reload.script also checks that a field a reload drops is still in the keyframe taken before it (expect-key). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* Record every run's frames to a sessions database in xitdbGabriel Schneider7 hours
| | | | | | | | | | | | | | | | | | | | | Live play was recorded only after someone typed record N, into 16 fixed slots. Now every run is a session in one xitdb database per sketch, beside its state file (<name>.xitdb): an append-only log of the frames live update was fed, one commit a second of session time, and keyframes of the State at start, every minute, on jumps, before and after reloads and at exit. A kill -9 loses at most the uncommitted second (test-kill). Whether a build records travels in the sketch: App.Options.record, null meaning Debug, reaching the host as Info.record. Scripted runs from fresh state record in memory, exports not at all. Each stretch of a session keeps its build, layout and Info.source: the repository revision (one jj or git call per build, build_info), zig version, backend and mode. Sessions.zig takes plain data (bytes, events, strings, a path, an Io), so a second host can drive it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
* sketchbook: a drawing layer on top, host fixes for replay and migrationGabriel Schneider5 days
|
* sketchbook: Zig 0.17, a Store on disk, requests, a scope (waveform, ↵Gabriel Schneider5 days
| | | | spectrum, spectrogram), audio codecs and fonts, web host
* sketchbook: await in scriptsGabriel Schneider2026-09-25
| | | | | | await FIELD VALUE plays frames until a state field holds the value, for up to a minute: for waits whose length is the sketch's business, such as a line of dialogue typing out.
* sketchbook: what the game's review neededGabriel Schneider2026-09-25
| | | | | | | | | | | - input.started: true on the first update of a run, never after a reload, for a sketch to stop what should not resume from saved state. - A console line that errors fails its script. Sketch commands answer unknown, done or failed (abi.Outcome) instead of a bool that hid errors. - addScript also takes the hot-reloadable library, run through the generic host, so scripts can reload a real build. - Sounds that do not load are .none, not an empty clip. - sk_tag reads an enum field's tag name from the web build, for tests.
* Put the game first: lib/sketchbook, sketches/vecanimGabriel Schneider2026-09-25
The root is the game. The platform library moves to lib/sketchbook (with serve_web.py, which serves any sketch's web build, as a tool of it), and vecanim to sketches/vecanim, still its own package on the same library.