summaryrefslogtreecommitdiff
path: root/core/Core.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 /core/Core.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 'core/Core.zig')
-rw-r--r--core/Core.zig128
1 files changed, 65 insertions, 63 deletions
diff --git a/core/Core.zig b/core/Core.zig
index e3238a6e..282094b3 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -956,7 +956,7 @@ pub fn emitWrite(p: *Pardes, id: usize, bytes: []const u8) void {
if (p.pending_write[id] == null) {
while (off < bytes.len and p.effects_len < p.effects.len) {
const n = @min(bytes.len - off, effect_write_cap);
- p.emit(.{ .write = .{ .pane = @intCast(id), .bytes = .from(bytes[off .. off + n]) } });
+ p.emit(.{ .write = .{ .pane = .at(id), .bytes = .from(bytes[off .. off + n]) } });
off += n;
}
}
@@ -1278,7 +1278,7 @@ fn refillPendingWrites(p: *Pardes) void {
// a copy's cursor and re-send the same chunk for ever.
const pw = if (slot.*) |*live| live else break;
const n = @min(pw.bytes.len - pw.off, effect_write_cap);
- p.emit(.{ .write = .{ .pane = @intCast(id), .bytes = .from(pw.bytes[pw.off..][0..n]) } });
+ p.emit(.{ .write = .{ .pane = .at(id), .bytes = .from(pw.bytes[pw.off..][0..n]) } });
pw.off += n;
p.pending_write_bytes -= n;
if (pw.off == pw.bytes.len) {
@@ -1324,17 +1324,17 @@ fn nextQueued(p: *Pardes) ?Event {
pub fn hostForegroundName(p: *const Pardes, id: usize, buf: []u8) ?[]const u8 {
const f = p.host.vtable.fg_name orelse return null;
- return f(p.host.ctx, @intCast(id), buf);
+ return f(p.host.ctx, .at(id), buf);
}
pub fn hostTtyTaken(p: *const Pardes, id: usize) bool {
const f = p.host.vtable.tty_taken orelse return false;
- return f(p.host.ctx, @intCast(id));
+ return f(p.host.ctx, .at(id));
}
pub fn hostKillJob(p: *const Pardes, id: usize) bool {
const f = p.host.vtable.kill_job orelse return false;
- return f(p.host.ctx, @intCast(id));
+ return f(p.host.ctx, .at(id));
}
/// A terminal whose shell could not be started: said, and a run waiting
@@ -1626,8 +1626,8 @@ fn updateInner(p: *Pardes, ev: Event) void {
const hover_stays = switch (ev) {
.tick, .search => true,
.mouse => |m| m.button == .none and m.kind == .motion,
- .output => |o| look.lookHoverPane(p) != o.pane,
- .file_changed => |changed| look.lookHoverPane(p) != changed.pane,
+ .output => |o| look.lookHoverPane(p) != o.pane.index(),
+ .file_changed => |changed| look.lookHoverPane(p) != changed.pane.index(),
else => false,
};
if (!hover_stays) {
@@ -1665,30 +1665,30 @@ fn updateInner(p: *Pardes, ev: Event) void {
p.resize_count += 1;
},
.output => |o| {
- const pane = p.panes[o.pane] orelse return;
+ const pane = p.panes[o.pane.index()] orelse return;
pane.shell_spoke = true;
- ctlfs.events.notePtyOutput(p, o.pane, o.bytes);
+ ctlfs.events.notePtyOutput(p, o.pane.index(), o.bytes);
pane.feedOutput(p, o.bytes);
- ctlfs.pty.noteMarks(p, o.pane, pane);
- exec.flushReplEnter(p, o.pane, true);
+ ctlfs.pty.noteMarks(p, o.pane.index(), pane);
+ exec.flushReplEnter(p, o.pane.index(), true);
},
- .exited => |e| if (p.panes[e.pane]) |pane| {
+ .exited => |e| if (p.panes[e.pane.index()]) |pane| {
if (pane.command == null)
ctlfs.pty.shellExited(p, pane, e.status)
else if (!pane.command_done)
- pane.commandDone(p, e.pane, e.status);
+ pane.commandDone(p, e.pane.index(), e.status);
},
- .eof => |e| if (p.panes[e.pane]) |pane| if (pane.command != null) {
+ .eof => |e| if (p.panes[e.pane.index()]) |pane| if (pane.command != null) {
// Output is over; the command is over when its child exits.
pane.command_pty = false;
- } else p.removePane(e.pane, null) catch |err| {
+ } else p.removePane(e.pane.index(), null) catch |err| {
pane.body.mode = .normal;
- p.reportError(.at(e.pane), "terminal exited; Del retries close", err);
+ p.reportError(e.pane, "terminal exited; Del retries close", err);
},
.lsp_resp => |r| @import("lsp/Ask.zig").lspResponse(p, r.id, r.rows),
.pipe_resp => |r| Pipe.pipeResponse(p, r.id, r.success, r.outputs, r.failure),
.search => |b| Stream.receive(p, &b),
- .file_changed => |fc| _ = p.applyWatchedFileChanged(fc.pane, fc.bytes),
+ .file_changed => |fc| _ = p.applyWatchedFileChanged(fc.pane.index(), fc.bytes),
.key => |key| {
p.can_ask = true;
defer p.can_ask = false;
@@ -1706,8 +1706,8 @@ fn updateInner(p: *Pardes, ev: Event) void {
if (focused) if (p.host.vtable.newer_build) |f| if (f(p.host.ctx)) p.setMessage(.at(v.active), newer_build_words);
},
.handed => |h| p.handover.finish(p, h.seq, h.to, h.failure),
- .addon => |a| pardes.Addon.landed(p, a.op, a.pane, a.kind.*),
- .job => |j| pardes.Kind.jobDone(p, j.pane, j.serial, j.token, j.gen, j.bytes),
+ .addon => |a| pardes.Addon.landed(p, a.op, a.pane.index(), a.kind.*),
+ .job => |j| pardes.Kind.jobDone(p, j.pane.index(), j.serial, j.token, j.gen, j.bytes),
.frontend => |f| {
v.frontend = f;
},
@@ -1960,7 +1960,7 @@ pub fn sync(p: *Pardes) void {
if (pane.isTerminal()) {
pane.resizeGrid(cols, rows);
p.shell_rows.markStale(pane); // reflow moved every row
- p.emit(.{ .resize_pty = .{ .pane = @intCast(id), .cols = cols, .rows = rows } });
+ p.emit(.{ .resize_pty = .{ .pane = .at(id), .cols = cols, .rows = rows } });
pane.fs.winsize = null;
}
pane.cols = cols;
@@ -1987,7 +1987,7 @@ pub fn sync(p: *Pardes) void {
.wait => {},
.never => pane.greet = false,
.now => {
- p.emit(.{ .resize_pty = .{ .pane = @intCast(id), .cols = pane.cols, .rows = pane.rows } });
+ p.emit(.{ .resize_pty = .{ .pane = .at(id), .cols = pane.cols, .rows = pane.rows } });
p.emitWrite(id, "ls\r");
pane.greet = false;
},
@@ -2333,7 +2333,8 @@ const FakeTtyQuery = struct {
p.host = .{ .ctx = f, .vtable = &vtable };
}
- fn answer(ctx: ?*anyopaque, pane: u8) bool {
+ fn answer(ctx: ?*anyopaque, id: pardes.Pane.Id) bool {
+ const pane = id.index();
const f: *FakeTtyQuery = @ptrCast(@alignCast(ctx.?));
f.asked += 1;
return f.taken[pane];
@@ -2462,7 +2463,7 @@ test "pane-tag Exec prefers Term and argument builtins before shell fallback" {
var sent_len: usize = 0;
while (p.nextEffect()) |effect| switch (effect) {
.write => |w| {
- try std.testing.expectEqual(@as(u8, 0), w.pane);
+ try std.testing.expectEqual(0, w.pane.index());
try std.testing.expect(w.bytes.slice().len <= sent.len - sent_len);
@memcpy(sent[sent_len..][0..w.bytes.slice().len], w.bytes.slice());
sent_len += w.bytes.slice().len;
@@ -2684,7 +2685,7 @@ test "Term spawns a raw shell in the caller's directory" {
var found = false;
while (p.nextEffect()) |effect| switch (effect) {
- .spawn => |s| if (@as(usize, s.pane) == free) {
+ .spawn => |s| if (s.pane.index() == free) {
try std.testing.expectEqualStrings("/tmp/newtty-dir", s.cwd.slice());
found = true;
},
@@ -2708,11 +2709,11 @@ test "a terminal respawned into a closed pane's slot hangs the old shell up firs
var closed = false;
var spawned = false;
while (p.nextEffect()) |effect| switch (effect) {
- .close_pty => |c| if (c.pane == slot) {
+ .close_pty => |c| if (c.pane.index() == slot) {
try std.testing.expect(!spawned);
closed = true;
},
- .spawn => |s| if (s.pane == slot) {
+ .spawn => |s| if (s.pane.index() == slot) {
spawned = true;
},
else => {},
@@ -2784,7 +2785,7 @@ test "unknown Exec from a document runs as a command pane in its directory, type
var spawned = false;
while (p.nextEffect()) |effect| switch (effect) {
.write => return error.TypedIntoATerminal,
- .spawn => |sp| if (sp.pane == dst) {
+ .spawn => |sp| if (sp.pane.index() == dst) {
try std.testing.expectEqualStrings("/tmp/pardes-image-dir", sp.cwd.slice());
spawned = true;
},
@@ -2815,7 +2816,7 @@ test "Exec in a terminal whose tty is taken runs as a command pane instead of ty
var spawned = false;
while (p.nextEffect()) |effect| switch (effect) {
.write => return error.WroteACommandLineIntoATerminal,
- .spawn => |sp| if (sp.pane == dst) {
+ .spawn => |sp| if (sp.pane.index() == dst) {
// ...in the directory the command was about, the taken pane's own
try std.testing.expectEqualStrings("/tmp/pardes-taken", sp.cwd.slice());
spawned = true;
@@ -2843,7 +2844,7 @@ test "a command of several lines keeps its tag one row, and its echo does not st
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- p.update(.{ .exited = .{ .pane = @intCast(dst), .status = 0 } });
+ p.update(.{ .exited = .{ .pane = .at(dst), .status = 0 } });
_ = exec.execute(p, 1, two);
while (p.nextEffect()) |_| {}
_ = try p.render(frame.allocator());
@@ -2863,7 +2864,8 @@ test "a spawn is for the pane it was made for, not whatever took the slot since"
var command: [32]u8 = undefined;
var core: *Pardes = undefined;
const vtable: Host.VTable = .{ .spawn = spawn };
- fn spawn(_: ?*anyopaque, pane: u8, _: []const u8) void {
+ fn spawn(_: ?*anyopaque, id: pardes.Pane.Id, _: []const u8) void {
+ const pane = id.index();
spawns += 1;
const line = core.panes[pane].?.command.?;
@memcpy(command[0..line.len], line);
@@ -2901,8 +2903,8 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe
spawned = false;
while (pp.nextEffect()) |effect| switch (effect) {
.write => |w| {
- @memcpy(to[w.pane][len[w.pane]..][0..w.bytes.slice().len], w.bytes.slice());
- len[w.pane] += w.bytes.slice().len;
+ @memcpy(to[w.pane.index()][len[w.pane.index()]..][0..w.bytes.slice().len], w.bytes.slice());
+ len[w.pane.index()] += w.bytes.slice().len;
},
.spawn => spawned = true,
else => {},
@@ -2960,12 +2962,12 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe
try std.testing.expectEqualStrings("a = 1\rb = [201~2\r", Sent.said(1));
// Into a REPL that takes a bracketed paste (3.13's), the Enter waits
// for the REPL to answer the paste: read with it, it would be part of it.
- p.update(.{ .output = .{ .pane = 1, .bytes = "\x1b[?2004h" } });
+ p.update(.{ .output = .{ .pane = .at(1), .bytes = "\x1b[?2004h" } });
Sent.drain(p);
_ = exec.executeFrom(p, 0, "print(1)", true);
Sent.drain(p);
try std.testing.expectEqualStrings("\x1b[200~print(1)\x1b[201~", Sent.said(1));
- p.update(.{ .output = .{ .pane = 1, .bytes = "print(1)" } });
+ p.update(.{ .output = .{ .pane = .at(1), .bytes = "print(1)" } });
Sent.drain(p);
// Python's echo only restarts a short wait: the Enter goes once the
// echo of the whole paste has gone quiet.
@@ -2991,7 +2993,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe
p.update(.tick);
Sent.drain(p);
try std.testing.expectEqualStrings("\r", Sent.said(1));
- p.update(.{ .output = .{ .pane = 1, .bytes = "\x1b[?2004l" } });
+ p.update(.{ .output = .{ .pane = .at(1), .bytes = "\x1b[?2004l" } });
Sent.len[1] = 0;
// A block left open by its indented last line gets the blank line that
// ends it: a second Enter.
@@ -3095,7 +3097,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe
_ = try pardes.panes.newCommand(p, cmd, "", "python3");
try std.testing.expect(p.executeBuiltinLine(cmd, "Repl python"));
try std.testing.expect(p.panes[cmd].?.repl != null);
- p.update(.{ .exited = .{ .pane = @intCast(cmd), .status = 0 } });
+ p.update(.{ .exited = .{ .pane = .at(cmd), .status = 0 } });
try std.testing.expect(p.panes[cmd].?.repl == null);
try std.testing.expect(p.executeBuiltinLine(cmd, "Repl python"));
try std.testing.expect(p.panes[cmd].?.repl == null);
@@ -3203,32 +3205,32 @@ test "a command pane shows how its command ended, and the next command there run
const other = exec.execute(p, 1, "ls") orelse return error.NoCommandPane;
try std.testing.expect(other != dst);
while (p.nextEffect()) |_| {}
- p.update(.{ .output = .{ .pane = @intCast(dst), .bytes = "compiled\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(dst), .bytes = "compiled\r\n" } });
// Its exit comes first, a job it left still printing: done, and not
// the next command's until its pty closes.
- p.update(.{ .exited = .{ .pane = @intCast(dst), .status = 2 } });
+ p.update(.{ .exited = .{ .pane = .at(dst), .status = 2 } });
try std.testing.expect(pane.command_done and pane.command_pty);
const busy = exec.execute(p, 1, "true") orelse return error.NoCommandPane;
try std.testing.expect(busy != dst);
while (p.nextEffect()) |_| {}
// Its output ending: now it may be reused.
- p.update(.{ .eof = .{ .pane = @intCast(dst) } });
+ p.update(.{ .eof = .{ .pane = .at(dst) } });
try std.testing.expect(p.panes[dst] == pane and !pane.command_pty);
try std.testing.expect(p.panes[dst] == pane);
try std.testing.expect(pane.command_done);
try std.testing.expect(std.mem.endsWith(u8, try tagline.tagPrefix(p, pane), "(make -j8) exit 2"));
// Kill leaves a finished one be.
try std.testing.expect(p.executeBuiltinLine(0, "Kill make"));
- while (p.nextEffect()) |effect| if (effect == .signal_pty and effect.signal_pty.pane == dst) return error.SignalledAFinishedCommand;
+ while (p.nextEffect()) |effect| if (effect == .signal_pty and effect.signal_pty.pane.index() == dst) return error.SignalledAFinishedCommand;
// A program that crashed out of its full screen leaves the emulator
// in its modes; the next command starts clear of them.
- p.update(.{ .output = .{ .pane = @intCast(dst), .bytes = "\x1b[?1049h\x1b[?2004h\x1b[?1000h" } });
+ p.update(.{ .output = .{ .pane = .at(dst), .bytes = "\x1b[?1049h\x1b[?2004h\x1b[?1000h" } });
try std.testing.expect(pardes.Term.modes(pane.terminal).bracketed_paste);
// Done, the directory's next command runs there, below what it showed.
try std.testing.expectEqual(@as(?usize, dst), exec.execute(p, 1, "make test"));
try std.testing.expect(!pardes.Term.modes(pane.terminal).bracketed_paste);
var respawned = false;
- while (p.nextEffect()) |effect| if (effect == .spawn and effect.spawn.pane == dst) {
+ while (p.nextEffect()) |effect| if (effect == .spawn and effect.spawn.pane.index() == dst) {
respawned = true;
};
try std.testing.expect(respawned);
@@ -3242,7 +3244,7 @@ test "a command pane shows how its command ended, and the next command there run
// Kill stops a running one: its whole process group, SIGTERM.
try std.testing.expect(p.executeBuiltinLine(0, "Kill make"));
var signalled = false;
- while (p.nextEffect()) |effect| if (effect == .signal_pty and effect.signal_pty.pane == dst) {
+ while (p.nextEffect()) |effect| if (effect == .signal_pty and effect.signal_pty.pane.index() == dst) {
try std.testing.expectEqual(PtySignal.term, effect.signal_pty.sig);
signalled = true;
};
@@ -3260,7 +3262,7 @@ test "a command pane shows how its command ended, and the next command there run
const Count = struct {
var signals: usize = 0;
const vtable: Host.VTable = .{ .pty_signal = signal };
- fn signal(_: ?*anyopaque, _: u8, _: PtySignal) void {
+ fn signal(_: ?*anyopaque, _: pardes.Pane.Id, _: PtySignal) void {
signals += 1;
}
};
@@ -3300,7 +3302,7 @@ test "a terminal its program gave back takes command lines again" {
var sent_len: usize = 0;
while (p.nextEffect()) |effect| switch (effect) {
.write => |w| {
- try std.testing.expectEqual(@as(u8, 0), w.pane);
+ try std.testing.expectEqual(0, w.pane.index());
try std.testing.expect(w.bytes.slice().len <= sent.len - sent_len);
@memcpy(sent[sent_len..][0..w.bytes.slice().len], w.bytes.slice());
sent_len += w.bytes.slice().len;
@@ -3360,7 +3362,7 @@ test "a host with no methods at all is a complete in-process pardes" {
// the absent child is SILENT: the bytes are dropped, and nothing appears
// on the pane's screen to suggest a program answered
const before = pardes.Term.grid(p.panes[0].?.terminal).cursor_y;
- p.perform(.{ .write = .{ .pane = 0, .bytes = .from("ls\r") } });
+ p.perform(.{ .write = .{ .pane = .at(0), .bytes = .from("ls\r") } });
try std.testing.expectEqual(before, pardes.Term.grid(p.panes[0].?.terminal).cursor_y);
// the clipboard round-trips through the in-process one
@@ -3374,11 +3376,11 @@ test "a host with no methods at all is a complete in-process pardes" {
for (p.panes, 0..) |slot, i| if (slot == doc) {
doc_id = @intCast(i);
};
- p.perform(.{ .save_file = .{ .pane = doc_id } });
+ p.perform(.{ .save_file = .{ .pane = .at(doc_id) } });
try std.testing.expectEqualStrings("body\n", p.fallback.files.get(doc.file.?.path).?);
// a language backend nobody supplied answers nothing rather than hanging
- p.perform(.{ .lsp = .{ .id = 7, .kind = .hover, .pane = doc_id, .offset = 0, .arg = .{} } });
+ p.perform(.{ .lsp = .{ .id = 7, .kind = .hover, .pane = .at(doc_id), .offset = 0, .arg = .{} } });
p.perform(.quit);
try std.testing.expect(p.quit);
@@ -3775,7 +3777,7 @@ test "raw terminal cursor obeys visibility without hiding modal and tag cursors"
while (p.nextEffect()) |_| {}
const pane = p.panes[0].?;
pane.body.mode = .tty;
- p.update(.{ .output = .{ .pane = 0, .bytes = "abc" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "abc" } });
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
const visible = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor;
@@ -3784,7 +3786,7 @@ test "raw terminal cursor obeys visibility without hiding modal and tag cursors"
try std.testing.expectEqual(rect.x + config.GUTTER + 3, visible.x);
try std.testing.expectEqual(body_y, visible.y);
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?25l" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?25l" } });
try std.testing.expect((try p.render(frame.allocator())).cursor == null);
pane.body.mode = .normal;
pane.body.cur_pinned = true;
@@ -3800,13 +3802,13 @@ test "raw terminal cursor obeys visibility without hiding modal and tag cursors"
pane.body.mode = .tty;
try std.testing.expect((try p.render(frame.allocator())).cursor == null);
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?25h\x1b[?1049h\x1b[2;5H" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?25h\x1b[?1049h\x1b[2;5H" } });
const alternate = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor;
try std.testing.expectEqual(rect.x + config.GUTTER + 4, alternate.x);
try std.testing.expectEqual(body_y + 1, alternate.y);
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?25l" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?25l" } });
try std.testing.expect((try p.render(frame.allocator())).cursor == null);
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1049l\x1b[?25h" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?1049l\x1b[?25h" } });
const returned = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor;
try std.testing.expectEqual(visible.x, returned.x);
try std.testing.expectEqual(visible.y, returned.y);
@@ -3820,8 +3822,8 @@ test "raw terminal cursor follows its active row only while that row is visible"
while (p.nextEffect()) |_| {}
const pane = p.panes[0].?;
pane.body.mode = .tty;
- for (0..60) |_| p.update(.{ .output = .{ .pane = 0, .bytes = "row\r\n" } });
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[3;4H" } });
+ for (0..60) |_| p.update(.{ .output = .{ .pane = .at(0), .bytes = "row\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[3;4H" } });
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
const live = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor;
@@ -3881,7 +3883,7 @@ test "tty output follows only from the bottom" {
for (0..60) |i| {
var buf: [32]u8 = undefined;
- p.update(.{ .output = .{ .pane = @intCast(shell), .bytes = std.fmt.bufPrint(&buf, "line {d}\r\n", .{i}) catch unreachable } });
+ p.update(.{ .output = .{ .pane = .at(shell), .bytes = std.fmt.bufPrint(&buf, "line {d}\r\n", .{i}) catch unreachable } });
}
p.sync();
const bottom = pardes.Term.grid(sp.terminal).offset;
@@ -3894,7 +3896,7 @@ test "tty output follows only from the bottom" {
try std.testing.expect(parked < bottom);
for (60..70) |i| {
var buf: [32]u8 = undefined;
- p.update(.{ .output = .{ .pane = @intCast(shell), .bytes = std.fmt.bufPrint(&buf, "line {d}\r\n", .{i}) catch unreachable } });
+ p.update(.{ .output = .{ .pane = .at(shell), .bytes = std.fmt.bufPrint(&buf, "line {d}\r\n", .{i}) catch unreachable } });
}
p.sync();
try std.testing.expectEqual(parked, pardes.Term.grid(sp.terminal).offset);
@@ -3906,7 +3908,7 @@ test "tty output follows only from the bottom" {
// ...and from there output follows again.
const live = pardes.Term.grid(sp.terminal).offset;
- p.update(.{ .output = .{ .pane = @intCast(shell), .bytes = "tail\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(shell), .bytes = "tail\r\n" } });
p.sync();
try std.testing.expect(pardes.Term.grid(sp.terminal).offset > live);
}
@@ -3976,7 +3978,7 @@ test "a bracketed paste larger than the ring still closes its bracket" {
_ = test_api.ptyBytes(p, null, buf);
pardes.keys.enterTty(p, 0);
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?2004h" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?2004h" } });
try std.testing.expect(pardes.Term.modes(p.panes[0].?.terminal).bracketed_paste);
const text = try gpa.alloc(u8, 1536 * 1024);
defer gpa.free(text);
@@ -4007,7 +4009,7 @@ test "a terminal's answer to its program waits behind the paste still queued for
// host takes one write off, and the program asks where its cursor is.
const taken = p.nextEffect().?;
const off = if (taken == .write) taken.write.bytes.len else 0;
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[6n" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[6n" } });
const got = test_api.ptyBytes(p, null, buf);
// The whole paste first, then the answer, `CSI row ; col R`, whole.
try std.testing.expectEqualSlices(u8, text[off..], got[0 .. text.len - off]);
@@ -4047,7 +4049,7 @@ test "leaving tty hides the prompt and keeps the command typed at it" {
// Exactly what an OSC 133 shell draws: prompt, then the marker that says
// the rest of this row is the user's, then what they typed. One grid row.
p.update(.{ .output = .{
- .pane = @intCast(shell),
+ .pane = .at(shell),
.bytes = "\x1b]133;A\x1b\\user@box ~/src $ \x1b]133;B\x1b\\grep -rn TODO src/",
} });
p.sync();
@@ -4091,7 +4093,7 @@ test "leaving tty hides the prompt and keeps the command typed at it" {
// ...and a prompt with nothing typed at it yet is all chrome, so the whole
// row goes, which is what it has always done.
p.update(.{ .output = .{
- .pane = @intCast(shell),
+ .pane = .at(shell),
.bytes = "\r\n\x1b]133;A\x1b\\user@box ~/src $ \x1b]133;B\x1b\\",
} });
p.sync();
@@ -4109,7 +4111,7 @@ test "entering tty walks the shell cursor to the column clicked past the prompt"
const shell = p.view().active;
const sp = p.panes[shell].?;
p.update(.{ .output = .{
- .pane = @intCast(shell),
+ .pane = .at(shell),
.bytes = "\x1b]133;A;cl=line\x1b\\prompt> \x1b]133;B\x1b\\0123456789",
} });
p.sync();