summaryrefslogtreecommitdiff
path: root/test/column_drag.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 /test/column_drag.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 'test/column_drag.zig')
-rw-r--r--test/column_drag.zig50
1 files changed, 25 insertions, 25 deletions
diff --git a/test/column_drag.zig b/test/column_drag.zig
index 0e92e125..94d61827 100644
--- a/test/column_drag.zig
+++ b/test/column_drag.zig
@@ -33,10 +33,10 @@ fn expectOrder(p: *Pardes, before: []const Snapshot, order: []const usize) !void
try std.testing.expectEqual(order.len, p.ncol);
for (order, 0..) |original, column| {
const saved = before[original];
- try std.testing.expectEqual(saved.weight, p.col_weight[column]);
- try std.testing.expectEqual(saved.serial, p.col_serial[column]);
- try std.testing.expectEqual(saved.count, p.col_n[column]);
- try std.testing.expectEqualSlices(usize, saved.panes[0..saved.count], p.col_panes[column][0..p.col_n[column]]);
+ try std.testing.expectEqual(saved.weight, p.cols[column].weight);
+ try std.testing.expectEqual(saved.serial, p.cols[column].serial);
+ try std.testing.expectEqual(saved.count, p.cols[column].n);
+ try std.testing.expectEqualSlices(usize, saved.panes[0..saved.count], p.cols[column].panes[0..p.cols[column].n]);
try std.testing.expectEqualStrings(saved.tag, pardes.tagline.columnTag(p, column));
}
}
@@ -51,12 +51,12 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
const id = p.active;
try std.testing.expect(layout.splitColumn(p, id, id, false));
}
- p.active = p.col_panes[1][0];
+ p.active = p.cols[1].panes[0];
try std.testing.expect(p.executeBuiltinLine(p.active, "New"));
const active = p.active;
- try std.testing.expectEqual(@as(usize, 2), p.col_n[1]);
+ try std.testing.expectEqual(@as(usize, 2), p.cols[1].n);
for ([_]u64{ 2, 3, 5, 7 }, 0..) |weight, column| {
- p.col_weight[column] = weight;
+ p.cols[column].weight = weight;
p.col_tags[column].own = try p.gpa.dupe(u8, ([_][]const u8{ "zero column header", "one column header", "two column header", "three column header" })[column]);
}
p.update(.tick);
@@ -65,8 +65,8 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
_ = try p.render(frame.allocator());
var before: [4]Snapshot = undefined;
for (&before, 0..) |*saved, column| {
- saved.* = .{ .weight = p.col_weight[column], .serial = p.col_serial[column], .count = p.col_n[column], .tag = pardes.tagline.columnTag(p, column) };
- @memcpy(saved.panes[0..saved.count], p.col_panes[column][0..saved.count]);
+ saved.* = .{ .weight = p.cols[column].weight, .serial = p.cols[column].serial, .count = p.cols[column].n, .tag = pardes.tagline.columnTag(p, column) };
+ @memcpy(saved.panes[0..saved.count], p.cols[column].panes[0..saved.count]);
}
const layer = try tagLayer(p, 1);
const stale = headerMouse(layer, 4, .press);
@@ -77,14 +77,14 @@ test "column grip drag moves only its interval and keeps tag caret with the colu
const anchor = pardes.tagline.focusedHeader(p).?.vsel;
const scroll = p.header_scroll;
const target = p.col_x[3] + p.col_w[3] - 2;
- const last_rect = p.rects[p.col_panes[3][0]];
+ const last_rect = p.rects[p.cols[3].panes[0]];
const last_columns = (try tagLayer(p, 3)).cols;
mouse(p, .press, p.col_x[1]);
try std.testing.expect(p.drag == .column_move);
mouse(p, .drag, target);
_ = try p.render(frame.allocator());
try std.testing.expectEqual(p.col_w[3] - pardes.TAG_TEXT_INSET - 1, (try tagLayer(p, 3)).viewport.w);
- try std.testing.expectEqual(last_rect, p.rects[p.col_panes[3][0]]);
+ try std.testing.expectEqual(last_rect, p.rects[p.cols[3].panes[0]]);
try std.testing.expectEqual(last_columns, (try tagLayer(p, 3)).cols);
try expectOrder(p, &before, &.{ 0, 1, 2, 3 });
mouse(p, .release, target);
@@ -135,7 +135,7 @@ test "column grip is separate from compact text and the resize seam" {
try std.testing.expectEqual(p.col_x[1] + pardes.TAG_TEXT_INSET, layer.viewport.x);
const surface = &p.surface;
for (0..p.ncol) |column| {
- const pane_id = p.col_panes[column][0];
+ const pane_id = p.cols[column].panes[0];
const rect = p.rects[pane_id];
try std.testing.expectEqual(p.col_x[column], rect.x);
try std.testing.expectEqual(rect.x + pardes.TAG_TEXT_INSET, (try tagLayer(p, column)).viewport.x);
@@ -160,7 +160,7 @@ test "column grip is separate from compact text and the resize seam" {
try std.testing.expect(p.drag == .column_move);
mouse(p, .release, p.col_x[1] + config.GUTTER - 1);
const seam = p.col_x[0] + p.col_w[0] - 1;
- const body_row = p.rects[p.col_panes[0][0]].y + pardes.BOX_H + 1;
+ const body_row = p.rects[p.cols[0].panes[0]].y + pardes.BOX_H + 1;
p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = seam, .row = body_row } });
try std.testing.expect(p.drag == .border_v);
p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = seam, .row = body_row } });
@@ -178,7 +178,7 @@ test "column grips stay blank, and muted across focus and hover until grabbed" {
for ([_]bool{ false, true }) |focus_tint| {
p.settings.focus_tint = focus_tint;
for (0..p.ncol) |active_column| {
- p.active = p.col_panes[active_column][0];
+ p.active = p.cols[active_column].panes[0];
const x = p.col_x[active_column];
p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = x, .row = pardes.TOPBAR_H } });
for ([_]bool{ false, true }) |dragging| {
@@ -212,7 +212,7 @@ test "column grip dropped in its own place moves the column's left edge" {
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const serials = .{ p.col_serial[0], p.col_serial[1] };
+ const serials = .{ p.cols[0].serial, p.cols[1].serial };
const edge = p.col_x[1];
const total = p.col_w[0] + p.col_w[1];
// A click in place, from either grip cell, changes nothing.
@@ -231,13 +231,13 @@ test "column grip dropped in its own place moves the column's left edge" {
_ = try p.render(frame.allocator());
try std.testing.expectEqual(edge - 7, p.col_x[1]);
try std.testing.expectEqual(total, p.col_w[0] + p.col_w[1]);
- try std.testing.expectEqual(serials[0], p.col_serial[0]);
- try std.testing.expectEqual(serials[1], p.col_serial[1]);
+ try std.testing.expectEqual(serials[0], p.cols[0].serial);
+ try std.testing.expectEqual(serials[1], p.cols[1].serial);
// Past the neighbour's middle it is still a reorder, not a resize.
mouse(p, .press, p.col_x[1]);
mouse(p, .release, p.col_x[0] + 1);
- try std.testing.expectEqual(serials[1], p.col_serial[0]);
- try std.testing.expectEqual(serials[0], p.col_serial[1]);
+ try std.testing.expectEqual(serials[1], p.cols[0].serial);
+ try std.testing.expectEqual(serials[0], p.cols[1].serial);
}
/// The column of the drag preview's rail, checked to run the full height
@@ -278,7 +278,7 @@ test "column grip drag previews where the column lands, in the seam beside its r
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const serials = .{ p.col_serial[0], p.col_serial[1], p.col_serial[2] };
+ const serials = .{ p.cols[0].serial, p.cols[1].serial, p.cols[2].serial };
// Held on its own grip it lands nowhere new: no rail.
mouse(p, .press, p.col_x[1]);
@@ -293,8 +293,8 @@ test "column grip drag previews where the column lands, in the seam beside its r
// aims at a place: no word lights under it.
for (0..p.screen_w) |x| try std.testing.expect(!std.meta.eql(p.surface.at(@intCast(x), pardes.TOPBAR_H).style.bg, pardes.Color{ .rgb = p.theme().sel_bg }));
mouse(p, .release, 3);
- try std.testing.expectEqual(serials[1], p.col_serial[0]);
- try std.testing.expectEqual(serials[0], p.col_serial[1]);
+ try std.testing.expectEqual(serials[1], p.cols[0].serial);
+ try std.testing.expectEqual(serials[0], p.cols[1].serial);
// Past the middle column's middle it lands after it: the rail is in the
// seam cell left of the last column's rule, where a border drag's is.
@@ -306,9 +306,9 @@ test "column grip drag previews where the column lands, in the seam beside its r
mouse(p, .drag, p.col_x[2] + p.col_w[2] - 1);
try std.testing.expectEqual(@as(?u16, p.screen_w - 1), try previewRail(p, &frame));
mouse(p, .release, p.col_x[2] + p.col_w[2] - 1);
- try std.testing.expectEqual(serials[0], p.col_serial[0]);
- try std.testing.expectEqual(serials[2], p.col_serial[1]);
- try std.testing.expectEqual(serials[1], p.col_serial[2]);
+ try std.testing.expectEqual(serials[0], p.cols[0].serial);
+ try std.testing.expectEqual(serials[2], p.cols[1].serial);
+ try std.testing.expectEqual(serials[1], p.cols[2].serial);
// Short of a neighbour's middle the left edge moves, and the preview
// is the seam that edge will have: exactly where the release puts it.