summaryrefslogtreecommitdiff
path: root/test/panes.zig
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/panes.zig
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/panes.zig')
-rw-r--r--test/panes.zig214
1 files changed, 107 insertions, 107 deletions
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);
}