summaryrefslogtreecommitdiff
path: root/core/ninep/pty.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 20:31:32 -0300
committerGabriel Schneider <[email protected]>2026-11-19 20:31:32 -0300
commit0db34fbf28e70c8c6a3c6025c0888fc5ec75201c (patch)
treef2e288668decded9276ebc45907f16d651b06f9e /core/ninep/pty.zig
parent2ab05b536bc3b063666b5aaab497157adc2a9120 (diff)
parentbf351b62e8843a3d173cedeefa2dd0b8ef4b4392 (diff)
downloadpardes-0db34fbf28e70c8c6a3c6025c0888fc5ec75201c.tar.gz
pardes-0db34fbf28e70c8c6a3c6025c0888fc5ec75201c.zip
integration: a pane's and a view's slot as types, with the regular-expression fixes and the fixes the real loops asked for: pardes-ids (Pane.Id and View.Id through the entries, the events, the effects, the Host table and the device messages) and pardes-merge21, merged without a textual conflict; one call site written since on the old type follows (core/draw.zig: the twin test's file_changed event, .pane = .at(0)); tui core-test 848/991 (143 skipped), shell-test 1027/1030, the window builds; gates in the coordinator's ledger
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/ninep/pty.zig')
-rw-r--r--core/ninep/pty.zig42
1 files changed, 21 insertions, 21 deletions
diff --git a/core/ninep/pty.zig b/core/ninep/pty.zig
index 0fd75aa2..6f3a8af0 100644
--- a/core/ninep/pty.zig
+++ b/core/ninep/pty.zig
@@ -96,14 +96,14 @@ fn verb(p: *Pardes, id: usize, line: []const u8, apply: bool) ?[]const u8 {
// is refused, never quietly raised.
if (rows < pty_rows_min) return e_winsize_rows;
if (!apply) return null;
- 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 = .{ cols, rows };
},
.sig => {
const which = signalNamed(words.next() orelse return e_bad_pty_ctl) orelse return e_bad_pty_ctl;
if (words.next() != null) return e_bad_pty_ctl;
if (!apply) return null;
- p.emit(.{ .signal_pty = .{ .pane = @intCast(id), .serial = pane.serial, .sig = which } });
+ p.emit(.{ .signal_pty = .{ .pane = .at(id), .serial = pane.serial, .sig = which } });
},
.exec => {
if (words.next() != null) return e_bad_pty_ctl;
@@ -656,7 +656,7 @@ test "owned cwd pty exec rejects long paths before applying its batch" {
const ctl = Node.of(pane.serial, .pty_ctl);
var path: [1025]u8 = @splat('d');
path[0] = '/';
- p.setCwd(0, &path);
+ p.setCwd(.at(0), &path);
for ([_][]const u8{ "exec\n", "winsize 100 30\nexec\n", "sig TERM\nexec\n" }) |command| {
const result = wr(p, ctl, command);
try testing.expectEqual(E.INVAL, result.errno());
@@ -664,7 +664,7 @@ test "owned cwd pty exec rejects long paths before applying its batch" {
try testing.expect(result.signal == null and result.winsize == null);
}
try testing.expectEqualStrings(&path, pane.cwdSlice());
- p.setCwd(0, path[0..pardes.effect_path_cap]);
+ p.setCwd(.at(0), path[0..pardes.effect_path_cap]);
const accepted = wr(p, ctl, "exec\n");
try testing.expectEqual(Status.ok, accepted.reply.status);
try testing.expect(accepted.spawned);
@@ -709,7 +709,7 @@ test "pty/data writes at the shell and reads the raw stream" {
try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status);
- p.update(.{ .output = .{ .pane = 0, .bytes = "unwatched" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "unwatched" } });
while (p.nextEffect()) |_| {}
try testing.expectEqual(@as(usize, 0), p.panes[0].?.fs.pty_out.buf.items.len);
try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status);
@@ -724,20 +724,20 @@ test "pty/data writes at the shell and reads the raw stream" {
try testing.expectEqual(@as(u16, 0), p.fs.listeners);
try testing.expect(p.panes[0].?.fs.readers == 0);
- p.update(.{ .output = .{ .pane = 0, .bytes = "hello" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "hello" } });
while (p.nextEffect()) |_| {}
try testing.expectEqualStrings("hello", rd(p, data, 0, 64).bytes);
try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status);
- p.update(.{ .output = .{ .pane = 0, .bytes = "abcdef" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "abcdef" } });
while (p.nextEffect()) |_| {}
try testing.expectEqualStrings("ab", rd(p, data, 0, 2).bytes);
try testing.expectEqualStrings("cd", rd(p, data, 0, 2).bytes);
- p.update(.{ .output = .{ .pane = 0, .bytes = "ghi" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "ghi" } });
while (p.nextEffect()) |_| {}
try testing.expectEqualStrings("efghi", rd(p, data, 0, 64).bytes);
- p.update(.{ .output = .{ .pane = 0, .bytes = "orphan" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "orphan" } });
while (p.nextEffect()) |_| {}
_ = call(p, .{ .tag = 6, .op = .release, .node = data, .handle = reader.reply.handle });
try testing.expect(!p.panes[0].?.fs.pty_reader);
@@ -750,7 +750,7 @@ test "pty/data writes at the shell and reads the raw stream" {
try testing.expectEqual(Status.err, second.reply.status);
try testing.expectEqualStrings(tree.e_in_use, second.reply.ename);
try testing.expect(p.panes[0].?.fs.pty_reader);
- p.update(.{ .output = .{ .pane = 0, .bytes = "still" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "still" } });
while (p.nextEffect()) |_| {}
try testing.expectEqualStrings("still", rd(p, data, 0, 64).bytes);
}
@@ -765,7 +765,7 @@ test "a run waiting for a new terminal's first prompt is the only line typed the
const node = Node.of(serialOf(p), .pty_run);
const h = call(p, .{ .tag = 1, .op = .open, .node = node }).reply.handle;
_ = call(p, .{ .tag = 2, .op = .write, .node = node, .handle = h, .data = "true\n" });
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } });
var sent: [32]u8 = undefined;
var len: usize = 0;
while (p.nextEffect()) |e| if (e == .write) {
@@ -783,7 +783,7 @@ test "run answers how its command ended once the shell is back at a prompt" {
const node = Node.of(serialOf(p), .pty_run);
const out = struct {
fn put(pp: *Pardes, bytes: []const u8) void {
- pp.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ pp.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
while (pp.nextEffect()) |_| {}
}
};
@@ -799,9 +799,9 @@ test "run answers how its command ended once the shell is back at a prompt" {
try testing.expectEqual(Status.again, call(p, .{ .tag = 3, .op = .read, .node = node, .handle = early.reply.handle, .size = 64 }).reply.status);
try testing.expect(std.mem.endsWith(u8, rd(p, status, 0, 64).bytes, " 1\n"));
// A respawn before that prompt keeps it waiting for the new shell's.
- p.acknowledgeShell(0, "/bin/sh", true);
+ p.acknowledgeShell(.at(0), "/bin/sh", true);
try testing.expectEqual(Status.again, call(p, .{ .tag = 3, .op = .read, .node = node, .handle = early.reply.handle, .size = 64 }).reply.status);
- p.update(.{ .output = .{ .pane = 0, .bytes = prompt } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = prompt } });
var sent_late: [16]u8 = undefined;
var sent_len: usize = 0;
while (p.nextEffect()) |e| if (e == .write) {
@@ -909,7 +909,7 @@ test "a shell that exits under a run answers its status, and the log says exit b
const serial = serialOf(p);
const node = Node.of(serial, .pty_run);
const prompt = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07";
- p.update(.{ .output = .{ .pane = 0, .bytes = prompt } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = prompt } });
while (p.nextEffect()) |_| {}
const log = @backingInt(tree.TopFile.log);
const f = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle;
@@ -918,9 +918,9 @@ test "a shell that exits under a run answers its status, and the log says exit b
const r = call(p, .{ .tag = 4, .op = .open, .node = node });
_ = call(p, .{ .tag = 5, .op = .write, .node = node, .handle = r.reply.handle, .data = "echo bye; exit 3\n" });
- p.update(.{ .output = .{ .pane = 0, .bytes = "echo bye; exit 3\r\n\x1b]133;C;aid=pardes\x07bye\r\n" } });
- p.update(.{ .exited = .{ .pane = 0, .status = 3 } });
- p.update(.{ .eof = .{ .pane = 0 } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "echo bye; exit 3\r\n\x1b]133;C;aid=pardes\x07bye\r\n" } });
+ p.update(.{ .exited = .{ .pane = .at(0), .status = 3 } });
+ p.update(.{ .eof = .{ .pane = .at(0) } });
while (p.nextEffect()) |_| {}
try testing.expect(p.paneBySerial(serial) == null);
try testing.expectEqualStrings("exit 3\nbye\n", call(p, .{ .tag = 6, .op = .read, .node = node, .handle = r.reply.handle, .size = 64 }).bytes);
@@ -969,7 +969,7 @@ test "a run's answer says cut when its output's start is gone, and reads a bound
const pane = p.panes[0].?;
const sh = struct {
fn put(pp: *Pardes, bytes: []const u8) void {
- pp.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
+ pp.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
while (pp.nextEffect()) |_| {}
}
fn send(pp: *Pardes, n: u64) u32 {
@@ -1099,7 +1099,7 @@ test "a terminal's ctl counts its body, and a new directory is a rename in the l
const p = try withTerm(gpa);
defer p.deinit();
const serial = serialOf(p);
- p.update(.{ .output = .{ .pane = 0, .bytes = "some history\r\nmore" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "some history\r\nmore" } });
while (p.nextEffect()) |_| {}
const opened = call(p, .{ .tag = 1, .op = .open, .node = Node.of(serial, .body) });
const body_len = call(p, .{ .tag = 2, .op = .read, .node = Node.of(serial, .body), .handle = opened.reply.handle, .size = 1 << 16 }).bytes.len;
@@ -1114,7 +1114,7 @@ test "a terminal's ctl counts its body, and a new directory is a rename in the l
const f = call(p, .{ .tag = 4, .op = .open, .node = log }).reply.handle;
const frozen = call(p, .{ .tag = 5, .op = .read, .node = log, .handle = f, .size = 1 << 16 }).bytes.len;
_ = call(p, .{ .tag = 6, .op = .write, .node = log, .handle = f, .data = "follow" });
- p.setCwd(0, "/somewhere/else");
+ p.setCwd(.at(0), "/somewhere/else");
var want: [64]u8 = undefined;
try testing.expectEqualStrings(
try std.fmt.bufPrint(&want, "rename {d} /somewhere/else\n", .{serial}),