summaryrefslogtreecommitdiff
path: root/src/ninep/cols.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 00:52:52 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit5157579ff7f9ae0cfc3c7629e953da05bce340fc (patch)
tree02147789efdcea998981efcfe05d4bcb3e9bb7b0 /src/ninep/cols.zig
parent4c4b9bf54d77dbc0f9f4e2619746908e501c6001 (diff)
downloadpardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.tar.gz
pardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.zip
tests: at the end of their files: every top-level test block of the 46 files that had one mid-file (the locality analysis's 45 and test/hxdiff.zig; gui.zig, macos.zig, look, host_io, 9p_io, terminal, tui, mouse, fs, replica, layout among them, 11,429 test lines), with the functions only tests call, moved after the file's code in their order, a mechanical move (.scratch/suites/tests_to_end.py), zig fmt'd; the unit suites pass as before (tui 1486/1487, gui 1536/1537, core 956/956 on both), macos.zig only parse-checked here
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep/cols.zig')
-rw-r--r--src/ninep/cols.zig66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig
index 7eb08ba9..5218b937 100644
--- a/src/ninep/cols.zig
+++ b/src/ninep/cols.zig
@@ -36,7 +36,7 @@ pub fn writeLayout(p: *Pardes, w: *std.Io.Writer) std.Io.Writer.Error!void {
const active = activeColumn(p);
for (0..p.view().ncol) |c| {
try w.print("{d} {d} {d} {d} {s} {s}", .{
- layout.columnSerial(p, c), c, v.col_x[c], v.col_w[c],
+ layout.columnSerial(p, c), c, v.col_x[c], v.col_w[c],
if (active == c) "current" else "notcurrent", if (v.cols[c].n == 0) "empty" else "full",
});
for (v.cols[c].panes[0..p.view().cols[c].n]) |id| if (p.panes[id]) |pane| try w.print(" {d}", .{pane.serial});
@@ -212,6 +212,38 @@ pub fn writeExec(p: *Pardes, req: Req, serial: ?u32) Reply {
return .{ .tag = req.tag, .written = @intCast(req.data.len) };
}
+/// Whether `line` names a builtin that acts on a pane (every one of pane
+/// scope, Edit too, which the root's ctl takes at the active pane) and is
+/// not one of `own`, the words its tag holds by default: those a tag no
+/// pane owns refuses, never doing them at the pane with the keyboard.
+fn paneWord(line: []const u8, own: []const u8) bool {
+ const cmd = pardes.exec.commandText(line);
+ const word = cmd[0 .. std.mem.indexOfAny(u8, cmd, " \t+") orelse cmd.len];
+ const b = std.meta.stringToEnum(pardes.builtins.registry.Builtin(), word) orelse return false;
+ if (pardes.builtins.registry.scope(b) == .session) return false;
+ // A new pane is every tag's to make, in the session's directory.
+ if (b == .New or b == .Term) return false;
+ var words = std.mem.tokenizeScalar(u8, own, ' ');
+ while (words.next()) |w| if (std.mem.eql(u8, w, word)) return false;
+ return true;
+}
+
+/// rmdir of a column closes it when it is empty; one with panes is
+/// refused, saying so (close them, or Delcol on its ctl, which asks first).
+pub fn remove(p: *Pardes, req: Req, serial: u32, file: tree.ColFile) Reply {
+ if (file != .dir) return Reply.fail(req.tag, E.PERM);
+ const col = layout.columnBySerial(p, serial) orelse return Reply.fail(req.tag, E.NOENT);
+ if (p.view().cols[col].n > 0) return tree.failText(req.tag, E.NOTEMPTY, "column not empty: close its panes, or write Delcol to its ctl");
+ layout.removeColumn(p, col) catch return Reply.fail(req.tag, E.IO);
+ return .{ .tag = req.tag };
+}
+
+// ---- tests ----
+
+const testing = std.testing;
+const th = @import("testing.zig");
+const Node = tree.Node;
+
test "New written to a column's exec makes its scratch in the session's directory, as tagexec's does" {
const p = try th.withFile(testing.allocator, "x\n");
defer p.deinit();
@@ -369,22 +401,6 @@ test "New written to a column's ctl reads back the new pane alone, as its exec d
try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{p.panes[p.view().active].?.serial}), th.rd(p, root_exec, 0, 64).bytes);
}
-/// Whether `line` names a builtin that acts on a pane (every one of pane
-/// scope, Edit too, which the root's ctl takes at the active pane) and is
-/// not one of `own`, the words its tag holds by default: those a tag no
-/// pane owns refuses, never doing them at the pane with the keyboard.
-fn paneWord(line: []const u8, own: []const u8) bool {
- const cmd = pardes.exec.commandText(line);
- const word = cmd[0 .. std.mem.indexOfAny(u8, cmd, " \t+") orelse cmd.len];
- const b = std.meta.stringToEnum(pardes.builtins.registry.Builtin(), word) orelse return false;
- if (pardes.builtins.registry.scope(b) == .session) return false;
- // A new pane is every tag's to make, in the session's directory.
- if (b == .New or b == .Term) return false;
- var words = std.mem.tokenizeScalar(u8, own, ' ');
- while (words.next()) |w| if (std.mem.eql(u8, w, word)) return false;
- return true;
-}
-
test "a pane's word written to /tagexec or a column's exec is refused, and acts on no pane" {
const p = try th.withFile(testing.allocator, "x\n");
defer p.deinit();
@@ -491,22 +507,6 @@ test "every pane word a tag no pane owns does not hold is refused there, Edit in
try testing.expectEqualStrings("keep me\n", p.panes[0].?.file.?.content);
}
-/// rmdir of a column closes it when it is empty; one with panes is
-/// refused, saying so (close them, or Delcol on its ctl, which asks first).
-pub fn remove(p: *Pardes, req: Req, serial: u32, file: tree.ColFile) Reply {
- if (file != .dir) return Reply.fail(req.tag, E.PERM);
- const col = layout.columnBySerial(p, serial) orelse return Reply.fail(req.tag, E.NOENT);
- if (p.view().cols[col].n > 0) return tree.failText(req.tag, E.NOTEMPTY, "column not empty: close its panes, or write Delcol to its ctl");
- layout.removeColumn(p, col) catch return Reply.fail(req.tag, E.IO);
- return .{ .tag = req.tag };
-}
-
-// ---- tests ----
-
-const testing = std.testing;
-const th = @import("testing.zig");
-const Node = tree.Node;
-
test "layout lists each column's place, panes and state, and the active one" {
const p = try th.withFile(testing.allocator, "x\n");
defer p.deinit();