summaryrefslogtreecommitdiff
path: root/test/behaviour/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 17:22:47 -0300
committerGabriel Schneider <[email protected]>2026-11-03 17:24:11 -0300
commit3632bbeaa75f912281d0c9d636feb153d04f668e (patch)
treedd3e91c78036b3c168c71b030047f42a9b55aa31 /test/behaviour/panes.zig
parent5cc02232d522d5cd5a453caedd1e592ca20471ea (diff)
downloadpardes-3632bbeaa75f912281d0c9d636feb153d04f668e.tar.gz
pardes-3632bbeaa75f912281d0c9d636feb153d04f668e.zip
test: five more of src/pardes.zig's tests through the 9P tree alone (test/behaviour/placement, panes, terminals, modes): an empty active column taking a look from another column's text whole, Collapse folding a pane to its tag (no text drawn, no cursor, its tag still typed into) and restoring it, a pane its whole text fits in never scrolled for a margin, Togglettymode and Ctrl-B sharing the mode's transitions from the body or the tag and a text pane refusing it, Esc back into a file keeping its view where a look's :N centres; Session's where (the first place /screen draws a text); each checked to fail against a break (acmeColumn ignoring the active column, toggleCollapse never unfolding, the scroll margin clamped at the last line alone, toggleTty leaving the tag the keyboard, Last landing centred)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/panes.zig')
-rw-r--r--test/behaviour/panes.zig49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig
index d0773bfb..149c8da1 100644
--- a/test/behaviour/panes.zig
+++ b/test/behaviour/panes.zig
@@ -112,3 +112,52 @@ test "panes: focus on a closed pane goes to the pane that takes its place, not t
try s.write(s.at("/col/{d}/ctl", .{try s.column(0)}), "Delcol\n");
try std.testing.expectEqual(right_low, try s.focused());
}
+
+test "panes: Collapse keeps the text and folds the pane to its tag, and again restores it" {
+ var s = try Session.initFile(std.testing.allocator, "keep this text\n");
+ defer s.deinit();
+ var t = try Session.initTerm(std.testing.allocator);
+ defer t.deinit();
+ const n = try s.focused();
+ for ([_][]const u8{
+ try s.read(s.at("/pane/{d}/tag", .{n})),
+ try s.read(s.at("/pane/{d}/tag", .{try s.newPane()})),
+ try t.read(t.at("/pane/{d}/tag", .{try t.focused()})),
+ }) |tag| try std.testing.expect(std.mem.endsWith(u8, tag, " Collapse Del"));
+ try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Del\n");
+ const ctl = s.at("/pane/{d}/ctl", .{n});
+ try s.write(ctl, "Collapse\n");
+ // Folded to its tag: no text drawn, no cursor in it, the text kept.
+ try std.testing.expect(std.mem.indexOf(u8, try s.read(ctl), " collapsed ") != null);
+ try std.testing.expect(std.mem.indexOf(u8, try s.screen(), "keep this text") == null);
+ try std.testing.expectEqual(null, try s.cursor());
+ try s.expect(s.at("/pane/{d}/body", .{n}), "keep this text\n");
+ try s.expect(s.at("/pane/{d}/dirty", .{n}), "0\n");
+ // Its tag still takes the keyboard, the cursor on the tag's row.
+ try s.keys(":");
+ try std.testing.expectEqual((try s.where("/test.txt"))[1], (try s.cursor()).?[1]);
+ try s.write(ctl, "Collapse\n");
+ try std.testing.expect(std.mem.indexOf(u8, try s.read(ctl), " collapsed ") == null);
+ try std.testing.expectEqual((try s.where("/test.txt"))[1] + 1, (try s.where("1 keep this text"))[1]);
+}
+
+test "panes: a pane its whole text fits in never scrolls to keep a margin" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "f.txt", .data = "f\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, "one\ntwo\nthree\n");
+ defer s.deinit();
+ const n = try s.focused();
+ // A second pane under it, as acme's placement puts one: right under the
+ // three lines, which leaves the file exactly three body rows.
+ try s.write(s.at("/pane/{d}/look", .{n}), s.at("{s}/f.txt\n", .{at}));
+ try s.write("/focus", s.at("{d}\n", .{n}));
+ try s.keys("jj");
+ const top = (try s.where("/test.txt"))[1];
+ try std.testing.expectEqual(top + 4, (try s.where(at[0..@min(at.len, 20)]))[1]);
+ // On the last line, and line 1 still the first drawn.
+ try std.testing.expectEqual(.{ @as(u32, 8), @as(u32, 8) }, try s.range(s.at("/pane/{d}/dot", .{n})));
+ try std.testing.expectEqual(top + 1, (try s.where("1 one"))[1]);
+}