summaryrefslogtreecommitdiff
path: root/test/session.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 17:00:11 -0300
committerGabriel Schneider <[email protected]>2026-11-03 17:04:18 -0300
commit37408da299e21b8807ccd10545482a709bac88c7 (patch)
treeff29465e50538df66a712d9aeabf156c9185a1b1 /test/session.zig
parentd1273bbd99daf9b1855d82bf315db8ede20abde5 (diff)
downloadpardes-37408da299e21b8807ccd10545482a709bac88c7.tar.gz
pardes-37408da299e21b8807ccd10545482a709bac88c7.zip
test: eight of src/pardes.zig's tests through the 9P tree alone (test/behaviour/columns_and_tags, look_and_exec): Joincol folding a column into its right neighbour and refused with none, Newcol's empty column with its tag focused filled by the next Tty, a column's exec acting on that column and a pane's Delcol on its own, a column's last pane closed leaving it empty and Delcol taking it, a column's tag following it through Newcol and Joincol, Delcol on the last column leaving the window typed into, New in no pane's tag nor the workspace's, a look that finds nothing in the log; Session's columns and column (/layout as column:panes); each checked to fail against a break (joinCol inert, joinCol keeping the left tag, acmeColumn ignoring the active column, a scratch ignoring exec_column, no enterHeader for an emptied column, removeColumn refusing the last, New in a file pane's tail, missed logging nothing)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/session.zig')
-rw-r--r--test/session.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/session.zig b/test/session.zig
index 8b3c5c41..c4ed0db2 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -182,6 +182,34 @@ pub const Session = struct {
fn pardesOf(s: *Session) *Pardes {
return @ptrCast(@alignCast(s.core));
}
+
+ // core:
+
+ /// /layout as its columns, left to right, `column:pane,pane` each and
+ /// a blank between (`1:2,5 3:`, column 3 empty).
+ pub fn columns(s: *Session) ![]const u8 {
+ const a = s.arena.allocator();
+ var out: std.ArrayList(u8) = .empty;
+ var lines = std.mem.tokenizeScalar(u8, try s.read("/layout"), '\n');
+ while (lines.next()) |line| {
+ if (std.mem.startsWith(u8, line, "active ")) continue;
+ var words = std.mem.tokenizeScalar(u8, line, ' ');
+ if (out.items.len > 0) try out.append(a, ' ');
+ try out.print(a, "{s}:", .{words.next().?});
+ for (0..5) |_| _ = words.next(); // index x width current empty|full
+ var sep: []const u8 = "";
+ while (words.next()) |pane| : (sep = ",") try out.print(a, "{s}{s}", .{ sep, pane });
+ }
+ return out.items;
+ }
+
+ /// The serial of the `i`th column from the left.
+ pub fn column(s: *Session, i: usize) !u32 {
+ var cols = std.mem.tokenizeScalar(u8, try s.columns(), ' ');
+ for (0..i) |_| _ = cols.next();
+ const col = cols.next() orelse return error.NoColumn;
+ return std.fmt.parseInt(u32, col[0..std.mem.indexOfScalar(u8, col, ':').?], 10);
+ }
};
fn refusal(path: []const u8, r: Reply) error{Refused} {