diff options
Diffstat (limited to 'src/ninep/pane.zig')
| -rw-r--r-- | src/ninep/pane.zig | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 8cac55d6..4a50b9a1 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -259,7 +259,7 @@ pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 { .dot => range_len, .limit => if (pf.limit == null) 0 else range_len, .dirty, .mark, .scroll => 2, - .look, .exec => ctl.resultsLen(p), + .look, .exec, .tagexec => ctl.resultsLen(p), // What the next read would answer, which a client can see without // parking on it. .event => if (pf.events.peek()) |record| record.len else 0, @@ -328,7 +328,7 @@ pub fn read(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply .dirty => readFlag(p, req, dirtyOf(pane)), .mark => readFlag(p, req, !pf.nomark), .scroll => readFlag(p, req, !pf.noscroll), - .look, .exec => ctl.readResults(p, req), + .look, .exec, .tagexec => ctl.readResults(p, req), .event => events.readQueue(p, req, &pf.events), .pty_status => pty.readStatus(p, req, id, pane), .pty_data => pty.readData(p, req, pf), @@ -420,7 +420,9 @@ pub fn write(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply .data, .xdata => writeData(p, req, pane), .sel => writeSel(p, req, pane), .dirty, .mark, .scroll => writeFlag(p, req, pane, file), - .look, .exec => ctl.command(p, req, pane.serial, file == .exec), + .look, .exec => ctl.command(p, req, pane.serial, file == .exec, false), + // A click in its tag: never an event reader's to hear (cols.writeExec). + .tagexec => ctl.command(p, req, pane.serial, true, true), .event => events.writeEvent(p, req, id), .errors => if (appendErrors(p, id, req.data)) |took| .{ .tag = req.tag, .written = @intCast(took) } @@ -1275,3 +1277,14 @@ test "a limit write that fails keeps the limit a truncation cleared before it" { _ = call(p, .{ .tag = 3, .op = .release, .node = limit }); try testing.expectEqualStrings("", rd(p, limit, 0, 100).bytes); } + +test "a pane's tagexec runs a word as a click in its tag, and reads back what it touched" { + const gpa = testing.allocator; + const p = try withFile(gpa, "x\n"); + defer p.deinit(); + const serial = serialOf(p); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .tagexec), "Msg from the tag\n").reply.status); + try testing.expect(th.logHas(p, "from the tag")); + var want: [16]u8 = undefined; + try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{serial}), rd(p, Node.of(serial, .tagexec), 0, 64).bytes); +} |
