diff options
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/ctl.zig | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 66fa22ab..aebd07e2 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2563,6 +2563,32 @@ test "a 9P look keeps its leading blanks, a blank-only look included, and exec s try testing.expect(th.logHas(p, "blanks trimmed")); } +test "a focus moved over 9P tells the programs that asked for focus reports, as a click does" { + const p = try Pardes.init(testing.allocator, .{ .cols = 90, .rows = 30, .shells = 2 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + const first = for (p.panes) |slot| { + if (slot) |pane| if (pane.isTerminal()) break pane.serial; + } else return error.NoShell; + try testing.expectEqual(Status.ok, wr(p, Node.of(first, .exec), "Tty\n").reply.status); + var shells: [2]usize = undefined; + var n: usize = 0; + for (p.panes, 0..) |slot, id| if (slot) |pane| if (pane.isTerminal() and n < 2) { + shells[n] = id; + n += 1; + }; + try testing.expectEqual(@as(usize, 2), n); + p.active = shells[0]; + p.update(.{ .output = .{ .pane = @intCast(shells[0]), .bytes = "\x1b[?1004h" } }); + p.update(.{ .output = .{ .pane = @intCast(shells[1]), .bytes = "\x1b[?1004h" } }); + while (p.nextEffect()) |_| {} + var digits: [16]u8 = undefined; + const moved = wr(p, @intFromEnum(tree.TopFile.focus), try std.fmt.bufPrint(&digits, "{d}\n", .{p.panes[shells[1]].?.serial})); + try testing.expectEqual(Status.ok, moved.reply.status); + try testing.expectEqual(shells[1], p.active); + try testing.expectEqualStrings("\x1b[O\x1b[I", moved.pty_buf[0..moved.pty_len]); +} + test "a line starting with # runs as nothing at an exec or a ctl, silently" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); |
