diff options
| -rw-r--r-- | src/layout.zig | 4 | ||||
| -rw-r--r-- | test/behaviour/placement.zig | 23 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/layout.zig b/src/layout.zig index c7d7a189..f687cac7 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -847,6 +847,10 @@ fn splitAt(p: *Pardes, c: usize, id: usize, y: u16) void { pane.vweight = @floatFromInt(@max(1, (r.y + r.h) - row)); } +/// A pane's top plus its tag's rows, as heights go: a split this far down +/// leaves the pane its tag and that much of its body, whichever end the tag +/// is on (Tagbottom's is at its foot, the height the same; behaviour test +/// "placement: under Tagbottom..."). fn bodyTop(p: *const Pardes, id: usize) u16 { return p.rects[id].y + p.panes[id].?.tag_rows; } diff --git a/test/behaviour/placement.zig b/test/behaviour/placement.zig index 73d69883..f6823feb 100644 --- a/test/behaviour/placement.zig +++ b/test/behaviour/placement.zig @@ -108,6 +108,29 @@ test "placement: a look from a pane's text goes under its text when it has many try std.testing.expectEqual(was[big][0] + was[big][1], now[big + 1][0] + now[big + 1][1]); } +test "placement: under Tagbottom a look from a pane's text goes under its text too, every line of it still in sight above its tag" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "second.txt", .data = "second\n" }); + var dir: [4096]u8 = undefined; + const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)]; + var s = try Session.initFile(std.testing.allocator, "alpha\nbeta\ngamma\n"); + defer s.deinit(); + s.detach(); + try s.write("/ctl", "size 200 60\n"); + try s.write("/ctl", "Tagbottom on\n"); + const top = try s.focused(); + try s.write(s.at("/pane/{d}/look", .{top}), s.at("{s}/second.txt\n", .{at})); + // The first pane keeps its three lines with its tag under them, at its + // foot: the split leaves it its tag and its text whichever end the tag + // is on (makenewwindow, util.c:482-486). The new pane starts below. + const alpha = (try s.where("alpha"))[1]; + try std.testing.expectEqual(alpha + 1, (try s.where("beta"))[1]); + try std.testing.expectEqual(alpha + 2, (try s.where("gamma"))[1]); + try std.testing.expectEqual(alpha + 3, try tagRow(&s, "/test.txt")); + try std.testing.expectEqual(alpha + 4, (try s.where("second"))[1]); +} + test "placement: a look from the middle of a column splits only the pane it came from, short ones round it kept short, through a Newcol too" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); |
