diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:27:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:01:28 -0300 |
| commit | 55b842a1be818562a0d70bad3477405a5dc57afa (patch) | |
| tree | e988b15a4723855dbbfc572869e9b9ea466365c4 /test/pdf.zig | |
| parent | c62ddeed7b3b176f9a777e3670017542da898f17 (diff) | |
| download | pardes-55b842a1be818562a0d70bad3477405a5dc57afa.tar.gz pardes-55b842a1be818562a0d70bad3477405a5dc57afa.zip | |
pdf_view: the pane layer's one-caller wrappers are their callers (pageAtViewportY in pageAtGridRow, nativeReady in paneNativeReady, pointAtPage in panePointAtPage, stepPanePage in verticalWheel, panPane in horizontalWheel, reloadPane in reloadWatched, pointAt's two callers ask panePointAtPage for the page they stand on), setPage and beginSelection go (only test/pdf.zig called them: it calls activatePage and beginDrag with true), and a pane's rect and id are Pardes.paneIdOf's where four loops searched for them; three copies of the whole PDF state taken to read a field go with them
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.zig | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/test/pdf.zig b/test/pdf.zig index 21e84880..1bbfa59c 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -122,7 +122,7 @@ const PdfLinkTests = struct { _ = try p.render(frame.allocator()); while (p.nextEffect()) |_| {} const target_cell = try textCell(p, "target.txt"); - try std.testing.expect(panes.Pdf.beginSelection(p, p.panes[0].?, target_cell.col, target_cell.row)); + try std.testing.expect(panes.Pdf.beginDrag(p, p.panes[0].?, target_cell.col, target_cell.row, true)); try std.testing.expect(p.panes[0].?.pdf.?.selection != null); click(p, target_cell); try expectOpened(p, null); @@ -175,9 +175,9 @@ const PdfLinkTests = struct { p.update(.pointer_leave); try std.testing.expectEqual(Surface.PointerShape.arrow, (try p.render(frame.allocator())).pointer_shape); hover(p, blank); - panes.Pdf.setPage(p, pane, 1); + panes.Pdf.activatePage(p, pane, 1, true); try std.testing.expectEqual(Surface.PointerShape.arrow, (try p.render(frame.allocator())).pointer_shape); - panes.Pdf.setPage(p, pane, 0); + panes.Pdf.activatePage(p, pane, 0, true); _ = try p.render(frame.allocator()); hover(p, try cellAt(p, 0.3, 0.38)); try std.testing.expect(p.reloadWatchedFile(0, &.{})); @@ -382,7 +382,7 @@ test "watched PDF reload replaces MuPDF state and preserves the reading view" { state.pan_x = 1234; state.pan_y = 4321; try state.setSearchQuery(p.pdf_gpa, "needle"); - panes.Pdf.setPage(p, pane, 2); + panes.Pdf.activatePage(p, pane, 2, true); var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); _ = try p.render(frame.allocator()); @@ -739,7 +739,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { // the relay and the arriving page of the same size takes them, so a fling // never asks the allocator (or the kernel's fault handler) for megabytes it // just gave up. - panes.Pdf.setPage(p, pane, 1); + panes.Pdf.activatePage(p, pane, 1, true); _ = frame.reset(.retain_capacity); const away = try p.render(frame.allocator()); try std.testing.expect(away.images.items.len > 0); @@ -748,7 +748,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { 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.setPage(p, pane, 0); + panes.Pdf.activatePage(p, pane, 0, true); _ = frame.reset(.retain_capacity); const returned = try p.render(frame.allocator()); try std.testing.expectEqual(@as(u32, 0), returned.images.items[0].native.page); @@ -854,7 +854,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { try pane.pdf.?.setSearchQuery(p.pdf_gpa, long_query); try std.testing.expectEqualStrings(long_query, pane.pdf.?.search_query); const next_page = if (pane.pdf.?.page == 0) @as(usize, 1) else 0; - panes.Pdf.setPage(p, pane, next_page); + panes.Pdf.activatePage(p, pane, next_page, true); try std.testing.expectEqualStrings(long_query, pane.pdf.?.search_query); // PDF dumps keep the image-compatible schema: page/path, the exact @@ -1456,7 +1456,7 @@ test "PDF resize preserves page-relative document position" { var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); - panes.Pdf.setPage(p, pane, 1); + panes.Pdf.activatePage(p, pane, 1, true); _ = try p.render(frame.allocator()); const fraction: f64 = 0.375; pv.document_scroll_y = @as(f64, @floatFromInt(pv.page_starts[1])) + @@ -1507,7 +1507,7 @@ test "PDF pane geometry change preserves its page-relative position" { var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); - panes.Pdf.setPage(p, pane, 1); + panes.Pdf.activatePage(p, pane, 1, true); _ = try p.render(frame.allocator()); const fraction: f64 = 0.625; pv.document_scroll_y = @as(f64, @floatFromInt(pv.page_starts[1])) + @@ -1731,7 +1731,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { @as(i32, r.y + BOX_H), @as(i32, r.y + r.h - 1), )); - if (!panes.Pdf.beginSelection(p, pane, col, row)) continue; + if (!panes.Pdf.beginDrag(p, pane, col, row, true)) continue; if (std.ascii.findIgnoreCase(pv.selection_text, "Pardes") != null) { selected_col = col; selected_row = row; @@ -1751,7 +1751,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { // Repeating an identical drag endpoint is a no-op: Kitty/SDL keep the // same texture generation instead of retransmitting identical pixels. - try std.testing.expect(panes.Pdf.beginSelection(p, pane, word_col, selected_row)); + try std.testing.expect(panes.Pdf.beginDrag(p, pane, word_col, selected_row, true)); try std.testing.expect(raster.tried); _ = frame.reset(.retain_capacity); const duplicate = try p.render(frame.allocator()); @@ -1921,14 +1921,14 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { // Unsupported text-selection actions are consumed by the PDF adapter: // they neither invent a range over placeholder cells nor disturb the // native MuPDF selection. The select-button's no-drag click still clears. - try std.testing.expect(panes.Pdf.beginSelection(p, pane, word_col, selected_row)); + try std.testing.expect(panes.Pdf.beginDrag(p, pane, word_col, selected_row, true)); p.update(.{ .key = .{ .cp = 'v' } }); try std.testing.expect(pv.selection != null); try std.testing.expect(!pane.body.vsel.active); p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = word_col, .row = selected_row } }); p.update(.{ .mouse = .{ .button = config.select_button, .kind = .release, .col = word_col, .row = selected_row } }); try std.testing.expect(pv.selection == null); - try std.testing.expect(panes.Pdf.beginSelection(p, pane, word_col, selected_row)); + try std.testing.expect(panes.Pdf.beginDrag(p, pane, word_col, selected_row, true)); // Native drag events update MuPDF quads and copied text immediately, but // keep the already transmitted page generation stable until release. @@ -1993,7 +1993,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { const saved_selection = try gpa.dupe(u8, pv.selection_text); defer gpa.free(saved_selection); const selected_page = pv.selection_page; - panes.Pdf.setPage(p, pane, 1); + panes.Pdf.activatePage(p, pane, 1, true); try std.testing.expect(pv.selection != null); try std.testing.expectEqual(selected_page, pv.selection_page); try std.testing.expectEqualStrings(saved_selection, pv.selection_text); |
