diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 19:53:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 22:03:21 -0300 |
| commit | 12cb0a704075dea2512f77582635376fe967dee6 (patch) | |
| tree | 0f498bf581e3f8ece31f8a5eaa06accba7aa7415 /src/ninep | |
| parent | 1a1ce29051ea6aa3be4754074f6a00b905d6b208 (diff) | |
| download | pardes-12cb0a704075dea2512f77582635376fe967dee6.tar.gz pardes-12cb0a704075dea2512f77582635376fe967dee6.zip | |
split pardes.zig by noun, layout: the session's columns and the rows its chrome takes move into src/layout.zig: newColumn, setActiveColumn, activeColumn, noteTyped, newScratchIn, keyboardColumn, removeColumn, besideColumn, topBarHeight, columnBarHeight, wantedTagRows, bodyTop, tagTop, tagCapacity and reprojectTagHit; the session keeps four as declaration aliases (topBarHeight and bodyTop, called from everywhere; tagTop and setActiveColumn, which Store.zig and Handover.zig call, so the persistence agent's files are untouched), the rest are layout.x(p, ...) in their callers (draw.zig, mouse.zig, ninep/cols.zig, tagline.zig and seven more; gui.zig, whose locals are named layout, through pardes.layout); layout's own placement helper bodyTop, a pane's top past its tag as heights go, is bodyFrom now, the name going to the session's; tests moved with them, by name: a new column takes width only from the column that created it; Newcol refuses an unsplittable restored weight before spawning; repeated non-dyadic column splits preserve every unrelated boundary; dragging a column's only pane to another leaves that column in place, empty; tiny screens keep pane space before adding a column tag; a pure move, no field touched, a dump and the wire as they were; gates: tui core-test 960/960, behaviour-test 238/238, pane-test 171/172 (1 skipped), snap all 108 scripts ok, gui unit-test 1518/1519 (1 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/cols.zig | 18 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig index f53bb433..60071bd0 100644 --- a/src/ninep/cols.zig +++ b/src/ninep/cols.zig @@ -41,7 +41,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 (p.activeColumn() orelse active) |c| try w.print("active {d}\n", .{layout.columnSerial(p, c)}) else try w.writeAll("active -\n"); + if (layout.activeColumn(p) orelse active) |c| try w.print("active {d}\n", .{layout.columnSerial(p, c)}) else try w.writeAll("active -\n"); } /// A header by its node: the workspace's (`serial` null) or the column's @@ -496,7 +496,7 @@ 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.col_n[col] > 0) return tree.failText(req.tag, E.NOTEMPTY, "column not empty: close its panes, or write Delcol to its ctl"); - p.removeColumn(col) catch return Reply.fail(req.tag, E.IO); + layout.removeColumn(p, col) catch return Reply.fail(req.tag, E.IO); return .{ .tag = req.tag }; } @@ -509,7 +509,7 @@ 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(); - p.newColumn(p.active); + layout.newColumn(p, p.active); p.sync(); const first_serial = layout.columnSerial(p, 0); const new_serial = layout.columnSerial(p, 1); @@ -528,7 +528,7 @@ test "layout lists each column's place, panes and state, and the active one" { try testing.expect(std.mem.endsWith(u8, th.rd(p, @backingInt(tree.TopFile.index), 0, 4096).bytes, try std.fmt.bufPrint(&want, " {d}\n", .{first_serial}))); try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "newcol {d}\n", .{new_serial}))); // A column that closes takes its name with it; the others keep theirs. - try p.removeColumn(1); + try layout.removeColumn(p, 1); try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "delcol {d}\n", .{new_serial}))); try testing.expectEqual(E.NOENT, th.look_up(p, @backingInt(tree.TopFile.col), try std.fmt.bufPrint(&want, "{d}", .{new_serial})).errno()); try testing.expectEqual(first_serial, layout.columnSerial(p, 0)); @@ -564,7 +564,7 @@ test "a focus write makes its pane's column the active one: layout says so and p const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); const left = p.panes[0].?.serial; - p.newColumn(p.active); + layout.newColumn(p, p.active); panes.newScratchFor(p, p.active, .fs); // fills the new, right column p.sync(); try testing.expectEqual(@as(usize, 1), layout.findPane(p, p.active).?.col); @@ -613,7 +613,7 @@ test "a column's ctl and exec act on it as its tag would, and rmdir closes it on const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); const first = layout.columnSerial(p, 0); - p.newColumn(p.active); + layout.newColumn(p, p.active); const empty = layout.columnSerial(p, 1); // New on the empty column's ctl fills it, wherever the keyboard is. try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(empty, .ctl), "New\n").reply.status); @@ -630,14 +630,14 @@ test "a column's ctl and exec act on it as its tag would, and rmdir closes it on try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(empty, .exec), "Delcol\n").reply.status); try testing.expectEqual(@as(?usize, null), layout.columnBySerial(p, empty)); // An empty column goes on rmdir. - p.newColumn(p.active); + layout.newColumn(p, p.active); const made = layout.columnSerial(p, 1); try testing.expectEqual(tree.Status.ok, th.call(p, .{ .tag = 2, .op = .release, .node = Node.ofCol(made, .dir), .remove = true }).reply.status); try testing.expectEqual(@as(?usize, null), layout.columnBySerial(p, made)); try testing.expectEqual(first, layout.columnSerial(p, 0)); // Joincol folds a column into the one on its right, which keeps its own // serial and tag. - p.newColumn(p.active); + layout.newColumn(p, p.active); const right = layout.columnSerial(p, 1); _ = th.wr(p, Node.ofCol(right, .tag), " Mine"); try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(first, .ctl), "Joincol\n").reply.status); @@ -690,7 +690,7 @@ test "a word run from the workspace's or a column's tag runs in the session's di test "a command run from a column's tag gets its pane in that column, not the last" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - p.newColumn(p.active); + layout.newColumn(p, p.active); panes.newScratchFor(p, p.active, .fs); // fills the new, right column p.sync(); const left = layout.columnSerial(p, 0); diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 2d733af6..2151126d 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2385,7 +2385,7 @@ test "a column takes panes until their documented minimums fill it, not until no const new = @backingInt(tree.TopFile.new); while (call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status == .ok) p.sync(); p.sync(); - const avail = p.screen_h - (p.topBarHeight() + p.columnBarHeight()); + const avail = p.screen_h - (p.topBarHeight() + layout.columnBarHeight(p)); for (0..p.ncol) |c| { var need: u32 = 0; for (p.col_panes[c][0..p.col_n[c]]) |k| need += layout.minRows(p, k); |
