From d1d5d3cfb18841604bba2057eeb3598f729b4475 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 02:56:53 -0300 Subject: client #1, the views indexed: a view's share of the session is Pardes.View (the ~42 fields views.fields named: size, cell metrics, columns, rects, focus, jumps, pointer, gestures, prefixes, frontend), one of Pardes.views[4] (null when closed), the live one views[live] through Pardes.view() (index field `view` renamed `live`); going into another view is the index plus the panes' shares, which stay swapped (park and unpark now move only Pane.pv); views.zig loses fields, Part over Pardes, Parked, kept, emptied and the session half of every copy, and a pane closing leaves every view's layout at once (views.gone, at the two places a slot is freed) instead of the serials each parked view kept; drawOne and within put the drawn view's own share back whole; the views are in the digest now (tape's per-field parts name views[k].field), so a fresh view's col_x/col_w default to zeros, not undefined; the dump keeps every open view in the core and the panes' shares of the others under `shares`; an image from before (live view as the core's own fields, the rest under `views`) loads them into views[] once; the ~2,400 references rewritten mechanically from the compiler's errors (p.active is p.view().active, `const v = p.view()` hoisted in 823 places), Kind.zig (4 lines) and addon_test.zig (3) among them, macos.zig by pattern (not compiled here); tape's watched host writes read the live view's frontend and active; perf.zig's accessor lines change its harness hash, the debug baselines re-keyed to it (their numbers the base's); no golden changes; gates: core-test 956/956 both, unit-test 1487/1488 tui and 1530/1531 gui, behaviour-test 248/248 both, pane-test 171/172, snap all 105 ok, process-test 0 of 37 failed tui, replicas ok Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/pdf.zig | 178 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 89 insertions(+), 89 deletions(-) (limited to 'test/pdf.zig') diff --git a/test/pdf.zig b/test/pdf.zig index da1cb45d..5de72876 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -107,14 +107,14 @@ const PdfLinkTests = struct { const path = try std.fmt.allocPrint(std.testing.allocator, "{s}/links.pdf", .{dir_buf[0..len]}); defer std.testing.allocator.free(path); const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 100, .rows = 36 }); - p.frontend.native_images = true; + p.view().frontend.native_images = true; p.panes[0].?.pdf.?.fit = .height; return p; } fn cellAt(p: *Pardes, x: f32, y: f32) !Cell { const pane = p.panes[0].?; - const rect = p.rects[0]; + const rect = p.view().rects[0]; var best: ?Cell = null; var distance: f32 = std.math.inf(f32); for (rect.y..rect.y + rect.h) |row| for (rect.x..rect.x + rect.w) |col| { @@ -200,8 +200,8 @@ const PdfLinkTests = struct { pardes.look.lookAt(p, choices_id, "https://example.com/embedded"); try expectOpened(p, "https://example.com/embedded"); pardes.look.lookAt(p, choices_id, "target.txt"); - try std.testing.expectEqualStrings("chosen file\n", p.panes[p.active].?.file.?.content); - p.active = 0; + try std.testing.expectEqualStrings("chosen file\n", p.panes[p.view().active].?.file.?.content); + p.view().active = 0; _ = try p.render(frame.allocator()); click(p, try textCell(p, "https://example.com/same")); try expectOpened(p, "https://example.com/same"); @@ -376,16 +376,16 @@ test "PdfSections Look follows the exact owning PDF, not an equal path" { const first_row = std.mem.sliceTo(first_output.file.?.content, '\n'); const target = first_row[0 .. std.mem.indexOfScalar(u8, first_row, ' ') orelse first_row.len]; pardes.look.lookAt(p, first_output_id, target); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); pardes.look.lookAt(p, duplicate_output_id, target); - try std.testing.expectEqual(duplicate_id, p.active); + try std.testing.expectEqual(duplicate_id, p.view().active); // Once the original document is gone, its output cannot reinterpret an // old ordinal against the still-open equal-path duplicate. try std.testing.expect(pardes.test_api.runBuiltin(p, "Del", 0, "", null)); - p.active = first_output_id; + p.view().active = first_output_id; pardes.look.lookAt(p, first_output_id, target); - try std.testing.expectEqual(first_output_id, p.active); + try std.testing.expectEqual(first_output_id, p.view().active); } test "SDL PDF raster policy is materially denser than Kitty" { @@ -437,7 +437,7 @@ test "watched PDF reload replaces MuPDF state and preserves the reading view" { const sections = p.panes[sections_id].?; try std.testing.expect(sections.file.?.content.len > 0); - p.frontend.native_images = true; + p.view().frontend.native_images = true; state.fit = .height; state.tint = .full; state.pan_x = 1234; @@ -554,7 +554,7 @@ test "PDF reload does not re-center an already revealed matching search" { const path = try std.fmt.bufPrint(&path_buf, ".zig-cache/tmp/{s}/search.pdf", .{tmp.sub_path}); const p = try Pardes.init(gpa, .{ .file = path, .cols = 80, .rows = 28 }); defer p.deinit(); - p.frontend.native_images = true; + p.view().frontend.native_images = true; const pane = p.panes[0].?; const state = pane.pdf.?; try state.setSearchQuery(p.pdf_gpa, "Pardes"); @@ -614,14 +614,14 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { try std.testing.expectEqual(PdfFitMode.width, pane.pdf.?.fit); try std.testing.expectEqual(@as(u16, 0), pane.pdf.?.pan_x); try std.testing.expectEqual(@as(u16, 0), pane.pdf.?.pan_y); - try std.testing.expectEqual(@as(u16, 8), p.cell_pixels.w); - try std.testing.expectEqual(@as(u16, 16), p.cell_pixels.h); + try std.testing.expectEqual(@as(u16, 8), p.view().cell_pixels.w); + try std.testing.expectEqual(@as(u16, 16), p.view().cell_pixels.h); const initial_tag = try pardes.tagline.tagText(p, p.scratch.allocator(), pane); const expected_tag = try std.fmt.allocPrint(p.scratch.allocator(), "{s} [1/{d}]{s}", .{ pane.pdf.?.path, pane.pdf.?.page_count, pane_tail }); try std.testing.expectEqualStrings(expected_tag, initial_tag); try std.testing.expect(std.mem.endsWith(u8, initial_tag, pane_tail)); - p.frontend.native_images = true; + p.view().frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); const first = try p.render(frame.allocator()); @@ -668,7 +668,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { // replacing page pixels. Document placement, not texture identity, moves. p.update(.{ .key = .{ .cp = 'j' } }); try std.testing.expectEqual(@as(usize, 0), pane.pdf.?.page); - try std.testing.expectEqual(@as(f64, p.cell_pixels.h), pane.pdf.?.document_scroll_y); + try std.testing.expectEqual(@as(f64, p.view().cell_pixels.h), pane.pdf.?.document_scroll_y); try std.testing.expectEqual( first_place.revision, panes.Pdf.rasterForPage(pane.pdf.?, pane.pdf.?.page).?.revision, @@ -682,7 +682,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { pane.pdf.?.document_scroll_y = 0; p.update(.{ .key = .{ .cp = '3' } }); p.update(.{ .key = .{ .cp = 'j' } }); - try std.testing.expectEqual(@as(f64, p.cell_pixels.h * 3), pane.pdf.?.document_scroll_y); + try std.testing.expectEqual(@as(f64, p.view().cell_pixels.h * 3), pane.pdf.?.document_scroll_y); // Counts survive a shared multi-key prefix. An invalid continuation is // consumed and clears both prefix and count before the following action. @@ -690,7 +690,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { p.update(.{ .key = .{ .cp = '2' } }); p.update(.{ .key = .{ .cp = 'g' } }); p.update(.{ .key = .{ .cp = 'j' } }); - try std.testing.expectEqual(@as(f64, p.cell_pixels.h * 2), pane.pdf.?.document_scroll_y); + try std.testing.expectEqual(@as(f64, p.view().cell_pixels.h * 2), pane.pdf.?.document_scroll_y); pane.pdf.?.document_scroll_y = 0; p.update(.{ .key = .{ .cp = '4' } }); p.update(.{ .key = .{ .cp = 'g' } }); @@ -712,7 +712,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { p.update(.{ .key = .{ .cp = '2' } }); p.update(.{ .key = .{ .cp = 'u', .ctrl = true } }); try std.testing.expectEqual(@as(f64, 0), pane.pdf.?.document_scroll_y); - pane.pdf.?.document_scroll_y = @as(f64, p.cell_pixels.h) * 4; + pane.pdf.?.document_scroll_y = @as(f64, p.view().cell_pixels.h) * 4; p.update(.{ .key = .{ .cp = '3' } }); p.update(.{ .key = .{ .cp = 'k' } }); try std.testing.expectEqual(row_scroll, pane.pdf.?.document_scroll_y); @@ -784,7 +784,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { pane.pdf.?.document_scroll_y = before_boundary_scroll; p.update(.{ .key = .{ .cp = 'j' } }); - try std.testing.expectEqual(before_boundary_scroll + p.cell_pixels.h, pane.pdf.?.document_scroll_y); + try std.testing.expectEqual(before_boundary_scroll + p.view().cell_pixels.h, pane.pdf.?.document_scroll_y); _ = frame.reset(.retain_capacity); const second = try p.render(frame.allocator()); try std.testing.expectEqual(@as(usize, 2), second.placements.items.len); @@ -897,13 +897,13 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { // here is the unlooked +Search buffer, so focus lands THERE. Enter is what // jumps, and the document query survives both. p.update(.{ .key = .{ .cp = 'n' } }); - try std.testing.expectEqual(results_id, p.active); + try std.testing.expectEqual(results_id, p.view().active); const results_pane = p.panes[results_id].?; try std.testing.expect(results_pane.body.vsel.active and results_pane.body.vsel.explicit); try std.testing.expectEqual(@as(i32, 0), results_pane.body.cur_row); try std.testing.expectEqual(@as(i32, 0), results_pane.body.cur_col); p.update(.{ .key = .{ .cp = Key.enter } }); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); try std.testing.expectEqualStrings("Pardes", pane.pdf.?.search_query); // Search state is owned and untruncated, and changing pages invalidates @@ -951,7 +951,7 @@ test "a fling's banded pages show the reader exactly what whole pages would" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .file = "docs/design.pdf", .cols = 120, .rows = 40 }); defer p.deinit(); - p.frontend.native_images = true; + p.view().frontend.native_images = true; const pane = p.panes[0].?; const pv = pane.pdf.?; var frame = std.heap.ArenaAllocator.init(gpa); @@ -1055,7 +1055,7 @@ test "a tall page is drawn at the display's resolution, in bands that are the wh defer gpa.free(path); const p = try Pardes.init(gpa, .{ .file = path, .cols = 120, .rows = 40 }); defer p.deinit(); - p.frontend.native_images = true; + p.view().frontend.native_images = true; const pane = p.panes[0].?; const pv = pane.pdf.?; var frame = std.heap.ArenaAllocator.init(gpa); @@ -1175,7 +1175,7 @@ test "a tall page is drawn at the display's resolution, in bands that are the wh const right = @max(quad.ur.x, quad.lr.x); const top = @min(quad.ul.y, quad.ur.y); const bottom = @max(quad.ll.y, quad.lr.y); - const rect = p.rects[0]; + const rect = p.view().rects[0]; var inside: usize = 0; for (rect.y..rect.y + rect.h) |row| for (rect.x..rect.x + rect.w) |col| { const point = panes.Pdf.panePointAtPage(p, pane, 0, @intCast(col), @intCast(row), false) orelse continue; @@ -1216,7 +1216,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.?; - p.frontend.native_images = true; + p.view().frontend.native_images = true; // A second pane, then focus it and come back: `Last` has somewhere to go // and the PDF is where the keys land. @@ -1224,11 +1224,11 @@ test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape lea p.update(.{ .key = .{ .cp = 'w', .ctrl = true } }); p.update(.{ .key = .{ .cp = 'j' } }); p.update(.{ .key = .{ .cp = Key.enter } }); - try std.testing.expectEqual(@as(usize, 1), p.active); + try std.testing.expectEqual(@as(usize, 1), p.view().active); p.update(.{ .key = .{ .cp = 'w', .ctrl = true } }); p.update(.{ .key = .{ .cp = 'k' } }); p.update(.{ .key = .{ .cp = Key.enter } }); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); // Everything a reader can see over the page: a search overlay and a live // word selection. @@ -1248,7 +1248,7 @@ test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape lea // Escape drops the overlay and the selection, keeps the reading position, // and does NOT hand the keyboard to another pane. p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); try std.testing.expect(pv.selection == null and pv.selection_text.len == 0); try std.testing.expectEqual(@as(usize, 0), pv.search_query.len); try std.testing.expect(pv.search_results == null); @@ -1260,28 +1260,28 @@ test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape lea // With nothing left to drop, Escape goes back a pane as anywhere else, // and leaves the document as it found it. p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expectEqual(@as(usize, 1), p.active); + try std.testing.expectEqual(@as(usize, 1), p.view().active); try std.testing.expectEqual(page_before, pv.page); try std.testing.expectEqual(scroll_before, pv.document_scroll_y); // Shift-Escape goes at once, over a selection too. p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); try std.testing.expectEqual( panes.Pdf.SelectionUpdate.changed, pv.setSelection(p.pdf_gpa, quad.ul, quad.lr, false), ); p.update(.{ .key = .{ .cp = Key.escape, .shift = true } }); - try std.testing.expectEqual(@as(usize, 1), p.active); + try std.testing.expectEqual(@as(usize, 1), p.view().active); try std.testing.expect(pv.selection != null); // A text-only page shows neither: one Escape drops them and goes. - p.frontend.native_images = false; + p.view().frontend.native_images = false; p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); try pv.setSearchQuery(p.pdf_gpa, "Pardes"); p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expectEqual(@as(usize, 1), p.active); + try std.testing.expectEqual(@as(usize, 1), p.view().active); try std.testing.expect(pv.selection == null and pv.search_query.len == 0); } @@ -1298,7 +1298,7 @@ test "PDF continuous strip renders every intersecting short page" { const pane = p.panes[0].?; const pv = pane.pdf.?; try std.testing.expect(pv.page_count > 3); - p.frontend.native_images = true; + p.view().frontend.native_images = true; // A legal wide MediaBox can make more than three pages intersect one // viewport. Seed tiny matching rasters so this tests transport/cache @@ -1372,7 +1372,7 @@ test "PDF tint and tinted theme changes rebuild every visible raster only" { defer p.deinit(); const pane = p.panes[0].?; const pv = pane.pdf.?; - p.frontend.native_images = true; + p.view().frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); @@ -1496,7 +1496,7 @@ test "PDF resize preserves page-relative document position" { defer p.deinit(); const pane = p.panes[0].?; const pv = pane.pdf.?; - p.frontend.native_images = true; + p.view().frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); @@ -1508,7 +1508,7 @@ test "PDF resize preserves page-relative document position" { p.update(.{ .resize = .{ .cols = 100, .rows = 24, - .cell_pixels = p.cell_pixels, + .cell_pixels = p.view().cell_pixels, } }); try std.testing.expect(!pv.layout_valid); try std.testing.expect(pv.layout_anchor_pending); @@ -1524,7 +1524,7 @@ test "PDF resize preserves page-relative document position" { p.update(.{ .resize = .{ .cols = 100, .rows = 24, - .cell_pixels = p.cell_pixels, + .cell_pixels = p.view().cell_pixels, } }); try std.testing.expectEqual(held, pv.document_scroll_y); try std.testing.expect(pv.layout_valid); @@ -1547,7 +1547,7 @@ test "PDF pane geometry change preserves its page-relative position" { p.sync(); // rects for the new column, exactly as the two-pane boot did const pane = p.panes[0].?; const pv = pane.pdf.?; - p.frontend.native_images = true; + p.view().frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); @@ -1561,8 +1561,8 @@ test "PDF pane geometry change preserves its page-relative position" { // A divider/split changes rects through computeGeom without emitting a // shell resize. panes.Pdf.ensurePaneLayout anchors against the old layout // before rebuilding it for this wider pane. - const sibling_weight = p.cols[1].weight; - p.cols[0].weight = sibling_weight * 6; + const sibling_weight = p.view().cols[1].weight; + p.view().cols[0].weight = sibling_weight * 6; layout.compute(p); try std.testing.expect(panes.Pdf.paneViewport(p, pane).?.pixel_w != old_width); try std.testing.expect(pv.layout_valid); @@ -1577,7 +1577,7 @@ test "PDF pane geometry change preserves its page-relative position" { // An explicit pending reveal wins over an implicit layout anchor. pv.page = 2; pv.scroll_to_page_pending = true; - p.cols[0].weight = sibling_weight * 2; + p.view().cols[0].weight = sibling_weight * 2; layout.compute(p); _ = frame.reset(.retain_capacity); _ = try p.render(frame.allocator()); @@ -1599,7 +1599,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.?; - p.frontend.native_images = true; + p.view().frontend.native_images = true; var page_hits = try pv.document.search(gpa, 0, "Pardes"); defer page_hits.deinit(gpa); @@ -1634,8 +1634,8 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" { // distinct fit-width crops. The search/reveal math must use the same // reported metrics as placement, whatever a backend reports. p.update(.{ .resize = .{ - .cols = p.screen_w, - .rows = p.screen_h, + .cols = p.view().screen_w, + .rows = p.view().screen_h, .cell_pixels = .{ .w = 16, .h = 4 }, } }); @@ -1709,7 +1709,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { try std.testing.expectEqual(@as(usize, 1), pane.pdf.?.page); p.update(.{ .key = .{ .cp = 'k' } }); try std.testing.expectEqual(@as(usize, 0), pane.pdf.?.page); - const fallback_rect = p.rects[0]; + const fallback_rect = p.view().rects[0]; const fallback_col = fallback_rect.x + config.GUTTER + 1; const fallback_row = fallback_rect.y + BOX_H + 1; p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = fallback_col, .row = fallback_row } }); @@ -1719,7 +1719,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { try std.testing.expect(pane.pdf.?.selection == null); pane.sel[sel_slot].state = .none; - p.frontend.native_images = true; + p.view().frontend.native_images = true; _ = frame.reset(.retain_capacity); _ = try p.render(frame.allocator()); const plain_revision = (try shownAll(p, frame.allocator()))[0].revision; @@ -1757,9 +1757,9 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { const pixel_y = geometry.dst.y + @as(u32, @intCast( @as(u64, source_y - geometry.src.y) * geometry.dst.h / geometry.src.h, )); - const r = p.rects[0]; - const base_col: i32 = @intCast(r.x + config.GUTTER + pixel_x / p.cell_pixels.w); - const base_row: i32 = @intCast(r.y + BOX_H + pixel_y / p.cell_pixels.h); + const r = p.view().rects[0]; + const base_col: i32 = @intCast(r.x + config.GUTTER + pixel_x / p.view().cell_pixels.w); + const base_row: i32 = @intCast(r.y + BOX_H + pixel_y / p.view().cell_pixels.h); var selected_col: ?u16 = null; var selected_row: u16 = 0; @@ -1807,7 +1807,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { // of a gesture rather than observation. { const delay = config.look_preview_delay_frames; - const active_before = p.active; + const active_before = p.view().active; const page_before = pv.page; const scroll_before = pv.document_scroll_y; const sels_before = pane.sel; @@ -1823,9 +1823,9 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { const query_before = try gpa.dupe(u8, pv.search_query); defer gpa.free(query_before); const search_hit_before = pv.search_hit; - const jumps_before = .{ p.jumps.n, p.jumps.cur, p.n_look_src }; + const jumps_before = .{ p.view().jumps.n, p.view().jumps.cur, p.n_look_src }; const effects_before = p.effects_len; - try std.testing.expect(p.drag == .none); + try std.testing.expect(p.view().drag == .none); const hover_motion = Event{ .mouse = .{ .button = .none, @@ -1862,7 +1862,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { _ = try p.render(frame.allocator()); try std.testing.expect((try shownAll(p, frame.allocator()))[0].revision != hovered_revision); - try std.testing.expectEqual(active_before, p.active); + try std.testing.expectEqual(active_before, p.view().active); try std.testing.expectEqual(page_before, pv.page); try std.testing.expectEqual(scroll_before, pv.document_scroll_y); try std.testing.expect(std.meta.eql(sels_before, pane.sel)); @@ -1875,9 +1875,9 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { try std.testing.expect(std.meta.eql(selection_head_before, pv.selection_head)); try std.testing.expectEqualStrings(query_before, pv.search_query); try std.testing.expectEqual(search_hit_before, pv.search_hit); - try std.testing.expectEqual(jumps_before, .{ p.jumps.n, p.jumps.cur, p.n_look_src }); + try std.testing.expectEqual(jumps_before, .{ p.view().jumps.n, p.view().jumps.cur, p.n_look_src }); try std.testing.expectEqual(effects_before, p.effects_len); - try std.testing.expect(p.drag == .none); + try std.testing.expect(p.view().drag == .none); } // A native right-click resolves the same MuPDF-snapped word and feeds it @@ -1928,16 +1928,16 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { panes.Pdf.toggleFit(pane); // restore the reading-width geometry try std.testing.expect(pv.search_reveal_pending); pv.search_reveal_pending = false; - const original_cell_pixels = p.cell_pixels; + const original_cell_pixels = p.view().cell_pixels; p.update(.{ .resize = .{ - .cols = p.screen_w, - .rows = p.screen_h, - .cell_pixels = p.cell_pixels, + .cols = p.view().screen_w, + .rows = p.view().screen_h, + .cell_pixels = p.view().cell_pixels, } }); try std.testing.expect(!pv.search_reveal_pending); p.update(.{ .resize = .{ - .cols = p.screen_w, - .rows = p.screen_h, + .cols = p.view().screen_w, + .rows = p.view().screen_h, .cell_pixels = .{ .w = original_cell_pixels.w, .h = original_cell_pixels.h + 1, @@ -1955,8 +1955,8 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { (try shownAll(p, frame.allocator()))[0].revision, ); p.update(.{ .resize = .{ - .cols = p.screen_w, - .rows = p.screen_h, + .cols = p.view().screen_w, + .rows = p.view().screen_h, .cell_pixels = original_cell_pixels, } }); _ = frame.reset(.retain_capacity); @@ -2005,7 +2005,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { .col = drag_col, .row = drag_row, } }); - try std.testing.expect(p.drag.select.pdf.selection_changed); + try std.testing.expect(p.view().drag.select.pdf.selection_changed); _ = frame.reset(.retain_capacity); _ = try p.render(frame.allocator()); try std.testing.expectEqual( @@ -2058,7 +2058,7 @@ test "Esc back into a PDF keeps the offset within its page" { const p = try Pardes.init(gpa, .{ .file = path, .cols = 80, .rows = 28 }); defer p.deinit(); p.update(.{ .resize = .{ .cols = 80, .rows = 28 } }); - const doc = p.active; + const doc = p.view().active; const dp = p.panes[doc].?; try std.testing.expect(dp.pdf != null); p.sync(); @@ -2070,12 +2070,12 @@ test "Esc back into a PDF keeps the offset within its page" { pv.scroll_to_page_pending = false; p.update(.{ .key = .{ .cp = 'n', .alt = true } }); // a shell under the doc p.sync(); - const shell = p.active; + const shell = p.view().active; try std.testing.expect(shell != doc); p.update(.{ .key = .{ .cp = Key.escape } }); // Esc: back into the PDF p.sync(); - try std.testing.expectEqual(doc, p.active); + try std.testing.expectEqual(doc, p.view().active); // The jumps stack records a PDF as its PAGE, so returning revealed the page // you were already on — and a reveal sets `document_scroll_y` to that page's @@ -2090,20 +2090,20 @@ test "PDF Back and Forward clear selections and land on recorded pages" { if (!pdf_enabled) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .file = "docs/design.pdf", .cols = 80, .rows = 28 }); defer p.deinit(); - p.frontend.native_images = true; + p.view().frontend.native_images = true; const pane = p.panes[0].?; const state = pane.pdf.?; try std.testing.expect(state.page_count > 1); try std.testing.expect(state.focusLocation(p.pdf_gpa, 2, 0)); - p.jumps.n = 2; - p.jumps.cur = 1; - p.jumps.list[0] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 0 }; - p.jumps.list[1] = .{ .pane = 0, .serial = pane.serial, .line = 2, .col = 0 }; + p.view().jumps.n = 2; + p.view().jumps.cur = 1; + p.view().jumps.list[0] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 0 }; + p.view().jumps.list[1] = .{ .pane = 0, .serial = pane.serial, .line = 2, .col = 0 }; for ([_]u21{ 'o', 'i' }, 0..) |key, destination| { try std.testing.expectEqual(panes.Pdf.SelectionUpdate.changed, state.setSelection(p.pdf_gpa, .{ .x = 0, .y = 0 }, .{ .x = 1, .y = 1 }, true)); try std.testing.expect(state.selection != null and state.selection_text.len > 0); p.update(.{ .key = .{ .cp = key, .ctrl = true } }); - try std.testing.expectEqual(destination, p.jumps.cur); + try std.testing.expectEqual(destination, p.view().jumps.cur); try std.testing.expectEqual(destination, state.page); try std.testing.expect(state.selection == null); try std.testing.expect(state.selection_page == null); @@ -2167,18 +2167,18 @@ test "a PDF's jumps: Back after a far jump returns to the exact offset, two plac if (!pdf_enabled) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .file = jumpPdf(), .cols = 80, .rows = 28 }); defer p.deinit(); - p.frontend.native_images = true; - const id = p.active; + p.view().frontend.native_images = true; + const id = p.view().active; const pane = p.panes[id].?; 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. - const before = p.jumps.n; + const before = p.view().jumps.n; _ = try stripAtPlace(p, pane, 1, 0.05); const near = try stripAtPlace(p, pane, 1, 0.8); - try std.testing.expectEqual(before + 2, p.jumps.n); - try std.testing.expect(p.jumps.list[p.jumps.n - 1].pdf); + try std.testing.expectEqual(before + 2, p.view().jumps.n); + try std.testing.expect(p.view().jumps.list[p.view().jumps.n - 1].pdf); // A far jump (a Look at a page), then Back: the exact offset, not the // page's top, and its page. look.lookAt(p, id, if (pv.page_count > 3000) ":3000" else ":4"); @@ -2189,12 +2189,12 @@ test "a PDF's jumps: Back after a far jump returns to the exact offset, two plac try std.testing.expectEqual(@as(usize, 1), pv.page); try std.testing.expectApproxEqAbs(near, pv.document_scroll_y, 0.5); // A wheel's small steps are the same visit: the entry follows them. - const n = p.jumps.n; + const n = p.view().jumps.n; for (0..4) |_| { _ = panes.Pdf.scrollPane(p, pane, 30, true); try jumpFrame(p); } - try std.testing.expectEqual(n, p.jumps.n); + try std.testing.expectEqual(n, p.view().jumps.n); } test "a PDF's jumps keep to the PDF, and a closed PDF reopens at its place" { @@ -2207,21 +2207,21 @@ test "a PDF's jumps keep to the PDF, and a closed PDF reopens at its place" { const path = try std.fmt.bufPrint(&path_buf, "{s}/docs/design.pdf", .{cwd}); const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 28 }); defer p.deinit(); - p.frontend.native_images = true; - const doc = p.active; + p.view().frontend.native_images = true; + const doc = p.view().active; const pane = p.panes[doc].?; try jumpFrame(p); const first = try stripAtPlace(p, pane, 1, 0.3); // A text between, then a far place in the PDF. look.lookAt(p, doc, "../build.zig:10"); try jumpFrame(p); - try std.testing.expect(p.active != doc); - p.active = doc; + try std.testing.expect(p.view().active != doc); + p.view().active = doc; _ = try stripAtPlace(p, pane, 3, 0.5); // Back from the PDF keeps to it: its own earlier place, not the text. pardes.Jump.jumpBy(p, -1); try jumpFrame(p); - try std.testing.expectEqual(doc, p.active); + try std.testing.expectEqual(doc, p.view().active); try std.testing.expectApproxEqAbs(first, pane.pdf.?.document_scroll_y, 0.5); // Closed, its entries stay; Back from the text reopens it at the place. pardes.Jump.jumpBy(p, 1); @@ -2229,15 +2229,15 @@ test "a PDF's jumps keep to the PDF, and a closed PDF reopens at its place" { try p.removePane(doc, null); try jumpFrame(p); var closed = false; - for (p.jumps.list[0..p.jumps.n]) |j| closed = closed or (j.serial == 0 and j.pdf); + for (p.view().jumps.list[0..p.view().jumps.n]) |j| closed = closed or (j.serial == 0 and j.pdf); try std.testing.expect(closed); var tries: usize = 0; while (tries < 4) : (tries += 1) { pardes.Jump.jumpBy(p, -1); try jumpFrame(p); - if (p.panes[p.active].?.pdf != null) break; + if (p.panes[p.view().active].?.pdf != null) break; } - const reopened = p.panes[p.active].?; + const reopened = p.panes[p.view().active].?; try std.testing.expect(reopened.pdf != null); const pv = reopened.pdf.?; // The newest PDF place before the text: page 4, half way down. -- cgit v1.3