diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 09:41:38 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 10:16:37 -0300 |
| commit | 2dae98b564e677c24c5275070c413d05a85d12fc (patch) | |
| tree | 6a18f7ea935efdfca0b6f50229ca9eca6052741d /addons | |
| parent | 0fb10f2748bc1593b9c0dda0e74b53cb66a69a95 (diff) | |
| download | pardes-2dae98b564e677c24c5275070c413d05a85d12fc.tar.gz pardes-2dae98b564e677c24c5275070c413d05a85d12fc.zip | |
abi, Kind, pdf, fake: ABI 3.4, a kind's window holds the theme's search hit colours, `hit` and `hit_current` (Chrome's, read through p.chrome() as each pane of a kind is painted), and a PDF's search draws its hits in them, the current hit apart, where every hit was the literal amber #ffd54f (the colour line's leftover, themes DESIGN.md part F, L2e's row "PDF hits", B8's `PDF's ffd54f -> chrome.hit`: "current hit" had three colours, the body's, the rail's and the PDF's); THE ABI: pa_window gains `uint32_t hit, hit_current` at its end (24 to 32 bytes, the header's and Kind.zig's size checks), PA_ABI_MINOR 4; an addon reads them once `api->abi >= 0x30004`, so one built against 3.3 loads, opens and paints as before (the core refuses another major only, and reads nothing new of an addon), and one built against 3.4 under an older pardes is handed the amber its PDFs drew (abi/addon.zig's Window, filled by the glue); WHY THE WINDOW, NOT THE VIEW (pa_view, where fg, bg, sel and link are): a view's facts are a step's (`view` is on the tape, and a plain kind keeps them in its block: the pdf's Layout holds the whole pa_view), so two more colours there would grow the pdf's block, and an Upgrade's revival hands `load` the old block, whose size it would refuse, every open PDF a placeholder; the hits are drawn by paint alone, which writes nothing a step reads, and the window is made each paint; THE CORE: Kind.paint fills them, the theme colour's PA_RGB by Kind's one `rgb` (viewOf's, out of its function); THE PDF: paint hands its window to reconcile, and marksOf marks each hit of the page in `win.hit`, those of the current hit (`find.hit`, its quads) in `win.hit_current`, at the alpha they had; THE FAKE: paints `hits rrggbb rrggbb` on its fifth row (since 3.4), and is built once more with its head saying 3.3 (`fake_addon_old`, named fakeold); addons/fake/fake.out re-recorded (that row in each of its 11 frames, `hits 5e4923 917a53`, the addon test's theme; nothing else moved); docs/typ/reference.typ's paint says it; RUN (TEST FIRST): behaviour/addons.zig "addons: a kind's pane is painted with the theme's search hit colours, the current hit's apart (ABI 3.4), and a library whose head says 3.3 still loads, opens and paints": acme's `hits ffc790 a05200`, then neonotte84's `hits 4c301a e59d3c`, then fakeold listed `3.3 ... loaded` and its pane's `count 0`: with the header and the fake alone fails (the core's window `hits 000000 000000`), passes now; pdf.zig "a search's hits are marked in the theme's hit colours its window is painted with, the current hit in the current hit's (ABI 3.4)": a page's three quads, the second hit's two current: fails with the amber (expected 4c301a70, found ffd54f70), passes now; the ABI the addons say in /addons moves to 3.4 in five behaviour checks; a user saw every PDF hit amber in every theme and the current one no different; NEW HOT PATHS: per frame, per pane of a kind painted, two colours packed from the chrome (no allocation, no derivation: Chrome's resolved fields); none per key; GATES (the stack kysrwqpz, rqlxkzuq, this, Debug): core-test 1163/1338 (175 skipped: +1 skipped, the rerun test needs a terminal), shell-test 1379/1382 (3 skipped), pane-test 184/185, behaviour-test 288/288 (+1) and --replay 20 seeds of 70 steps, 0 failures, process-test 0 of 149 failed (3 skipped), term-test 17/17, kitty-test 45/45, addon-test 157/157 steps, 8/8 tests (fake.out, snake, pdf and their own tests); the soak with the pdf addon on this top found a second preview leak, pictures (the next change); the 40,000-seed dump fuzz crashed at join seed 8324 in draw.zig's Debug overlay (a General protection exception printing a string from a damaged dump), whose dumped session has no kind, no command pane and no window: these changes move none of its bytes (see the report); pdf-harness tui fails `KittyPdfBoundaryPageMissing` on M2 alike (8959b031dc33, run here), not this change's; no dump layout change (the window is made each paint); load 4.5 to 12.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/fake/fake.c | 13 | ||||
| -rw-r--r-- | addons/fake/fake.out | 22 | ||||
| -rw-r--r-- | addons/pdf/pdf.zig | 41 |
3 files changed, 54 insertions, 22 deletions
diff --git a/addons/fake/fake.c b/addons/fake/fake.c index b3f6b288..b5423317 100644 --- a/addons/fake/fake.c +++ b/addons/fake/fake.c @@ -6,7 +6,8 @@ * * 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. It paints - * which view it is painted for and that view's size as `view` told it. */ + * which view it is painted for and that view's size as `view` told it, + * and the theme's hit colours its window has (since 3.4). */ #include "pardes_addon.h" /* The loader's tests build it wrong on purpose: another ABI, no export, @@ -60,6 +61,10 @@ static void view(void *st, const pa_view *v) { f->cols[v->id - 1] = v->cols, f->rows[v->id - 1] = v->rows; } +static void hex(char *out, uint32_t rgb) { + for (int i = 0; i < 6; i++) out[i] = "0123456789abcdef"[rgb >> (20 - 4 * i) & 0xf]; +} + static void num(char *out, unsigned n) { char t[12]; int k = 0; @@ -84,6 +89,12 @@ static void paint(void *st, const pa_window *w, pa_paint *out) { if (w->glyphs) memcpy(v + strlen(v), " glyphs", 8); pa_put(w, 3, 0, v, PA_DEFAULT, PA_DEFAULT, 0); } + if (api->abi >= 0x30004u) { + char h[] = "hits rrggbb rrggbb"; + hex(h + 5, w->hit); + hex(h + 12, w->hit_current); + pa_put(w, 4, 0, h, 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}; diff --git a/addons/fake/fake.out b/addons/fake/fake.out index 8f92d24e..ef4c200b 100644 --- a/addons/fake/fake.out +++ b/addons/fake/fake.out @@ -6,7 +6,7 @@ tag fake petscii:on palette:commodore ascii:on | | |view 1 58x7 glyphs -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 4b3cd99b86ea3486 @@ -16,7 +16,7 @@ tag fake petscii:on palette:commodore ascii:on |kb | |view 1 58x7 glyphs -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key fdcaab9076ad067e @@ -26,7 +26,7 @@ tag fake petscii:on palette:commodore ascii:on |m3 | |view 1 58x7 glyphs -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 71e39225f0cec2a5 @@ -36,7 +36,7 @@ tag fake petscii:on palette:commodore ascii:on |m3 | |view 1 58x7 glyphs -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 54740e23065232cf @@ -46,7 +46,7 @@ tag fake petscii:on palette:commodore ascii:on |m3 | |view 1 58x7 glyphs -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 @@ -56,7 +56,7 @@ tag fake petscii:on palette:commodore ascii:on |m3 | |view 1 58x7 glyphs -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 @@ -66,7 +66,7 @@ tag fake petscii:on palette:commodore ascii:on |m3 | |view 2 58x7 -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 @@ -77,7 +77,7 @@ tag fake petscii:on palette:commodore ascii:on |m3 | |view 2 68x13 -| +|hits 5e4923 917a53 | | | @@ -93,7 +93,7 @@ tag fake petscii:on palette:commodore ascii:on |m3 | |view 1 58x7 glyphs -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 @@ -103,7 +103,7 @@ tag fake petscii:on palette:commodore ascii:on |m3 | |view 1 58x7 glyphs -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 @@ -113,7 +113,7 @@ tag fake petscii:on palette:commodore ascii:on |m3 | |view 1 58x7 glyphs -| +|hits 5e4923 917a53 | | placement 2x2 src 0,0 2x2 over 0,2 2x1 key 540d6c1b4eee5716 diff --git a/addons/pdf/pdf.zig b/addons/pdf/pdf.zig index 7ee3400a..a401c979 100644 --- a/addons/pdf/pdf.zig +++ b/addons/pdf/pdf.zig @@ -405,7 +405,7 @@ pub const Pdf = extern struct { // white tinted is the theme's paper const paper: u32 = if (st.tint == .disabled) 0xffffff else if (pixels(st, st.active)) |a| @backingInt(a.v.bg) else 0xffffff; o.blank = .{ @truncate(paper >> 16), @truncate(paper >> 8), @truncate(paper), 255 }; - reconcile(st, o, l, sp, win.view); + reconcile(st, o, l, sp, win); const vh = @min(@as(u32, win.rows) * win.cell_h, l.vh); const first, const count = visible(st, l, sp); for (first..first + count) |p| { @@ -1377,9 +1377,10 @@ fn rasterOf(st: *const Pdf, o: *Own, p: usize, q: Request) [2]u32 { // ---- highlights ---- -/// Page `p`'s highlights in view `l`, as painted: the pointer's, the -/// search's, the selection's. -fn marksOf(st: *const Pdf, o: *Own, l: *const Layout, p: u32, out: []Mark) []Mark { +/// Page `p`'s highlights in view `l`, as painted in `win`: the pointer's, +/// the search's (in the theme's hit colours, the current hit apart), the +/// selection's. +fn marksOf(st: *const Pdf, o: *Own, l: *const Layout, p: u32, out: []Mark, win: addon.Window) []Mark { const f = struct { fn mark(q: Quad, rgb: u32, a: u8, kind: c_int) Mark { return .{ .quad = q, .rgba = .{ @truncate(rgb >> 16), @truncate(rgb >> 8), @truncate(rgb), a }, .kind = kind }; @@ -1393,7 +1394,7 @@ fn marksOf(st: *const Pdf, o: *Own, l: *const Layout, p: u32, out: []Mark) []Mar if (st.find.hits_page == p) { const hits = hitsOf(st, o); for (hits[0..@min(hits.len, out.len - n)]) |h| { - out[n] = f.mark(h.quad, 0xffd54f, 0x70, m.PARDES_PDF_HIGHLIGHT_SEARCH); + out[n] = f.mark(h.quad, @backingInt(if (h.hit == st.find.hit) win.hit_current else win.hit), 0x70, m.PARDES_PDF_HIGHLIGHT_SEARCH); n += 1; } } @@ -1528,10 +1529,11 @@ fn repaint(o: *Own, s: *Slot, now: []const Mark) bool { return keepMarks(&s.shown, now); } -/// What view `id`'s window shows (and the page past it) made so, as it is -/// painted: pages gone dropped, highlights moved repainted, the rest asked -/// of the lanes as draws. -fn reconcile(st: *const Pdf, o: *Own, l: *const Layout, sp: *const Strip, id: u8) void { +/// What view `win.view`'s window shows (and the page past it) made so, as +/// it is painted: pages gone dropped, highlights moved repainted, the rest +/// asked of the lanes as draws. +fn reconcile(st: *const Pdf, o: *Own, l: *const Layout, sp: *const Strip, win: addon.Window) void { + const id = win.view; const first, var n = visible(st, l, sp); if (n > 0 and first + n < st.pages and !st.go.fling) n += 1; // the page ahead, at rest for (&o.s) |*s| if (s.view == id and (s.page < first or s.page >= first + n)) { @@ -1556,7 +1558,7 @@ fn reconcile(st: *const Pdf, o: *Own, l: *const Layout, sp: *const Strip, id: u8 const same = s.rgba.len > 0 and std.meta.eql(s.is.req, q); const wh = if (same) [2]u32{ s.is.w, s.is.h } else rasterOf(st, o, p, q); const y, const bh = bandOf(st, l, sp, p, wh[0], wh[1]); - const marks = marksOf(st, o, l, p, &now.at); + const marks = marksOf(st, o, l, p, &now.at, win); if (same and s.is.tint == st.tint and s.is.ink == @backingInt(l.v.fg) and s.is.paper == @backingInt(l.v.bg) and s.is.band_y <= y and s.is.band_y + s.is.band_h >= y + bh) { if (now.eq(s.shown, marks) or repaint(o, s, marks)) continue; } @@ -1860,3 +1862,22 @@ test "every pointer the bridge's structs hand back is read through addon.cSlice: }; } } + +test "a search's hits are marked in the theme's hit colours its window is painted with, the current hit in the current hit's (ABI 3.4)" { + var st: Pdf = .{}; + st.find.query[0] = 'x'; + st.find.len = 1; + st.find.hits_page = 0; + st.find.hit = 1; + // The page's hits as its search found them: the second, in two quads, current. + const q = std.mem.zeroes(Quad); + var quads = [_]m.pardes_pdf_search_quad{ .{ .quad = q, .hit = 0 }, .{ .quad = q, .hit = 1 }, .{ .quad = q, .hit = 1 } }; + var o: Own = .{ .hits = &quads, .hits_of = .{ .page = 0, .query = st.find.query } }; + var cells: [1]c.pa_cell = undefined; + const win: addon.Window = .{ .cells = &cells, .stride = 1, .cols = 1, .rows = 1, .cell_w = 8, .cell_h = 16, .focused = false, .view = 1, .glyphs = false, .hit = .rgb(0x4c, 0x30, 0x1a), .hit_current = .rgb(0xe5, 0x9d, 0x3c) }; + var out: [8]Mark = undefined; + const marks = marksOf(&st, &o, &st.views[0], 0, &out, win); + try std.testing.expectEqual(@as(usize, 3), marks.len); + try std.testing.expectEqual([4]u8{ 0x4c, 0x30, 0x1a, 0x70 }, marks[0].rgba); + for (marks[1..]) |mk| try std.testing.expectEqual([4]u8{ 0xe5, 0x9d, 0x3c, 0x70 }, mk.rgba); +} |
