summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 13:54:44 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commit72937852d08a6a49f3c0cb2e903b533530b88ae1 (patch)
treea1fdcb9ac8db482a061f1df42e78494d4cd78457 /src/ninep/ctl.zig
parentfaca1504a2296fba9631c45c9f01f3c252cbd0d8 (diff)
downloadpardes-72937852d08a6a49f3c0cb2e903b533530b88ae1.tar.gz
pardes-72937852d08a6a49f3c0cb2e903b533530b88ae1.zip
The root exec is a click at the keyboard's pane, and goes to its event reader too
A line written to the root's look or exec is a click at the pane with the keyboard, and in acme every click on a window whose event file is open goes to its reader; the root's acted at once. It now goes to the reader as the pane's own does. The docs say what that means for a helper holding event (its own exec comes back as a record: run it through ctl, or write the record back), and why an event record counts bytes where acme counts runes: every offset pardes serves is in bytes, #n and q0/q1 too, so the count follows them rather than switch alone, and an acme library reads it right for ASCII text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 1ba78457..c1cfa1f6 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -51,13 +51,14 @@ fn noteResult(p: *Pardes, serial: u32) void {
/// Runs one look or exec from the pane `id`, then records the panes it
/// created; failing that, a look records the pane it focused and an exec
/// the pane it acted on (even one it closed).
-fn run(p: *Pardes, id: usize, exec: bool, text: []const u8, own: bool) void {
+fn run(p: *Pardes, id: usize, exec: bool, text: []const u8) void {
const context = p.panes[id].?.serial;
// A pane an event reader holds hears its clicks instead of acting on
// them (editors/acme/look.c:53 and exec.c:173 send them to winevent),
- // and a line written to its own look or exec is a click on it; the
- // reader writes the record back to have it done.
- if (own and p.panes[id].?.fs.readers > 0) {
+ // and a line written to a look or exec is a click: on that pane, or for
+ // the root's, on the pane with the keyboard. The reader writes the
+ // record back to have it done.
+ if (p.panes[id].?.fs.readers > 0) {
const named = std.meta.stringToEnum(Builtin, exec_line.commandText(text)) != null;
var flag: u32 = pardes.ctlfs.events.flag_expansion;
if (named) flag |= pardes.ctlfs.events.flag_builtin;
@@ -94,7 +95,7 @@ pub fn command(p: *Pardes, req: Req, serial: ?u32, exec: bool) Reply {
if (!apply) continue;
const id = if (serial) |s| p.paneBySerial(s) orelse break else p.active;
if (p.panes[id] == null) return Reply.fail(req.tag, E.NOENT);
- run(p, id, exec, text, serial != null);
+ run(p, id, exec, text);
}
}
return .{ .tag = req.tag, .written = @intCast(req.data.len) };
@@ -909,6 +910,10 @@ test "a pane's own look and exec go to the event reader holding it, which writes
try testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "routed") != null);
try testing.expectEqual(tree.Status.ok, wr(p, Node.of(serial, .look), "one.txt:3\n").reply.status);
try testing.expectEqualStrings("FL0 0 6 9 one.txt:3\n", call(p, .{ .tag = 3, .op = .read, .node = event, .handle = h, .size = 256 }).bytes);
+ // The root's is a click at the pane with the keyboard, this one.
+ try testing.expectEqual(tree.Status.ok, wr(p, root_exec, "Msg rooted\n").reply.status);
+ try testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "rooted") == null);
+ try testing.expectEqualStrings("FX0 0 2 10 Msg rooted\n", call(p, .{ .tag = 5, .op = .read, .node = event, .handle = h, .size = 256 }).bytes);
_ = call(p, .{ .tag = 4, .op = .release, .node = event, .handle = h });
// With no reader, the root's and the pane's act at once.
try testing.expectEqual(tree.Status.ok, wr(p, Node.of(serial, .exec), "Msg direct\n").reply.status);