diff options
Diffstat (limited to 'src/ninep/cols.zig')
| -rw-r--r-- | src/ninep/cols.zig | 25 |
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); + } +} |
