summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/ctl.zig25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 258ea1ee..d9bd4372 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -380,10 +380,14 @@ fn statusText(p: *Pardes, buf: []u8) []const u8 {
for (p.panes) |slot| count += @intFromBool(slot != null);
const pid: u32 = if (comptime pardes.hosted) @intCast(std.c.getpid()) else 0;
w.print("pid {d}\nversion {s}\npanes {d}\n", .{ pid, pardes.version, count }) catch {};
+ // Whether the pointer is over this window: what a grip let go past
+ // another window's edge asks of every window, to find the one it was
+ // let go over (Handover.zig), where no window may know another's place.
+ if (p.windowed) w.print("pointer {s}\n", .{if (p.pointer_inside) "in" else "out"}) catch {};
return w.buffered();
}
-pub const status_text_cap = 64 + pardes.version.len;
+pub const status_text_cap = 80 + pardes.version.len;
pub fn statusLen(p: *Pardes) u64 {
var buf: [status_text_cap]u8 = undefined;
@@ -804,6 +808,19 @@ pub fn writeRoot(p: *Pardes, req: Req) Reply {
}
continue;
}
+ // `adopt <dump>`: a pane or column another window's grip carried
+ // here (Handover.zig), taken in where the pointer is. A window's
+ // word to a window, as `size` is a frontend's: no builtin.
+ if (std.mem.startsWith(u8, line, "adopt ")) {
+ const path = std.mem.trim(u8, line["adopt".len..], " \t");
+ if (!apply) continue;
+ // ponytail: read on the 9P task, a small local file; a big
+ // one would want pardes.turn's yield.
+ const bytes = fs.readFile(p.gpa, path) catch |err| return refuseQuoting(p, req, @errorName(err), path);
+ defer p.gpa.free(bytes);
+ _ = pardes.Handover.adopt(p, bytes) catch |err| return refuseQuoting(p, req, @errorName(err), path);
+ continue;
+ }
if (!apply) {
if (checkBuiltin(p, req, line, .session)) |refusal| return refusal;
continue;
@@ -1731,6 +1748,12 @@ test "status reads the editor, and look and exec validate whole batches" {
for (p.panes) |slot| live += @intFromBool(slot != null);
try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "panes {d}", .{live}), lines.next().?);
try testing.expect(lines.next() == null);
+ // A window says whether the pointer is over it.
+ p.windowed = true;
+ var again = std.mem.tokenizeScalar(u8, rd(p, root_status, 0, 4096).bytes, '\n');
+ for (0..3) |_| _ = again.next();
+ try testing.expectEqualStrings("pointer out", again.next().?);
+ p.windowed = false;
const stat = call(p, .{ .tag = 1, .op = .getattr, .node = root_status });
try testing.expectEqual(@as(u64, status.bytes.len), stat.reply.attr.size);
try testing.expectEqual(@as(u16, 0o444), stat.reply.attr.mode);