summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 18:35:16 -0300
committerGabriel Schneider <[email protected]>2026-11-19 20:24:14 -0300
commitbf351b62e8843a3d173cedeefa2dd0b8ef4b4392 (patch)
treeed415f31749669a36d5df304af4101f56e9fdd23 /test/panes.zig
parent78d94c4a62ec3f4039a475b637ff6a60649fde52 (diff)
downloadpardes-bf351b62e8843a3d173cedeefa2dd0b8ef4b4392.tar.gz
pardes-bf351b62e8843a3d173cedeefa2dd0b8ef4b4392.zip
core, dev: what carries a slot across the core's edge carries its type (P21, pardes-ids change 3): `Pane.Id` in Event's six variants that carry a pane (output, eof, exited, file_changed, addon, job), in the fourteen effects that do (spawn, write, resize_pty, signal_pty, close_pty, start, save_file, save_text, lsp, watch, dump_themes, detach, addon, job), in the fourteen Host functions that take one (dev/Host.zig: adopt, upgrade, spawn, pty_write, pty_resize, pty_signal, close_pty, tty_taken, fg_name, kill_job, write_file, watch_file, dump_themes, job; tape.zig's Wrap follows with no edit), in the device messages that carry one into the core (the inbox's output and eof and the five reader functions that make them, dev/Lsp.zig's Request, host_io's Adoption and Adoptions.take, which hold what adoptShell answered); `View.Id` in abi/wire.zig's welcome.view (its bytes on the wire unchanged: one byte, hand-encoded, `.at(takeByte())`/`writeByte(view.index())`); every producer converts at its own line (`.pane = .at(id)`, a script that refuses any path outside the workspace, `fields.py`), every consumer where it indexes or compares (`o.pane.index()`), every Host implementer at its own first line (`fn spawn(ctx, id: pardes.Pane.Id, ..) { const pane = id.index(); ..}`: the terminal's 14, the window's 14, the Mac's 10, and the tests' hosts), and an id that went integer and back is passed through whole (`s.core.readerFailed(e.pane, err)`); the compiler caught no pane's slot passed as a view's or the reverse, only integers meeting the type; kept integers on purpose: KindJob.pane (core/Kind.zig, another agent's, reads it four times; converted at KindJob's and Effect's lines), the Watch table (file_watch: its last slot is the theme's, no pane), the hello's view and the replica's Peer/Joined/Replica views (core/replica.zig, another agent's), the C ABI's `pardes_watch_changed(uint8_t pane)` (abi/pardes.h unchanged; runtime/macos.zig converts at its Host functions); in files another agent is in, each conversion on the line that was there: core/Kind.zig 2 lines, core/Addon.zig 4, core/replica.zig 31 (the welcome's view, 3 test hosts, test literals), test/replicas.zig 12 (4 host functions with their first lines, 1 signature, the welcome's view, 5 literals); the tape's shape moves (Event is update's input), so the semantics word moves, c47ecf638b3f4b9f -> 38b5ae573b965550; test/perf.zig follows on 6 lines its Event and effect literals forced, so its harness id moves, be7cc504010471bc -> 1ed95030eb768eae (unit-test's perf check was BaselineHarnessMismatch already); 607 lines added, 562 deleted in 48 files. Gate (load 4 to 8): tui core-test 841/984 (143 skipped), shell-test 1020/1023, term-test 15/15, pane-test 183/184, kitty-test 45/45, behaviour-test 275/275 and --replay 20 seeds of 70 steps, 0 failures, process-test lspcomplete and lspcompletemoved (the base's; hscroll failed once and passed on the runner's retry), gui unit-test 1618/1622 (BaselineHarnessMismatch, the base's); replicas --clients 5 (TMPDIR /tmp/claude-1000/ids): diverged 0, unequal 0 at rtt 30, 80, 207, deltas checked/wrong 1811/0, 1838/0, 1660/0, quiet checks 567/0, 650/0, 655/0, stops not on may_wait 0 (corpus through a client fails at step 21 as on the base with that TMPDIR); daemon.py plain, --far, --games, --window-clients, --upgrade both ways against pardes-tree's base prefix pass (the semantics words differ: the upgrade carries the session by its dump); test/cross_replay.py (tui records, gui replays): 27 digests agree in each of three replicas; rollback-bench runs; the macOS library for Linux and aarch64-macos and the FreeBSD cross-build build; frames (gpu/ids-3 against tree1) 77/77 byte-identical in Debug, unit-test 1618/1622 there, perfab corpus2x -0.021% (session noise 0.036%, threshold 0.4%), pictures identical in all 10 runs, perfops 97 counts within 0.1% (largest image-frame on longline +0.0231%), key-down on medium 10,040,108 -> 10,039,990 an operation (-0.0012%), render on medium 11,455,765 -> 11,455,683 (-0.0007%), terminal on all +0.0030%
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig150
1 files changed, 75 insertions, 75 deletions
diff --git a/test/panes.zig b/test/panes.zig
index 022d672c..dbdbec2f 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -453,7 +453,7 @@ const TtySelectionTests = struct {
const pane = p.panes[0].?;
pane.tty_filter = false;
while (p.nextEffect()) |_| {}
- p.update(.{ .output = .{ .pane = 0, .bytes = "alpha" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "alpha" } });
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
@@ -478,7 +478,7 @@ const TtySelectionTests = struct {
pane.body.mode = .tty;
pane.tty_filter = false;
while (p.nextEffect()) |_| {}
- p.update(.{ .output = .{ .pane = 0, .bytes = if (prompt)
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = if (prompt)
"\x1b]133;A\x07$ \x1b]133;B\x07abc"
else
"alpha\r\nbravo" } });
@@ -519,7 +519,7 @@ const TtySelectionTests = struct {
try noChildInput(p);
_ = try p.render(frame.allocator());
try std.testing.expectEqualStrings(expected, pardes.exec.heldSelection(p, 0).?);
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;C\x07" ++ std.mem.asBytes(&@as([30][12]u8, @splat("\r\nnew output".*))) } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;C\x07" ++ std.mem.asBytes(&@as([30][12]u8, @splat("\r\nnew output".*))) } });
_ = try p.render(frame.allocator());
try std.testing.expectEqual(panes.Text.Mode.tty, pane.body.mode);
try std.testing.expectEqualStrings(expected, pardes.exec.heldSelection(p, 0).?);
@@ -542,10 +542,10 @@ const TtySelectionTests = struct {
}
p.update(.tick);
while (p.nextEffect()) |_| {}
- p.update(.{ .output = .{ .pane = 0, .bytes = "alpha\r\nbravo" } });
- p.update(.{ .output = .{ .pane = 1, .bytes = "target> " } });
- if (bracketed) p.update(.{ .output = .{ .pane = 1, .bytes = "\x1b[?2004h" } });
- if (reports_mouse) p.update(.{ .output = .{ .pane = 1, .bytes = "\x1b[?1000h\x1b[?1006h" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "alpha\r\nbravo" } });
+ p.update(.{ .output = .{ .pane = .at(1), .bytes = "target> " } });
+ if (bracketed) p.update(.{ .output = .{ .pane = .at(1), .bytes = "\x1b[?2004h" } });
+ if (reports_mouse) p.update(.{ .output = .{ .pane = .at(1), .bytes = "\x1b[?1000h\x1b[?1006h" } });
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
@@ -569,7 +569,7 @@ const TtySelectionTests = struct {
defer written.deinit();
while (p.nextEffect()) |effect| {
if (effect == .write) {
- try std.testing.expectEqual(@as(u8, 1), effect.write.pane);
+ try std.testing.expectEqual(1, effect.write.pane.index());
try written.writer.writeAll(effect.write.bytes.slice());
}
}
@@ -613,7 +613,7 @@ const TtySelectionTests = struct {
defer p.deinit();
const pane = p.panes[0].?;
try std.testing.expectEqual(panes.Text.Mode.tty, pane.body.mode);
- if (bracketed) p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?2004h" } });
+ if (bracketed) p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?2004h" } });
try std.testing.expectEqual(bracketed, pardes.Term.modes(pane.terminal).bracketed_paste);
try p.registers.put(p.gpa, '"', "one\ntwo", 0, 1, true); // what a `y` anywhere left behind
var buf: [256]u8 = undefined;
@@ -964,7 +964,7 @@ test "terminal overlay recoloring never materializes unrelated history" {
while (p.nextEffect()) |_| {}
const pane = p.panes[0].?;
pane.tty_filter = false;
- for (0..1000) |_| p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[32mcaf\xc3\xa9 \xe7\x95\x8c\x1b[0m\r\n" } });
+ for (0..1000) |_| p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[32mcaf\xc3\xa9 \xe7\x95\x8c\x1b[0m\r\n" } });
pane.body.mode = .normal;
pane.ovl = .{ .row = 0, .rows = 1, .text = try p.gpa.dupe(u8, "edited history") };
var frame = std.heap.ArenaAllocator.init(testing.allocator);
@@ -1009,7 +1009,7 @@ test "terminal output keeps following new rows after scrollback eviction" {
var buf: [64]u8 = undefined;
const bytes = try std.fmt.bufPrint(&buf, "\x1b[32mrow-{d:0>5}\x1b[0m\r\n", .{n});
const previous = pages.scrollbar().total;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
if (pages.scrollbar().total < previous) evictions += 1;
}
try std.testing.expect(evictions > phase);
@@ -1036,7 +1036,7 @@ test "terminal output keeps following new rows after scrollback eviction" {
p.update(.{ .key = .{ .cp = 'f', .text = "f" } });
const effect = p.nextEffect() orelse return error.MissingTerminalInput;
try std.testing.expectEqual(.write, std.meta.activeTag(effect));
- try std.testing.expectEqual(@as(u8, 0), effect.write.pane);
+ try std.testing.expectEqual(0, effect.write.pane.index());
try std.testing.expectEqualStrings("f", effect.write.bytes.slice());
try std.testing.expect(p.nextEffect() == null);
}
@@ -1055,7 +1055,7 @@ test "terminal edit stays on its surviving row when old scrollback is evicted" {
while (next < 3000) {
var buf: [32]u8 = undefined;
const bytes = try std.fmt.bufPrint(&buf, "row-{d:0>5}\r\n", .{next});
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
next += 1;
if (pages.scrollbar().total > pages.pages.first.?.rows() + pane.rows + 10) break;
}
@@ -1073,7 +1073,7 @@ test "terminal edit stays on its surviving row when old scrollback is evicted" {
var buf: [32]u8 = undefined;
const bytes = try std.fmt.bufPrint(&buf, "row-{d:0>5}\r\n", .{n});
const previous = pages.scrollbar().total;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
if (pages.scrollbar().total < previous) {
removed = previous + 1 - pages.scrollbar().total;
break;
@@ -1099,8 +1099,8 @@ test "terminal edits and undo survive partial history clearing and whole-screen
const pane = p.panes[0].?;
pane.body.mode = .tty;
if (action == .reset_alternate)
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1049h" } });
- p.update(.{ .output = .{ .pane = 0, .bytes = std.mem.asBytes(&@as([40][9]u8, @splat("old row\r\n".*))) } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?1049h" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = std.mem.asBytes(&@as([40][9]u8, @splat("old row\r\n".*))) } });
const pages = &pardes.Term.emulatorOf(pane.terminal.?).vt.screens.active.pages;
pages.limits.set(.bytes, 64 * 1024);
const row: i32 = @as(i32, @intCast(pages.total_rows - pane.rows)) +
@@ -1130,7 +1130,7 @@ test "terminal edits and undo survive partial history clearing and whole-screen
.reset_primary, .reset_alternate => "\x1bc",
.evict_all, .hidden_undo => std.mem.asBytes(&@as([4000][9]u8, @splat("new row\r\n".*))),
};
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
const expected: i32 = if (action == .clear_history) 2 else 0;
// The copy's top row was in the history ED 3 erased: the copy goes
// with it (terminal.zig's rule for rows that are gone), and the
@@ -1166,7 +1166,7 @@ test "terminal lower scroll regions do not move edits above them" {
while (p.nextEffect()) |_| {}
const pane = p.panes[0].?;
pane.body.mode = .normal;
- p.update(.{ .output = .{ .pane = 0, .bytes = "top\r\nsecond\r\nthird" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "top\r\nsecond\r\nthird" } });
pane.ovl = .{ .row = 1, .rows = 1, .text = try gpa.dupe(u8, "unsent") };
pane.body.cur_row = 1;
pane.body.cur_pinned = true;
@@ -1174,8 +1174,8 @@ test "terminal lower scroll regions do not move edits above them" {
const total = pardes.Term.grid(pane.terminal).total;
var setup: [64]u8 = undefined;
const bytes = try std.fmt.bufPrint(&setup, "\x1b[4;{d}r\x1b[{d};1H", .{ pane.rows, pane.rows });
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
- p.update(.{ .output = .{ .pane = 0, .bytes = std.mem.asBytes(&@as([50][6]u8, @splat("tail\r\n".*))) } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = std.mem.asBytes(&@as([50][6]u8, @splat("tail\r\n".*))) } });
try std.testing.expectEqual(total, pardes.Term.grid(pane.terminal).total);
try std.testing.expectEqual(@as(i32, 1), pane.ovl.?.row);
try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row);
@@ -1198,7 +1198,7 @@ test "terminal eviction and lower-region scrolling in one read preserve a surviv
while (next < 3000) {
var buf: [32]u8 = undefined;
const bytes = try std.fmt.bufPrint(&buf, "row-{d:0>5}\r\n", .{next});
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
next += 1;
if (pages.pages.first != pages.pages.last and
pages.pages.last.?.rows() == pages.pages.last.?.capacity().rows) break;
@@ -1214,7 +1214,7 @@ test "terminal eviction and lower-region scrolling in one read preserve a surviv
const old_total = pages.total_rows;
var buf: [128]u8 = undefined;
const bytes = try std.fmt.bufPrint(&buf, "new\r\n\x1b[4;{d}r\x1b[{d};1Hregion\r\n", .{ pane.rows, pane.rows });
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
try std.testing.expectEqual(old_total + 1 - removed, pages.total_rows);
try std.testing.expectEqual(@as(i32, 2), pane.ovl.?.row);
try std.testing.expectEqual(@as(i32, 2), pane.body.cur_row);
@@ -1412,12 +1412,12 @@ test "Save rearms renamed file watches only after a successful write" {
watches: usize = 0,
err: ?anyerror = null,
- fn write(ctx: ?*anyopaque, id: u8, _: []const u8, _: []const u8) void {
+ fn write(ctx: ?*anyopaque, id: pardes.Pane.Id, _: []const u8, _: []const u8) void {
const h: *@This() = @ptrCast(@alignCast(ctx.?));
switch (h.result) {
.success => {},
- .failure => h.core.saveFailed(.at(id), "save", error.PermissionDenied),
- .edited => h.core.panes[id].?.file.?.revision +%= 1,
+ .failure => h.core.saveFailed(id, "save", error.PermissionDenied),
+ .edited => h.core.panes[id.index()].?.file.?.revision +%= 1,
.replaced => {
const replacement = h.core.setTestFile("replacement\n") catch |err| {
h.err = err;
@@ -1427,16 +1427,16 @@ test "Save rearms renamed file watches only after a successful write" {
replacement.file.?.saved_revision -%= 1;
},
.closed => {
- pardes.panes.deinitPane(h.core, h.core.panes[id].?) catch |err| {
+ pardes.panes.deinitPane(h.core, h.core.panes[id.index()].?) catch |err| {
h.err = err;
return;
};
- h.core.panes[id] = null;
+ h.core.panes[id.index()] = null;
},
}
}
- fn watch(ctx: ?*anyopaque, _: u8, _: []const u8, on: bool, _: pardes.WatchMode) void {
+ fn watch(ctx: ?*anyopaque, _: pardes.Pane.Id, _: []const u8, on: bool, _: pardes.WatchMode) void {
const h: *@This() = @ptrCast(@alignCast(ctx.?));
if (on) h.watches += 1;
}
@@ -1484,9 +1484,9 @@ test "Save rearms renamed file watches only after a successful write" {
test "Save on a scratch does not watch a path the host could not create" {
const Refusing = struct {
- fn write(ctx: ?*anyopaque, id: u8, _: []const u8, _: []const u8) void {
+ fn write(ctx: ?*anyopaque, id: pardes.Pane.Id, _: []const u8, _: []const u8) void {
const p: *Pardes = @ptrCast(@alignCast(ctx.?));
- p.saveFailed(.at(id), "save", error.PermissionDenied);
+ p.saveFailed(id, "save", error.PermissionDenied);
}
};
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 12 });
@@ -1518,9 +1518,9 @@ test "Save on a scratch does not watch a path the host could not create" {
test "a failed Save to another name leaves a clean named file clean" {
const Refusing = struct {
- fn write(ctx: ?*anyopaque, id: u8, _: []const u8, _: []const u8) void {
+ fn write(ctx: ?*anyopaque, id: pardes.Pane.Id, _: []const u8, _: []const u8) void {
const p: *Pardes = @ptrCast(@alignCast(ctx.?));
- p.saveFailed(.at(id), "save", error.AccessDenied);
+ p.saveFailed(id, "save", error.AccessDenied);
}
};
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 12 });
@@ -1544,14 +1544,14 @@ test "unplaced terminal panes keep their allocated grid until placement" {
const id = p.freeSlot().?;
const pane = try p.newShell(id, "");
try std.testing.expectEqual(pardes.Rect{}, p.view().rects[id]);
- p.update(.{ .output = .{ .pane = @intCast(id), .bytes = "unplaced\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(id), .bytes = "unplaced\r\n" } });
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, pardes.Term.emulatorOf(pane.terminal.?).vt.cols);
try std.testing.expectEqual(pane.rows, pardes.Term.emulatorOf(pane.terminal.?).vt.rows);
while (p.nextEffect()) |effect| {
- if (effect == .resize_pty and effect.resize_pty.pane == id) return error.ResizedUnplacedPane;
+ if (effect == .resize_pty and effect.resize_pty.pane.index() == id) return error.ResizedUnplacedPane;
}
pardes.layout.insert(p, 0, 1, id);
p.update(.tick);
@@ -1572,7 +1572,7 @@ test "document panes ignore terminal output without allocating terminal state" {
const resizes = allocator.resize_index;
allocator.fail_index = allocations;
allocator.resize_fail_index = resizes;
- p.update(.{ .output = .{ .pane = 0, .bytes = "unrelated PTY output\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "unrelated PTY output\r\n" } });
try std.testing.expect(!allocator.has_induced_failure);
try std.testing.expectEqual(allocations, allocator.alloc_index);
try std.testing.expectEqual(resizes, allocator.resize_index);
@@ -2442,19 +2442,19 @@ const TerminalTests = struct {
.write => return error.GreetedBeforeOutput,
else => {},
};
- p.update(.{ .output = .{ .pane = 0, .bytes = "startup banner\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "startup banner\r\n" } });
while (p.nextEffect()) |effect| switch (effect) {
.write => return error.GreetedBeforePrompt,
else => {},
};
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A;aid=pardes\x07prompt$ " } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;A;aid=pardes\x07prompt$ " } });
try std.testing.expect(!pardes.Term.prompt(pane.terminal).input_ready);
while (p.nextEffect()) |effect| switch (effect) {
.write => return error.GreetedDuringPrompt,
else => {},
};
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;B;aid=pardes\x07" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;B;aid=pardes\x07" } });
try std.testing.expect(pardes.Term.prompt(pane.terminal).input_ready);
var greeted = false;
while (p.nextEffect()) |effect| switch (effect) {
@@ -2477,9 +2477,9 @@ const TerminalTests = struct {
const pane = p.panes[0].?;
while (p.nextEffect()) |_| {}
p.update(.{ .resize = .{ .cols = 80, .rows = 24 } });
- p.update(.{ .output = .{ .pane = 0, .bytes = output } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = output } });
// and a later, quiet prompt changes nothing
- p.update(.{ .output = .{ .pane = 0, .bytes = "\r\n\x1b]133;A;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\r\n\x1b]133;A;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } });
while (p.nextEffect()) |effect| switch (effect) {
.write => |write| if (std.mem.eql(u8, write.bytes.slice(), "ls\r")) return error.GreetedLate,
else => {},
@@ -2505,13 +2505,13 @@ const TerminalTests = struct {
.write => return error.CommandEscapedBeforePrompt,
else => {},
};
- p.update(.{ .output = .{ .pane = 0, .bytes = "startup\r\n\x1b]133;A\x07prompt$ " } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "startup\r\n\x1b]133;A\x07prompt$ " } });
while (p.nextEffect()) |effect| switch (effect) {
.write => return error.CommandEscapedDuringPrompt,
else => {},
};
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;B\x07" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;B\x07" } });
var sent: [64]u8 = undefined;
var sent_len: usize = 0;
while (p.nextEffect()) |effect| switch (effect) {
@@ -2536,7 +2536,7 @@ const TerminalTests = struct {
p.acknowledgeShell(.at(0), "/bin/sh", false);
try std.testing.expect(!pane.greet);
try std.testing.expectEqual(.none, pane.pending_command.wait);
- p.update(.{ .output = .{ .pane = 0, .bytes = "plain prompt$ " } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "plain prompt$ " } });
while (p.nextEffect()) |effect| switch (effect) {
.write => return error.UnmarkedGreetingEscaped,
else => {},
@@ -2569,7 +2569,7 @@ const TerminalTests = struct {
const effect = p.nextEffect() orelse return error.MissingWriteEffect;
switch (effect) {
.write => |write| {
- try std.testing.expectEqual(@as(u8, 0), write.pane);
+ try std.testing.expectEqual(0, write.pane.index());
try std.testing.expectEqualStrings(expected, write.bytes.slice());
},
else => return error.UnexpectedEffect,
@@ -2603,7 +2603,7 @@ const TerminalTests = struct {
pane.tty_filter = false;
pane.body.mode = .normal;
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[31mAAA\x1b[0m\r\n\x1b[32mBBB\x1b[0m\r\n\x1b[34mCCC\x1b[0m" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[31mAAA\x1b[0m\r\n\x1b[32mBBB\x1b[0m\r\n\x1b[34mCCC\x1b[0m" } });
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
@@ -2658,7 +2658,7 @@ const TerminalTests = struct {
// grapheme for that cell, not one per stored codepoint: stepping twice ate
// the `A`, and left every colour a cell to the left of its glyph with the
// last one stranded on a blank.
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A\x1b\\\x1b[32me\u{301}\x1b]133;B\x1b\\\x1b[31mA\x1b[34mB\x1b[35mC" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;A\x1b\\\x1b[32me\u{301}\x1b]133;B\x1b\\\x1b[31mA\x1b[34mB\x1b[35mC" } });
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
@@ -2694,7 +2694,7 @@ const TerminalTests = struct {
for (0..60) |i| {
var buf: [32]u8 = undefined;
const bytes = std.fmt.bufPrint(&buf, "\x1b[4{d}mL{d:0>2}\x1b[0m\r\n", .{ (i % 6) + 1, i }) catch unreachable;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
}
p.shell_rows.stale = true;
pardes.Term.scroll(pane.terminal.?, -20);
@@ -2745,7 +2745,7 @@ const TerminalTests = struct {
pane.tty_filter = false;
pane.body.mode = .normal;
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[31mAAA\x1b[0m\r\n\x1b[32mBBB\x1b[0m\r\n\x1b[34mCCC\x1b[0m" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[31mAAA\x1b[0m\r\n\x1b[32mBBB\x1b[0m\r\n\x1b[34mCCC\x1b[0m" } });
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
@@ -2782,7 +2782,7 @@ const TerminalTests = struct {
pane.tty_filter = false;
pane.body.mode = .normal;
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[31mAAA\x1b[0m\r\n\x1b[32mBBB\x1b[0m\r\n\x1b[34mCCC\x1b[0m" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[31mAAA\x1b[0m\r\n\x1b[32mBBB\x1b[0m\r\n\x1b[34mCCC\x1b[0m" } });
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
@@ -2821,7 +2821,7 @@ const TerminalTests = struct {
while (p.nextEffect()) |_| {}
const pane = p.panes[0].?;
pane.tty_filter = filter;
- p.update(.{ .output = .{ .pane = 0, .bytes = payload } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = payload } });
const diffs = try modeStyleDiffs(p, pane, testing.allocator, if (filter) "session filter=on" else "session filter=off");
try testing.expectEqual(@as(usize, 0), diffs);
}
@@ -2864,7 +2864,7 @@ const TerminalTests = struct {
"\x1b]133;A\x1b\\\x1b[32m{s}$ \x1b]133;B\x1b\\\x1b[31mab\x1b[34mcd\x1b[0m",
.{prompt},
);
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
@@ -2923,7 +2923,7 @@ const TerminalTests = struct {
while (p.nextEffect()) |_| {}
const pane = p.panes[0].?;
pane.tty_filter = filter;
- p.update(.{ .output = .{ .pane = 0, .bytes = payload } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = payload } });
const diffs = try modeStyleDiffs(p, pane, testing.allocator, if (filter) "bg filter=on" else "bg filter=off");
try testing.expectEqual(@as(usize, 0), diffs);
}
@@ -2941,7 +2941,7 @@ const TerminalTests = struct {
for (0..60) |i| {
var buf: [40]u8 = undefined;
const bytes = std.fmt.bufPrint(&buf, "\x1b[3{d}mL{d:0>2}\x1b[0m\r\n", .{ (i % 6) + 1, i }) catch unreachable;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
}
var frame = std.heap.ArenaAllocator.init(testing.allocator);
@@ -3004,7 +3004,7 @@ const TerminalTests = struct {
p.sync();
pane.tty_filter = filter;
pane.body.mode = mode;
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[32m\u{754C}\x1b[41m\x1b[K\x1b[7G\x1b[44m\x1b[K\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[32m\u{754C}\x1b[41m\x1b[K\x1b[7G\x1b[44m\x1b[K\r\n" } });
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
@@ -3040,7 +3040,7 @@ const TerminalTests = struct {
const pane = p.panes[0].?;
pane.tty_filter = false;
pane.body.mode = mode;
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[41mzzzzzzzzzzzzz\u{754C}\x1b[0m\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[41mzzzzzzzzzzzzz\u{754C}\x1b[0m\r\n" } });
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
@@ -3070,7 +3070,7 @@ const TerminalTests = struct {
for (0..40) |i| {
var buf: [64]u8 = undefined;
const bytes = std.fmt.bufPrint(&buf, "\x1b[38;5;{d}mline-{d:0>2}\x1b[0m\r\n", .{ 20 + i, i }) catch unreachable;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
}
p.shell_rows.stale = true;
@@ -3124,12 +3124,12 @@ const TerminalTests = struct {
const tx = r.x + config.GUTTER;
const body_y = bodyY(p, r);
- p.update(.{ .output = .{ .pane = 0, .bytes = "plain text\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "plain text\r\n" } });
p.shell_rows.stale = true;
const before = try p.render(frame.allocator());
const plain = before.at(tx, body_y).style;
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?5h" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?5h" } });
p.shell_rows.stale = true;
_ = frame.reset(.retain_capacity);
const after = try p.render(frame.allocator());
@@ -3153,7 +3153,7 @@ const TerminalTests = struct {
for (0..6) |i| {
var buf: [40]u8 = undefined;
const bytes = std.fmt.bufPrint(&buf, "\x1b[38;5;{d}mrow-{d:0>2}\x1b[0m\r\n", .{ 16 + i, i }) catch unreachable;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
}
var frame = std.heap.ArenaAllocator.init(testing.allocator);
@@ -3192,7 +3192,7 @@ const TerminalTests = struct {
pane.tty_filter = false;
pane.body.mode = .normal;
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[31m000\x1b[0m\r\n\x1b[32m111\x1b[0m\r\n\r\n\x1b[34m333\x1b[0m\r\n\x1b[35m444\x1b[0m" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[31m000\x1b[0m\r\n\x1b[32m111\x1b[0m\r\n\r\n\x1b[34m333\x1b[0m\r\n\x1b[35m444\x1b[0m" } });
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
@@ -3228,7 +3228,7 @@ const TerminalTests = struct {
pane.tty_filter = false;
pane.body.mode = .tty;
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[31mAAA\x1b[0m\r\n\x1b[32mBBB\x1b[0m\r\n\x1b[34mCCC\x1b[0m" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[31mAAA\x1b[0m\r\n\x1b[32mBBB\x1b[0m\r\n\x1b[34mCCC\x1b[0m" } });
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
@@ -3267,7 +3267,7 @@ const TerminalTests = struct {
for (0..6) |i| {
var buf: [64]u8 = undefined;
const bytes = std.fmt.bufPrint(&buf, "\x1b[38;5;{d}mrow-{d}-abcdefgh\x1b[0m\r\n", .{ 30 + i, i }) catch unreachable;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
}
// One `Z` typed into the middle of row 3's own text.
pane.ovl = .{ .row = 3, .rows = 1, .text = try p.gpa.dupe(u8, "row-3-abcZdefgh") };
@@ -3317,7 +3317,7 @@ const TerminalTests = struct {
for (0..26) |i| {
var buf: [64]u8 = undefined;
const bytes = std.fmt.bufPrint(&buf, "\x1b[38;5;{d}mrow-{d:0>2}-xyzzy\x1b[0m\r\n", .{ 20 + i, i }) catch unreachable;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
}
pane.ovl = .{
.row = 23,
@@ -3376,7 +3376,7 @@ const TerminalTests = struct {
for (0..26) |i| {
var buf: [64]u8 = undefined;
const bytes = std.fmt.bufPrint(&buf, "\x1b[38;5;{d}mrow-{d:0>2}-xyzzy\x1b[0m\r\n", .{ 20 + i, i }) catch unreachable;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
}
p.shell_rows.stale = true;
@@ -3464,7 +3464,7 @@ const TerminalTests = struct {
for (0..26) |i| {
var buf: [64]u8 = undefined;
const bytes = std.fmt.bufPrint(&buf, "\x1b[38;5;{d}mrow-{d:0>2}-xyzzy\x1b[0m\r\n", .{ 20 + i, i }) catch unreachable;
- p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
}
// A newline typed at column 0 of row 24, and `WW` typed on the blank row
// below the output: the span covers rows 24, 25 and that blank row.
@@ -3528,7 +3528,7 @@ test "cancelled normal gestures leave no count or subprefix through raw tty mode
defer p.deinit();
const pane = p.panes[0].?;
pane.body.mode = .normal;
- p.update(.{ .output = .{ .pane = 0, .bytes = "abcdefghij\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "abcdefghij\r\n" } });
for (keys) |cp| p.update(.{ .key = .{ .cp = cp } });
try std.testing.expect(!std.meta.eql(modal.Normal.State{}, pane.body.normal));
p.update(.{ .key = .{ .cp = p.opts.tty_toggle, .ctrl = true } });
@@ -3621,7 +3621,7 @@ test "terminal overlays preserve trailing blank styles without coloring inserted
while (p.nextEffect()) |_| {}
const pane = p.panes[0].?;
pane.tty_filter = false;
- p.update(.{ .output = .{ .pane = 0, .bytes = "A\r\n\x1b[41m\x1b[2K\r\n\x1b[42m\x1b[2K\r\n\x1b[44m\x1b[2K\x1b[0m" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "A\r\n\x1b[41m\x1b[2K\r\n\x1b[42m\x1b[2K\r\n\x1b[44m\x1b[2K\x1b[0m" } });
pane.body.mode = .normal;
pane.ovl = .{ .row = 0, .rows = 3, .text = try gpa.dupe(u8, "A\n\n") };
var frame = std.heap.ArenaAllocator.init(gpa);
@@ -3713,7 +3713,7 @@ test "a terminal keeps its tag and two body rows through a squeeze, a drag and a
p.sync();
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) {
+ while (p.nextEffect()) |effect| if (effect == .resize_pty and effect.resize_pty.pane.index() == term) {
rows = effect.resize_pty.rows;
};
try std.testing.expectEqual(@as(?u16, layout.min_body_rows), rows);
@@ -3751,7 +3751,7 @@ const PdfAddon = struct {
const j = pardes.host_io.KindJob.take(core, a.pane, a.serial, a.token) orelse continue;
defer j.drop();
j.run();
- try land.step(.{ .job = .{ .pane = j.pane, .serial = j.serial, .token = j.token, .gen = j.gen, .bytes = j.out } });
+ try land.step(.{ .job = .{ .pane = .at(j.pane), .serial = j.serial, .token = j.token, .gen = j.gen, .bytes = j.out } });
}
}
@@ -3760,7 +3760,7 @@ const PdfAddon = struct {
items: [16]Asked = undefined,
n: usize = 0,
fn append(q: *@This(), j: anytype) void {
- if (q.n < q.items.len) q.items[q.n] = .{ .pane = j.pane, .serial = j.serial, .token = j.token };
+ if (q.n < q.items.len) q.items[q.n] = .{ .pane = j.pane.index(), .serial = j.serial, .token = j.token };
q.n += @intFromBool(q.n < q.items.len);
}
fn pop(q: *@This()) ?Asked {
@@ -3777,7 +3777,7 @@ const PdfAddon = struct {
}
}.f,
.job = struct {
- fn f(_: ?*anyopaque, pane: u8, serial: u32, token: u32) void {
+ fn f(_: ?*anyopaque, pane: pardes.Pane.Id, serial: u32, token: u32) void {
asked.append(.{ .pane = pane, .serial = serial, .token = token });
}
}.f,
@@ -3833,7 +3833,7 @@ const PdfAddon = struct {
var words: [64]pardes.Kind.LoadedWord = undefined;
var why: pardes.Kind.Buf(160) = .{};
const lib = pardes.Addon.readLoaded(pdf_lib, &words, &why);
- try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } });
+ try land.step(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &lib } });
var buf: [4096]u8 = undefined;
const real = try std.Io.Dir.cwd().realPathFile(std.testing.io, "docs/design.pdf", &buf);
var line: [4200]u8 = undefined;
@@ -3903,7 +3903,7 @@ const PdfAddon = struct {
var words: [64]pardes.Kind.LoadedWord = undefined;
var why: pardes.Kind.Buf(160) = .{};
const lib = pardes.Addon.readLoaded(@import("test_addons").image, &words, &why);
- try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } });
+ try land.step(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &lib } });
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "dot.ppm", .data = "P6\n1 1\n255\n\x01\x02\x03" });
@@ -4202,7 +4202,7 @@ const PdfAddon = struct {
var words: [64]pardes.Kind.LoadedWord = undefined;
var why: pardes.Kind.Buf(160) = .{};
const lib = pardes.Addon.readLoaded(pdf_lib, &words, &why);
- try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } });
+ try land.step(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &lib } });
const kind = a.core.kinds.n - 1;
win.core().kinds.ops[kind] = a.core.kinds.ops[kind];
const id = try opened(a, land);
@@ -4245,7 +4245,7 @@ const PdfAddon = struct {
var words: [64]pardes.Kind.LoadedWord = undefined;
var why: pardes.Kind.Buf(160) = .{};
const lib = pardes.Addon.readLoaded(pdf_lib, &words, &why);
- try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } });
+ try land.step(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &lib } });
const kind = a.core.kinds.n - 1;
win.core().kinds.ops[kind] = a.core.kinds.ops[kind];
const id = try opened(a, land);