diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 00:02:06 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 01:21:34 -0300 |
| commit | e9b4f0e1c37c5c1f369d152d0a70b672433c94b5 (patch) | |
| tree | f49224e1467153c8a464bb62eb2d8b5529bc88d0 /src/kinds | |
| parent | 423440f25b4b23b56162008bba35218d438767fe (diff) | |
| download | pardes-e9b4f0e1c37c5c1f369d152d0a70b672433c94b5.tar.gz pardes-e9b4f0e1c37c5c1f369d152d0a70b672433c94b5.zip | |
kinds #3, addons: src/Addon.zig loads a library that brings a kind (each *.so of $XDG_DATA_HOME/pardes/addons, then <prefix>/lib/pardes/addons at start; `Addon load <path>`, `Addon unload <name>` refused while a pane of the kind is open, `Addon reload <name>`; bare, the kinds here), from a copy of its bytes in a memfd so a reload is the file as it is now, its BLAKE3 kept; a load is marked on disk while it runs and a start that finds the mark skips that library until `Addon load` asks again; the crash record says `in addon <file>, <call>`; Kind.zig checks a head before taking it (size, ABI major, a paint, a name, words, leader paths and extensions none else has, the core's or another addon's: refused whole, in words; ctl with words; jobs paired), and a reload checks the new library beside the old (the old kind's own names looked past), opens every pane of the kind again in a fresh arena from the old state's dump and the new load (or its place and its words' last values), and only then swaps, dropping the old library's jobs; any failure says why and leaves the old one running; /addons lists `<kind> <version> <abi> <panes open> <path> <blake3> static|loaded|refused: why`; the tail: an addon's words join /commands and Help marked `(addon <name>)`, run from exec, a ctl and a leader path after the core's, a word that opens its kind opens a pane of it from anywhere and any other goes to a pane of its kind, its ctl read ends with the kind's fields, its body is the kind's text over 9P, its keys (all but Esc, as a raw terminal's) and clicks go to it, a 9P request steps its ticks and jobs as an event does; the dump record keeps the words' last values; the size of every record is asserted in the header and seen again from Kind.zig; pa_api gains `seed` (a number the same for a pane on every machine, for a game's board), and a zero cell is an unpainted one (PA_PAINTED, which pa_put sets), so a window is cleared by one memset; the hook in the settings agent's files is one arm each: exec.zig executeBuiltinLine's miss goes to Kind.runLine, builtins.zig gains the Addon word, config.zig its leader path (none); the tree gains /addons (README and reference.typ's tree, and an Addons section), builtins-<tui|gui>.json the Addon row; no golden changes; tests: a crash mark skipped at two starts and cleared by a load (Addon.zig), the tree listing tests (tree.zig and the process suite's) with /addons; the README keeps its 45 lines
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/kinds')
| -rw-r--r-- | src/kinds/pardes_addon.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/kinds/pardes_addon.h b/src/kinds/pardes_addon.h index 8a95d6d7..c3fbc097 100644 --- a/src/kinds/pardes_addon.h +++ b/src/kinds/pardes_addon.h @@ -39,8 +39,10 @@ #define PA_REVERSE 0x10u #define PA_UNDERLINE 0x100u -/* A cell: one character, `len` bytes of UTF-8 (at most 7). */ -#define PA_UNPAINTED 0x01u /* flags: the pane's background, nothing drawn */ +/* A cell: one character, `len` bytes of UTF-8 (at most 7), drawn only + * with PA_PAINTED in its flags (pa_put sets it); a zero cell is the pane's + * background. */ +#define PA_PAINTED 0x01u typedef struct pa_cell { uint8_t text[8]; uint32_t fg, bg; @@ -50,7 +52,7 @@ typedef struct pa_cell { } pa_cell; /* The pane's body, which `paint` writes: `rows` rows of `cols` cells, - * `stride` cells apart, every one PA_UNPAINTED when the call begins. */ + * `stride` cells apart, every one zero (unpainted) when the call begins. */ typedef struct pa_window { pa_cell *cells; uint32_t stride; @@ -146,6 +148,9 @@ typedef struct pa_api { void (*say)(const char *text, uint32_t n, int err); /* A new text pane named `name` holding `bytes`; its serial, 0 if none. */ uint32_t (*text)(const char *name, uint32_t name_len, const char *bytes, uint32_t n); + /* The pane's seed: the same pane, the same number, on every machine (a + * game's board), and what `pardes --addon-test`'s `seed N` sets. */ + uint64_t (*seed)(void); } pa_api; /* A job's answer buffer: `alloc` it once, write it, return its length. */ @@ -224,6 +229,20 @@ typedef struct pa_ops { int (*load)(void *st, const uint8_t *buf, uint32_t n, uint32_t version); } pa_ops; +/* The records' sizes on a 64-bit target: an addon built against another + * copy of this header that disagrees does not compile. */ +#if UINTPTR_MAX == 0xffffffffffffffffu +_Static_assert(sizeof(pa_cell) == 20, "pa_cell"); +_Static_assert(sizeof(pa_window) == 24, "pa_window"); +_Static_assert(sizeof(pa_rect) == 16 && sizeof(pa_cells) == 8, "pa_rect"); +_Static_assert(sizeof(pa_placement) == 72, "pa_placement"); +_Static_assert(sizeof(pa_paint) == 120, "pa_paint"); +_Static_assert(sizeof(pa_key) == 8 && sizeof(pa_mouse) == 10, "pa_key"); +_Static_assert(sizeof(pa_api) == 64 && sizeof(pa_out) == 16, "pa_api"); +_Static_assert(sizeof(pa_word) == 40 && sizeof(pa_head) == 56, "pa_head"); +_Static_assert(sizeof(pa_ops) == 192, "pa_ops"); +#endif + /* ---- helpers ---- */ static inline pa_cell *pa_at(const pa_window *w, unsigned row, unsigned col) { @@ -244,7 +263,7 @@ static inline unsigned pa_put(const pa_window *w, unsigned row, unsigned col, co c->fg = fg; c->bg = bg; c->attrs = 0; - c->flags = 0; + c->flags = PA_PAINTED; n++; } text += len; |
