From bf351b62e8843a3d173cedeefa2dd0b8ef4b4392 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 18:35:16 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/fs_namespace.zig | 4 +- test/hxdiff.zig | 2 +- test/kitty.zig | 4 +- test/output.zig | 6 +- test/panes.zig | 150 ++++++++++++++++++++++++------------------------ test/perf.zig | 12 ++-- test/replicas.zig | 26 +++++---- test/rollback_bench.zig | 2 +- test/session.zig | 4 +- test/terminal.zig | 72 +++++++++++------------ 10 files changed, 143 insertions(+), 139 deletions(-) (limited to 'test') diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index ef5dec60..ceda8158 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -203,7 +203,7 @@ test "explicit OS file opens and restores keep their names and request watches" try std.testing.expectEqualStrings("const disk = 1;\n", pane.file.?.content); var watched_open = false; while (p.nextEffect()) |effect| if (effect == .watch and effect.watch.on) { - if (effect.watch.pane == opened) watched_open = true; + if (effect.watch.pane.index() == opened) watched_open = true; }; try std.testing.expect(watched_open); // Unsaved, dumped and loaded: its text kept, its file watched again. @@ -216,7 +216,7 @@ test "explicit OS file opens and restores keep their names and request watches" try std.testing.expectEqualStrings("// unsaved\nconst disk = 1;\n", copy.file.?.content); var watched_restore = false; while (restored.nextEffect()) |effect| if (effect == .watch and effect.watch.on) { - if (effect.watch.pane == opened) watched_restore = true; + if (effect.watch.pane.index() == opened) watched_restore = true; }; try std.testing.expect(watched_restore); } diff --git a/test/hxdiff.zig b/test/hxdiff.zig index 01169504..db858561 100644 --- a/test/hxdiff.zig +++ b/test/hxdiff.zig @@ -352,7 +352,7 @@ fn runCase(arena: std.mem.Allocator, case: Case, pane_kind: []const u8) !Result cooked[cooked_i] = ch; cooked_i += 1; } - core.update(.{ .output = .{ .pane = 0, .bytes = cooked } }); + core.update(.{ .output = .{ .pane = .at(0), .bytes = cooked } }); pump(core); // leave tty mode the way a live session does: Ctrl-, // then park the cursor at (0,0) — the helix harness's initial diff --git a/test/kitty.zig b/test/kitty.zig index 6db6e8fc..76d97421 100644 --- a/test/kitty.zig +++ b/test/kitty.zig @@ -90,13 +90,13 @@ const Rig = struct { fn drain(r: *Rig) void { while (r.p.nextEffect()) |effect| { - if (effect == .write) r.read[effect.write.pane].appendSlice(gpa, effect.write.bytes.slice()) catch @panic("OOM"); + if (effect == .write) r.read[effect.write.pane.index()].appendSlice(gpa, effect.write.bytes.slice()) catch @panic("OOM"); } } /// One pty read of pane `id`'s output. fn feed(r: *Rig, id: u8, bytes: []const u8) void { - r.p.update(.{ .output = .{ .pane = id, .bytes = bytes } }); + r.p.update(.{ .output = .{ .pane = .at(id), .bytes = bytes } }); r.drain(); } diff --git a/test/output.zig b/test/output.zig index a8a1f239..38e8ba0d 100644 --- a/test/output.zig +++ b/test/output.zig @@ -389,7 +389,7 @@ test "Mini asks for no watch on its pane" { try std.testing.expect(id != 0); try std.testing.expect(p.executeBuiltinLine(id, "Mini build.zig")); while (p.nextEffect()) |effect| switch (effect) { - .watch => |watch| try std.testing.expect(watch.pane != id), + .watch => |watch| try std.testing.expect(watch.pane.index() != id), else => {}, }; } @@ -414,7 +414,7 @@ test "Mini dump preserves its exact virtual snapshot and body writes detach colo 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.view().active), + .watch => |watch| try std.testing.expect(watch.pane.index() != restored.view().active), else => {}, }; var body_buf: [128]u8 = undefined; @@ -534,7 +534,7 @@ test "Config with no startup file opens a pane of its name, and Save makes its d try std.testing.expectError(error.FileNotFound, tmp.dir.statFile(std.testing.io, "pardes", .{})); // Save's effect, as a host performs it. try std.testing.expect(p.executeBuiltinLine(opened, "Save")); - p.perform(.{ .save_file = .{ .pane = @intCast(opened) } }); + p.perform(.{ .save_file = .{ .pane = .at(opened) } }); const made = try tmp.dir.statFile(std.testing.io, "pardes", .{}); try std.testing.expectEqual(std.Io.File.Kind.directory, made.kind); } 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); diff --git a/test/perf.zig b/test/perf.zig index 17df0bdc..880e6abe 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -732,7 +732,7 @@ fn measureTerm(op: TermOp, fx: TermFixture, reps: usize) !Cell { const t0 = nowNs(); switch (op) { .render => {}, - .output => core.update(.{ .output = .{ .pane = 0, .bytes = term_chunk } }), + .output => core.update(.{ .output = .{ .pane = .at(0), .bytes = term_chunk } }), .resize_rows => { rows = if (rows == screen_rows) screen_rows - 1 else screen_rows; core.update(.{ .resize = .{ .cols = cols, .rows = rows } }); @@ -782,7 +782,7 @@ fn bootTerm(fx: TermFixture) !*pardes.Pardes { var off: usize = 0; while (off < text.len) { const end = @min(off + 8192, text.len); - core.update(.{ .output = .{ .pane = 0, .bytes = text[off..end] } }); + core.update(.{ .output = .{ .pane = .at(0), .bytes = text[off..end] } }); pump(core); off = end; } @@ -925,7 +925,7 @@ fn measureUndoOutput(core: *pardes.Pardes, counter: *Allocations, arena: *std.he while (offset < bytes.len) { const stop = @min(offset + 4096, bytes.len); const update_begin = nowNs(); - core.update(.{ .output = .{ .pane = 0, .bytes = bytes[offset..stop] } }); + core.update(.{ .output = .{ .pane = .at(0), .bytes = bytes[offset..stop] } }); pump(core); updates[nupdates] = nowNs() - update_begin; nupdates += 1; @@ -1001,7 +1001,7 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void var offset: usize = 0; while (offset < bytes.len) { const end = @min(offset + 4096, bytes.len); - core.update(.{ .output = .{ .pane = 0, .bytes = bytes[offset..end] } }); + core.update(.{ .output = .{ .pane = .at(0), .bytes = bytes[offset..end] } }); pump(core); offset = end; } @@ -1043,7 +1043,7 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void try checkTerminalTail(core, try core.render(arena.allocator()), batches - 1); core.update(.{ .key = .{ .cp = 'f', .text = "f" } }); const input = core.nextEffect() orelse return error.TerminalInputMissing; - if (input != .write or input.write.pane != 0 or !std.mem.eql(u8, "f", input.write.bytes.slice())) + if (input != .write or input.write.pane.index() != 0 or !std.mem.eql(u8, "f", input.write.bytes.slice())) return error.TerminalInputWrong; if (core.nextEffect() != null) return error.UnexpectedTerminalEffect; std.mem.sort(u64, samples[0..batches], {}, std.sort.asc(u64)); @@ -1063,7 +1063,7 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void const update = try std.fmt.bufPrint(&update_buffer, "\r\n\x1b[32mTURN {d:0>10} READY\x1b[0m", .{tail_id}); _ = arena.reset(.retain_capacity); const begin = nowNs(); - core.update(.{ .output = .{ .pane = 0, .bytes = update } }); + core.update(.{ .output = .{ .pane = .at(0), .bytes = update } }); pump(core); const cursor_row = @as(i32, @intCast(pardes.Term.grid(pane.terminal).offset)) + @as(i32, pardes.Term.grid(pane.terminal).cursor_y); pane.ovl.?.row = if (phase == 0) 0 else cursor_row - 1; diff --git a/test/replicas.zig b/test/replicas.zig index 88881dd7..57b6ff23 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -102,7 +102,8 @@ const Host = struct { return h.draws; } - fn ptyWrite(ctx: ?*anyopaque, pane: u8, bytes: []const u8) void { + fn ptyWrite(ctx: ?*anyopaque, id: pardes.Pane.Id, bytes: []const u8) void { + const pane = id.index(); const h: *Host = @ptrCast(@alignCast(ctx.?)); h.echo.append(gpa, .{ .pane = pane, .bytes = gpa.dupe(u8, bytes) catch return }) catch {}; } @@ -123,7 +124,8 @@ const Host = struct { /// it at once on the core's side, inside the perform that asked it, /// where no tape records it: a client replays that perform without it). /// At the setup, before any client, at once inside this call. - fn job(ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void { + fn job(ctx: ?*anyopaque, id: pardes.Pane.Id, serial: u32, token: u32) void { + const pane = id.index(); const h: *Host = @ptrCast(@alignCast(ctx.?)); const j = pardes.host_io.KindJob.take(h.core.?, pane, serial, token) orelse return; if (Draws.go(null, j)) return; @@ -807,7 +809,8 @@ const Soak = struct { return of(ctx).at_frame; } - fn ptyWrite(ctx: ?*anyopaque, pane: u8, bytes: []const u8) void { + fn ptyWrite(ctx: ?*anyopaque, id: pardes.Pane.Id, bytes: []const u8) void { + const pane = id.index(); const s = of(ctx); s.echo.append(gpa, .{ .pane = pane, .bytes = gpa.dupe(u8, bytes) catch return }) catch {}; } @@ -827,7 +830,8 @@ const Soak = struct { /// its loop's event (with no `job`, Effect.perform runs it at once on /// the core's side, inside the perform that asked it, where no tape /// records it: a client replays that perform without it). - fn job(ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void { + fn job(ctx: ?*anyopaque, id: pardes.Pane.Id, serial: u32, token: u32) void { + const pane = id.index(); const core = of(ctx).l.core; const j = pardes.host_io.KindJob.take(core, pane, serial, token) orelse return; if (Draws.go(null, j)) return; @@ -1014,7 +1018,7 @@ const Soak = struct { cl.read_done = false; cl.gen += 1; cl.id = welcome.client; - cl.view = welcome.view; + cl.view = welcome.view.index(); cl.digest = welcome.digest; s.totals.joins += 1; try net.toClient(c, now, .dump, cl.gen, try whole.toOwnedSlice(gpa)); @@ -1185,7 +1189,7 @@ const Soak = struct { // program's output a frame a tick (tui.zig `waitInput`). .echo => { s.clock(); - core.update(.{ .output = .{ .pane = @intCast(m.who), .bytes = m.bytes } }); + core.update(.{ .output = .{ .pane = .at(m.who), .bytes = m.bytes } }); return false; }, .output => { @@ -1205,7 +1209,7 @@ const Soak = struct { if (s.program.at < s.program.bytes.len) try net.send(.{ .at = m.at + if (m.who == 1) @as(u64, 450) else 3_000, .n = 0, .kind = .output, .who = m.who, .bytes = &.{} }) else if (m.who == 1) s.flood_end = m.at; - core.update(.{ .output = .{ .pane = s.shell, .bytes = chunk } }); + core.update(.{ .output = .{ .pane = .at(s.shell), .bytes = chunk } }); took_output = true; }, .frame => { @@ -1271,7 +1275,7 @@ const Soak = struct { // A state job's answer: a step of the session's own. if (j.draw == null) { s.clock(); - core.update(.{ .job = .{ .pane = j.pane, .serial = j.serial, .token = j.token, .gen = j.gen, .bytes = j.out } }); + core.update(.{ .job = .{ .pane = .at(j.pane), .serial = j.serial, .token = j.token, .gen = j.gen, .bytes = j.out } }); j.drop(); return false; } @@ -2139,7 +2143,7 @@ const EchoHost = struct { return false; } - fn ptyWrite(ctx: ?*anyopaque, _: u8, bytes: []const u8) void { + fn ptyWrite(ctx: ?*anyopaque, _: pardes.Pane.Id, bytes: []const u8) void { const h: *EchoHost = @ptrCast(@alignCast(ctx.?)); h.writes.append(gpa, .{ .seq = h.current, .bytes = gpa.dupe(u8, bytes) catch return }) catch {}; } @@ -2287,7 +2291,7 @@ fn runEcho(seed: u64, rtt_ms: u64, on: bool, et: *EchoTotals) !void { // The shell's first prompt. sh.put(prompt_bytes); - a.output(.{ .output = .{ .pane = shell, .bytes = sh.out.items } }); + a.output(.{ .output = .{ .pane = .at(shell), .bytes = sh.out.items } }); sh.out.clearRetainingCapacity(); var next_step: usize = 0; try push(&queue, &n, .{ .at = corpus.steps.items[0].gap, .n = 0, .kind = .input, .who = 1, .bytes = &.{} }); @@ -2351,7 +2355,7 @@ fn runEcho(seed: u64, rtt_ms: u64, on: bool, et: *EchoTotals) !void { } sh.key(m.bytes); if (sh.out.items.len > 0) { - a.output(.{ .output = .{ .pane = shell, .bytes = sh.out.items } }); + a.output(.{ .output = .{ .pane = .at(shell), .bytes = sh.out.items } }); sh.out.clearRetainingCapacity(); if (ty) |k| k.echoed = true; } diff --git a/test/rollback_bench.zig b/test/rollback_bench.zig index d750871e..24203308 100644 --- a/test/rollback_bench.zig +++ b/test/rollback_bench.zig @@ -80,7 +80,7 @@ fn build(s: Session, dir: []const u8, a: std.mem.Allocator) !*pardes.Pardes { var off: usize = 0; while (off < chunk.written().len) { const end = @min(off + 8192, chunk.written().len); - core.update(.{ .output = .{ .pane = 0, .bytes = chunk.written()[off..end] } }); + core.update(.{ .output = .{ .pane = .at(0), .bytes = chunk.written()[off..end] } }); pump(core); off = end; } diff --git a/test/session.zig b/test/session.zig index bf118533..1cbee9df 100644 --- a/test/session.zig +++ b/test/session.zig @@ -288,11 +288,11 @@ pub const Session = struct { .addon => pardesOf(s).perform(e), // A kind's job, here and at once, as the host's worker would; // held while a test holds them (`hold_jobs`). - .job => |j| if (!s.hold_jobs) pardesOf(s).perform(e) else if (pardes.host_io.KindJob.take(pardesOf(s), j.pane, j.serial, j.token)) |taken| s.held.append(pardesOf(s).gpa, taken) catch taken.drop(), + .job => |j| if (!s.hold_jobs) pardesOf(s).perform(e) else if (pardes.host_io.KindJob.take(pardesOf(s), j.pane.index(), j.serial, j.token)) |taken| s.held.append(pardesOf(s).gpa, taken) catch taken.drop(), .lsp => |q| if (s.languages) |io| s.askServer(io, .{ .id = q.id, .kind = q.kind, .pane = q.pane, .offset = q.offset, .arg = q.arg.slice() }), .watch => |w| { if (s.watch_fd < 0) s.watch_fd = pardes.file_watch.init(true); - if (s.watch_fd >= 0) _ = pardes.file_watch.applyEffect(pardesOf(s), std.Io.Threaded.global_single_threaded.io(), s.watch_fd, &s.watches, w.pane, w.on, w.mode); + if (s.watch_fd >= 0) _ = pardes.file_watch.applyEffect(pardesOf(s), std.Io.Threaded.global_single_threaded.io(), s.watch_fd, &s.watches, w.pane.index(), w.on, w.mode); }, else => {}, }; diff --git a/test/terminal.zig b/test/terminal.zig index fafaa605..e6c530d5 100644 --- a/test/terminal.zig +++ b/test/terminal.zig @@ -57,7 +57,7 @@ fn ptyWritesByPane(p: *Pardes, out: *std.ArrayList(u8)) ![]const u8 { var per: [pardes.MAX_PANES]std.ArrayList(u8) = @splat(.empty); defer for (&per) |*b| b.deinit(p.gpa); while (p.nextEffect()) |effect| { - if (effect == .write) try per[effect.write.pane].appendSlice(p.gpa, effect.write.bytes.slice()); + if (effect == .write) try per[effect.write.pane.index()].appendSlice(p.gpa, effect.write.bytes.slice()); } for (per, 0..) |b, id| if (b.items.len > 0) try out.print(p.gpa, "{d}:{s}\n", .{ id, b.items }); return out.items; @@ -163,15 +163,15 @@ test "terminal state keeps parser fragments and sends emulator replies through i const pane = p.panes[0].?; const state = of(pane.terminal.?); try std.testing.expect(state.stream.handler.inner.terminal == &state.vt); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[" } }); while (p.nextEffect()) |effect| { if (effect == .write) return error.PrematureTerminalReply; } - p.update(.{ .output = .{ .pane = 0, .bytes = "6n" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "6n" } }); var answers: usize = 0; while (p.nextEffect()) |effect| { if (effect != .write) continue; - try std.testing.expectEqual(@as(u8, 0), effect.write.pane); + try std.testing.expectEqual(0, effect.write.pane.index()); try std.testing.expectEqualStrings("\x1b[1;1R", effect.write.bytes.slice()); answers += 1; } @@ -212,7 +212,7 @@ test "a restored command pane comes back finished, its command not run again" { const cmd = p.freeSlot().?; _ = try panes.newCommand(p, cmd, "/tmp", "make test"); p.panes[cmd].?.feedOutput(p, "ok\r\n"); - p.update(.{ .exited = .{ .pane = @intCast(cmd), .status = 2 } }); + p.update(.{ .exited = .{ .pane = .at(cmd), .status = 2 } }); try pardes.dump.dumpState(p); const restored = try pardes.dump.initFromDump(gpa, .{ .tty_only = true, .cols = 60, .rows = 16 }, p.dump_out.?); defer restored.deinit(); @@ -248,7 +248,7 @@ test "a restored terminal keeps its history above a marker and gets a shell wher defer restored.deinit(); var spawned = false; while (restored.nextEffect()) |effect| switch (effect) { - .spawn => |sp| spawned = sp.pane == 0 and std.mem.eql(u8, sp.cwd.slice(), "/tmp"), + .spawn => |sp| spawned = sp.pane.index() == 0 and std.mem.eql(u8, sp.cwd.slice(), "/tmp"), else => {}, }; try std.testing.expect(spawned); @@ -323,7 +323,7 @@ test "terminal Filter keys indexed truecolor OSC and background-only cells throu try testing.expect(pane.tty_filter); pane.tty_filter = false; - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[31mA" ++ + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[31mA" ++ "\x1b[38;5;196mB" ++ "\x1b[38;2;255;0;0mC" ++ "\x1b[0;48;5;25mD" ++ @@ -384,7 +384,7 @@ test "terminal Filter keys indexed truecolor OSC and background-only cells throu } } - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]4;1;#ff0000\x1b\\" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]4;1;#ff0000\x1b\\" } }); const osc_red = of(pane.terminal.?).vt.colorForXterm(.{ .palette = 1 }).?; try testing.expect(osc_red.eql(.{ .r = 255, .g = 0, .b = 0 })); pane.tty_filter = false; @@ -396,7 +396,7 @@ test "terminal Filter keys indexed truecolor OSC and background-only cells throu // Dynamic default foreground/background colours key every default cell, // including the otherwise blank end of the row. - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]10;#ff0000\x1b\\" ++ + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]10;#ff0000\x1b\\" ++ "\x1b]11;#5f5f5f\x1b\\" } }); const dyn_fg = of(pane.terminal.?).vt.colorForXterm(.{ .dynamic = .foreground }).?; const dyn_bg = of(pane.terminal.?).vt.colorForXterm(.{ .dynamic = .background }).?; @@ -410,7 +410,7 @@ test "terminal Filter keys indexed truecolor OSC and background-only cells throu const explicit_before_reverse = dynamic.at(tx, body_y).style.fg; try testing.expectEqual(asPardesColor(asGhostRgb(expected[196])), explicit_before_reverse); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?5h" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?5h" } }); _ = frame.reset(.retain_capacity); const reversed = try p.render(frame.allocator()); const reversed_blank = reversed.at(tx + r.w - config.GUTTER - 1, body_y + 2).style; @@ -421,7 +421,7 @@ test "terminal Filter keys indexed truecolor OSC and background-only cells throu try testing.expectEqual(plain.Color{ .rgb = p.theme().bg.? }, reversed_explicit.fg); try testing.expect(!std.meta.eql(reversed_explicit.fg, reversed_explicit.bg)); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?5l" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?5l" } }); _ = frame.reset(.retain_capacity); const unreversed = try p.render(frame.allocator()); const unreversed_blank = unreversed.at(tx + r.w - config.GUTTER - 1, body_y + 2).style; @@ -430,7 +430,7 @@ test "terminal Filter keys indexed truecolor OSC and background-only cells throu // The cache is keyed by values, not a theme name. Replacing a custom // theme in place immediately recolours already-rendered indexed cells. - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]104;1\x1b\\" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]104;1\x1b\\" } }); var custom = p.theme().*; custom.name = try p.gpa.dupe(u8, "same-name"); custom.palette = null; @@ -482,7 +482,7 @@ test "terminal Filter preserves exact palette-null light theme default roles" { try testing.expectEqual(plain.Color{ .rgb = light.fg.? }, ordinary.at(tx, body_y).style.fg); try testing.expectEqual(plain.Color{ .rgb = light.bg.? }, ordinary.at(tx, body_y).style.bg); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?5h" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?5h" } }); _ = frame.reset(.retain_capacity); const reversed = try p.render(frame.allocator()); try testing.expectEqual(plain.Color{ .rgb = light.bg.? }, reversed.at(tx, body_y).style.fg); @@ -514,7 +514,7 @@ test "terminal Filter maps the default roles before it maps anything else" { } p.settings.theme = 0; - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]11;#5f5f5f\x1b\\" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]11;#5f5f5f\x1b\\" } }); var moved = filterOf(&ansi.inkOf(p.theme()), &p.tty_filter_palette, &of(pane.terminal.?).vt); try testing.expect(!asGhostRgb(moved.default_bg).eql(asGhostRgb(moved.theme_bg))); try testing.expect(asGhostRgb(moved.default_bg).eql(keyedRgb(&moved, .{ .r = 0x5f, .g = 0x5f, .b = 0x5f }))); @@ -528,7 +528,7 @@ test "terminal Filter refuses a foreground that would collapse onto the page" { const pane = p.panes[0].?; try testing.expect(pane.tty_filter); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[38;2;255;255;255mW" ++ + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[38;2;255;255;255mW" ++ "\x1b[0;30mB" ++ "\x1b[0;31mR" } }); @@ -623,7 +623,7 @@ test "tty ansi colors follow the prompt hug into normal mode" { const pane = p.panes[0].?; pane.tty_filter = false; - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A\x1b\\\x1b[32mPP\x1b]133;B\x1b\\\x1b[31mR\x1b[34mB\x1b[0m out" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;A\x1b\\\x1b[32mPP\x1b]133;B\x1b\\\x1b[31mR\x1b[34mB\x1b[0m out" } }); var frame = std.heap.ArenaAllocator.init(testing.allocator); defer frame.deinit(); @@ -660,7 +660,7 @@ test "a prompt row hidden end to end paints nothing at all" { p.sync(); pane.tty_filter = false; pane.body.mode = .normal; - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A\x1b\\\x1b[32maaaaaaaaa\x1b]133;B\x1b\\\x1b[41;36m\u{754C}\x1b[0m\r\n" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;A\x1b\\\x1b[32maaaaaaaaa\x1b]133;B\x1b\\\x1b[41;36m\u{754C}\x1b[0m\r\n" } }); var frame = std.heap.ArenaAllocator.init(testing.allocator); defer frame.deinit(); @@ -686,9 +686,9 @@ test "a program that asked for focus reports hears CSI I and CSI O as its pane t _ = try ptyWritesByPane(p, &out); p.view().active = 0; // Asking while its pane has the keyboard: told at once that it has. - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1004h" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?1004h" } }); try std.testing.expectEqualStrings("0:\x1b[I\n", try ptyWritesByPane(p, &out)); - p.update(.{ .output = .{ .pane = 1, .bytes = "\x1b[?1004h" } }); + p.update(.{ .output = .{ .pane = .at(1), .bytes = "\x1b[?1004h" } }); try std.testing.expectEqualStrings("", try ptyWritesByPane(p, &out)); // A click into the other pane moves the keyboard: out of one, into the // other. @@ -724,7 +724,7 @@ test "a terminal's kitty graphics image is drawn where its program placed it, an defer frame.deinit(); const pane = p.panes[0].?; pane.body.mode = .tty; - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[3;5H" ++ kittyTransmit("c=2,r=1") } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[3;5H" ++ kittyTransmit("c=2,r=1") } }); var s = try p.render(frame.allocator()); const places = imagePlaces(s); try std.testing.expectEqual(@as(usize, 1), places.len); @@ -740,20 +740,20 @@ test "a terminal's kitty graphics image is drawn where its program placed it, an try std.testing.expectEqual(plain.RectPx{ .x = 0, .y = 0, .w = 20, .h = 20 }, place.at.?); // Scrolled up by the shell's output, it goes up with the text. - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[24;1H\n\n" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[24;1H\n\n" } }); _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); try std.testing.expectEqual(p.bodyTop(pane, r), imagePlaces(s)[0].dst.y); - p.update(.{ .output = .{ .pane = 0, .bytes = "\n" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\n" } }); _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); try std.testing.expectEqual(@as(usize, 0), imagePlaces(s).len); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[1;1H" ++ kittyTransmit("c=2,r=1") } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[1;1H" ++ kittyTransmit("c=2,r=1") } }); _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); try std.testing.expectEqual(@as(usize, 1), imagePlaces(s).len); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b_Ga=d,d=A\x1b\\" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b_Ga=d,d=A\x1b\\" } }); _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); try std.testing.expectEqual(@as(usize, 0), imagePlaces(s).len); @@ -770,15 +770,15 @@ test "ED 3 takes away a kitty placement whose row it erased: it never comes back defer frame.deinit(); const pane = p.panes[0].?; pane.body.mode = .tty; - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[1;1H" ++ kittyTransmit("c=2,r=1") } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[1;1H" ++ kittyTransmit("c=2,r=1") } }); const storage = &of(pane.terminal.?).vt.screens.active.kitty_images; try std.testing.expectEqual(@as(usize, 1), storage.placements.count()); // Scrolled into the history, it is not on screen; `clear` (ED 2 then // ED 3) erases that history and the placement with it. - p.update(.{ .output = .{ .pane = 0, .bytes = &lineBreaks(40) } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = &lineBreaks(40) } }); var s = try p.render(frame.allocator()); try std.testing.expectEqual(@as(usize, 0), imagePlaces(s).len); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[H\x1b[2J\x1b[3J" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[H\x1b[2J\x1b[3J" } }); try std.testing.expectEqual(@as(usize, 0), storage.placements.count()); _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); @@ -791,7 +791,7 @@ test "a finished command's output erased by a later ED 3 is not called whole, an defer p.deinit(); const pane = p.panes[0].?; const marked = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07"; - p.update(.{ .output = .{ .pane = 0, .bytes = marked ++ "\r\n\x1b]133;C;aid=pardes\x07printed\r\n\x1b]133;D;0;aid=pardes\x07" ++ marked } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = marked ++ "\r\n\x1b]133;C;aid=pardes\x07printed\r\n\x1b]133;D;0;aid=pardes\x07" ++ marked } }); const before = try commandOutput(pane.terminal, gpa, 100); defer gpa.free(before.text); try std.testing.expect(before.whole); @@ -799,8 +799,8 @@ test "a finished command's output erased by a later ED 3 is not called whole, an // The command's rows go into the history, and ED 3 erases them: its // pins are `garbage` now (ghostty 1.4), not moved to the screen's top, // where another program's text would be read as its output. - p.update(.{ .output = .{ .pane = 0, .bytes = &lineBreaks(20) } }); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[3J" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = &lineBreaks(20) } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[3J" } }); const after = try commandOutput(pane.terminal, gpa, 100); defer gpa.free(after.text); try std.testing.expect(!after.whole); @@ -814,13 +814,13 @@ test "a selection whose row ED 3 erased goes; one on the screen stays" { defer p.deinit(); const pane = p.panes[0].?; pane.body.mode = .tty; - p.update(.{ .output = .{ .pane = 0, .bytes = &lineBreaks(20) } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = &lineBreaks(20) } }); pane.body.mode = .normal; const pages = &of(pane.terminal.?).vt.screens.active.pages; const top: i32 = @intCast(pages.total_rows - pane.rows); const row: i32 = if (in_history) top - 3 else top + 2; pane.body.vsel = .{ .active = true, .row = row, .col = 1 }; - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[3J" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[3J" } }); try std.testing.expectEqual(!in_history, pane.body.vsel.active); if (!in_history) try std.testing.expectEqual(@as(i32, 2), pane.body.vsel.row); } @@ -840,7 +840,7 @@ test "a virtual kitty placement shows through its placeholder cells, which draw // yazi's way: a virtual placement two cells by one, then the two // placeholders, the image's id in their colour, row and column in // their diacritics. - p.update(.{ .output = .{ .pane = 0, .bytes = kittyTransmit("U=1,c=2,r=1,q=2") ++ + p.update(.{ .output = .{ .pane = .at(0), .bytes = kittyTransmit("U=1,c=2,r=1,q=2") ++ "\x1b[2;3H\x1b[38;2;0;0;7m\u{10EEEE}\u{0305}\u{0305}\u{10EEEE}\u{0305}\u{030D}\x1b[39mX" } }); const s = try p.render(frame.allocator()); const places = imagePlaces(s); @@ -864,7 +864,7 @@ test "a terminal's image is a placement whatever the frontend draws, and the Pet defer frame.deinit(); const pane = p.panes[0].?; pane.body.mode = .tty; - p.update(.{ .output = .{ .pane = 0, .bytes = kittyTransmit("c=2,r=1") } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = kittyTransmit("c=2,r=1") } }); const r = p.view().rects[0]; const tx = r.x + config.GUTTER; const y = p.bodyTop(pane, r); @@ -921,7 +921,7 @@ test "a program asking the cell size in pixels (CSI 16 t) is told the shell's" { var out: std.ArrayList(u8) = .empty; defer out.deinit(gpa); _ = try ptyWritesByPane(p, &out); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[16t" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[16t" } }); try std.testing.expectEqualStrings("0:\x1b[6;20;10t\n", try ptyWritesByPane(p, &out)); } @@ -960,7 +960,7 @@ test "a replica's terminal pane draws as its authority's does" { var line: [256]u8 = undefined; for (0..60) |i| { const bytes = try std.fmt.bufPrint(&line, "\x1b[1;3{d}m{d}\x1b[0m 漢字 e\u{301} \x1b[48;2;{d};40;60mbg\x1b[0m and then some text that wraps past the width of the pane\r\n", .{ i % 8, i, i * 4 % 256 }); - a.update(.{ .output = .{ .pane = 0, .bytes = bytes } }); + a.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } }); delta.clearRetainingCapacity(); try testing.expect(try encode(&enc, &tr, &peer, ta, @intCast(i + 1), "", &delta.writer)); peer.ack((try rep.apply(gpa, std.Io.Threaded.global_single_threaded.io(), tb, delta.written())).seq); -- cgit v1.3