summaryrefslogtreecommitdiff
path: root/src/Handover.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 20:39:55 -0300
committerGabriel Schneider <[email protected]>2026-11-05 22:07:27 -0300
commit50914b0e04ac0129b11bff0f0007d5cedbfc7f8d (patch)
treefdb18c730b1b5908c8e4048dec6606ca730890c2 /src/Handover.zig
parentce4ac94f7887025afabad92402e5f04a276da9a4 (diff)
downloadpardes-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/Handover.zig')
-rw-r--r--src/Handover.zig40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/Handover.zig b/src/Handover.zig
index 2233d228..2d47bb4e 100644
--- a/src/Handover.zig
+++ b/src/Handover.zig
@@ -94,14 +94,14 @@ pub fn begin(h: *Handover, p: *Pardes, carried: Kind, at: usize) void {
.pane => {
const f = layout.findPane(p, at) orelse return;
const end = if (layout.ownerOf(p, at) == null) layout.groupEnd(p, f.col, f.idx) else f.idx + 1;
- for (p.col_panes[f.col][f.idx..end]) |id| {
+ for (p.cols[f.col].panes[f.idx..end]) |id| {
ids[n] = id;
n += 1;
}
},
.column => {
- if (at >= p.ncol or p.col_n[at] == 0) return;
- for (p.col_panes[at][0..p.col_n[at]]) |id| {
+ if (at >= p.ncol or p.cols[at].n == 0) return;
+ for (p.cols[at].panes[0..p.cols[at].n]) |id| {
ids[n] = id;
n += 1;
}
@@ -172,7 +172,7 @@ pub fn finish(h: *Handover, p: *Pardes, seq: u32, to: []const u8, failure: ?[]co
};
}
if (h.carried == .column) if (layout.columnBySerial(p, h.column_serial)) |c| {
- if (p.col_n[c] == 0 and p.ncol > 1) layout.dropColumn(p, c);
+ if (p.cols[c].n == 0 and p.ncol > 1) layout.dropColumn(p, c);
};
layout.compute(p);
p.setMessage(p.active, if (kept == 0)
@@ -293,18 +293,18 @@ pub fn adopt(p: *Pardes, bytes: []const u8) !usize {
p.sync();
return slots[0];
}
- for (0..p.ncol) |c| for (p.col_panes[c][0..p.col_n[c]]) |id| {
+ for (0..p.ncol) |c| for (p.cols[c].panes[0..p.cols[c].n]) |id| {
heights[id] = p.rects[id].h;
};
// The group under the pointer (a pane with what is attached to it): the
// new panes go under all of it, out of its owner's rows.
- var after: usize = p.col_n[tc];
+ var after: usize = p.cols[tc].n;
var root: ?usize = null;
var k: usize = 0;
- while (k < p.col_n[tc]) {
+ while (k < p.cols[tc].n) {
const end = layout.groupEnd(p, tc, k);
- const first = p.col_panes[tc][k];
- const last = p.col_panes[tc][end - 1];
+ const first = p.cols[tc].panes[k];
+ const last = p.cols[tc].panes[end - 1];
root = first;
after = end;
if (y < p.rects[last].y + p.rects[last].h) break;
@@ -520,8 +520,8 @@ test "a grip let go past the window's edge dumps its pane alone, and closes it o
const p = try twoPanes(std.testing.allocator);
defer p.deinit();
const f = layout.findPane(p, 0).?;
- try std.testing.expect(p.col_n[f.col] == 2);
- const other = p.col_panes[f.col][1 - f.idx];
+ try std.testing.expect(p.cols[f.col].n == 2);
+ const other = p.cols[f.col].panes[1 - f.idx];
const before = p.rects[other];
releaseOutside(p, 0);
// Dumped and asked for; nothing moved yet.
@@ -552,7 +552,7 @@ test "a grip let go past the window's edge dumps its pane alone, and closes it o
// (Store.zig): Panes does not offer it back here.
try std.testing.expect(p.store.closedBySerial(serial) == null);
p.sync();
- try std.testing.expectEqual(@as(usize, 1), p.col_n[layout.findPane(p, other).?.col]);
+ try std.testing.expectEqual(@as(usize, 1), p.cols[layout.findPane(p, other).?.col].n);
}
test "a pane edited while it is on its way to another window stays here too" {
@@ -569,7 +569,7 @@ test "a terminal's grip let go past the edge stays: its shell is this window's"
const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30, .shells = 3 });
defer p.deinit();
p.update(.{ .resize = .{ .cols = 100, .rows = 30 } });
- const id = p.col_panes[1][0];
+ const id = p.cols[1].panes[0];
try std.testing.expect(p.panes[id].?.isTerminal());
releaseOutside(p, id);
try std.testing.expect(!p.handover.flying);
@@ -587,8 +587,8 @@ test "a pane let go over another window goes under the pane the pointer is over,
to.sync();
const before = to.rects;
const c = layout.findPane(to, 0).?.col;
- const upper = to.col_panes[c][0];
- const lower = to.col_panes[c][1];
+ const upper = to.cols[c].panes[0];
+ const lower = to.cols[c].panes[1];
// The pointer over the upper pane, six rows into it.
to.pointer_inside = true;
to.hover_col = to.rects[upper].x + 5;
@@ -598,9 +598,9 @@ test "a pane let go over another window goes under the pane the pointer is over,
const pane = to.panes[id].?;
try std.testing.expectEqualStrings("unsaved alpha\nbeta\n", pane.file.?.content);
try std.testing.expect(tagline.dirty(pane));
- try std.testing.expectEqual(upper, to.col_panes[c][0]);
- try std.testing.expectEqual(id, to.col_panes[c][1]);
- try std.testing.expectEqual(lower, to.col_panes[c][2]);
+ try std.testing.expectEqual(upper, to.cols[c].panes[0]);
+ try std.testing.expectEqual(id, to.cols[c].panes[1]);
+ try std.testing.expectEqual(lower, to.cols[c].panes[2]);
// The pane under the pointer keeps its top and gives its rows below
// the pointer; the new one is just there; every other pane is where it was.
try std.testing.expectEqual(before[upper].y, to.rects[upper].y);
@@ -639,12 +639,12 @@ test "a column let go over another window goes beside the column the pointer is
to.sync();
try std.testing.expectEqual(ncol + 1, to.ncol);
try std.testing.expectEqual(ncol, layout.findPane(to, id).?.col);
- try std.testing.expectEqual(@as(usize, 2), to.col_n[ncol]);
+ try std.testing.expectEqual(@as(usize, 2), to.cols[ncol].n);
for (0..ncol - 1) |k| {
try std.testing.expectEqual(widths[k], to.col_w[k]);
try std.testing.expectEqual(xs[k], to.col_x[k]);
}
// The finish here: both panes and their column gone from the window.
from.update(.{ .handed = .{ .seq = from.handover.seq, .to = "pardes/2" } });
- try std.testing.expect(from.ncol == 1 or from.col_n[c] == 0 or layout.findPane(from, 0) == null);
+ try std.testing.expect(from.ncol == 1 or from.cols[c].n == 0 or layout.findPane(from, 0) == null);
}