diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 15:58:05 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 17:53:43 -0300 |
| commit | e9f9f65ace7650a02cee6bf2b2eb466522485834 (patch) | |
| tree | caf5b7a2344b8da002f3952e3225e0db38b492fc /addons/fake | |
| parent | 75e4787be773c8cbfd2e60e59d409b9556898365 (diff) | |
| download | pardes-e9f9f65ace7650a02cee6bf2b2eb466522485834.tar.gz pardes-e9f9f65ace7650a02cee6bf2b2eb466522485834.zip | |
kinds #36, the five kinds on ABI 3: fake.c with every function (view painting each view's size, search through found, FakeJob cancel) and PA_PICTURES, snake, life and image over the module's prefix and open(path, bytes), image without a record (a Restore reads its file), and pdf.c ported mechanically (tick into pa_tick with its [P/N] prefix, a table of the views it is told, its strip laid out for the view its last key or click came from, the text layer painted for a window of glyphs and read on the tick while some view shows text, a body read keeping nothing, search through found, the record its fit, tint and place, PA_PICTURES); the goldens moved once, said in the report: the art words from the first frame, fake's view line, a pane ticked when opened or loaded, a view told after a frame re-wrapped its tag
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'addons/fake')
| -rw-r--r-- | addons/fake/fake.c | 52 | ||||
| -rw-r--r-- | addons/fake/fake.out | 72 | ||||
| -rw-r--r-- | addons/fake/fake.script | 7 |
3 files changed, 108 insertions, 23 deletions
diff --git a/addons/fake/fake.c b/addons/fake/fake.c index 81a78741..648dcace 100644 --- a/addons/fake/fake.c +++ b/addons/fake/fake.c @@ -5,7 +5,8 @@ * cc -shared -fPIC -I src/kinds -o fake.so addons/fake/fake.c * * A pane of it counts: keys and clicks and ticks and words each add to a - * count it paints, dumps and answers `where` with; `:N` sets it. */ + * count it paints, dumps and answers `where` with; `:N` sets it. It paints + * which view it is painted for and that view's size as `view` told it. */ #include "pardes_addon.h" /* The loader's tests build it wrong on purpose: another ABI, no export, @@ -26,6 +27,7 @@ typedef struct { unsigned count, ticks; char last[16]; uint8_t pixels[2 * 2 * 4]; + uint16_t cols[8], rows[8]; /* each view's, by id */ } fake; static int init(const pa_api *a) { @@ -45,11 +47,17 @@ static void *open(const char *path, const uint8_t *bytes, uint64_t len) { static void close(void *st) { (void)st; } -static uint64_t tick(void *st, uint64_t now, uint32_t flags) { +static void tick(void *st, pa_tick *t) { fake *f = st; - (void)flags; f->ticks++; - return f->ticks < 3 ? now + 100000000u : 0; /* ten a second, three times */ + t->next = f->ticks < 3 ? t->now + 100000000u : 0; /* ten a second, three times */ + memcpy(t->prefix, "fake", 4), t->prefix_len = 4; +} + +static void view(void *st, const pa_view *v) { + fake *f = st; + if (v->id == 0 || v->id > 8) return; + f->cols[v->id - 1] = v->cols, f->rows[v->id - 1] = v->rows; } static void num(char *out, unsigned n) { @@ -66,8 +74,16 @@ static void paint(void *st, const pa_window *w, pa_paint *out) { num(line + 6, f ? f->count : 0); pa_put(w, 0, 0, line, PA_INDEX(2), PA_DEFAULT, 0); if (f && f->last[0]) pa_put(w, 1, 0, f->last, PA_DEFAULT, PA_DEFAULT, 0); - const char *p = "fake"; - for (out->prefix_len = 0; p[out->prefix_len]; out->prefix_len++) out->prefix[out->prefix_len] = p[out->prefix_len]; + if (f && w->view >= 1 && w->view <= 8) { + char v[48] = "view "; + v[5] = (char)('0' + w->view), v[6] = ' '; + num(v + 7, f->cols[w->view - 1]); + char *e = v + strlen(v); + *e++ = 'x'; + num(e, f->rows[w->view - 1]); + if (w->glyphs) memcpy(v + strlen(v), " glyphs", 8); + pa_put(w, 3, 0, v, PA_DEFAULT, PA_DEFAULT, 0); + } if (f && out->cap > 0 && w->rows > 2) { pa_placement *pl = &out->placements[out->n++]; *pl = (pa_placement){.rgba = f->pixels, .w = 2, .h = 2, .src = {0, 0, 2, 2}, .dst = {0, 2, 2, 1}, .key = f->count}; @@ -131,7 +147,11 @@ static int ctl(void *st, const char *line, uint32_t n, char *reply, uint32_t cap f->count += by ? by : 1; return PA_OK; } - if (n >= 7 && line[4] == 'J') return api->job("abc", 3) ? PA_OK : 1; + if (n >= 7 && line[4] == 'J') { /* FakeJob cancel: its answer dropped */ + uint32_t token = api->job("abc", 3); + if (token && n > 8) api->cancel(token); + return token ? PA_OK : 1; + } const char *no = "no such fake word"; uint32_t k = 0; while (no[k] && k + 1 < cap) { reply[k] = no[k]; k++; } @@ -161,6 +181,18 @@ static void job_done(void *st, uint32_t token, const uint8_t *out, uint32_t n) { f->count += n; } +/* `/`: a row naming the count, at once. */ +static void search(void *st, const char *pat, uint32_t n) { + fake *f = st; + char row[64] = "fake:1 count "; + num(row + 13, f->count); + size_t k = strlen(row); + row[k++] = ' '; + for (uint32_t i = 0; i < n && k < sizeof row - 1; i++) row[k++] = pat[i]; + row[k++] = '\n'; + api->found(row, (uint32_t)k); +} + #ifndef FAKE_NO_DUMP static uint32_t dump(void *st, uint8_t *buf, uint32_t n) { fake *f = st; @@ -179,18 +211,18 @@ static int load(void *st, const uint8_t *buf, uint32_t n, uint32_t version) { static const pa_word words[] = { PA_WORD(FAKE_WORD, "zf", PA_ARG_NONE, 1, "a fake pane, counting"), PA_WORD("FakeBump", 0, PA_ARG_OPTIONAL, 0, "add to the count"), - PA_WORD("FakeJob", 0, PA_ARG_NONE, 0, "count a job's answer"), + PA_WORD("FakeJob", 0, PA_ARG_OPTIONAL, 0, "count a job's answer (cancel: drop it)"), }; const pa_ops pardes_addon = { - .head = PA_ADDON(FAKE_NAME, 1, ".fake", words, 3), + .head = PA_ADDON(FAKE_NAME, 1, PA_PICTURES, ".fake", words, 3), #ifdef FAKE_ABI .head.abi = FAKE_ABI, #endif .init = init, .open = open, .close = close, .tick = tick, .paint = paint, .key = key, .mouse = mouse, .body_len = body_len, .body = body, .address = address, .where = where, .ctl = ctl, .ctl_read = ctl_read, - .job_run = job_run, .job_done = job_done, + .job_run = job_run, .job_done = job_done, .search = search, .view = view, #ifndef FAKE_NO_DUMP .dump = dump, .load = load, #endif diff --git a/addons/fake/fake.out b/addons/fake/fake.out index 3693f2c3..1699ffa6 100644 --- a/addons/fake/fake.out +++ b/addons/fake/fake.out @@ -1,71 +1,117 @@ > seed 7 > size 60 20 window 58x7 -tag fake +tag fake petscii:on palette:commodore ascii:on |count 0 | | -| +|view 1 58x7 glyphs | | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 4b3cd99b86ea3486 > key ab -tag fake +tag fake petscii:on palette:commodore ascii:on |count 2 |kb | -| +|view 1 58x7 glyphs | | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key fdcaab9076ad067e > click 3 1 -tag fake +tag fake petscii:on palette:commodore ascii:on |count 3 |m3 | -| +|view 1 58x7 glyphs | | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 71e39225f0cec2a5 > FakeBump 10 -tag fake +tag fake petscii:on palette:commodore ascii:on |count 13 |m3 | -| +|view 1 58x7 glyphs | | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 54740e23065232cf > FakeJob -tag fake +tag fake petscii:on palette:commodore ascii:on |count 19 |m3 | +|view 1 58x7 glyphs +| +| +| +placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 +> FakeJob cancel +tag fake petscii:on palette:commodore ascii:on +|count 19 +|m3 | +|view 1 58x7 glyphs | | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 -> tick 100 -tag fake +> view 2 on +tag fake petscii:on palette:commodore ascii:on +|count 19 +|m3 +| +|view 2 58x7 +| +| +| +placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 +> size 70 30 +window 68x12 +tag fake petscii:on palette:commodore ascii:on +|count 19 +|m3 +| +|view 2 68x12 +| +| +| +| +| +| +| +| +placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 +> view 1 off +tag fake petscii:on palette:commodore ascii:on |count 19 |m3 | +|view 1 58x7 glyphs | | | +placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 +> tick 100 +tag fake petscii:on palette:commodore ascii:on +|count 19 +|m3 +| +|view 1 58x7 glyphs +| +| | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 > settle -tag fake +tag fake petscii:on palette:commodore ascii:on |count 19 |m3 | -| +|view 1 58x7 glyphs | | | diff --git a/addons/fake/fake.script b/addons/fake/fake.script index 35407cd7..58fc9f4c 100644 --- a/addons/fake/fake.script +++ b/addons/fake/fake.script @@ -5,5 +5,12 @@ key ab click 3 1 FakeBump 10 FakeJob +# A job asked and cancelled: its answer is dropped, the count stays. +FakeJob cancel +# A second view, a window's (pictures): the kind is told its size and +# paints for it; then the first, a terminal's, as it was. +view 2 on +size 70 30 +view 1 off tick 100 settle |
