summaryrefslogtreecommitdiff
path: root/core/ninep/pty.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/ninep/pty.zig')
-rw-r--r--core/ninep/pty.zig34
1 files changed, 17 insertions, 17 deletions
diff --git a/core/ninep/pty.zig b/core/ninep/pty.zig
index 96f2a6bf..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;
@@ -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()) |_| {}
}
};
@@ -801,7 +801,7 @@ test "run answers how its command ended once the shell is back at a prompt" {
// A respawn before that prompt keeps it waiting for the new shell's.
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;