From 50914b0e04ac0129b11bff0f0007d5cedbfc7f8d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 20:39:55 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/Finder.zig | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/Finder.zig') diff --git a/src/Finder.zig b/src/Finder.zig index 3744e5d1..1e8fa022 100644 --- a/src/Finder.zig +++ b/src/Finder.zig @@ -58,8 +58,8 @@ pub fn place(f: *Finder, p: *Pardes, id: usize) bool { fold(p, c, id); // The oldest goes once there are too many: the bottom one, as the top // is always the newest. - while (p.col_n[c] > max_results) { - const oldest = p.col_panes[c][p.col_n[c] - 1]; + while (p.cols[c].n > max_results) { + const oldest = p.cols[c].panes[p.cols[c].n - 1]; p.removePane(oldest, null) catch break; } return true; @@ -75,13 +75,11 @@ fn open(f: *Finder, p: *Pardes) ?usize { const before_min = layout.minima(p); const before = p.rects; const c = p.ncol; - p.col_n[c] = 0; - // Not used for its width (layout.compute), only kept positive for the - // code that halves and joins weights. - p.col_weight[c] = layout.column_weight_unit; + // Its weight, the default, is not used for its width (layout.compute), + // only kept positive for the code that halves and joins weights. + p.cols[c] = .{}; p.col_tags[c] = .{ .what = .column, .gpa = p.gpa }; p.col_tags[c].own = p.gpa.dupe(u8, tag_text) catch null; - p.col_serial[c] = 0; p.ncol += 1; f.serial = layout.columnSerial(p, c); // Where nothing holds every minimum there is no finder, as Newcol is @@ -99,7 +97,7 @@ fn open(f: *Finder, p: *Pardes) ?usize { /// to it, its +Preview) to its tag. fn fold(p: *Pardes, c: usize, top: usize) void { layout.compute(p); - for (p.col_panes[c][0..p.col_n[c]]) |k| { + for (p.cols[c].panes[0..p.cols[c].n]) |k| { const pane = p.panes[k] orelse continue; if (k == top or layout.groupRoot(p, k) == top) { pane.collapsed = false; @@ -124,7 +122,7 @@ pub fn raise(f: *Finder, p: *Pardes, id: usize) void { const end = layout.groupEnd(p, c, at.idx); var moved: [pardes.MAX_PANES]usize = undefined; const n = end - at.idx; - @memcpy(moved[0..n], p.col_panes[c][at.idx..end]); + @memcpy(moved[0..n], p.cols[c].panes[at.idx..end]); for (moved[0..n]) |k| layout.removePane(p, k); for (moved[0..n], 0..) |k, i| layout.insert(p, c, i, k); } @@ -154,7 +152,7 @@ pub fn away(f: *Finder, p: *Pardes, from: usize, kind: pardes.exec.NewPane) ?usi /// The finder column has lost its last pane: it goes, and every other /// column is as wide as before it came. pub fn emptied(f: *Finder, p: *Pardes, c: usize) bool { - if (f.column(p) != c or p.col_n[c] != 0) return false; + if (f.column(p) != c or p.cols[c].n != 0) return false; layout.dropColumn(p, c); f.serial = 0; return true; @@ -173,13 +171,13 @@ pub fn dragWidth(f: *Finder, p: *Pardes, other: usize, finder_w: u64) void { var rest_weight: u128 = 0; var rest_cells: u64 = 0; for (0..p.ncol) |k| if (k != fc and k != other) { - rest_weight += p.col_weight[k]; + rest_weight += p.cols[k].weight; rest_cells += p.col_w[k]; }; if (rest_cells > 0) { const other_cells = combined - fw; const w = @as(u128, other_cells) * rest_weight / rest_cells; - p.col_weight[other] = @intCast(std.math.clamp(w, 1, layout.max_column_weight)); + p.cols[other].weight = @intCast(std.math.clamp(w, 1, layout.max_column_weight)); } layout.compute(p); } @@ -203,7 +201,7 @@ test "SearchPlace column: query panes stack in a finder column at the right edge typeKeys(p, "/"); const fc = p.finder.column(p).?; try std.testing.expectEqual(@as(usize, 1), fc); - const first = p.col_panes[fc][0]; + const first = p.cols[fc].panes[0]; try std.testing.expect(p.panes[first].?.query != null); // the first search narrows the column once; its panes keep their rows try std.testing.expect(p.col_w[0] < width_before); @@ -218,7 +216,7 @@ test "SearchPlace column: query panes stack in a finder column at the right edge // a second search, from the other pane: on top, the first folded p.active = other; typeKeys(p, "/"); - const second = p.col_panes[fc][0]; + const second = p.cols[fc].panes[0]; try std.testing.expect(second != first); try std.testing.expect(p.panes[first].?.collapsed); layout.compute(p); -- cgit v1.3