diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 20:39:55 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 22:07:27 -0300 |
| commit | 50914b0e04ac0129b11bff0f0007d5cedbfc7f8d (patch) | |
| tree | fdb18c730b1b5908c8e4048dec6606ca730890c2 /src/ninep | |
| parent | ce4ac94f7887025afabad92402e5f04a276da9a4 (diff) | |
| download | pardes-50914b0e04ac0129b11bff0f0007d5cedbfc7f8d.tar.gz pardes-50914b0e04ac0129b11bff0f0007d5cedbfc7f8d.zip | |
fields #37, a column is one Column: the four parallel arrays a column's own state was kept in (col_panes, col_n, col_weight, col_serial) are the session's cols: [MAX_COLS]Column, a struct of panes, n, weight and serial (acme's Column, cols.c), so a column shifted, saved or reset is one assignment where it was four (layout.reorderColumn, dropColumn, insertColumn, firstColumn, joinFits, Finder.open; joinFits and the resets now give back a column's panes beyond its count too, which nothing reads); its tag stays the session's col_tags, as a view opened takes the live one's columns but tags of its own (views.open), and col_x and col_w stay with the rects, worked out each sync; the uses in 20 files read p.cols[c].n for p.col_n[c] and so on, tests that compared the arrays whole compare the columns whole (or their weights, layout.zig's weightsOf); views.zig's per-view fields name cols; a dump written before this change loads its columns as the default once: an Upgrade or Restore from it comes back with its columns empty and its panes in none of them, and the wire's semantics change (the digest walks cols); dump.zig and Handover.zig, the persistence agent's, are edited only where they name these fields; gates on 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 | 22 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 6 | ||||
| -rw-r--r-- | src/ninep/tree.zig | 8 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig index 60071bd0..3a7f0dbb 100644 --- a/src/ninep/cols.zig +++ b/src/ninep/cols.zig @@ -36,9 +36,9 @@ pub fn writeLayout(p: *Pardes, w: *std.Io.Writer) !void { for (0..p.ncol) |c| { try w.print("{d} {d} {d} {d} {s} {s}", .{ layout.columnSerial(p, c), c, p.col_x[c], p.col_w[c], - if (active == c) "current" else "notcurrent", if (p.col_n[c] == 0) "empty" else "full", + if (active == c) "current" else "notcurrent", if (p.cols[c].n == 0) "empty" else "full", }); - for (p.col_panes[c][0..p.col_n[c]]) |id| if (p.panes[id]) |pane| try w.print(" {d}", .{pane.serial}); + for (p.cols[c].panes[0..p.cols[c].n]) |id| if (p.panes[id]) |pane| try w.print(" {d}", .{pane.serial}); try w.writeByte('\n'); } if (layout.activeColumn(p) orelse active) |c| try w.print("active {d}\n", .{layout.columnSerial(p, c)}) else try w.writeAll("active -\n"); @@ -238,9 +238,9 @@ test "Joincol is refused when the joined column cannot give each pane its tag an _ = th.wr(p, focus, try std.fmt.bufPrint(&digits, "{d}\n", .{b})); _ = try th.newPane(p); try testing.expectEqual(@as(usize, 2), p.ncol); - try testing.expect(p.col_n[0] >= 2 and p.col_n[1] >= 2); + try testing.expect(p.cols[0].n >= 2 and p.cols[1].n >= 2); // Focus in the left column: joined, four panes want 12 rows of 10. - const left = p.panes[p.col_panes[0][0]].?.serial; + const left = p.panes[p.cols[0].panes[0]].?.serial; _ = th.wr(p, focus, try std.fmt.bufPrint(&digits, "{d}\n", .{left})); const r = th.wr(p, ctl, "Joincol\n"); try testing.expectEqual(tree.Status.err, r.reply.status); @@ -311,12 +311,12 @@ test "a Newcol refused because the tags would not fit logs its err alone and spe const made = try th.newPane(p); const pane = p.panes[p.paneBySerial(made).?].?; const col = layout.findPane(p, p.paneBySerial(made).?).?.col; - for (p.col_panes[col][0..p.col_n[col]]) |k| { + for (p.cols[col].panes[0..p.cols[col].n]) |k| { const each = p.panes[k].?; if (each.tag.own) |old| p.gpa.free(old); each.tag.own = try p.gpa.dupe(u8, std.mem.asBytes(&@as([60][5]u8, @splat("word ".*)))); } - try testing.expect(p.col_n[col] >= 2); + try testing.expect(p.cols[col].n >= 2); p.sync(); const ctl = @backingInt(tree.TopFile.ctl); const focus = @backingInt(tree.TopFile.focus); @@ -450,7 +450,7 @@ test "New and Term run at /tagexec and a column's exec, with no pane at all too" // Every pane gone: the workspace tag makes one all the same. for ([_][]const u8{ "New\n", "Term\n" }) |line| { while (p.ncol > 0) { - const first = p.panes[p.col_panes[0][0]].?.serial; + const first = p.panes[p.cols[0].panes[0]].?.serial; _ = th.wr(p, tree.Node.of(first, .ctl), "delete\n"); if (panes.anyPane(p) == null) break; } @@ -495,7 +495,7 @@ test "every pane word a tag no pane owns does not hold is refused there, Edit in 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"); + if (p.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 }; } @@ -617,7 +617,7 @@ test "a column's ctl and exec act on it as its tag would, and rmdir closes it on 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); - try testing.expectEqual(@as(usize, 1), p.col_n[1]); + try testing.expectEqual(@as(usize, 1), p.cols[1].n); try testing.expectEqual(E.INVAL, th.wr(p, Node.ofCol(empty, .ctl), "Exit\n").errno()); var rec: [64]u8 = undefined; try testing.expect(th.logHas(p, try std.fmt.bufPrint(&rec, "err - col/{d}/ctl: unknown control message \"Exit\"", .{empty}))); @@ -662,7 +662,7 @@ test "tagexec runs a word as a click in the workspace tag; exec files read back // A column's exec makes a pane there and reads it back. const right = layout.columnSerial(p, 1); try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(right, .exec), "New\n").reply.status); - const made = p.panes[p.col_panes[1][0]].?.serial; + const made = p.panes[p.cols[1].panes[0]].?.serial; var want: [16]u8 = undefined; try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{made}), th.rd(p, Node.ofCol(right, .exec), 0, 64).bytes); try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{made}), th.rd(p, tagexec, 0, 64).bytes); @@ -716,7 +716,7 @@ test "a column's ctl refuses an unknown word and an argument as the other ctls d const extra = th.wr(p, ctl_node, "New extra\n"); try testing.expectEqual(E.INVAL, extra.errno()); try testing.expect(std.mem.startsWith(u8, extra.reply.ename, "wrong #args")); - try testing.expectEqual(@as(usize, 1), p.col_n[0]); + try testing.expectEqual(@as(usize, 1), p.cols[0].n); // A pane's bare answer and a winsize of no size say what they take. try testing.expectEqualStrings("answer takes a choice or -", th.wr(p, Node.of(p.panes[0].?.serial, .ctl), "answer\n").reply.ename); } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 2151126d..dc95e0ec 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2388,11 +2388,11 @@ test "a column takes panes until their documented minimums fill it, not until no 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); + for (p.cols[c].panes[0..p.cols[c].n]) |k| need += layout.minRows(p, k); // Refused only when one more pane's tag and two rows would not fit. - if (p.col_n[c] > 1) try testing.expect(avail - need < 3); + if (p.cols[c].n > 1) try testing.expect(avail - need < 3); // Every pane keeps its minimum. - for (p.col_panes[c][0..p.col_n[c]]) |k| try testing.expect(p.rects[k].h >= layout.minRows(p, k)); + for (p.cols[c].panes[0..p.cols[c].n]) |k| try testing.expect(p.rects[k].h >= layout.minRows(p, k)); } } diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 8c0743bd..08db0d75 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1832,7 +1832,7 @@ test "random placements, refused or not, leave no pane under its tag and two row } for (0..p.ncol) |c| if (!layout.columnAtMinimums(p, c)) { std.debug.print("seed {d} rows {d} step {d} action {d}: column {d} under its minimums\n", .{ seed, rows, step, action, c }); - for (p.col_panes[c][0..p.col_n[c]]) |id| std.debug.print(" pane {d} h {d} min {d}\n", .{ id, p.rects[id].h, layout.minRows(p, id) }); + for (p.cols[c].panes[0..p.cols[c].n]) |id| std.debug.print(" pane {d} h {d} min {d}\n", .{ id, p.rects[id].h, layout.minRows(p, id) }); return error.TestUnexpectedResult; }; } @@ -2052,8 +2052,8 @@ test "no placement leaves a pane shorter than its tag and two rows; a full colum var count: usize = 0; for (p.panes) |slot| count += @intFromBool(slot != null); try testing.expectEqual(made, count); // the refused one is gone - for (0..p.ncol) |c| for (p.col_panes[c][0..p.col_n[c]]) |k| { - if (p.col_n[c] > 1 and !p.panes[k].?.collapsed) + for (0..p.ncol) |c| for (p.cols[c].panes[0..p.cols[c].n]) |k| { + if (p.cols[c].n > 1 and !p.panes[k].?.collapsed) try testing.expect(p.rects[k].h >= p.panes[k].?.tag_rows + pardes.layout.min_body_rows); }; } @@ -2102,6 +2102,6 @@ test "a pane made from pane/new goes last in its column, even when the last pane for (0..3) |_| { const made = call(p, .{ .tag = 1, .op = .open, .node = @backingInt(TopFile.new) }).reply.handle; p.sync(); - try testing.expectEqual(made, p.panes[p.col_panes[0][p.col_n[0] - 1]].?.serial); + try testing.expectEqual(made, p.panes[p.cols[0].panes[p.cols[0].n - 1]].?.serial); } } |
