summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 02:56:53 -0300
committerGabriel Schneider <[email protected]>2026-11-06 04:13:33 -0300
commitd1d5d3cfb18841604bba2057eeb3598f729b4475 (patch)
tree298c29ab8767852bf74eb86ad4d15acc4348f109 /test
parent33037ece5af9ae1c7048819bbbae3fc5e6fc4ade (diff)
downloadpardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.tar.gz
pardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
-rw-r--r--test/column_drag.zig177
-rw-r--r--test/fs_namespace.zig16
-rw-r--r--test/hxdiff.zig4
-rw-r--r--test/kitty.zig8
-rw-r--r--test/mode.zig2
-rw-r--r--test/output.zig84
-rw-r--r--test/panes.zig214
-rw-r--r--test/pdf.zig178
-rw-r--r--test/perf-baseline-gui-debug.json2
-rw-r--r--test/perf-baseline-tui-debug.json2
-rw-r--r--test/perf.zig12
-rw-r--r--test/replicas.zig2
-rw-r--r--test/session.zig4
13 files changed, 353 insertions, 352 deletions
diff --git a/test/column_drag.zig b/test/column_drag.zig
index 013d536f..e64656e3 100644
--- a/test/column_drag.zig
+++ b/test/column_drag.zig
@@ -30,13 +30,14 @@ const Snapshot = struct {
};
fn expectOrder(p: *Pardes, before: []const Snapshot, order: []const usize) !void {
- try std.testing.expectEqual(order.len, p.ncol);
+ const v = p.view();
+ try std.testing.expectEqual(order.len, v.ncol);
for (order, 0..) |original, column| {
const saved = before[original];
- try std.testing.expectEqual(saved.weight, p.cols[column].weight);
- try std.testing.expectEqual(saved.serial, p.cols[column].serial);
- try std.testing.expectEqual(saved.count, p.cols[column].n);
- try std.testing.expectEqualSlices(usize, saved.panes[0..saved.count], p.cols[column].panes[0..p.cols[column].n]);
+ try std.testing.expectEqual(saved.weight, v.cols[column].weight);
+ try std.testing.expectEqual(saved.serial, v.cols[column].serial);
+ try std.testing.expectEqual(saved.count, v.cols[column].n);
+ try std.testing.expectEqualSlices(usize, saved.panes[0..saved.count], v.cols[column].panes[0..p.view().cols[column].n]);
try std.testing.expectEqualStrings(saved.tag, pardes.tagline.columnTag(p, column));
}
}
@@ -45,19 +46,19 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 180, .rows = 30 });
defer p.deinit();
_ = try p.setTestFile("body\n");
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
+ p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
for (0..3) |_| {
- try std.testing.expect(p.executeBuiltinLine(p.active, "New"));
- const id = p.active;
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "New"));
+ const id = p.view().active;
try std.testing.expect(layout.splitColumn(p, id, id, false));
}
- p.active = p.cols[1].panes[0];
- try std.testing.expect(p.executeBuiltinLine(p.active, "New"));
- const active = p.active;
- try std.testing.expectEqual(@as(usize, 2), p.cols[1].n);
+ p.view().active = p.view().cols[1].panes[0];
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "New"));
+ const active = p.view().active;
+ try std.testing.expectEqual(@as(usize, 2), p.view().cols[1].n);
for ([_]u64{ 2, 3, 5, 7 }, 0..) |weight, column| {
- p.cols[column].weight = weight;
- p.col_tags[column].own = try p.gpa.dupe(u8, ([_][]const u8{ "zero column header", "one column header", "two column header", "three column header" })[column]);
+ p.view().cols[column].weight = weight;
+ p.view().col_tags[column].own = try p.gpa.dupe(u8, ([_][]const u8{ "zero column header", "one column header", "two column header", "three column header" })[column]);
}
p.update(.tick);
var frame = std.heap.ArenaAllocator.init(p.gpa);
@@ -65,8 +66,8 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
_ = try p.render(frame.allocator());
var before: [4]Snapshot = undefined;
for (&before, 0..) |*saved, column| {
- saved.* = .{ .weight = p.cols[column].weight, .serial = p.cols[column].serial, .count = p.cols[column].n, .tag = pardes.tagline.columnTag(p, column) };
- @memcpy(saved.panes[0..saved.count], p.cols[column].panes[0..saved.count]);
+ saved.* = .{ .weight = p.view().cols[column].weight, .serial = p.view().cols[column].serial, .count = p.view().cols[column].n, .tag = pardes.tagline.columnTag(p, column) };
+ @memcpy(saved.panes[0..saved.count], p.view().cols[column].panes[0..saved.count]);
}
const layer = try tagLayer(p, 1);
const stale = headerMouse(layer, 4, .press);
@@ -75,25 +76,25 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
try std.testing.expectEqual(@as(?usize, 1), p.headerColumn());
const caret = pardes.tagline.focusedHeader(p).?.cur_col;
const anchor = pardes.tagline.focusedHeader(p).?.vsel;
- const scroll = p.header_scroll;
- const target = p.col_x[3] + p.col_w[3] - 2;
- const last_rect = p.rects[p.cols[3].panes[0]];
+ const scroll = p.view().header_scroll;
+ const target = p.view().col_x[3] + p.view().col_w[3] - 2;
+ const last_rect = p.view().rects[p.view().cols[3].panes[0]];
const last_columns = (try tagLayer(p, 3)).cols;
- mouse(p, .press, p.col_x[1]);
- try std.testing.expect(p.drag == .column_move);
+ mouse(p, .press, p.view().col_x[1]);
+ try std.testing.expect(p.view().drag == .column_move);
mouse(p, .drag, target);
_ = try p.render(frame.allocator());
- try std.testing.expectEqual(p.col_w[3] - pardes.TAG_TEXT_INSET - 1, (try tagLayer(p, 3)).viewport.w);
- try std.testing.expectEqual(last_rect, p.rects[p.cols[3].panes[0]]);
+ try std.testing.expectEqual(p.view().col_w[3] - pardes.TAG_TEXT_INSET - 1, (try tagLayer(p, 3)).viewport.w);
+ try std.testing.expectEqual(last_rect, p.view().rects[p.view().cols[3].panes[0]]);
try std.testing.expectEqual(last_columns, (try tagLayer(p, 3)).cols);
try expectOrder(p, &before, &.{ 0, 1, 2, 3 });
mouse(p, .release, target);
try expectOrder(p, &before, &.{ 0, 2, 3, 1 });
- try std.testing.expectEqual(active, p.active);
+ try std.testing.expectEqual(active, p.view().active);
try std.testing.expectEqual(@as(?usize, 3), p.headerColumn());
try std.testing.expectEqual(caret, pardes.tagline.focusedHeader(p).?.cur_col);
try std.testing.expectEqual(anchor, pardes.tagline.focusedHeader(p).?.vsel);
- try std.testing.expectEqual(scroll, p.header_scroll);
+ try std.testing.expectEqual(scroll, p.view().header_scroll);
// The old tag envelope must not edit the new occupant of its old index,
// including the interval before hosts request another rendered frame.
p.update(.{ .mouse = stale });
@@ -101,43 +102,43 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
try std.testing.expectEqual(caret, pardes.tagline.focusedHeader(p).?.cur_col);
_ = try p.render(frame.allocator());
try std.testing.expectEqual(before[1].serial, (try tagLayer(p, 3)).serial);
- try std.testing.expectEqual(p.col_w[3] - pardes.TAG_TEXT_INSET, (try tagLayer(p, 3)).viewport.w);
- mouse(p, .press, p.col_x[3]);
- const back = p.col_x[1] + config.GUTTER;
+ try std.testing.expectEqual(p.view().col_w[3] - pardes.TAG_TEXT_INSET, (try tagLayer(p, 3)).viewport.w);
+ mouse(p, .press, p.view().col_x[3]);
+ const back = p.view().col_x[1] + config.GUTTER;
mouse(p, .drag, back);
mouse(p, .release, back);
try expectOrder(p, &before, &.{ 0, 1, 2, 3 });
try std.testing.expectEqual(@as(?usize, 1), p.headerColumn());
try std.testing.expectEqual(caret, pardes.tagline.focusedHeader(p).?.cur_col);
- try std.testing.expectEqual(active, p.active);
+ try std.testing.expectEqual(active, p.view().active);
// A structural change between press and release must not retarget the
// in-flight drag to whichever column now occupies the original index.
- mouse(p, .press, p.col_x[1]);
+ mouse(p, .press, p.view().col_x[1]);
layout.reorderColumn(p, 1, 2);
- mouse(p, .release, p.col_x[0] + config.GUTTER);
+ mouse(p, .release, p.view().col_x[0] + config.GUTTER);
try expectOrder(p, &before, &.{ 1, 0, 2, 3 });
try std.testing.expectEqual(@as(?usize, 0), p.headerColumn());
- try std.testing.expect(p.drag == .none);
+ try std.testing.expect(p.view().drag == .none);
}
test "column grip is separate from compact text and the resize seam" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 });
defer p.deinit();
_ = try p.setTestFile("body\n");
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
+ p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
try std.testing.expect(p.executeBuiltinLine(0, "New"));
- try std.testing.expect(layout.splitColumn(p, p.active, p.active, false));
+ try std.testing.expect(layout.splitColumn(p, p.view().active, p.view().active, false));
p.update(.tick);
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
const layer = try tagLayer(p, 1);
- try std.testing.expectEqual(p.col_x[1] + pardes.TAG_TEXT_INSET, layer.viewport.x);
+ try std.testing.expectEqual(p.view().col_x[1] + pardes.TAG_TEXT_INSET, layer.viewport.x);
const surface = &p.surface;
- for (0..p.ncol) |column| {
- const pane_id = p.cols[column].panes[0];
- const rect = p.rects[pane_id];
- try std.testing.expectEqual(p.col_x[column], rect.x);
+ for (0..p.view().ncol) |column| {
+ const pane_id = p.view().cols[column].panes[0];
+ const rect = p.view().rects[pane_id];
+ try std.testing.expectEqual(p.view().col_x[column], rect.x);
try std.testing.expectEqual(rect.x + pardes.TAG_TEXT_INSET, (try tagLayer(p, column)).viewport.x);
for (p.surface.tagLayers()) |pane_layer| {
if (pane_layer.rows > 0 and pane_layer.kind == .pane and pane_layer.id == pane_id)
@@ -152,17 +153,17 @@ test "column grip is separate from compact text and the resize seam" {
try std.testing.expectEqual(pardes.FontRole.tagline, surface.at(rect.x + pardes.TAG_TEXT_INSET, pane_tag_y).style.font_role);
}
p.update(.{ .mouse = headerMouse(layer, 0, .press) });
- try std.testing.expect(p.drag != .column_move);
- try std.testing.expect(p.header_drag);
+ try std.testing.expect(p.view().drag != .column_move);
+ try std.testing.expect(p.view().header_drag);
p.update(.{ .mouse = headerMouse(layer, 0, .release) });
try std.testing.expectEqual(@as(i32, 0), pardes.tagline.focusedHeader(p).?.cur_col);
- mouse(p, .press, p.col_x[1] + config.GUTTER - 1);
- try std.testing.expect(p.drag == .column_move);
- mouse(p, .release, p.col_x[1] + config.GUTTER - 1);
- const seam = p.col_x[0] + p.col_w[0] - 1;
- const body_row = p.rects[p.cols[0].panes[0]].y + pardes.BOX_H + 1;
+ mouse(p, .press, p.view().col_x[1] + config.GUTTER - 1);
+ try std.testing.expect(p.view().drag == .column_move);
+ mouse(p, .release, p.view().col_x[1] + config.GUTTER - 1);
+ const seam = p.view().col_x[0] + p.view().col_w[0] - 1;
+ const body_row = p.view().rects[p.view().cols[0].panes[0]].y + pardes.BOX_H + 1;
p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = seam, .row = body_row } });
- try std.testing.expect(p.drag == .border_v);
+ try std.testing.expect(p.view().drag == .border_v);
p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = seam, .row = body_row } });
}
@@ -170,14 +171,14 @@ test "column grips stay blank, and muted across focus and hover until grabbed" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 20 });
defer p.deinit();
_ = try p.setTestFile("left\n");
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
+ p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
try std.testing.expect(p.executeBuiltinLine(0, "New"));
- try std.testing.expect(layout.splitColumn(p, p.active, p.active, false));
+ try std.testing.expect(layout.splitColumn(p, p.view().active, p.view().active, false));
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
- for (0..p.ncol) |active_column| {
- p.active = p.cols[active_column].panes[0];
- const x = p.col_x[active_column];
+ for (0..p.view().ncol) |active_column| {
+ p.view().active = p.view().cols[active_column].panes[0];
+ const x = p.view().col_x[active_column];
p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = x, .row = pardes.TOPBAR_H } });
for ([_]bool{ false, true }) |dragging| {
if (dragging) mouse(p, .press, x);
@@ -185,14 +186,14 @@ test "column grips stay blank, and muted across focus and hover until grabbed" {
const surface = try p.render(frame.allocator());
const muted: pardes.Color = .{ .rgb = p.chromeTheme().column_box_dim };
const lit: pardes.Color = .{ .rgb = p.chromeTheme().column_box };
- for (0..p.ncol) |column| {
+ for (0..p.view().ncol) |column| {
for (0..config.GUTTER) |offset| {
- const cell = surface.at(p.col_x[column] + @as(u16, @intCast(offset)), pardes.TOPBAR_H);
+ const cell = surface.at(p.view().col_x[column] + @as(u16, @intCast(offset)), pardes.TOPBAR_H);
try std.testing.expectEqualStrings(" ", cell.grapheme());
try std.testing.expectEqual(if (dragging and column == active_column) lit else muted, cell.style.bg);
try std.testing.expectEqual(pardes.FontRole.tagline, cell.style.font_role);
}
- try std.testing.expectEqual(p.col_x[column] + pardes.TAG_TEXT_INSET, (try tagLayer(p, column)).viewport.x);
+ try std.testing.expectEqual(p.view().col_x[column] + pardes.TAG_TEXT_INSET, (try tagLayer(p, column)).viewport.x);
}
if (dragging) mouse(p, .release, x);
}
@@ -204,21 +205,21 @@ test "column grip dropped in its own place moves the column's left edge" {
defer p.deinit();
_ = try p.setTestFile("body\n");
try std.testing.expect(p.executeBuiltinLine(0, "New"));
- try std.testing.expect(layout.splitColumn(p, p.active, p.active, false));
+ try std.testing.expect(layout.splitColumn(p, p.view().active, p.view().active, false));
p.update(.tick);
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const serials = .{ p.cols[0].serial, p.cols[1].serial };
- const edge = p.col_x[1];
- const total = p.col_w[0] + p.col_w[1];
+ const serials = .{ p.view().cols[0].serial, p.view().cols[1].serial };
+ const edge = p.view().col_x[1];
+ const total = p.view().col_w[0] + p.view().col_w[1];
// A click in place, from either grip cell, changes nothing.
for (0..config.GUTTER) |offset| {
const x = edge + @as(u16, @intCast(offset));
mouse(p, .press, x);
mouse(p, .release, x);
_ = try p.render(frame.allocator());
- try std.testing.expectEqual(edge, p.col_x[1]);
+ try std.testing.expectEqual(edge, p.view().col_x[1]);
}
// Grabbed by its second cell and dropped 7 cells left: the edge follows.
mouse(p, .press, edge + 1);
@@ -226,15 +227,15 @@ test "column grip dropped in its own place moves the column's left edge" {
_ = try p.render(frame.allocator());
mouse(p, .release, edge + 1 - 7);
_ = try p.render(frame.allocator());
- try std.testing.expectEqual(edge - 7, p.col_x[1]);
- try std.testing.expectEqual(total, p.col_w[0] + p.col_w[1]);
- try std.testing.expectEqual(serials[0], p.cols[0].serial);
- try std.testing.expectEqual(serials[1], p.cols[1].serial);
+ try std.testing.expectEqual(edge - 7, p.view().col_x[1]);
+ try std.testing.expectEqual(total, p.view().col_w[0] + p.view().col_w[1]);
+ try std.testing.expectEqual(serials[0], p.view().cols[0].serial);
+ try std.testing.expectEqual(serials[1], p.view().cols[1].serial);
// Past the neighbour's middle it is still a reorder, not a resize.
- mouse(p, .press, p.col_x[1]);
- mouse(p, .release, p.col_x[0] + 1);
- try std.testing.expectEqual(serials[1], p.cols[0].serial);
- try std.testing.expectEqual(serials[0], p.cols[1].serial);
+ mouse(p, .press, p.view().col_x[1]);
+ mouse(p, .release, p.view().col_x[0] + 1);
+ try std.testing.expectEqual(serials[1], p.view().cols[0].serial);
+ try std.testing.expectEqual(serials[0], p.view().cols[1].serial);
}
/// The column of the drag preview's rail, checked to run the full height
@@ -267,19 +268,19 @@ test "column grip drag previews where the column lands, in the seam beside its r
defer p.deinit();
_ = try p.setTestFile("body\n");
for (0..2) |_| {
- try std.testing.expect(p.executeBuiltinLine(p.active, "New"));
- try std.testing.expect(layout.splitColumn(p, p.active, p.active, false));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "New"));
+ try std.testing.expect(layout.splitColumn(p, p.view().active, p.view().active, false));
}
- try std.testing.expectEqual(@as(usize, 3), p.ncol);
+ try std.testing.expectEqual(@as(usize, 3), p.view().ncol);
p.update(.tick);
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const serials = .{ p.cols[0].serial, p.cols[1].serial, p.cols[2].serial };
+ const serials = .{ p.view().cols[0].serial, p.view().cols[1].serial, p.view().cols[2].serial };
// Held on its own grip it lands nowhere new: no rail.
- mouse(p, .press, p.col_x[1]);
- mouse(p, .drag, p.col_x[1] + 1);
+ mouse(p, .press, p.view().col_x[1]);
+ mouse(p, .drag, p.view().col_x[1] + 1);
try std.testing.expectEqual(@as(?u16, null), try previewRail(p, &frame));
// Over the first column's left half it goes first. The window edge has
// no seam, and the gutter there is the GUI's scroll rail, so the rail
@@ -288,33 +289,33 @@ test "column grip drag previews where the column lands, in the seam beside its r
try std.testing.expectEqual(@as(?u16, config.GUTTER - 1), try previewRail(p, &frame));
// The pointer is over the first column's "New", but a carried column
// aims at a place: no word lights under it.
- for (0..p.screen_w) |x| try std.testing.expect(!std.meta.eql(p.surface.at(@intCast(x), pardes.TOPBAR_H).style.bg, pardes.Color{ .rgb = p.theme().sel_bg }));
+ for (0..p.view().screen_w) |x| try std.testing.expect(!std.meta.eql(p.surface.at(@intCast(x), pardes.TOPBAR_H).style.bg, pardes.Color{ .rgb = p.theme().sel_bg }));
mouse(p, .release, 3);
- try std.testing.expectEqual(serials[1], p.cols[0].serial);
- try std.testing.expectEqual(serials[0], p.cols[1].serial);
+ try std.testing.expectEqual(serials[1], p.view().cols[0].serial);
+ try std.testing.expectEqual(serials[0], p.view().cols[1].serial);
// Past the middle column's middle it lands after it: the rail is in the
// seam cell left of the last column's rule, where a border drag's is.
- mouse(p, .press, p.col_x[0]);
- const past = p.col_x[1] + p.col_w[1] - 2;
+ mouse(p, .press, p.view().col_x[0]);
+ const past = p.view().col_x[1] + p.view().col_w[1] - 2;
mouse(p, .drag, past);
- try std.testing.expectEqual(@as(?u16, p.col_x[2] - 1), try previewRail(p, &frame));
+ try std.testing.expectEqual(@as(?u16, p.view().col_x[2] - 1), try previewRail(p, &frame));
// Past the last column's middle: the window's last cell.
- mouse(p, .drag, p.col_x[2] + p.col_w[2] - 1);
- try std.testing.expectEqual(@as(?u16, p.screen_w - 1), try previewRail(p, &frame));
- mouse(p, .release, p.col_x[2] + p.col_w[2] - 1);
- try std.testing.expectEqual(serials[0], p.cols[0].serial);
- try std.testing.expectEqual(serials[2], p.cols[1].serial);
- try std.testing.expectEqual(serials[1], p.cols[2].serial);
+ mouse(p, .drag, p.view().col_x[2] + p.view().col_w[2] - 1);
+ try std.testing.expectEqual(@as(?u16, p.view().screen_w - 1), try previewRail(p, &frame));
+ mouse(p, .release, p.view().col_x[2] + p.view().col_w[2] - 1);
+ try std.testing.expectEqual(serials[0], p.view().cols[0].serial);
+ try std.testing.expectEqual(serials[2], p.view().cols[1].serial);
+ try std.testing.expectEqual(serials[1], p.view().cols[2].serial);
// Short of a neighbour's middle the left edge moves, and the preview
// is the seam that edge will have: exactly where the release puts it.
- const edge = p.col_x[2];
+ const edge = p.view().col_x[2];
mouse(p, .press, edge + 1);
mouse(p, .drag, edge + 1 - 6);
try std.testing.expectEqual(@as(?u16, edge - 6 - 1), try previewRail(p, &frame));
mouse(p, .release, edge + 1 - 6);
_ = try p.render(frame.allocator());
- try std.testing.expectEqual(edge - 6, p.col_x[2]);
+ try std.testing.expectEqual(edge - 6, p.view().col_x[2]);
try std.testing.expectEqual(@as(?u16, null), try previewRail(p, &frame));
}
diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig
index 939232fc..6ee50f77 100644
--- a/test/fs_namespace.zig
+++ b/test/fs_namespace.zig
@@ -89,8 +89,8 @@ test "transactional restore preserves host capabilities and advances pane identi
const pane = try p.setTestFile("before\n");
p.lsp_ask.seq = 41;
p.pipe.seq = 73;
- if (@hasField(pardes.CellPixels, "w")) p.cell_pixels = .{ .w = 9, .h = 18 };
- p.frontend.native_images = true;
+ if (@hasField(pardes.CellPixels, "w")) p.view().cell_pixels = .{ .w = 9, .h = 18 };
+ p.view().frontend.native_images = true;
p.fs.socket_path = "/tmp/session.sock";
p.fs.tcp_address = .{ .ip4 = .loopback(5640) };
try pardes.dump.dumpState(p);
@@ -98,13 +98,13 @@ test "transactional restore preserves host capabilities and advances pane identi
defer restored.deinit();
try std.testing.expectEqual(@as(u32, 41), restored.lsp_ask.seq);
try std.testing.expectEqual(@as(u32, 73), restored.pipe.seq);
- try std.testing.expectEqual(p.cell_pixels, restored.cell_pixels);
- try std.testing.expect(restored.frontend.native_images);
+ try std.testing.expectEqual(p.view().cell_pixels, restored.view().cell_pixels);
+ try std.testing.expect(restored.view().frontend.native_images);
// The dump's pane, its serial too; a new one is past the old session's.
try std.testing.expectEqual(pane.serial, restored.panes[0].?.serial);
try std.testing.expect(restored.next_serial >= p.next_serial);
- try std.testing.expectEqual(p.screen_w, restored.screen_w);
- try std.testing.expectEqual(p.screen_h, restored.screen_h);
+ try std.testing.expectEqual(p.view().screen_w, restored.view().screen_w);
+ try std.testing.expectEqual(p.view().screen_h, restored.view().screen_h);
try std.testing.expect(p.panes[0] == pane);
try std.testing.expectEqualStrings("before\n", pane.file.?.content);
try std.testing.expectError(error.BadDump, pardes.dump.restore(
@@ -263,7 +263,7 @@ test "owned cwd failed file opens never publish a pane or retain a reservation"
const name = try std.fmt.bufPrint(&path, "/virtual/pane/{d}/body", .{source.serial});
const slot = p.freeSlot().?;
const serial = p.next_serial;
- const columns = p.cols;
+ const columns = p.view().cols;
allocator.fail_index = allocator.alloc_index + failure;
const opened = pardes.panes.File.open(p, slot, name, 0) catch |err| {
try std.testing.expect(err == error.OutOfMemory or err == error.ReadFailed or err == error.WriteFailed);
@@ -271,7 +271,7 @@ test "owned cwd failed file opens never publish a pane or retain a reservation"
try std.testing.expect(!p.reserved_slots[slot]);
try std.testing.expectEqual(serial, p.next_serial);
try std.testing.expectEqual(slot, p.freeSlot().?);
- try std.testing.expectEqualDeep(columns, p.cols);
+ try std.testing.expectEqualDeep(columns, p.view().cols);
try std.testing.expectEqual(@as(usize, 0), p.effects_len);
try std.testing.expectEqualStrings("/source/directory", source.cwdSlice());
allocator.fail_index = std.math.maxInt(usize);
diff --git a/test/hxdiff.zig b/test/hxdiff.zig
index 1cb4d86f..03b135e2 100644
--- a/test/hxdiff.zig
+++ b/test/hxdiff.zig
@@ -407,7 +407,7 @@ fn runCase(arena: std.mem.Allocator, case: Case, pane_kind: []const u8) !Result
// modal cursor tracking the shell cursor below the output)
core.update(.{ .key = .{ .cp = core.opts.tty_toggle, .ctrl = true } });
pump(core);
- if (core.panes[core.active]) |pane| {
+ if (core.panes[core.view().active]) |pane| {
pane.body.cur_row = 0;
pane.body.cur_col = 0;
pane.body.cur_pinned = true;
@@ -492,7 +492,7 @@ fn runCase(arena: std.mem.Allocator, case: Case, pane_kind: []const u8) !Result
}
// one contract result line off the active pane's final state
- const pane = core.panes[core.active] orelse return error.NoActivePane;
+ const pane = core.panes[core.view().active] orelse return error.NoActivePane;
var text: []const u8 = undefined;
if (pane.file) |f| {
text = f.content;
diff --git a/test/kitty.zig b/test/kitty.zig
index f222f9cf..70e20139 100644
--- a/test/kitty.zig
+++ b/test/kitty.zig
@@ -71,7 +71,7 @@ const Rig = struct {
std.testing.log_level = .err;
// A core boots one shell or the classic three.
const p = try Pardes.init(gpa, .{ .cols = 120, .rows = 40, .shells = if (shells > 1) 3 else 1 });
- p.frontend.native_images = true;
+ p.view().frontend.native_images = true;
p.update(.{ .resize = .{ .cols = 120, .rows = 40, .cell_pixels = .{ .w = 10, .h = 20 } } });
for (p.panes) |slot| if (slot) |each| {
each.body.mode = .tty;
@@ -141,7 +141,7 @@ const Rig = struct {
/// The top-left cell of pane `id`'s body, in screen cells.
fn origin(r: *Rig, id: u8) struct { x: u16, y: u16 } {
- const rect = r.p.rects[id];
+ const rect = r.p.view().rects[id];
return .{ .x = rect.x + config.GUTTER, .y = r.p.bodyTop(r.pane(id), rect) };
}
@@ -1200,7 +1200,7 @@ test "kitty: an image wider than its pane is cut at the pane's edge, never drawn
var r = try Rig.init(3);
defer r.deinit();
// The classic boot: two columns. Pane 0 is in the left one.
- const rect = r.p.rects[0];
+ const rect = r.p.view().rects[0];
const o = r.origin(0);
const right = rect.x + rect.w;
// 2x1 cells at its last-but-one column: one cell is the pane's.
@@ -1319,7 +1319,7 @@ test "kitty: under a shell that draws no pixels, a 64x64 image over 8x4 cells is
// The glyph art a tty draws there is the tty's test (tui.zig).
var r = try Rig.init(1);
defer r.deinit();
- r.p.frontend.native_images = false;
+ r.p.view().frontend.native_images = false;
r.p.update(.{ .resize = .{ .cols = 120, .rows = 40, .cell_pixels = .{ .w = 8, .h = 16 } } });
r.drain();
// Not the frame's arena: each frame resets that.
diff --git a/test/mode.zig b/test/mode.zig
index a03d9dc1..cb93b73e 100644
--- a/test/mode.zig
+++ b/test/mode.zig
@@ -13,7 +13,7 @@ fn clickModeTag(p: *Pardes) !void {
const pane = p.panes[0].?;
const text = try pardes.tagline.tagText(p, p.scratch.allocator(), pane);
const col = std.mem.indexOf(u8, text, "Mode") orelse return error.MissingModeTag;
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const row = rect.y;
for ([_]pardes.Mouse.Kind{ .press, .release }) |kind|
p.update(.{ .mouse = .{ .button = .left, .kind = kind, .col = rect.x + pardes.TAG_TEXT_INSET + @as(u16, @intCast(col)), .row = row } });
diff --git a/test/output.zig b/test/output.zig
index 7fb9f237..d7b8a816 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -69,7 +69,7 @@ test "search tint survives wrapping and theme changes while selections remain au
fn outputCell(p: *Pardes, surface: *pardes.Surface, id: usize, byte: usize) *pardes.Cell {
const pane = p.panes[id].?;
const line = modal.lineSlice(pane.file.?.content, 0);
- const rect = p.rects[id];
+ const rect = p.view().rects[id];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane) + @as(u16, @intCast(panes.File.displayWidth(line[0..byte])));
const y = p.bodyTop(pane, rect);
return surface.at(x, y);
@@ -213,22 +213,22 @@ test "references fill the asking text's query pane: sorted under their files, th
try std.testing.expectEqual(@as(usize, 6), results.query.?.total);
// A list answered, not a query typed: the keyboard on its current row in
// normal mode; n, Enter: the keyboard on that ref in the text
- try std.testing.expectEqual(qid, p.active);
+ try std.testing.expectEqual(qid, p.view().active);
try std.testing.expect(results.body.mode == .normal and results.body.cur_row > 0);
p.update(.{ .key = .{ .cp = 'n' } });
try std.testing.expectEqual(@as(?usize, 3), source.places.current);
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.expectEqual(@as(i32, 4), source.body.cur_row);
p.update(.{ .key = .{ .cp = 'N' } });
try std.testing.expectEqual(@as(?usize, 2), source.places.current);
// n in the owner steps them, round the end without a word
- p.active = 0;
+ p.view().active = 0;
p.update(.{ .key = .{ .cp = 'n' } });
try std.testing.expectEqual(@as(?usize, 3), source.places.current);
p.update(.{ .key = .{ .cp = 'n' } });
try std.testing.expectEqual(@as(?usize, 0), source.places.current);
- try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(@as(usize, 0), p.view().active);
}
test "location sorting leaves mixed prose alone and preserves newline shape" {
@@ -267,8 +267,8 @@ test "a single language location opens the full spaced filename" {
defer p.deinit();
p.lspRequest(0, .references, "");
pardes.lsp.Ask.lspResponse(p, p.lsp_ask.wait.?.id, "with space.zig:2:1 second\n");
- try std.testing.expect(std.mem.endsWith(u8, p.panes[p.active].?.file.?.path, "/with space.zig"));
- try std.testing.expectEqual(@as(i32, 1), p.panes[p.active].?.body.cur_row);
+ try std.testing.expect(std.mem.endsWith(u8, p.panes[p.view().active].?.file.?.path, "/with space.zig"));
+ try std.testing.expectEqual(@as(i32, 1), p.panes[p.view().active].?.body.cur_row);
for (p.panes) |slot| {
const pane = slot orelse continue;
if (pane.file) |file| try std.testing.expect(file.output == null);
@@ -348,7 +348,7 @@ test "result sorting allocation failures preserve the previous answer and naviga
try std.testing.expectEqualStrings("before", result.file.?.output.?.arg());
try std.testing.expectEqual(id, source.search_pane.?);
try std.testing.expectEqual(@as(usize, 0), source.search_row.?);
- try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(@as(usize, 0), p.view().active);
try std.testing.expectEqual(owner, p.look_walk_owner);
}
}
@@ -385,7 +385,7 @@ test "Mini asks for no watch on its pane" {
defer p.deinit();
try p.panes[0].?.setOwnedCwd(dir);
try std.testing.expect(p.executeBuiltinLine(0, "Mini build.zig"));
- const id = p.active;
+ const id = p.view().active;
try std.testing.expect(id != 0);
try std.testing.expect(p.executeBuiltinLine(id, "Mini build.zig"));
while (p.nextEffect()) |effect| switch (effect) {
@@ -401,20 +401,20 @@ test "Mini dump preserves its exact virtual snapshot and body writes detach colo
var command_buf: [128]u8 = undefined;
const command = try std.fmt.bufPrint(&command_buf, "Mini /virtual/pane/{d}/body", .{source.serial});
try std.testing.expect(p.executeBuiltinLine(0, command));
- const id = p.active;
+ const id = p.view().active;
const before = p.panes[id].?.file.?;
try std.testing.expect(before.mini != null);
try pardes.dump.dumpState(p);
panes.File.setContent(p, &source.file.?, try p.gpa.dupe(u8, "changed\n"));
const restored = try pardes.dump.initFromDump(std.testing.allocator, .{ .tty_only = true }, p.dump_out.?);
defer restored.deinit();
- const mini = restored.panes[restored.active].?;
+ const mini = restored.panes[restored.view().active].?;
try std.testing.expectEqualStrings(before.content, mini.file.?.content);
try std.testing.expectEqualStrings(before.mini.?.source, mini.file.?.mini.?.source);
try std.testing.expectEqualSlices(u8, before.mini.?.colors, mini.file.?.mini.?.colors);
try std.testing.expect(before.content.ptr != mini.file.?.content.ptr);
while (restored.nextEffect()) |effect| switch (effect) {
- .watch => |watch| try std.testing.expect(watch.pane != restored.active),
+ .watch => |watch| try std.testing.expect(watch.pane != restored.view().active),
else => {},
};
var body_buf: [128]u8 = undefined;
@@ -438,7 +438,7 @@ test "Mini syntax colors survive themes and rendering without source access" {
defer p.deinit();
try p.panes[0].?.setOwnedCwd(dir);
try panes.mini.open(p, 0, "demo.zig");
- const id = p.active;
+ const id = p.view().active;
const mini = p.panes[id].?;
const keyword = std.mem.indexOfScalar(u8, mini.file.?.mini.?.colors, @backingInt(pardes.syntax.Syn.keyword)) orelse return error.MissingKeywordColor;
// Direct pane construction bypasses the host update's layout sync.
@@ -452,7 +452,7 @@ test "Mini syntax colors survive themes and rendering without source access" {
for (0..4) |_| {
mini.file.?.syntax_dirty = true;
const surface = try p.render(frame.allocator());
- const rect = p.rects[id];
+ const rect = p.view().rects[id];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(mini) + @as(u16, @intCast(column));
const y = p.bodyTop(mini, rect) + @as(u16, @intCast(position.row));
try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().kw }, surface.at(x, y).style.fg);
@@ -468,7 +468,7 @@ test "DumpConfig prints the startup path" {
const p = try Pardes.init(std.testing.allocator, .{ .startup_config_path = path });
defer p.deinit();
try std.testing.expect(p.executeBuiltinLine(0, "DumpConfig"));
- try std.testing.expect(std.mem.indexOf(u8, p.panes[p.active].?.file.?.content, "Startup config: " ++ path ++ "\n") != null);
+ try std.testing.expect(std.mem.indexOf(u8, p.panes[p.view().active].?.file.?.content, "Startup config: " ++ path ++ "\n") != null);
}
/// The file Config names, in a fresh temporary directory: `pardes/init`
@@ -489,19 +489,19 @@ test "Config opens the startup file, and a second Config goes back to its pane"
const path = try configFixture(&tmp, "Theme orchard\n", &buf);
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .startup_config_path = path });
defer p.deinit();
- const first = p.active;
+ const first = p.view().active;
try std.testing.expect(p.executeBuiltinLine(first, "Config"));
- const opened = p.active;
+ const opened = p.view().active;
try std.testing.expect(opened != first);
const f = p.panes[opened].?.file.?;
try std.testing.expectEqualStrings(path, f.path);
try std.testing.expectEqualStrings("Theme orchard\n", f.content);
try std.testing.expect(f.output == null);
- p.active = first;
+ p.view().active = first;
try std.testing.expect(p.executeBuiltinLine(first, "Config"));
- try std.testing.expectEqual(opened, p.active);
+ try std.testing.expectEqual(opened, p.view().active);
var named: usize = 0;
for (p.panes) |slot| if (slot) |pane| if (pane.file) |file| {
named += @intFromBool(std.mem.eql(u8, file.path, path));
@@ -516,10 +516,10 @@ test "Config with no startup file opens a pane of its name, and Save makes its d
const path = try configFixture(&tmp, null, &buf);
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .startup_config_path = path });
defer p.deinit();
- const first = p.active;
+ const first = p.view().active;
try std.testing.expect(p.executeBuiltinLine(first, "Config"));
- const opened = p.active;
+ const opened = p.view().active;
try std.testing.expect(opened != first);
const f = p.panes[opened].?.file.?;
try std.testing.expectEqualStrings(path, f.path);
@@ -527,9 +527,9 @@ test "Config with no startup file opens a pane of its name, and Save makes its d
try std.testing.expect(f.output == null);
// Again: the same pane, not a second one.
- p.active = first;
+ p.view().active = first;
try std.testing.expect(p.executeBuiltinLine(first, "Config"));
- try std.testing.expectEqual(opened, p.active);
+ try std.testing.expectEqual(opened, p.view().active);
try std.testing.expectError(error.FileNotFound, tmp.dir.statFile(std.testing.io, "pardes", .{}));
// Save's effect, as a host performs it.
@@ -559,22 +559,22 @@ test "a window's setting builtins (TaglineSize, Font) reach the report DumpConfi
.font => continue,
else => setting.word,
};
- try std.testing.expect(p.executeBuiltinLine(p.active, command));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, command));
}
if (comptime font_picker) {
const before_invalid = p.settings.font.tagline_percent;
- try std.testing.expect(p.executeBuiltinLine(p.active, "TaglineSize 0"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "TaglineSize 0"));
try std.testing.expectEqual(before_invalid, p.settings.font.tagline_percent);
const installed = fonts.list(font_arena.allocator(), null);
if (installed.len > 0) {
chosen_font = installed[0].name;
const command = try std.fmt.bufPrint(&buf, "Font {s}", .{installed[0].name});
- try std.testing.expect(p.executeBuiltinLine(p.active, command));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, command));
}
}
- try std.testing.expect(p.executeBuiltinLine(p.active, "DumpConfig"));
- const report = p.panes[p.active].?.file.?.content;
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "DumpConfig"));
+ const report = p.panes[p.view().active].?.file.?.content;
// The toggles, Theme and Shell are test/behaviour/settings.zig's, through
// the root ctl; what is left is a window's (fonts).
const tagline = if (!builtins.viewCapabilities(p).tagline_font_size)
@@ -662,7 +662,7 @@ test "LookNext/LookPrev skips formatted context and selects comment match locati
.{ .key = 'N', .match = 0 },
}) |step| {
lookKey(p, step.key);
- try std.testing.expectEqual(id, p.active);
+ try std.testing.expectEqual(id, p.view().active);
const row = matches[step.match];
try std.testing.expectEqual(@as(i32, @intCast(row)), result.body.cur_row);
const line = modal.lineSlice(file.content, row);
@@ -696,12 +696,12 @@ test "LookNext/LookPrev selects one output location per row and opens nothing" {
defer p.deinit();
p.locations_config.layout = .@"inline";
p.update(.{ .resize = .{ .cols = 100, .rows = 40 } });
- const rid = try walkFixture(p, p.active, paths.cwd, "one");
+ const rid = try walkFixture(p, p.view().active, paths.cwd, "one");
const results = p.panes[rid].?;
const panes_before = p.freeSlot();
lookKey(p, 'n');
- try std.testing.expectEqual(rid, p.active);
+ try std.testing.expectEqual(rid, p.view().active);
try std.testing.expectEqual(panes_before, p.freeSlot());
try std.testing.expect(results.body.vsel.active and results.body.vsel.explicit);
try std.testing.expectEqualStrings("build.zig:1:1", selectedOutputText(results) orelse "");
@@ -718,8 +718,8 @@ test "LookNext/LookPrev selects one output location per row and opens nothing" {
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expect(p.freeSlot() != panes_before);
- try std.testing.expect(std.mem.endsWith(u8, p.panes[p.active].?.file.?.path, "/build.zig"));
- try std.testing.expectEqual(panes.Output.Grain.word, panes.Output.grain(p.panes[p.active].?.file.?.output));
+ try std.testing.expect(std.mem.endsWith(u8, p.panes[p.view().active].?.file.?.path, "/build.zig"));
+ try std.testing.expectEqual(panes.Output.Grain.word, panes.Output.grain(p.panes[p.view().active].?.file.?.output));
}
test "LookPrev exactly reverses LookNext across output panes and the ring seam" {
@@ -730,16 +730,16 @@ test "LookPrev exactly reverses LookNext across output panes and the ring seam"
defer p.deinit();
p.locations_config.layout = .@"inline";
p.update(.{ .resize = .{ .cols = 100, .rows = 40 } });
- const first = try walkFixture(p, p.active, paths.cwd, "one");
+ const first = try walkFixture(p, p.view().active, paths.cwd, "one");
p.update(.{ .key = .{ .cp = 'n', .alt = true } });
- const second = try walkFixture(p, p.active, paths.cwd, "two");
+ const second = try walkFixture(p, p.view().active, paths.cwd, "two");
try std.testing.expect(first != second);
const Mark = struct { pane: usize, row: i32, col: i32 };
const here = struct {
fn at(pp: *Pardes) Mark {
- const pane = pp.panes[pp.active].?;
- return .{ .pane = pp.active, .row = pane.body.cur_row, .col = pane.body.cur_col };
+ const pane = pp.panes[pp.view().active].?;
+ return .{ .pane = pp.view().active, .row = pane.body.cur_row, .col = pane.body.cur_col };
}
}.at;
lookKey(p, 'n');
@@ -805,7 +805,7 @@ test "identical result refresh keeps warm content caches without allocation" {
const deallocations = allocator.deallocations;
allocator.fail_index = allocator.alloc_index;
defer allocator.fail_index = std.math.maxInt(usize);
- p.active = id;
+ p.view().active = id;
source.search_pane = null;
source.search_row = null;
p.look_walk_owner = null;
@@ -830,7 +830,7 @@ test "identical result refresh keeps warm content caches without allocation" {
try std.testing.expectEqual(@as(usize, 1), file.scroll);
try std.testing.expectEqual(@as(i32, 3), result.hscroll);
try std.testing.expectEqualStrings("after", file.output.?.arg());
- try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(@as(usize, 0), p.view().active);
try std.testing.expectEqual(id, source.search_pane.?);
try std.testing.expectEqual(@as(usize, 1), source.search_row.?);
try std.testing.expectEqual(result.serial, p.look_walk_owner.?);
@@ -897,7 +897,7 @@ test "rejected result refresh frees incoming text and leaves the existing output
try std.testing.expectEqual(free_slot, p.freeSlot());
try std.testing.expectEqual(id, source.search_pane.?);
try std.testing.expectEqual(@as(usize, 1), source.search_row.?);
- try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(@as(usize, 0), p.view().active);
}
try std.testing.expect(allocator.has_induced_failure);
}
@@ -1309,7 +1309,7 @@ test "stacked search and LSP results retain source tint navigation and dump owne
try std.testing.expectEqual(@as(usize, 6), marked);
const number = std.mem.indexOf(u8, file.content, "42").?;
try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.number), file.highlights[number]);
- p.active = id;
+ p.view().active = id;
pane.body.mode = .normal;
pardes.look.armLookWalk(p, id);
for ([_]struct { key: u21, match: usize }{ .{ .key = 'n', .match = 0 }, .{ .key = 'n', .match = 1 }, .{ .key = 'N', .match = 0 } }) |step| {
@@ -1333,7 +1333,7 @@ test "stacked search and LSP results retain source tint navigation and dump owne
try std.testing.expectEqual(before.location_end, after.location_end);
try std.testing.expectEqualSlices(u8, before.colors, after.colors);
}
- restored.active = id;
+ restored.view().active = id;
pardes.look.armLookWalk(restored, id);
// The dot came back on the match it was on; the walk goes on
// from it both ways, N wrapping to the last as it does live.
diff --git a/test/panes.zig b/test/panes.zig
index 2a24e62e..e0c383fd 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -35,7 +35,7 @@ const TagLayerTests = struct {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 16 });
defer p.deinit();
const pane = try p.setTestFile("body\n");
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
+ p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
p.gpa.free(pane.file.?.path);
pane.file.?.path = try p.gpa.dupe(u8, "/x");
try setTag(pane, " " ++ &@as([38]u8, @splat('a')) ++ "\t界 END");
@@ -46,7 +46,7 @@ const TagLayerTests = struct {
const text = try pardes.tagline.tagText(p, frame.allocator(), pane);
const at = std.mem.indexOf(u8, text, "END").?;
const col = panes.File.displayWidth(text[0..at]);
- try std.testing.expect(col > p.rects[0].w);
+ try std.testing.expect(col > p.view().rects[0].w);
try std.testing.expect(col + 3 < layer.cols);
try std.testing.expectEqualStrings("E", layer.cells[col].grapheme());
try std.testing.expectEqual(@as(u16, 0), pane.tag_scroll);
@@ -74,9 +74,9 @@ const TagLayerTests = struct {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 });
defer p.deinit();
_ = try p.setTestFile("body\n");
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
+ p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
try std.testing.expect(p.executeBuiltinLine(0, "New"));
- const second = p.active;
+ const second = p.view().active;
try std.testing.expect(layout.splitColumn(p, second, second, false));
p.update(.tick);
var frame = std.heap.ArenaAllocator.init(p.gpa);
@@ -85,13 +85,13 @@ const TagLayerTests = struct {
const layer = try findLayer(p, .pane, second);
const edge = @as(f32, @floatFromInt(layer.viewport.x)) * 10;
p.update(.{ .mouse = mouse(layer, edge - 0.1, .press) });
- try std.testing.expect(p.drag == .move);
- try std.testing.expectEqual(second, p.drag.move.id);
+ try std.testing.expect(p.view().drag == .move);
+ try std.testing.expectEqual(second, p.view().drag.move.id);
p.update(.{ .mouse = mouse(layer, edge - 0.1, .release) });
try std.testing.expectEqualStrings(" ", p.surface.at(layer.viewport.x - 1, layer.viewport.y).grapheme());
p.update(.{ .mouse = mouse(layer, edge + 0.1, .press) });
p.update(.{ .mouse = mouse(layer, edge + 0.1, .release) });
- try std.testing.expectEqual(second, p.active);
+ try std.testing.expectEqual(second, p.view().active);
// The first cell of the tag is its path: a click there drafts a name.
try std.testing.expect(p.panes[second].?.prompt == .name);
try std.testing.expectEqual(@as(i32, 0), p.panes[second].?.input.cur_col);
@@ -106,14 +106,14 @@ const TagLayerTests = struct {
p.update(.{ .mouse = mouse(left_layer, start_x, .press) });
p.update(.{ .mouse = mouse(layer, beyond_x, .drag) });
p.update(.{ .mouse = mouse(layer, beyond_x, .release) });
- try std.testing.expectEqual(@as(usize, 0), p.active);
- const end_col = left_layer.capacity(p.row_metrics) - 1;
+ try std.testing.expectEqual(@as(usize, 0), p.view().active);
+ const end_col = left_layer.capacity(p.view().row_metrics) - 1;
try std.testing.expectEqual(panes.File.rawAtDisplay(left_text, end_col), @as(usize, @intCast(left.tag.cur_col)));
try std.testing.expect(left.sel[0].state == .done and left.sel[0].r0 == 0);
p.update(.{ .key = .{ .cp = Key.escape } });
const long = &@as([60]u8, @splat('a')) ++ "界END";
p.global_tag.own = try p.gpa.dupe(u8, long);
- for (p.col_tags[0..p.ncol]) |*tag| tag.own = try p.gpa.dupe(u8, long);
+ for (p.view().col_tags[0..p.view().ncol]) |*tag| tag.own = try p.gpa.dupe(u8, long);
_ = try p.render(frame.allocator());
for ([_]Kind{ .workspace, .column }) |kind| {
const id: usize = if (kind == .column) 1 else 0;
@@ -131,7 +131,7 @@ const TagLayerTests = struct {
// Rows relative to where the pane's body and tag are, whatever height its
// tag has (a tag wraps onto more rows when it is long).
fn paneAt(p: *Pardes, r: anytype) *pardes.Pane {
- for (p.panes, 0..) |slot, id| if (slot) |pane| if (std.meta.eql(p.rects[id], r)) return pane;
+ for (p.panes, 0..) |slot, id| if (slot) |pane| if (std.meta.eql(p.view().rects[id], r)) return pane;
unreachable;
}
fn bodyY(p: *Pardes, r: anytype) u16 {
@@ -156,7 +156,7 @@ const BodyHitTests = struct {
if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
+ p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
const pane = try TreeContextTests.setZigFile(p, "const Box = struct {\n pub fn work(\n value: usize,\n ) void {\n" ++ std.mem.asBytes(&@as([60][16]u8, @splat(" // body\n".*))) ++ " }\n};\n");
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext"));
pane.scrollBy(10);
@@ -205,7 +205,7 @@ const LineNumberLookTests = struct {
if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
+ p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
const pane = try TreeContextTests.setZigFile(p, "const Box = struct {\n pub fn work(\n value: usize,\n ) void {\n" ++ std.mem.asBytes(&@as([60][16]u8, @splat(" // body\n".*))) ++ " }\n};\n");
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext"));
pane.scrollBy(30);
@@ -264,7 +264,7 @@ const TreeContextTests = struct {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 });
defer p.deinit();
const pane = try setZigFile(p, "const Box = struct {\n\n // omitted member comment\n\n pub fn work(\n value: usize,\n ) void {\n" ++ std.mem.asBytes(&@as([30][16]u8, @splat(" // body\n".*))) ++ " }\n};\n");
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
+ p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext"));
pane.scrollBy(10);
var frame = std.heap.ArenaAllocator.init(p.gpa);
@@ -302,7 +302,7 @@ const TreeContextTests = struct {
_ = try p.render(frame.allocator());
try std.testing.expectEqual(@as(i32, 0), pane.scroll());
pardes.look.lookAt(p, 0, "/tree-context.zig:60");
- try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(@as(usize, 0), p.view().active);
try std.testing.expectEqual(@as(i32, 59), pane.body.cur_row);
const surface = try p.render(frame.allocator());
const visible = pane.wrapRow(pane.body.cur_row, pane.body.cur_col);
@@ -310,7 +310,7 @@ const TreeContextTests = struct {
try std.testing.expect(visible.row < pane.rows);
try std.testing.expectEqual(@as(i32, 59), pane.wrapAt(visible.row).line);
const cursor = surface.cursor orelse return error.MissingLookCursor;
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const y = p.bodyTop(pane, rect);
try std.testing.expectEqual(y + @as(u16, @intCast(visible.row)), cursor.y);
}
@@ -333,7 +333,7 @@ const TreeContextTests = struct {
try std.testing.expectEqual(@as(u16, 4), pane.context_rows);
for (0..4) |row| try std.testing.expectEqual(@as(i32, @intCast(row)), pane.wrapAt(@intCast(row)).line);
try std.testing.expectEqual(@as(i32, 7), pane.wrapAt(pane.context_rows).line);
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane);
const y = p.bodyTop(pane, rect);
ClickCursorTests.click(p, .left, x + 6, y);
@@ -344,7 +344,7 @@ const TreeContextTests = struct {
try std.testing.expectEqual(x + 6, cursor.x);
// Read the body top again: the click cleared the announcement band the
// builtin above put up, and the body moved back up with it.
- try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y);
+ try std.testing.expectEqual(p.bodyTop(pane, p.view().rects[0]), cursor.y);
p.update(.{ .key = .{ .cp = 'i' } });
p.update(.{ .key = .{ .cp = 'Z', .text = "Z" } });
try std.testing.expect(std.mem.startsWith(u8, pane.file.?.content, "const ZBox = struct {"));
@@ -384,7 +384,7 @@ const TreeContextTests = struct {
p.sync();
const surface = try p.render(frame.allocator());
try std.testing.expectEqual(@as(u16, 3), pane.context_rows);
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const y = p.bodyTop(pane, rect);
var glyph_x: ?u16 = null;
for (0..surface.cols) |col| {
@@ -399,7 +399,7 @@ const TreeContextTests = struct {
try std.testing.expectEqual(x, cursor.x);
// Read the body top again: the click cleared the announcement band the
// builtin above put up, so the body moved with it.
- try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y);
+ try std.testing.expectEqual(p.bodyTop(pane, p.view().rects[0]), cursor.y);
panes.File.setContent(p, &pane.file.?, try p.gpa.dupe(u8, std.mem.asBytes(&@as([18][28]u8, @splat("// no enclosing declaration\n".*)))));
p.sync();
_ = try p.render(frame.allocator());
@@ -458,7 +458,7 @@ const TtySelectionTests = struct {
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const x = rect.x + config.GUTTER;
const y = p.bodyTop(pane, rect);
JumpSelectionTests.drag(p, x + 1, y, x + 3, y);
@@ -486,7 +486,7 @@ const TtySelectionTests = struct {
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const x = rect.x + config.GUTTER;
const y = p.bodyTop(pane, rect);
JumpSelectionTests.drag(p, x + @as(u16, if (prompt) 0 else 1), y, x + 3, y + @as(u16, if (prompt) 0 else 1));
@@ -550,14 +550,14 @@ const TtySelectionTests = struct {
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const source = p.rects[0];
+ const source = p.view().rects[0];
const sx = source.x + config.GUTTER;
const sy = bodyY(p, source);
JumpSelectionTests.drag(p, sx + 1, sy, sx + 3, sy + 1);
try std.testing.expectEqualStrings("lpha\nbrav", p.registers.text(p.gpa, '"') orelse return error.MissingAutomaticTtyYank);
try noChildInput(p);
- const target = p.rects[1];
+ const target = p.view().rects[1];
const tx = target.x + config.GUTTER + 2;
const ty = bodyY(p, target);
// Over a program that tracks the mouse B1 is its own, so
@@ -628,7 +628,7 @@ const TtySelectionTests = struct {
if (bracketed) "\x1b[200~one\ntwo\x1b[201~" else "one\rtwo",
childInput(p, &buf),
);
- try std.testing.expect(p.clip_pending == null);
+ try std.testing.expect(p.view().clip_pending == null);
// Ctrl-Shift-V is the other store: it ASKS, types nothing yet, and
// the answer lands at the program rather than in an edit buffer. A
@@ -638,10 +638,10 @@ const TtySelectionTests = struct {
.{ .cp = 'V', .ctrl = true },
}) |chord| {
p.update(.{ .key = chord });
- try std.testing.expect(p.clip_pending != null);
+ try std.testing.expect(p.view().clip_pending != null);
try std.testing.expectEqualStrings("", childInput(p, &buf));
p.update(.{ .paste = "from-desktop" });
- try std.testing.expect(p.clip_pending == null);
+ try std.testing.expect(p.view().clip_pending == null);
try std.testing.expectEqualStrings(
if (bracketed) "\x1b[200~from-desktop\x1b[201~" else "from-desktop",
childInput(p, &buf),
@@ -669,7 +669,7 @@ const ClickCursorTests = struct {
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane);
const y = p.bodyTop(pane, rect);
// The pane reaches the screen's bottom: its last row is the edge.
@@ -693,7 +693,7 @@ const ClickCursorTests = struct {
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane);
const y = bodyY(p, rect);
JumpSelectionTests.drag(p, x + 1, y + 4, x + 3, y + 4);
@@ -757,14 +757,14 @@ const JumpSelectionTests = struct {
layout.compute(p);
try LookResetTests.seed(source, "source held text");
try LookResetTests.seed(destination, "destination held text");
- p.active = 0;
- p.jumps.n = 2;
- p.jumps.cur = 1;
- p.jumps.list[0] = .{ .pane = @intCast(id), .serial = destination.serial, .line = 3, .col = 2 };
- p.jumps.list[1] = .{ .pane = 0, .serial = source.serial, .line = 2, .col = 1 };
+ p.view().active = 0;
+ p.view().jumps.n = 2;
+ p.view().jumps.cur = 1;
+ p.view().jumps.list[0] = .{ .pane = @intCast(id), .serial = destination.serial, .line = 3, .col = 2 };
+ p.view().jumps.list[1] = .{ .pane = 0, .serial = source.serial, .line = 2, .col = 1 };
p.update(.{ .key = .{ .cp = 'o', .ctrl = true } });
- try std.testing.expectEqual(id, p.active);
- try std.testing.expectEqual(@as(usize, 0), p.jumps.cur);
+ try std.testing.expectEqual(id, p.view().active);
+ try std.testing.expectEqual(@as(usize, 0), p.view().jumps.cur);
try LookResetTests.cleared(source);
try LookResetTests.cleared(destination);
try std.testing.expect(!source.body.vsel.active and !destination.body.vsel.active);
@@ -774,8 +774,8 @@ const JumpSelectionTests = struct {
try LookResetTests.seed(source, "new source held text");
try LookResetTests.seed(destination, "new destination held text");
p.update(.{ .key = .{ .cp = 'i', .ctrl = true } });
- try std.testing.expectEqual(@as(usize, 0), p.active);
- try std.testing.expectEqual(@as(usize, 1), p.jumps.cur);
+ try std.testing.expectEqual(@as(usize, 0), p.view().active);
+ try std.testing.expectEqual(@as(usize, 1), p.view().jumps.cur);
try LookResetTests.cleared(source);
try LookResetTests.cleared(destination);
try std.testing.expect(!source.body.vsel.active and !destination.body.vsel.active);
@@ -808,7 +808,7 @@ const TagNameTintTests = struct {
// tag's own to say whether it is in the name.
const shown = try pardes.tagline.shownTag(p, arena.allocator(), pane);
const base = std.mem.lastIndexOfScalar(u8, name, '/') orelse return error.MissingDirectory;
- const rect = p.rects[id];
+ const rect = p.view().rects[id];
const left = rect.x + pardes.TAG_TEXT_INSET;
var visible_name: usize = 0;
for (0..pane.tag_rows) |row| {
@@ -872,8 +872,8 @@ const TagNameTintTests = struct {
const col: i32 = @intCast(panes.File.rawDisplayCol(modal.lineSlice(shown.text, pos.row), pos.col));
pane.sel[0] = .{ .state = .done, .c0 = col, .c1 = col + 1, .r0 = @intCast(pos.row), .r1 = @intCast(pos.row) };
const surface = try p.render(arena.allocator());
- const x = p.rects[0].x + pardes.TAG_TEXT_INSET + @as(u16, @intCast(col));
- const y = tagY(p, p.rects[0]) + @as(u16, @intCast(pos.row));
+ const x = p.view().rects[0].x + pardes.TAG_TEXT_INSET + @as(u16, @intCast(col));
+ const y = tagY(p, p.view().rects[0]) + @as(u16, @intCast(pos.row));
try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().sel_fg }, surface.at(x, y).style.fg);
try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().sel_fg }, surface.at(x + 1, y).style.fg);
}
@@ -893,8 +893,8 @@ const TagNameTintTests = struct {
var arena = std.heap.ArenaAllocator.init(p.gpa);
defer arena.deinit();
const surface = try p.render(arena.allocator());
- const x = p.rects[0].x + pardes.TAG_TEXT_INSET;
- const y = tagY(p, p.rects[0]);
+ const x = p.view().rects[0].x + pardes.TAG_TEXT_INSET;
+ const y = tagY(p, p.view().rects[0]);
const fg = active_fg;
// The directory in the ink; the name tinted, never in it.
const chrome = p.chromeTheme();
@@ -955,7 +955,7 @@ test "a tag that exactly fills its row stays one row, its caret at the edge as a
// The layer's caret is past the last character; the grid's, on the pane's
// last cell, since it has none past it.
try std.testing.expectEqual(@as(u16, @intCast(width)), surface.tag_layers[0].cursor.?.x);
- try std.testing.expectEqual(p.rects[0].x + p.rects[0].w - 1, surface.cursor.?.x);
+ try std.testing.expectEqual(p.view().rects[0].x + p.view().rects[0].w - 1, surface.cursor.?.x);
}
test "terminal overlay recoloring never materializes unrelated history" {
@@ -979,7 +979,7 @@ test "terminal overlay recoloring never materializes unrelated history" {
_ = frame.reset(.retain_capacity);
const surface = try p.render(frame.allocator());
try testing.expect(p.shell_rows.pane == null);
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const body_y = bodyY(p, rect);
const cell = surface.at(rect.x + config.GUTTER, body_y);
try testing.expectEqualStrings("c", cell.grapheme());
@@ -1025,7 +1025,7 @@ test "terminal output keeps following new rows after scrollback eviction" {
try std.testing.expect(std.mem.endsWith(u8, std.mem.trimEnd(u8, full, "\n"), last));
_ = frame.reset(.retain_capacity);
const surface = try p.render(frame.allocator());
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const x = rect.x + config.GUTTER;
const y = (bodyY(p, rect)) + pane.rows - 2;
for (last, 0..) |byte, col| {
@@ -1493,7 +1493,7 @@ test "Save on a scratch does not watch a path the host could not create" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 12 });
defer p.deinit();
try std.testing.expect(p.executeBuiltinLine(0, "New"));
- const id = p.active;
+ const id = p.view().active;
while (p.nextEffect()) |_| {}
p.host = .{ .ctx = p, .vtable = &.{ .write_file = Refusing.write } };
const file = &p.panes[id].?.file.?;
@@ -1544,9 +1544,9 @@ test "unplaced terminal panes keep their allocated grid until placement" {
while (p.nextEffect()) |_| {}
const id = p.freeSlot().?;
const pane = try p.newShell(id, "");
- try std.testing.expectEqual(pardes.Rect{}, p.rects[id]);
+ try std.testing.expectEqual(pardes.Rect{}, p.view().rects[id]);
p.update(.{ .output = .{ .pane = @intCast(id), .bytes = "unplaced\r\n" } });
- try std.testing.expectEqual(pardes.Rect{}, p.rects[id]);
+ try std.testing.expectEqual(pardes.Rect{}, p.view().rects[id]);
try std.testing.expectEqual(@as(u16, 100), pane.cols);
try std.testing.expectEqual(@as(u16, 30), pane.rows);
try std.testing.expectEqual(pane.cols, pane.terminal.?.vt.cols);
@@ -1556,9 +1556,9 @@ test "unplaced terminal panes keep their allocated grid until placement" {
}
pardes.layout.insert(p, 0, 1, id);
p.update(.tick);
- try std.testing.expect(p.rects[id].w > 0 and p.rects[id].h > pardes.BOX_H);
- try std.testing.expectEqual(p.rects[id].w - config.GUTTER, pane.cols);
- try std.testing.expectEqual(bodyH(p, p.rects[id]), pane.rows);
+ try std.testing.expect(p.view().rects[id].w > 0 and p.view().rects[id].h > pardes.BOX_H);
+ try std.testing.expectEqual(p.view().rects[id].w - config.GUTTER, pane.cols);
+ try std.testing.expectEqual(bodyH(p, p.view().rects[id]), pane.rows);
}
test "document panes ignore terminal output without allocating terminal state" {
@@ -1589,29 +1589,29 @@ test "removed and recycled pane slots have no stale geometry" {
const original = try p.newDocPane(id);
pardes.layout.insert(p, 0, 1, id);
layout.compute(p);
- try std.testing.expect(p.rects[id].w > 0 and p.rects[id].h > 0);
+ try std.testing.expect(p.view().rects[id].w > 0 and p.view().rects[id].h > 0);
layout.removePane(p, id);
layout.compute(p);
- try std.testing.expectEqual(pardes.Rect{}, p.rects[id]);
+ try std.testing.expectEqual(pardes.Rect{}, p.view().rects[id]);
try pardes.panes.deinitPane(p, original);
p.panes[id] = null;
- p.rects[id] = .{ .x = 10, .y = 5, .w = 20, .h = 10 };
+ p.view().rects[id] = .{ .x = 10, .y = 5, .w = 20, .h = 10 };
const replacement = try p.newDocPane(id);
try std.testing.expect(replacement.serial != original.serial);
- try std.testing.expectEqual(pardes.Rect{}, p.rects[id]);
+ try std.testing.expectEqual(pardes.Rect{}, p.view().rects[id]);
pardes.layout.insert(p, 0, 1, id);
for ([_]u16{ 1, 2, 3, 10 }) |size| {
p.update(.{ .resize = .{ .cols = size, .rows = size } });
- for (p.rects) |rect| {
+ for (p.view().rects) |rect| {
try std.testing.expect(rect.x + rect.w <= size);
try std.testing.expect(rect.y + rect.h <= size);
}
}
- p.ncol = 0;
+ p.view().ncol = 0;
layout.compute(p);
- for (p.rects) |rect| try std.testing.expectEqual(pardes.Rect{}, rect);
+ for (p.view().rects) |rect| try std.testing.expectEqual(pardes.Rect{}, rect);
}
const FileTests = struct {
@@ -1743,11 +1743,11 @@ const OutputTests = struct {
try std.testing.expectEqual(i == 0 or i == 4, panes.Output.isResultRow(file, i));
if (i != 5) try std.testing.expect(!row.mark_occurrence);
}
- p.active = result_id;
+ p.view().active = result_id;
result.body.cur_row = 4;
result.body.cur_col = " ╰─ ".len;
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.expectEqual(@as(i32, 3), pane.body.cur_row);
try pardes.dump.dumpState(p);
const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?);
@@ -1797,7 +1797,7 @@ const OutputTests = struct {
try std.testing.expect(file.location_rows[5].mark_occurrence);
try std.testing.expect(!file.location_rows[5].declaration);
try std.testing.expect(!panes.Output.isWalkRow(file, 1, modal.lineSlice(file.content, 1)));
- p.active = result_id;
+ p.view().active = result_id;
result.body.cur_row = 0;
result.body.cur_col = 0;
p.update(.{ .key = .{ .cp = ' ' } });
@@ -1808,7 +1808,7 @@ const OutputTests = struct {
// Enter on the selected signature address must open source, not a path
// accidentally prefixed with tree glyphs.
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.expectEqual(@as(i32, 1), pane.body.cur_row);
p.settings.callstack_depth = 16;
try pardes.dump.dumpState(p);
@@ -1827,8 +1827,8 @@ const OutputTests = struct {
// Narrow enough that the location itself wraps. The repeated guide
// consumes cells, but neither changes the source address nor steals
// a click from the wrapped portion of that address.
- p.active = result_id;
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
+ p.view().active = result_id;
+ p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
p.update(.{ .resize = .{ .cols = 28, .rows = 40 } });
result.file.?.scroll = 0;
var frame = std.heap.ArenaAllocator.init(p.gpa);
@@ -1842,14 +1842,14 @@ const OutputTests = struct {
const shown = try panes.File.bodyText(frame.allocator(), result, file);
const shown_line = modal.lineSlice(shown, wrapped);
try std.testing.expect(std.mem.startsWith(u8, shown_line[panes.File.gutterWidth(result)..], "│ │ "));
- const rect = p.rects[result_id];
+ const rect = p.view().rects[result_id];
const press: pardes.Mouse = .{ .button = .right, .kind = .press, .col = @intCast(rect.x + config.GUTTER + panes.File.gutterWidth(result) + w.pad + 1), .row = @intCast(p.bodyTop(result, rect) + wrapped) };
var release = press;
release.kind = .release;
p.update(.{ .mouse = press });
p.update(.{ .mouse = release });
- try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(@as(usize, 0), p.view().active);
try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row);
}
@@ -2047,7 +2047,7 @@ const OutputTests = struct {
result.scrollBy(-1000);
layout.compute(p);
const surface = try p.render(frame.allocator());
- const rect = p.rects[pane.search_pane.?];
+ const rect = p.view().rects[pane.search_pane.?];
const body_y = bodyY(p, rect);
for (file.location_rows, 0..) |row, index| {
if (!row.declaration) continue;
@@ -2077,14 +2077,14 @@ const OutputTests = struct {
defer p.deinit();
_ = try p.setTestFile("notes\n");
try std.testing.expect(p.executeBuiltinLine(0, "Help"));
- const id = p.active;
+ const id = p.view().active;
const help = p.panes[id].?;
for ("gevkk") |key| p.update(.{ .key = .{ .cp = key } });
try std.testing.expect(help.body.vsel.active);
try std.testing.expect(help.body.vsel.row > 5);
try std.testing.expect(help.body.cur_row != help.body.vsel.row);
for (" h?") |key| p.update(.{ .key = .{ .cp = key } });
- try std.testing.expectEqual(id, p.active);
+ try std.testing.expectEqual(id, p.view().active);
const content = help.file.?.content;
try std.testing.expect(std.mem.startsWith(u8, content, "pardes builtins under SPC h\n"));
const at = std.mem.indexOf(u8, content, "Tutor") orelse return error.MissingTutorRow;
@@ -2093,13 +2093,13 @@ const OutputTests = struct {
var frame: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const rect = p.rects[id];
+ const rect = p.view().rects[id];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(help) + @as(u16, @intCast(at - line_start + 2));
const y = (bodyY(p, rect)) + @as(u16, @intCast(row));
p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .press, .col = x, .row = y } });
p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .release, .col = x, .row = y } });
- try std.testing.expect(p.active != id);
- const tutor = p.panes[p.active].?.file orelse return error.MissingTutor;
+ try std.testing.expect(p.view().active != id);
+ const tutor = p.panes[p.view().active].?.file orelse return error.MissingTutor;
try std.testing.expect(std.mem.indexOf(u8, tutor.content, "PARDES TUTOR") != null);
}
@@ -2114,7 +2114,7 @@ const OutputTests = struct {
if (slot != null and slot.?.file != null and slot.?.file.?.output != null) break id;
} else return error.MissingResults;
const result = p.panes[id].?;
- p.active = id;
+ p.view().active = id;
for ("Cv3") |key| p.update(.{ .key = .{ .cp = key } });
try std.testing.expect(result.body.nsel > 0);
try std.testing.expect(result.body.select);
@@ -2162,15 +2162,15 @@ const OutputTests = struct {
defer frame.deinit();
_ = try p.render(frame.allocator());
p.presented();
- const rect = p.rects[id];
+ const rect = p.view().rects[id];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(result);
const y = bodyY(p, rect);
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = x, .row = y } });
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .drag, .col = x + 2, .row = y + 1 } });
- try std.testing.expect(p.drag == .select);
+ try std.testing.expect(p.view().drag == .select);
try std.testing.expectEqual(.dragging, result.sel[@backingInt(config.select_button)].state);
try fillResults(p, 0, "/", .{ .query = .hover }, "", try p.gpa.dupe(u8, "short\n"), null);
- try std.testing.expect(p.drag == .none);
+ try std.testing.expect(p.view().drag == .none);
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .release, .col = x + 2, .row = y + 1 } });
for (result.sel) |selection| try std.testing.expectEqual(.none, selection.state);
try std.testing.expect(!result.body.vsel.active);
@@ -2429,7 +2429,7 @@ const TerminalTests = struct {
fn modeStyleDiffs(p: *Pardes, pane: *Pane, gpa: std.mem.Allocator, note: []const u8) !usize {
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
const rows: usize = bodyH(p, r);
@@ -2690,7 +2690,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
const red: pardes.Color = .{ .index = 1 };
@@ -2745,7 +2745,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
@@ -2793,7 +2793,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
const body_h = bodyH(p, r);
@@ -2832,7 +2832,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
const red: pardes.Color = .{ .index = 1 };
@@ -2869,7 +2869,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
const red: pardes.Color = .{ .index = 1 };
@@ -2951,7 +2951,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
p.shell_rows.stale = true;
@@ -3029,7 +3029,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
const rows: usize = bodyH(p, r);
@@ -3091,7 +3091,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
p.shell_rows.stale = true;
@@ -3127,7 +3127,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
p.shell_rows.stale = true;
@@ -3160,7 +3160,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
const s = try p.render(frame.allocator());
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
@@ -3203,7 +3203,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
@@ -3241,7 +3241,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
@@ -3279,7 +3279,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
@@ -3315,7 +3315,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
const blue: pardes.Color = .{ .index = 4 };
@@ -3358,7 +3358,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
@@ -3411,7 +3411,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
@@ -3465,7 +3465,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
const body_h = bodyH(p, r);
@@ -3560,7 +3560,7 @@ const TerminalTests = struct {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
@@ -3662,7 +3662,7 @@ test "Zig keywords keep every rendered byte colored across line-number widths" {
const surface = try p.render(frame.allocator());
var seen: usize = 0;
var if_position: ?struct { x: u16, y: u16 } = null;
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const body_y = bodyY(p, rect);
for (body_y..body_y + bodyH(p, rect)) |y| {
for (rect.x + config.GUTTER..rect.x + rect.w - 1) |x| {
@@ -3710,7 +3710,7 @@ test "terminal overlays preserve trailing blank styles without coloring inserted
pane.ovl = .{ .row = 0, .rows = 3, .text = try gpa.dupe(u8, "A\n\n") };
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
- const rect = p.rects[0];
+ const rect = p.view().rects[0];
const x = rect.x + config.GUTTER;
const y = bodyY(p, rect);
const palette = p.theme().palette.?;
@@ -3791,11 +3791,11 @@ test "a terminal keeps its tag and two body rows through a squeeze, a drag and a
const floor = p.panes[term].?.tag_rows + layout.min_body_rows;
// Squeezed by the weights: the others give it its floor.
p.panes[term].?.vweight = 0.01;
- for (p.cols[col].panes[0..p.cols[col].n]) |k| if (k != term) {
+ for (p.view().cols[col].panes[0..p.view().cols[col].n]) |k| if (k != term) {
p.panes[k].?.vweight = 1000;
};
p.sync();
- try std.testing.expectEqual(floor, p.rects[term].h);
+ try std.testing.expectEqual(floor, p.view().rects[term].h);
var rows: ?u16 = null;
while (p.nextEffect()) |effect| if (effect == .resize_pty and effect.resize_pty.pane == term) {
rows = effect.resize_pty.rows;
@@ -3804,17 +3804,17 @@ test "a terminal keeps its tag and two body rows through a squeeze, a drag and a
// A drag of the grip under it up to its tag stops at the floor; one
// the other way takes a text pane down to its tag alone.
const k = layout.findPane(p, term).?.idx;
- if (k + 1 < p.cols[col].n) {
- layout.applyRowSplit(p, col, k, p.rects[term].y);
+ if (k + 1 < p.view().cols[col].n) {
+ layout.applyRowSplit(p, col, k, p.view().rects[term].y);
p.sync();
- try std.testing.expectEqual(floor, p.rects[term].h);
- const text = p.cols[col].panes[k + 1];
- layout.applyRowSplit(p, col, k, p.screen_h);
+ try std.testing.expectEqual(floor, p.view().rects[term].h);
+ const text = p.view().cols[col].panes[k + 1];
+ layout.applyRowSplit(p, col, k, p.view().screen_h);
p.sync();
- try std.testing.expect(p.rects[text].h <= p.panes[text].?.tag_rows);
+ try std.testing.expect(p.view().rects[text].h <= p.panes[text].?.tag_rows);
}
// A window too short for all: the terminal keeps its floor still.
p.update(.{ .resize = .{ .cols = 100, .rows = 10 } });
p.sync();
- try std.testing.expect(p.rects[term].h >= p.panes[term].?.tag_rows + layout.min_body_rows);
+ try std.testing.expect(p.view().rects[term].h >= p.panes[term].?.tag_rows + layout.min_body_rows);
}
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.
diff --git a/test/perf-baseline-gui-debug.json b/test/perf-baseline-gui-debug.json
index 0bf89243..4c687484 100644
--- a/test/perf-baseline-gui-debug.json
+++ b/test/perf-baseline-gui-debug.json
@@ -1 +1 @@
-{"harness":"4fb8a759a45cd6fa","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"gui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400}],"cells":[{"op":"open","fixture":"medium","min_us":2290,"med_us":2523,"p90_us":2642,"max_us":2642},{"op":"render","fixture":"medium","min_us":96,"med_us":97,"p90_us":99,"max_us":99},{"op":"key-down","fixture":"medium","min_us":104,"med_us":106,"p90_us":113,"max_us":113},{"op":"key-right","fixture":"medium","min_us":105,"med_us":107,"p90_us":111,"max_us":112},{"op":"page-down","fixture":"medium","min_us":104,"med_us":107,"p90_us":121,"max_us":125},{"op":"wheel","fixture":"medium","min_us":101,"med_us":104,"p90_us":105,"max_us":106},{"op":"edit-char","fixture":"medium","min_us":1023,"med_us":1293,"p90_us":1447,"max_us":1467},{"op":"edit-twin","fixture":"medium","min_us":1089,"med_us":1340,"p90_us":1418,"max_us":1441},{"op":"body-2m","fixture":"medium","min_us":5061,"med_us":8829,"p90_us":11118,"max_us":11667},{"op":"body-appends","fixture":"medium","min_us":149285,"med_us":210882,"p90_us":266047,"max_us":279235},{"op":"deep-sel","fixture":"medium","min_us":87,"med_us":90,"p90_us":96,"max_us":96}]}
+{"harness":"626d3244f10269ee","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"gui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400}],"cells":[{"op":"open","fixture":"medium","min_us":2290,"med_us":2523,"p90_us":2642,"max_us":2642},{"op":"render","fixture":"medium","min_us":96,"med_us":97,"p90_us":99,"max_us":99},{"op":"key-down","fixture":"medium","min_us":104,"med_us":106,"p90_us":113,"max_us":113},{"op":"key-right","fixture":"medium","min_us":105,"med_us":107,"p90_us":111,"max_us":112},{"op":"page-down","fixture":"medium","min_us":104,"med_us":107,"p90_us":121,"max_us":125},{"op":"wheel","fixture":"medium","min_us":101,"med_us":104,"p90_us":105,"max_us":106},{"op":"edit-char","fixture":"medium","min_us":1023,"med_us":1293,"p90_us":1447,"max_us":1467},{"op":"edit-twin","fixture":"medium","min_us":1089,"med_us":1340,"p90_us":1418,"max_us":1441},{"op":"body-2m","fixture":"medium","min_us":5061,"med_us":8829,"p90_us":11118,"max_us":11667},{"op":"body-appends","fixture":"medium","min_us":149285,"med_us":210882,"p90_us":266047,"max_us":279235},{"op":"deep-sel","fixture":"medium","min_us":87,"med_us":90,"p90_us":96,"max_us":96}]}
diff --git a/test/perf-baseline-tui-debug.json b/test/perf-baseline-tui-debug.json
index e98d37c2..66a2f2da 100644
--- a/test/perf-baseline-tui-debug.json
+++ b/test/perf-baseline-tui-debug.json
@@ -1 +1 @@
-{"harness":"4fb8a759a45cd6fa","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"tui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400}],"cells":[{"op":"open","fixture":"medium","min_us":1820,"med_us":2128,"p90_us":2500,"max_us":3046},{"op":"render","fixture":"medium","min_us":90,"med_us":96,"p90_us":98,"max_us":101},{"op":"key-down","fixture":"medium","min_us":101,"med_us":103,"p90_us":105,"max_us":114},{"op":"key-right","fixture":"medium","min_us":101,"med_us":103,"p90_us":106,"max_us":112},{"op":"page-down","fixture":"medium","min_us":97,"med_us":102,"p90_us":103,"max_us":105},{"op":"wheel","fixture":"medium","min_us":97,"med_us":102,"p90_us":112,"max_us":160},{"op":"edit-char","fixture":"medium","min_us":838,"med_us":899,"p90_us":1129,"max_us":1167},{"op":"edit-twin","fixture":"medium","min_us":869,"med_us":1099,"p90_us":1321,"max_us":1393},{"op":"body-2m","fixture":"medium","min_us":4820,"med_us":8314,"p90_us":11931,"max_us":12182},{"op":"body-appends","fixture":"medium","min_us":125039,"med_us":170714,"p90_us":213376,"max_us":232728},{"op":"deep-sel","fixture":"medium","min_us":90,"med_us":92,"p90_us":96,"max_us":101}]}
+{"harness":"626d3244f10269ee","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"tui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400}],"cells":[{"op":"open","fixture":"medium","min_us":1820,"med_us":2128,"p90_us":2500,"max_us":3046},{"op":"render","fixture":"medium","min_us":90,"med_us":96,"p90_us":98,"max_us":101},{"op":"key-down","fixture":"medium","min_us":101,"med_us":103,"p90_us":105,"max_us":114},{"op":"key-right","fixture":"medium","min_us":101,"med_us":103,"p90_us":106,"max_us":112},{"op":"page-down","fixture":"medium","min_us":97,"med_us":102,"p90_us":103,"max_us":105},{"op":"wheel","fixture":"medium","min_us":97,"med_us":102,"p90_us":112,"max_us":160},{"op":"edit-char","fixture":"medium","min_us":838,"med_us":899,"p90_us":1129,"max_us":1167},{"op":"edit-twin","fixture":"medium","min_us":869,"med_us":1099,"p90_us":1321,"max_us":1393},{"op":"body-2m","fixture":"medium","min_us":4820,"med_us":8314,"p90_us":11931,"max_us":12182},{"op":"body-appends","fixture":"medium","min_us":125039,"med_us":170714,"p90_us":213376,"max_us":232728},{"op":"deep-sel","fixture":"medium","min_us":90,"med_us":92,"p90_us":96,"max_us":101}]}
diff --git a/test/perf.zig b/test/perf.zig
index 55b64a99..fbe6fa49 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -564,13 +564,13 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
pardes.look.lookAt(core, 0, path);
pump(core);
const id = filePane(core) orelse return error.OpenDidNotOpenFile;
- core.active = id;
+ core.view().active = id;
const pane = core.panes[id].?;
_ = try frame(core);
if (op == .edit_twin) {
if (!core.executeBuiltinLine(id, "Zerox")) return error.ZeroxRefused;
pump(core);
- core.active = id;
+ core.view().active = id;
_ = try frame(core);
}
if (op == .edit_char or op == .edit_twin) {
@@ -589,7 +589,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
if (op != .deep_selection) seek(pane, fx, n);
_ = try frame(core); // settle the view at the new spot, untimed
const before = .{ .row = pane.body.cur_row, .col = pane.body.cur_col, .scroll = pane.scroll(), .len = pane.file.?.content.len };
- const rect = core.rects[id];
+ const rect = core.view().rects[id];
const wheel_col = rect.x + pardes.config.GUTTER;
const wheel_row = rect.y + pardes.BOX_H;
const t0 = nowNs();
@@ -768,7 +768,7 @@ fn terminalBatch(buffer: []u8, batch: usize, cols: u16) ![]const u8 {
fn checkTerminalTail(core: *pardes.Pardes, surface: *pardes.Surface, batch: usize) !void {
const pane = core.panes[0] orelse return error.MissingTerminal;
- const rect = core.rects[0];
+ const rect = core.view().rects[0];
const x = rect.x + pardes.config.GUTTER;
const y = rect.y + pardes.BOX_H + pardes.panes.terminal.gridCursor(pane).y;
var expected_buffer: [32]u8 = undefined;
@@ -1486,9 +1486,9 @@ fn miniMeasurement(fallback: std.mem.Allocator, probe: MiniProbe, path: []const
if (core) |p| {
pump(p);
try pardes.panes.mini.open(p, 0, path);
- for (p.panes, 0..) |slot, id| if (slot != null and id != p.active) try p.removePane(id, null);
+ for (p.panes, 0..) |slot, id| if (slot != null and id != p.view().active) try p.removePane(id, null);
pump(p);
- const file = p.panes[p.active].?.file.?;
+ const file = p.panes[p.view().active].?.file.?;
try checkMini(.{ .content = file.content, .colors = file.mini.?.colors }, expected);
}
var frame_hash: ?u64 = null;
diff --git a/test/replicas.zig b/test/replicas.zig
index 338dae16..f50fb04f 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -274,7 +274,7 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void {
// Where a wheel over the shell lands in the session's view (the first
// client's); the others' views put it elsewhere, and their wheels hit
// whatever is there.
- const sr = a.core.rects[shell];
+ const sr = a.core.view().rects[shell];
const wheel_at: ?[2]u16 = if (sr.h > 2) .{ sr.x + sr.w / 2, sr.y + sr.h / 2 } else null;
// What the shell's program prints: a full-screen program, a shell's
diff --git a/test/session.zig b/test/session.zig
index 4919c0a3..db33d7b0 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -278,9 +278,9 @@ pub const Session = struct {
const p = pardesOf(s);
const gpa = p.gpa;
const name = p.takeRestore() orelse return;
- const bytes = pardes.dump.restoreBytes(p, gpa, name) catch |err| return p.reportError(p.active, "Restore", err);
+ const bytes = pardes.dump.restoreBytes(p, gpa, name) catch |err| return p.reportError(p.view().active, "Restore", err);
defer gpa.free(bytes);
- const nc = pardes.dump.restore(p, bytes, name) catch |err| return p.reportError(p.active, "Restore", err);
+ const nc = pardes.dump.restore(p, bytes, name) catch |err| return p.reportError(p.view().active, "Restore", err);
p.deinit();
s.core = nc;
s.drain();