diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 11:29:28 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 11:29:40 -0300 |
| commit | 3d60aa05ec1a6f9ed535186be6c6c2850c71b24d (patch) | |
| tree | e55587fb9d1ec5f55c55fa81b7d81f3a91bf5375 /addons | |
| parent | add0837dc1927389096cbaaf65b7e1a42028eafc (diff) | |
| parent | 8723462d8e02bc9d78b5004de38b910e83540575 (diff) | |
| download | pardes-3d60aa05ec1a6f9ed535186be6c6c2850c71b24d.tar.gz pardes-3d60aa05ec1a6f9ed535186be6c6c2850c71b24d.zip | |
merge: L2a (tags, grips, band, notice onto chrome) + M2's fix + FP (PDF leaks, spawn stop, PDF hits)
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); +} |
