summaryrefslogtreecommitdiff
path: root/src/ninep/cols.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 00:41:23 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commit0fe78621cc0db8b835ebcb7c51bbd2d20d6dbcc2 (patch)
tree9e263810f35b82f4d1b667fa601e6b55cdcb0ebc /src/ninep/cols.zig
parent6732ce6edcf1562d3e126ed02f96466ab07c498e (diff)
downloadpardes-0fe78621cc0db8b835ebcb7c51bbd2d20d6dbcc2.tar.gz
pardes-0fe78621cc0db8b835ebcb7c51bbd2d20d6dbcc2.zip
A focus write makes its pane's column the active one, and layout's active is it
Writing a serial to /focus gave that pane the keyboard but left the active column where it was, so pane/new under Placement acme went elsewhere, and /layout's active named the keyboard's column rather than where a new pane would go. A focus write now sets the active column as the user's click there would, under either Placement, and /layout's active names the active column, which pane/new and a look place into. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/cols.zig')
-rw-r--r--src/ninep/cols.zig25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig
index 682c2a02..79943b1b 100644
--- a/src/ninep/cols.zig
+++ b/src/ninep/cols.zig
@@ -27,7 +27,8 @@ pub fn activeColumn(p: *const Pardes) ?usize {
/// it, which stays while it lives), its index left to right, x and width in
/// cells, `current` or `notcurrent` (rio's words, for the column with the
/// keyboard), `empty` or `full`, and its panes' serials, top to bottom;
-/// then `active <serial>`.
+/// then `active <serial>`: the active column, where pane/new and a look
+/// place a pane next (acme's activecol), not always the keyboard's.
pub fn writeLayout(p: *Pardes, w: *std.Io.Writer) !void {
const active = activeColumn(p);
for (0..p.ncol) |c| {
@@ -38,7 +39,7 @@ pub fn writeLayout(p: *Pardes, w: *std.Io.Writer) !void {
for (p.col_panes[c][0..p.col_n[c]]) |id| if (p.panes[id]) |pane| try w.print(" {d}", .{pane.serial});
try w.writeByte('\n');
}
- if (active) |c| try w.print("active {d}\n", .{layout.columnSerial(p, c)}) else try w.writeAll("active -\n");
+ if (p.activeColumn() orelse active) |c| try w.print("active {d}\n", .{layout.columnSerial(p, c)}) else try w.writeAll("active -\n");
}
pub fn layoutLen(p: *Pardes) u64 {
@@ -179,3 +180,23 @@ test "a column's tag and the workspace's read, replace and append as a pane tag
_ = th.wr(p, top, "Newcol Exit\n");
try testing.expectEqualStrings("Newcol Exit", tagline.topbar(p));
}
+
+test "a focus write makes its pane's column the active one: layout says so and pane/new goes there" {
+ for ([_][]const u8{ "Placement acme", "Placement pardes" }) |placement| {
+ const p = try th.withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ try testing.expect(p.executeBuiltinLine(p.active, placement));
+ const left = p.panes[0].?.serial;
+ p.newColumn(p.active);
+ p.newScratchFor(p.active, .fs); // fills the new, right column
+ p.sync();
+ try testing.expectEqual(@as(usize, 1), layout.findPane(p, p.active).?.col);
+ var digits: [16]u8 = undefined;
+ _ = th.wr(p, @intFromEnum(tree.TopFile.focus), try std.fmt.bufPrint(&digits, "{d}\n", .{left}));
+ var want: [32]u8 = undefined;
+ const text = th.rd(p, @intFromEnum(tree.TopFile.layout), 0, 4096).bytes;
+ try testing.expect(std.mem.endsWith(u8, text, try std.fmt.bufPrint(&want, "active {d}\n", .{layout.columnSerial(p, 0)})));
+ const made = th.call(p, .{ .tag = 1, .op = .open, .node = @intFromEnum(tree.TopFile.new) }).reply.handle;
+ try testing.expectEqual(@as(usize, 0), layout.findPane(p, p.paneBySerial(made).?).?.col);
+ }
+}