diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 06:24:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 11:19:44 -0300 |
| commit | c1917b949b9580de8bf0977874a210f0266812da (patch) | |
| tree | 447dd2235ea00634f662cd3becf4bceb8a895f41 /test/session.zig | |
| parent | 76c55b5bce0f181b0b15b16596c900397dfef544 (diff) | |
| download | pardes-c1917b949b9580de8bf0977874a210f0266812da.tar.gz pardes-c1917b949b9580de8bf0977874a210f0266812da.zip | |
kinds #14, the core's PDF code gone: pdf.zig and pdf_view.zig leave and every pdf_enabled branch with them; look, Jump, Recent, dumps (one from before the addon opens as its pane), the watch, mouse, keys, the rail and the tag go through Kind for any kind's pane; test/pdf.zig's behaviours are T1 cases over 9P (addons_pdf.zig) and pane cases (a Shadow over a replica, a file changed under it), the harnesses load pdf.so by path
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/session.zig')
| -rw-r--r-- | test/session.zig | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/test/session.zig b/test/session.zig index 5b608521..8b8ec17f 100644 --- a/test/session.zig +++ b/test/session.zig @@ -403,24 +403,39 @@ pub const Session = struct { // pdf: + /// The pdf addon (addons/pdf/pdf.c), as the build makes it; a build + /// without it (-Dmupdf=false) has none. + pub const pdf_addon: ?[]const u8 = if (@import("session_options").has_pdf_addon) @import("session_options").pdf_addon else null; + + /// The pdf addon loaded into the session, once: a test of a PDF in a + /// build without it skips. + pub fn loadPdf(s: *Session) !void { + const lib = pdf_addon orelse return error.SkipZigTest; + if (std.mem.indexOf(u8, try s.read("/addons"), "pdf ") != null) return; + const real = try std.Io.Dir.cwd().realPathFileAlloc(std.testing.io, lib, s.arena.allocator()); + try s.write("/ctl", s.at("Addon load {s}\n", .{real})); + } + /// A Look of `path` at the root (one relative to the working directory /// made absolute first); the serial of the pane with the keyboard after. - /// A PDF in a build without them (-Dmupdf=false: no PdfTint in - /// /commands) skips the test. + /// A PDF loads the pdf addon first. pub fn lookFile(s: *Session, path: []const u8) !u32 { - if (std.mem.endsWith(u8, path, ".pdf") and std.mem.indexOf(u8, try s.read("/commands"), "PdfTint") == null) return error.SkipZigTest; + if (std.mem.endsWith(u8, path, ".pdf")) try s.loadPdf(); var buf: [4096]u8 = undefined; const abs = if (std.fs.path.isAbsolute(path)) path else s.at("{s}/{s}", .{ buf[0..try std.Io.Dir.cwd().realPath(std.testing.io, &buf)], path }); try s.write("/look", s.at("{s}\n", .{abs})); return s.focused(); } - /// The page a PDF pane shows and its pages, from its tag's `[page/pages]`. + /// The page a PDF pane shows and its pages, from its tag's `[page/pages]` + /// (the pdf addon's prefix, which starts it). pub fn pdfPage(s: *Session, n: u32) !struct { u32, u32 } { + // A kind's prefix is its last frame's: one drawn first. + _ = try s.read("/screen"); const tag = try s.read(s.at("/pane/{d}/tag", .{n})); - const lo = std.mem.indexOf(u8, tag, " [") orelse return error.NoPage; - const close = std.mem.indexOfScalarPos(u8, tag, lo, ']') orelse return error.NoPage; - var it = std.mem.splitScalar(u8, tag[lo + 2 .. close], '/'); + if (!std.mem.startsWith(u8, tag, "[")) return error.NoPage; + const close = std.mem.indexOfScalar(u8, tag, ']') orelse return error.NoPage; + var it = std.mem.splitScalar(u8, tag[1..close], '/'); return .{ try std.fmt.parseInt(u32, it.next().?, 10), try std.fmt.parseInt(u32, it.next() orelse return error.NoPage, 10) }; } |
