summaryrefslogtreecommitdiff
path: root/test/pdf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 00:31:38 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:02:28 -0300
commit7d359addc420eca66bd1583d8fd8d6a104986a03 (patch)
tree2b8991a9a4e5b9c16a2b7683018d60c7c6985c1e /test/pdf.zig
parent96cabca7ebe287692ebdff0dba6bb2897eba9d3e (diff)
downloadpardes-7d359addc420eca66bd1583d8fd8d6a104986a03.tar.gz
pardes-7d359addc420eca66bd1583d8fd8d6a104986a03.zip
panes: a pane's PDF state is its own allocation, `pdf: ?*Pdf.State` (made by openPane with pdf_gpa, freed by deinitPane), as a terminal's is, where every Pane held the State inline, a text file's and a terminal's too: a Pane is 49232 bytes where it was 88936 (the State 39704), and a replica's rollback copy of a pane without a PDF is that much smaller; the dump and the wire change with it, the walk writing the slot as a pointer to a State where it wrote the State in place, so a dump written before this, or a peer of an older build, gives its PDF panes no PDF (the walk notes `Pane.pdf: its kind changed; its default taken`, and dump.ensureKind makes each a terminal); the 97 uses change form only (a `|*x|` capture or a `&` dropped, normal.zig's one among them), applyNormal untouched
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/pdf.zig')
-rw-r--r--test/pdf.zig52
1 files changed, 26 insertions, 26 deletions
diff --git a/test/pdf.zig b/test/pdf.zig
index 9e183224..655e046a 100644
--- a/test/pdf.zig
+++ b/test/pdf.zig
@@ -369,7 +369,7 @@ test "watched PDF reload replaces MuPDF state and preserves the reading view" {
try std.testing.expect(watched);
const pane = p.panes[0].?;
- const state = &pane.pdf.?;
+ const state = pane.pdf.?;
try std.testing.expectEqual(@as(usize, 3), state.page_count);
panes.Pdf.openSections(p, 0);
const sections_id = pane.search_pane orelse return error.MissingPdfSectionsOutput;
@@ -495,7 +495,7 @@ test "PDF reload does not re-center an already revealed matching search" {
defer p.deinit();
p.native_images = true;
const pane = p.panes[0].?;
- const state = &pane.pdf.?;
+ const state = pane.pdf.?;
try state.setSearchQuery(p.pdf_gpa, "Pardes");
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
@@ -578,7 +578,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" {
try std.testing.expectEqual(pdf_raster_policy.max_dimension, request.max_dimension);
try std.testing.expectEqual(
request,
- panes.Pdf.rasterForPage(&pane.pdf.?, pane.pdf.?.page).?.request,
+ panes.Pdf.rasterForPage(pane.pdf.?, pane.pdf.?.page).?.request,
);
try std.testing.expect(@max(first_place.iw, first_place.ih) <= request.max_dimension);
if (pdf_raster_policy.match_viewport) {
@@ -611,7 +611,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" {
try std.testing.expectEqual(@as(f64, p.cell_pixels.h), pane.pdf.?.document_scroll_y);
try std.testing.expectEqual(
first_place.native.revision,
- panes.Pdf.rasterForPage(&pane.pdf.?, pane.pdf.?.page).?.revision,
+ panes.Pdf.rasterForPage(pane.pdf.?, pane.pdf.?.page).?.revision,
);
_ = frame.reset(.retain_capacity);
const panned = try p.render(frame.allocator());
@@ -671,7 +671,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" {
try std.testing.expectEqual(@max(@as(f64, 0), counted_full - @as(f64, @floatFromInt(key_viewport.pixel_h * 2))), pane.pdf.?.document_scroll_y);
try std.testing.expectEqual(
first_place.native.revision,
- panes.Pdf.rasterForPage(&pane.pdf.?, pane.pdf.?.page).?.revision,
+ panes.Pdf.rasterForPage(pane.pdf.?, pane.pdf.?.page).?.revision,
);
// At a page boundary both page rasters coexist, the gap remains uncovered,
@@ -712,13 +712,13 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" {
pane.pdf.?.document_scroll_y = @as(f64, @floatFromInt(pane.pdf.?.page_starts[1])) - 0.5;
try std.testing.expectEqual(
page0_revision,
- panes.Pdf.rasterForPage(&pane.pdf.?, 0).?.revision,
+ panes.Pdf.rasterForPage(pane.pdf.?, 0).?.revision,
);
try std.testing.expect(panes.Pdf.scrollPane(p, pane, 1, false));
try std.testing.expectEqual(@as(usize, 1), pane.pdf.?.page);
try std.testing.expectEqual(
page1_revision,
- panes.Pdf.rasterForPage(&pane.pdf.?, pane.pdf.?.page).?.revision,
+ panes.Pdf.rasterForPage(pane.pdf.?, pane.pdf.?.page).?.revision,
);
panes.Pdf.activatePage(p, pane, 0, false);
pane.pdf.?.document_scroll_y = before_boundary_scroll;
@@ -745,7 +745,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" {
try std.testing.expect(away.images.items.len > 0);
for (away.images.items) |place|
try std.testing.expect(place.native.page != 0);
- try std.testing.expect(panes.Pdf.rasterForPage(&pane.pdf.?, 0) == null);
+ try std.testing.expect(panes.Pdf.rasterForPage(pane.pdf.?, 0) == null);
try std.testing.expectEqual(@as(usize, 1), pane.pdf.?.spare_len);
const retired = pane.pdf.?.spare[0];
panes.Pdf.activatePage(p, pane, 0, true);
@@ -761,7 +761,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" {
const fit_builtin = std.meta.stringToEnum(Builtin, "PdfFit") orelse
return error.MissingPdfFitBuiltin;
const revision_before_toggle = panes.Pdf.rasterForPage(
- &pane.pdf.?,
+ pane.pdf.?,
pane.pdf.?.page,
).?.revision;
try std.testing.expect(pardes.test_api.runBuiltin(
@@ -776,7 +776,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" {
try std.testing.expectEqual(@as(u16, 0), pane.pdf.?.pan_y);
try std.testing.expectEqual(
revision_before_toggle,
- panes.Pdf.rasterForPage(&pane.pdf.?, pane.pdf.?.page).?.revision,
+ panes.Pdf.rasterForPage(pane.pdf.?, pane.pdf.?.page).?.revision,
);
const height_tag = try pardes.tagline.tagText(p, p.scratch.allocator(), pane);
const expected_height_tag = try std.fmt.allocPrint(p.scratch.allocator(), "{s} [{d}/{d}]{s}", .{ pane.pdf.?.path, pane.pdf.?.page + 1, pane.pdf.?.page_count, pane_tail });
@@ -792,7 +792,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" {
// A fit-height landscape page exposes horizontal overflow to a horizontal
// wheel without rerasterizing. Use synthetic dimensions only for the
// geometry check; no frame is drawn while they differ from the buffer.
- const active_raster = panes.Pdf.rasterForPage(&pane.pdf.?, pane.pdf.?.page).?;
+ const active_raster = panes.Pdf.rasterForPage(pane.pdf.?, pane.pdf.?.page).?;
const saved_iw = active_raster.iw;
const saved_ih = active_raster.ih;
active_raster.iw = 2000;
@@ -893,7 +893,7 @@ test "a fling's banded pages show the reader exactly what whole pages would" {
defer p.deinit();
p.native_images = true;
const pane = p.panes[0].?;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
@@ -997,7 +997,7 @@ test "a tall page is drawn at the display's resolution, in bands that are the wh
defer p.deinit();
p.native_images = true;
const pane = p.panes[0].?;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
@@ -1155,7 +1155,7 @@ test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape lea
});
defer p.deinit();
const pane = p.panes[0].?;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
p.native_images = true;
// A second pane, then focus it and come back: `Last` has somewhere to go
@@ -1236,7 +1236,7 @@ test "PDF continuous strip renders every intersecting short page" {
});
defer p.deinit();
const pane = p.panes[0].?;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
try std.testing.expect(pv.page_count > 3);
p.native_images = true;
@@ -1312,7 +1312,7 @@ test "PDF tint and tinted theme changes rebuild every visible raster only" {
defer p.deinit();
p.settings.motion = .off; // placements, not the glide (anim 11)
const pane = p.panes[0].?;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
p.native_images = true;
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
@@ -1451,7 +1451,7 @@ test "PDF resize preserves page-relative document position" {
});
defer p.deinit();
const pane = p.panes[0].?;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
p.native_images = true;
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
@@ -1502,7 +1502,7 @@ test "PDF pane geometry change preserves its page-relative position" {
_ = layout.splitColumn(p, 0, 1, false);
p.sync(); // rects for the new column, exactly as the two-pane boot did
const pane = p.panes[0].?;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
p.native_images = true;
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
@@ -1554,7 +1554,7 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" {
});
defer p.deinit();
const pane = p.panes[0].?;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
p.native_images = true;
var page_hits = try pv.document.search(gpa, 0, "Pardes");
@@ -1685,7 +1685,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" {
const quad = found.quads[0].quad;
const nx = (quad.ul.x + quad.ur.x + quad.ll.x + quad.lr.x) / 4;
const ny = (quad.ul.y + quad.ur.y + quad.ll.y + quad.lr.y) / 4;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
const raster = panes.Pdf.rasterForPage(pv, pv.page).?;
const source_x: u32 = @intCast(@min(
raster.iw - 1,
@@ -2020,7 +2020,7 @@ test "Esc back into a PDF keeps the offset within its page" {
p.sync();
// Read a little way DOWN the page you are on, then step away.
- const pv = &dp.pdf.?;
+ const pv = dp.pdf.?;
pv.document_scroll_y += 137;
const mid = pv.document_scroll_y;
pv.scroll_to_page_pending = false;
@@ -2049,7 +2049,7 @@ test "PDF Back and Forward clear selections and land on recorded pages" {
p.native_images = true;
p.presentation.enabled = false;
const pane = p.panes[0].?;
- const state = &pane.pdf.?;
+ const state = pane.pdf.?;
try std.testing.expect(state.page_count > 1);
try std.testing.expect(state.focusLocation(p.pdf_gpa, 2, 0));
p.njumps = 2;
@@ -2091,7 +2091,7 @@ test "a PDF's fit and tint, and Collapse, read in its ctl and come back from a D
try pardes.dump.dumpState(p);
const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon");
defer restored.deinit();
- const pv = &restored.panes[0].?.pdf.?;
+ const pv = restored.panes[0].?.pdf.?;
try std.testing.expectEqualStrings("height", @tagName(pv.fit));
try std.testing.expectEqualStrings("full", @tagName(pv.tint));
}
@@ -2114,7 +2114,7 @@ fn jumpFrame(p: *Pardes) !void {
}
fn stripAtPlace(p: *Pardes, pane: *pardes.Pane, page: usize, fraction: f64) !f64 {
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
pv.document_scroll_y = @as(f64, @floatFromInt(pv.page_starts[page])) + fraction * @as(f64, @floatFromInt(pv.page_heights[page]));
try jumpFrame(p);
return pv.document_scroll_y;
@@ -2128,7 +2128,7 @@ test "a PDF's jumps: Back after a far jump returns to the exact offset, two plac
p.presentation.enabled = false;
const id = p.active;
const pane = p.panes[id].?;
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
try jumpFrame(p);
try std.testing.expect(pv.page_count > 3);
// Two places on page 1, more than a body apart: two entries.
@@ -2199,7 +2199,7 @@ test "a PDF's jumps: JumpScope file keeps to the PDF, and a closed PDF reopens a
}
const reopened = p.panes[p.active].?;
try std.testing.expect(reopened.pdf != null);
- const pv = &reopened.pdf.?;
+ const pv = reopened.pdf.?;
// The newest PDF place before the text: page 4, half way down.
try std.testing.expectEqual(@as(usize, 3), pv.page);
const want = @as(f64, @floatFromInt(pv.page_starts[3])) + 0.5 * @as(f64, @floatFromInt(pv.page_heights[3]));