summaryrefslogtreecommitdiff
path: root/src/ninep/tree.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 12:57:24 -0300
committerGabriel Schneider <[email protected]>2026-11-03 12:57:31 -0300
commit32d3ec7ea8bda6afc8614a100dfdc7421ecf76be (patch)
tree16a0ad8d535f3f80fb3f72f44d13eb5f497b267e /src/ninep/tree.zig
parentb421b07697cc4c9834e2db401ccf3083eab346ae (diff)
downloadpardes-32d3ec7ea8bda6afc8614a100dfdc7421ecf76be.tar.gz
pardes-32d3ec7ea8bda6afc8614a100dfdc7421ecf76be.zip
fs: kbdin and mousein at the root, rio's and devmouse's (windows/rio/xfid.c:515, kernel/devices/mouse/devmouse.c:445): each rune written to kbdin is a key typed at the pane with the keyboard (control runes Ctrl and a letter but Plan 9's keys: \n Enter, \t Tab, \b Backspace, 0x7f Delete, 0x1b Esc, keyboard.h's private-use runes for the arrows, Home, End, Page Up and Down, Insert, F1-F12), a mousein line `m col row buttons` the mouse as it now is in cells (1 left, 2 middle, 4 right, 8 and 16 a wheel notch), what changed released, moved or pressed; each done before the write is answered, so a script's next read sees it with no sleep; the held buttons are core state, which a replica replays; test/fs.py's keys_and_mouse types, finds the word on /screen and right-clicks it, the first e2e case written through the files alone
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep/tree.zig')
-rw-r--r--src/ninep/tree.zig23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig
index c3eb3636..6bf14243 100644
--- a/src/ninep/tree.zig
+++ b/src/ninep/tree.zig
@@ -266,6 +266,11 @@ pub const TopFile = enum(u5) {
/// them: `daemon <pid>`, `session <pid> tty|gui attached|detached
/// <name>`, `shell <pid>` (the session above's), `orphan <pid>`.
sessions,
+ /// rio's kbdin (windows/rio/xfid.c:515): each rune written is a key
+ /// typed at the pane with the keyboard, done before the write answers.
+ kbdin,
+ /// devmouse's mousein: `m col row buttons`, the mouse as it now is.
+ mousein,
pub fn fileName(f: TopFile) []const u8 {
return if (f == .root) "/" else @tagName(f);
@@ -276,6 +281,7 @@ pub const TopFile = enum(u5) {
.root, .pane, .col => 0o755,
.look, .exec, .log, .focus, .ctl, .tag, .tagexec, .pager => 0o666,
.README, .index, .status, .screen, .listeners, .new, .commands, .layout, .recent, .sessions => 0o444,
+ .kbdin, .mousein => 0o222,
};
}
@@ -681,7 +687,7 @@ fn topSize(p: *Pardes, f: TopFile) u64 {
// frame, /pane/new until an open has a pane to name, and the index,
// layout, recent list and listeners, which a stat would otherwise
// have to build to count.
- .root, .pane, .col, .screen, .new, .layout, .index, .recent, .listeners, .sessions => 0,
+ .root, .pane, .col, .screen, .new, .layout, .index, .recent, .listeners, .sessions, .kbdin, .mousein => 0,
.tag => cols.headerText(p, null).?.len,
.README => fs.help.len,
.status => ctl.statusLen(p),
@@ -789,7 +795,7 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply {
.root => {
// The guide, then what describes the session, then the
// files that act, then the directories.
- inline for (.{ TopFile.README, TopFile.index, TopFile.status, TopFile.focus, TopFile.ctl, TopFile.commands, TopFile.recent, TopFile.look, TopFile.exec, TopFile.pager, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.sessions, TopFile.layout, TopFile.tag, TopFile.tagexec, TopFile.pane, TopFile.col }) |t| {
+ inline for (.{ TopFile.README, TopFile.index, TopFile.status, TopFile.focus, TopFile.ctl, TopFile.commands, TopFile.recent, TopFile.look, TopFile.exec, TopFile.pager, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.sessions, TopFile.layout, TopFile.tag, TopFile.tagexec, TopFile.kbdin, TopFile.mousein, TopFile.pane, TopFile.col }) |t| {
if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @backingInt(t), t.dir(), t.fileName());
}
if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, fs.os_root, true, "os");
@@ -1092,6 +1098,7 @@ fn read(p: *Pardes, req: Req, target: Target) Reply {
fn readFile(p: *Pardes, req: Req, target: Target) Reply {
switch (target) {
.top => |f| return switch (f) {
+ .kbdin, .mousein => Reply.fail(req.tag, E.PERM),
.README => help: {
const off = @min(req.off, fs.help.len);
const bytes = fs.help[off..][0..@min(req.size, fs.help.len - off)];
@@ -1360,6 +1367,8 @@ fn writeNow(p: *Pardes, req: Req, target: Target) Reply {
.look, .exec => ctl.command(p, req, null, f == .exec, false),
.log => events.writeLog(p, req),
.focus => ctl.writeFocus(p, req),
+ .kbdin => ctl.writeKbdin(p, req),
+ .mousein => ctl.writeMousein(p, req),
.ctl => ctl.writeRoot(p, req),
.pager => ctl.writePager(p, req),
.tag => cols.write(p, req, null),
@@ -1557,13 +1566,13 @@ test "readdir lists the root and a pane directory without creating anything" {
@memcpy(top_bytes[0..top_reply.bytes.len], top_reply.bytes);
const top = th.dirents(top_bytes[0..top_reply.bytes.len], &buf);
try testing.expect(top.len >= 10);
- for ([_][]const u8{ "README", "index", "status", "focus", "ctl", "commands", "recent", "look", "exec", "pager", "log", "screen", "listeners", "sessions", "layout", "tag", "tagexec", "pane", "col", "os" }, 0..) |name, i| {
+ for ([_][]const u8{ "README", "index", "status", "focus", "ctl", "commands", "recent", "look", "exec", "pager", "log", "screen", "listeners", "sessions", "layout", "tag", "tagexec", "kbdin", "mousein", "pane", "col", "os" }, 0..) |name, i| {
try testing.expectEqualStrings(name, top[i].name);
- try testing.expectEqual(i >= 17, top[i].dir);
+ try testing.expectEqual(i >= 19, top[i].dir);
}
- try testing.expectEqual(@backingInt(TopFile.pane), top[17].node);
- try testing.expectEqual(@backingInt(TopFile.col), top[18].node);
- try testing.expectEqual(fs.os_root, top[19].node);
+ try testing.expectEqual(@backingInt(TopFile.pane), top[19].node);
+ try testing.expectEqual(@backingInt(TopFile.col), top[20].node);
+ try testing.expectEqual(fs.os_root, top[21].node);
var idbuf: [16]u8 = undefined;
try testing.expect(th.nameAt(top, try std.fmt.bufPrint(&idbuf, "{d}", .{serial})) == null);
try testing.expect(th.nameAt(top, "self") == null);