summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--abi/addon.zig12
-rw-r--r--abi/pardes_addon.h7
-rw-r--r--addons/fake/fake.c13
-rw-r--r--addons/fake/fake.out22
-rw-r--r--addons/pdf/pdf.zig41
-rw-r--r--build/tests.zig8
-rw-r--r--core/Kind.zig15
-rw-r--r--docs/typ/reference.typ4
-rw-r--r--test/behaviour/addons.zig31
-rw-r--r--test/behaviour/addons_pdf.zig2
-rw-r--r--test/session.zig1
11 files changed, 114 insertions, 42 deletions
diff --git a/abi/addon.zig b/abi/addon.zig
index 53227fbb..dfbac270 100644
--- a/abi/addon.zig
+++ b/abi/addon.zig
@@ -37,9 +37,9 @@ pub const c = @import("pardes_addon");
const Allocator = std.mem.Allocator;
/// The ABI this file speaks: a header of another needs it brought along.
-pub const abi = 0x30003;
+pub const abi = 0x30004;
comptime {
- if (c.PA_ABI != abi) @compileError("addon.zig speaks ABI 3.3 and the header another");
+ if (c.PA_ABI != abi) @compileError("addon.zig speaks ABI 3.4 and the header another");
}
/// A word the kind brings: `opens` a pane of it, else goes to the pane's
@@ -160,6 +160,10 @@ pub const Window = struct {
/// The view painted (View.id), and whether it shows pictures as glyph art.
view: u8,
glyphs: bool,
+ /// The theme's search hits and the current one (a pardes older than
+ /// ABI 3.4: the amber its PDFs drew them in).
+ hit: Color,
+ hit_current: Color,
/// `text` (UTF-8) from column x of row y on, a character a cell, cut at
/// the edge: column first, where the header's pa_put is row first.
@@ -315,7 +319,9 @@ pub fn ops(comptime T: type) c.pa_ops {
if (@hasDecl(T, "prefix")) t.*.prefix_len = write(T.prefix, s, &t.*.prefix, t.*.prefix.len);
}
fn paint(st: ?*anyopaque, w: [*c]const c.pa_window, out: [*c]c.pa_paint) callconv(.c) void {
- T.paint(self(st) orelse return, .{ .cells = w.*.cells, .stride = w.*.stride, .cols = w.*.cols, .rows = w.*.rows, .cell_w = w.*.cell_w, .cell_h = w.*.cell_h, .focused = w.*.focused != 0, .view = w.*.view, .glyphs = w.*.glyphs != 0 }, .{ .out = out });
+ const amber: Color = .rgb(0xff, 0xd5, 0x4f);
+ const hits = api.abi >= 0x30004;
+ T.paint(self(st) orelse return, .{ .cells = w.*.cells, .stride = w.*.stride, .cols = w.*.cols, .rows = w.*.rows, .cell_w = w.*.cell_w, .cell_h = w.*.cell_h, .focused = w.*.focused != 0, .view = w.*.view, .glyphs = w.*.glyphs != 0, .hit = if (hits) @fromBackingInt(w.*.hit) else amber, .hit_current = if (hits) @fromBackingInt(w.*.hit_current) else amber }, .{ .out = out });
}
fn view(st: ?*anyopaque, v: [*c]const c.pa_view) callconv(.c) void {
T.view(self(st) orelse return, @as(*const View, @ptrCast(v)).*);
diff --git a/abi/pardes_addon.h b/abi/pardes_addon.h
index d8257a0b..e467a239 100644
--- a/abi/pardes_addon.h
+++ b/abi/pardes_addon.h
@@ -37,7 +37,7 @@
/* Major in the high half: an addon of another major is refused. */
#define PA_ABI_MAJOR 3u
-#define PA_ABI_MINOR 3u
+#define PA_ABI_MINOR 4u
#define PA_ABI ((PA_ABI_MAJOR << 16) | PA_ABI_MINOR)
#define PA_OK 0
#define PA_RASTER_MAX (32u << 20) /* a placement's w*h*4 above this is dropped, said once */
@@ -83,6 +83,9 @@ typedef struct pa_window {
* `view`: the id of the view painted (pa_view's), whose layout paint
* draws; `glyphs`: it shows pictures as glyph art. */
uint8_t focused, view, glyphs, pad;
+ /* Since 3.4 (check api->abi): the theme's search hits, and the current
+ * one, as the body draws them (PA_RGB). */
+ uint32_t hit, hit_current;
} pa_window;
typedef struct pa_rect { uint32_t x, y, w, h; } pa_rect; /* pixels */
@@ -390,7 +393,7 @@ typedef struct pa_ops {
* 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_window) == 32, "pa_window");
_Static_assert(sizeof(pa_rect) == 16 && sizeof(pa_cells) == 8, "pa_rect");
_Static_assert(sizeof(pa_placement) == 80, "pa_placement");
_Static_assert(sizeof(pa_paint) == 48 && sizeof(pa_view) == 32 && sizeof(pa_tick) == 128, "pa_paint");
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);
+}
diff --git a/build/tests.zig b/build/tests.zig
index c35857f7..05bdc2b6 100644
--- a/build/tests.zig
+++ b/build/tests.zig
@@ -111,18 +111,20 @@ pub fn add(b: *std.Build, c: struct {
const session_options = b.addOptions();
session_options.addOptionPath("lspmock", c.lspmock.getEmittedBin());
var fake_addon_lib: ?*std.Build.Step.Compile = null;
- // The fake addon (addons/fake/fake.c) and three copies of it built
- // wrong, which the loader must refuse (test/behaviour/addons.zig).
+ // The fake addon (addons/fake/fake.c), copies of it built wrong, which
+ // the loader must refuse, and one whose head says ABI 3.3, which it
+ // takes (test/behaviour/addons.zig).
for ([_]struct { []const u8, []const u8 }{
.{ "fake_addon", "-DFAKE_PLAIN" },
.{ "fake_addon_abi", "-DFAKE_ABI=0x20002" },
.{ "fake_addon_no_export", "-DFAKE_NO_EXPORT" },
.{ "fake_addon_core_word", "-DFAKE_WORD=\"Save\"" },
.{ "fake_addon_no_dump", "-DFAKE_NO_DUMP" },
+ .{ "fake_addon_old", "-DFAKE_ABI=0x30003" },
}) |variant| {
const lib = b.addLibrary(.{ .name = variant[0], .linkage = .dynamic, .root_module = b.createModule(.{ .target = c.target, .optimize = c.optimize, .link_libc = true }) });
lib.root_module.addIncludePath(b.path("abi"));
- const name_flag = if (std.mem.eql(u8, variant[0], "fake_addon_abi")) "-DFAKE_NAME=\"fakeabi\"" else if (std.mem.eql(u8, variant[0], "fake_addon_core_word")) "-DFAKE_NAME=\"fakeword\"" else "-DFAKE_PLAIN";
+ const name_flag = if (std.mem.eql(u8, variant[0], "fake_addon_abi")) "-DFAKE_NAME=\"fakeabi\"" else if (std.mem.eql(u8, variant[0], "fake_addon_core_word")) "-DFAKE_NAME=\"fakeword\"" else if (std.mem.eql(u8, variant[0], "fake_addon_old")) "-DFAKE_NAME=\"fakeold\"" else "-DFAKE_PLAIN";
// The header is the whole contract: it compiles clean under every warning.
lib.root_module.addCSourceFile(.{ .file = b.path("addons/fake/fake.c"), .flags = &.{ "-std=c11", "-Wall", "-Wextra", "-Werror", "-Wno-override-init", variant[1], name_flag } });
session_options.addOptionPath(variant[0], lib.getEmittedBin());
diff --git a/core/Kind.zig b/core/Kind.zig
index 22a7ebe0..9316c502 100644
--- a/core/Kind.zig
+++ b/core/Kind.zig
@@ -39,7 +39,7 @@ pub const abi: u32 = c.PA_ABI;
// records the core reads are the ones addons are built to.
comptime {
if (@sizeOf(usize) == 8) for (.{
- .{ c.pa_cell, 20 }, .{ c.pa_window, 24 }, .{ c.pa_rect, 16 }, .{ c.pa_cells, 8 },
+ .{ c.pa_cell, 20 }, .{ c.pa_window, 32 }, .{ c.pa_rect, 16 }, .{ c.pa_cells, 8 },
.{ c.pa_placement, 80 }, .{ c.pa_paint, 48 }, .{ c.pa_key, 8 }, .{ c.pa_mouse, 16 },
.{ c.pa_api, 128 }, .{ c.pa_out, 16 }, .{ c.pa_word, 32 }, .{ c.pa_head, 56 },
.{ c.pa_ops, 208 }, .{ c.pa_view, 32 }, .{ c.pa_tick, 128 },
@@ -529,7 +529,8 @@ pub fn paint(p: *const Pardes, slot: *Slot, id: usize, arena: std.mem.Allocator,
var gpu: GpuPaint = .{ .arena = arena, .frame = frame };
var out: c.pa_paint = std.mem.zeroInit(c.pa_paint, .{ .placements = &frame.buf, .cap = frame.buf.len, .gpu = GpuPaint.emit, .gpu_ctx = &gpu });
const px = p.view().cell_pixels;
- const win = std.mem.zeroInit(c.pa_window, .{ .cells = cells.ptr, .stride = cols, .rows = rows, .cols = cols, .cell_w = px.w, .cell_h = px.h, .focused = @intFromBool(focusedAnywhere(p, id)), .view = p.live + 1, .glyphs = @intFromBool(!p.view().frontend.native_images) });
+ const chrome = p.chrome();
+ const win = std.mem.zeroInit(c.pa_window, .{ .cells = cells.ptr, .stride = cols, .rows = rows, .cols = cols, .cell_w = px.w, .cell_h = px.h, .focused = @intFromBool(focusedAnywhere(p, id)), .view = p.live + 1, .glyphs = @intFromBool(!p.view().frontend.native_images), .hit = rgb(chrome.hit), .hit_current = rgb(chrome.hit_current) });
var cl: Call = .{ .p = null, .id = id, .slot = slot, .quiet = true, .core = p };
const prev = cl.begin("paint");
const before = if (checked) usedHash(slot) else {};
@@ -803,11 +804,6 @@ pub fn viewOf(p: *const Pardes, k: u8, id: usize) c.pa_view {
// derived, so a client joined from a dump has none.
const notices = pardes.Messages.bands(p, pane, tag_rows, r).span();
const th = p.theme();
- const rgb = struct {
- fn f(x: [3]u8) u32 {
- return @as(u32, x[0]) << 16 | @as(u32, x[1]) << 8 | x[2];
- }
- }.f;
const policy = rasterPolicy(v.frontend.windowed);
return .{
.cols = r.w -| pardes.config.GUTTER,
@@ -827,6 +823,11 @@ pub fn viewOf(p: *const Pardes, k: u8, id: usize) c.pa_view {
};
}
+/// A theme's colour as the header's PA_RGB.
+fn rgb(x: [3]u8) u32 {
+ return @as(u32, x[0]) << 16 | @as(u32, x[1]) << 8 | x[2];
+}
+
/// Whether pane `id` has the keyboard in some view (its window focused).
fn focusedAnywhere(p: *const Pardes, id: usize) bool {
for (&p.views) |*v| if (v.*) |*vw| if (vw.active == id and vw.window_focused) return true;
diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ
index 126330fa..2b0f31c0 100644
--- a/docs/typ/reference.typ
+++ b/docs/typ/reference.typ
@@ -1171,6 +1171,10 @@ of it is laid out by `view` and drawn by `paint`.
and a click say the view they came from. `paint` is called once a frame
in each view, `win->view` the one, and changes nothing (a Debug build
checks the kind's memory across it); a picture over 32 MiB is dropped.
+ Since ABI 3.4 the window holds the theme's search hit colours,
+ `win->hit` and the current hit's `win->hit_current` (`PA_RGB`), which an
+ addon reads once `api->abi >= 0x30004`: a PDF's search draws its hits
+ in them, as the body draws a file's.
- Every call returns within 2 ms; what takes longer goes on a job. A Debug
pardes says a call over 16 ms once (`pdf: search took 118 ms, over 16
ms`) and `--addon-test` fails on it.
diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig
index 0b0555c2..88c477ea 100644
--- a/test/behaviour/addons.zig
+++ b/test/behaviour/addons.zig
@@ -37,7 +37,7 @@ test "addons: Addon load takes a library in, /addons lists it with the kinds com
defer unload(&s, "fake");
// `<kind> <version> <abi> <panes open> <path> <blake3> <state>`.
const listed = try s.read("/addons");
- try std.testing.expect(std.mem.startsWith(u8, listed, "fake 1 3.3 0 /"));
+ try std.testing.expect(std.mem.startsWith(u8, listed, "fake 1 3.4 0 /"));
var fields = std.mem.tokenizeScalar(u8, listed[0..std.mem.indexOfScalar(u8, listed, '\n').?], ' ');
for (0..5) |_| _ = fields.next();
try std.testing.expectEqual(@as(usize, 64), fields.next().?.len);
@@ -51,7 +51,7 @@ test "addons: Addon load takes a library in, /addons lists it with the kinds com
// A pane of it open, it stays; closed, it goes.
try s.write("/ctl", "Fake\n");
const pane = try paneOf(&s, "fake");
- try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "fake 1 3.3 1 /"));
+ try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "fake 1 3.4 1 /"));
try std.testing.expect(try s.refused("/ctl", "Addon unload fake\n") != 0);
try std.testing.expect(has(s.said, "1 fake pane is open"));
try s.write(s.at("/pane/{d}/ctl", .{pane}), "Del\n");
@@ -68,7 +68,7 @@ test "addons: a library of another ABI, one with no pardes_addon, and one whose
try std.testing.expect(std.mem.startsWith(u8, listed, "fakeabi 1 2.2 0 /"));
try std.testing.expect(has(listed, " refused: wants abi 2, this pardes speaks 3\n"));
try std.testing.expect(has(listed, " refused: it has no pardes_addon\n"));
- try std.testing.expect(has(listed, "\nfakeword 1 3.3 0 /"));
+ try std.testing.expect(has(listed, "\nfakeword 1 3.4 0 /"));
try std.testing.expect(has(listed, " refused: word Save is the core's\n"));
// A file that is no library at all: listed with what the loader said.
var tmp = std.testing.tmpDir(.{});
@@ -120,7 +120,7 @@ test "addons: the image addon opens the pictures a Look names, fitted, with the
defer s.deinit();
try load(&s, Session.image_addon);
const listed = try s.read("/addons");
- try std.testing.expect(std.mem.startsWith(u8, listed, "image 1 3.3 0 /") and has(listed, " loaded\n"));
+ try std.testing.expect(std.mem.startsWith(u8, listed, "image 1 3.4 0 /") and has(listed, " loaded\n"));
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
var buf: [4096]u8 = undefined;
@@ -530,3 +530,26 @@ test "addons: Enter on a picture in a picker opens its kind's pane, never its by
try std.testing.expect(has(screen, s.at("\"serial\":{d},", .{image})) and has(screen, "\"src\":[0,0,2,1]"));
try std.testing.expect(!has(try s.screen(), "1 P6"));
}
+
+test "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" {
+ {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try load(&s, fake.ok);
+ defer unload(&s, "fake");
+ try s.write("/ctl", "Theme acme\n");
+ try s.write("/ctl", "Fake\n");
+ // acme's: its hit ground, and its amber held for its page's ink.
+ try std.testing.expect(has(try s.screen(), "hits ffc790 a05200"));
+ try s.write("/ctl", "Theme neonotte84\n");
+ try std.testing.expect(has(try s.screen(), "hits 4c301a e59d3c"));
+ }
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try load(&s, fake.old);
+ defer unload(&s, "fakeold");
+ const listed = try s.read("/addons");
+ try std.testing.expect(std.mem.startsWith(u8, listed, "fakeold 1 3.3 0 /") and has(listed, " loaded\n"));
+ try s.write("/ctl", "Fake\n");
+ try std.testing.expect(has(try s.screen(), "count 0"));
+}
diff --git a/test/behaviour/addons_pdf.zig b/test/behaviour/addons_pdf.zig
index 7df5d5ee..c59b4a93 100644
--- a/test/behaviour/addons_pdf.zig
+++ b/test/behaviour/addons_pdf.zig
@@ -38,7 +38,7 @@ test "addons: a PDF is the pdf addon's pane, its pages pictures, its page in its
s.graphics();
const n = try s.lookFile("docs/design.pdf");
try std.testing.expect(has(try s.read("/index"), " pdf "));
- try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "pdf 1 3.3 1 /"));
+ try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "pdf 1 3.4 1 /"));
const pages = (try s.pdfPage(n))[1];
try std.testing.expectEqual(@as(u32, 16), pages);
// Its first page, a picture over its body.
diff --git a/test/session.zig b/test/session.zig
index 9285c13b..91cca3e5 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -23,6 +23,7 @@ pub const Session = struct {
pub const no_export = o.fake_addon_no_export;
pub const core_word = o.fake_addon_core_word;
pub const no_dump = o.fake_addon_no_dump;
+ pub const old = o.fake_addon_old;
};
core: *anyopaque,