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/mouse.zig | |
| 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/mouse.zig')
| -rw-r--r-- | src/mouse.zig | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/src/mouse.zig b/src/mouse.zig index 5c3821e7..43d66e0b 100644 --- a/src/mouse.zig +++ b/src/mouse.zig @@ -162,14 +162,14 @@ fn clampBorderRow(ay: u16, ah: u16, bh: u16, mrow: u16, tag_bottom: bool) u16 { } fn seamRowOf(p: *const Pardes, c: usize, k: usize) u16 { - const r = p.rects[p.col_panes[c][k]]; + const r = p.rects[p.cols[c].panes[k]]; return if (p.settings.tag_bottom) r.y +| r.h else r.y + r.h -| 1; } fn cornerFixture(gpa: std.mem.Allocator) !*Pardes { const p = try Pardes.init(gpa, .{ .cols = 100, .rows = 30, .shells = 3 }); p.update(.{ .resize = .{ .cols = 100, .rows = 30 } }); - p.active = p.col_panes[1][0]; + p.active = p.cols[1].panes[0]; p.update(.{ .key = .{ .cp = 'n', .alt = true } }); // a shell below it, same column p.sync(); return p; @@ -189,8 +189,8 @@ test "a pane's last row of text is no resize handle; the rule over the next pane test "a pane's grip dragged up or down its own column moves its top, down to the floor of the pane above" { const p = try cornerFixture(std.testing.allocator); defer p.deinit(); - const upper = p.col_panes[1][0]; - const lower = p.col_panes[1][1]; + const upper = p.cols[1].panes[0]; + const lower = p.cols[1].panes[1]; const grip_x = p.rects[lower].x; // Up, past the pane above's first row: a text pane keeps its tag, a // terminal its tag and two rows (layout.floorRows). @@ -202,7 +202,7 @@ test "a pane's grip dragged up or down its own column moves its top, down to the p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = grip_x, .row = top } }); p.sync(); try std.testing.expectEqual(floor, p.rects[upper].h); - try std.testing.expectEqual(lower, p.col_panes[1][1]); + try std.testing.expectEqual(lower, p.cols[1].panes[1]); // Down, inside itself: its top follows, the pane above taking the rows. const to = p.rects[lower].y + 6; p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = grip_x, .row = p.rects[lower].y } }); @@ -246,7 +246,7 @@ pub fn chromeTarget(p: *const Pardes, col: u16, row: u16) ?ChromeTarget { } for (0..p.ncol) |column| { if (col < p.col_x[column] or col >= p.col_x[column] + p.col_w[column]) continue; - for (0..p.col_n[column] -| 1) |index| { + for (0..p.cols[column].n -| 1) |index| { const seam = seamRowOf(p, column, index); if (@max(row, seam) - @min(row, seam) == slack) return .{ .col = col, .row = seam }; } @@ -263,8 +263,8 @@ test "a press near chrome takes it: the tag rows, a column's handle or a seam on const handle = p.col_x[0] + p.col_w[0] - 1; const seam = seamRowOf(p, 0, 0); const mid = p.col_x[0] + p.col_w[0] / 2; - const top = p.rects[p.col_panes[0][0]].y; - const low = p.rects[p.col_panes[1][1]]; + const top = p.rects[p.cols[0].panes[0]].y; + const low = p.rects[p.cols[1].panes[1]]; const body = low.y + low.h / 2; try std.testing.expectEqual(ChromeTarget{ .col = 5, .row = 0 }, chromeTarget(p, 5, 0).?); try std.testing.expectEqual(ChromeTarget{ .col = handle, .row = body }, chromeTarget(p, handle, body).?); @@ -597,7 +597,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { if (mcol < p.col_x[column] or mcol >= p.col_x[column] + @min(config.GUTTER, p.col_w[column])) continue; if (m.button == config.select_button) { p.header_drag = false; - p.drag = .{ .column_move = .{ .serial = p.col_serial[column], .cur_x = mcol, .grab = mcol - p.col_x[column] } }; + p.drag = .{ .column_move = .{ .serial = p.cols[column].serial, .cur_x = mcol, .grab = mcol - p.col_x[column] } }; } return; } @@ -632,7 +632,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { column = c; x = p.col_x[c] + TAG_TEXT_INSET; if (layout.findPane(p, p.active)) |active_col| { - if (active_col.col != c and p.col_n[c] > 0) p.active = p.col_panes[c][0]; + if (active_col.col != c and p.cols[c].n > 0) p.active = p.cols[c].panes[0]; } break; }; @@ -653,7 +653,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { // Held, as a pane tag's sweep is: it runs when the button // comes up (headerSweepRun). p.header_sweep = .{ - .serial = if (column) |c| p.col_serial[c] else null, + .serial = if (column) |c| p.cols[c].serial else null, .button = m.button, .anchor = point.at, .cur = point.at, @@ -888,7 +888,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { /// row `mrow`. Out-of-range columns simply have no seam. fn seamIdxAt(p: *const Pardes, c: usize, mrow: u16) ?usize { if (c >= p.ncol) return null; - for (0..p.col_n[c] -| 1) |k| if (mrow == seamRowOf(p, c, k)) return k; + for (0..p.cols[c].n -| 1) |k| if (mrow == seamRowOf(p, c, k)) return k; return null; } @@ -900,9 +900,9 @@ pub fn dragUpdate(p: *Pardes, mcol: u16, mrow: u16, body_hit: ?Mouse.BodyHit) vo clampBorderCol(p.col_x[c], p.col_w[c], p.col_w[c + 1], mcol) else mcol; - if (d.corner) |k| if (k.idx + 1 < p.col_n[k.col]) { - const a = p.rects[p.col_panes[k.col][k.idx]]; - const b = p.rects[p.col_panes[k.col][k.idx + 1]]; + if (d.corner) |k| if (k.idx + 1 < p.cols[k.col].n) { + const a = p.rects[p.cols[k.col].panes[k.idx]]; + const b = p.rects[p.cols[k.col].panes[k.idx + 1]]; d.cur_y = clampBorderRow(a.y, a.h, b.h, mrow, p.settings.tag_bottom); } else { d.cur_y = mrow; @@ -911,9 +911,9 @@ pub fn dragUpdate(p: *Pardes, mcol: u16, mrow: u16, body_hit: ?Mouse.BodyHit) vo .border_h => |*d| { const cc = d.col; const k = d.top_idx; - if (k + 1 < p.col_n[cc]) { - const a = p.rects[p.col_panes[cc][k]]; - const b = p.rects[p.col_panes[cc][k + 1]]; + if (k + 1 < p.cols[cc].n) { + const a = p.rects[p.cols[cc].panes[k]]; + const b = p.rects[p.cols[cc].panes[k + 1]]; // Held by the rule over the lower pane: the seam is the row above. const seam = if (p.settings.tag_bottom) mrow else mrow -| 1; d.cur_y = clampBorderRow(a.y, a.h, b.h, seam, p.settings.tag_bottom); @@ -1573,15 +1573,15 @@ test "a corner drag's two axes clamp independently" { test "a v-handle press at the RIGHT column's seam drags both boundaries" { const p = try cornerFixture(std.testing.allocator); defer p.deinit(); - try std.testing.expectEqual(@as(usize, 2), p.col_n[1]); + try std.testing.expectEqual(@as(usize, 2), p.cols[1].n); const handle = p.col_x[0] + p.col_w[0] - 1; const right_seam = nudgeRightSeam(p, 3); try std.testing.expect(right_seam != seamRowOf(p, 0, 0)); - const w0 = p.col_weight[0]; - const v_left = p.panes[p.col_panes[0][0]].?.vweight; - const v_right = p.panes[p.col_panes[1][0]].?.vweight; + const w0 = p.cols[0].weight; + const v_left = p.panes[p.cols[0].panes[0]].?.vweight; + const v_right = p.panes[p.cols[1].panes[0]].?.vweight; p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = handle, .row = right_seam } }); try std.testing.expect(p.drag == .border_v); @@ -1595,9 +1595,9 @@ test "a v-handle press at the RIGHT column's seam drags both boundaries" { // both halves committed: the column pair widened, and the RIGHT column's // pane pair reweighted — while the left column's panes stayed put - try std.testing.expect(p.col_weight[0] > w0); - try std.testing.expect(p.panes[p.col_panes[1][0]].?.vweight != v_right); - try std.testing.expectEqual(v_left, p.panes[p.col_panes[0][0]].?.vweight); + try std.testing.expect(p.cols[0].weight > w0); + try std.testing.expect(p.panes[p.cols[1].panes[0]].?.vweight != v_right); + try std.testing.expectEqual(v_left, p.panes[p.cols[0].panes[0]].?.vweight); } test "a tie row still moves the LEFT column's pane pair only" { @@ -1611,8 +1611,8 @@ test "a tie row still moves the LEFT column's pane pair only" { try std.testing.expectEqual(left_seam, seamRowOf(p, 1, 0)); const handle = p.col_x[0] + p.col_w[0] - 1; - const v_left = p.panes[p.col_panes[0][0]].?.vweight; - const v_right = p.panes[p.col_panes[1][0]].?.vweight; + const v_left = p.panes[p.cols[0].panes[0]].?.vweight; + const v_right = p.panes[p.cols[1].panes[0]].?.vweight; p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = handle, .row = left_seam } }); const corner = p.drag.border_v.corner orelse return error.NoCorner; @@ -1621,8 +1621,8 @@ test "a tie row still moves the LEFT column's pane pair only" { p.update(.{ .mouse = .{ .button = .left, .kind = .drag, .col = handle, .row = left_seam - 4 } }); p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = handle, .row = left_seam - 4 } }); p.sync(); - try std.testing.expect(p.panes[p.col_panes[0][0]].?.vweight != v_left); - try std.testing.expectEqual(v_right, p.panes[p.col_panes[1][0]].?.vweight); + try std.testing.expect(p.panes[p.cols[0].panes[0]].?.vweight != v_left); + try std.testing.expectEqual(v_right, p.panes[p.cols[1].panes[0]].?.vweight); } test "a v-handle press at nobody's seam is still a plain edge drag" { @@ -1635,9 +1635,9 @@ test "a v-handle press at nobody's seam is still a plain edge drag" { var row: u16 = TOPBAR_H + 1; while (row == left_seam or row == right_seam) row += 1; - const w0 = p.col_weight[0]; - const v_left = p.panes[p.col_panes[0][0]].?.vweight; - const v_right = p.panes[p.col_panes[1][0]].?.vweight; + const w0 = p.cols[0].weight; + const v_left = p.panes[p.cols[0].panes[0]].?.vweight; + const v_right = p.panes[p.cols[1].panes[0]].?.vweight; p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = handle, .row = row } }); try std.testing.expect(p.drag == .border_v); try std.testing.expect(p.drag.border_v.corner == null); @@ -1645,9 +1645,9 @@ test "a v-handle press at nobody's seam is still a plain edge drag" { p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = handle + 8, .row = row + 5 } }); p.sync(); // exactly ONE boundary moved - try std.testing.expect(p.col_weight[0] > w0); - try std.testing.expectEqual(v_left, p.panes[p.col_panes[0][0]].?.vweight); - try std.testing.expectEqual(v_right, p.panes[p.col_panes[1][0]].?.vweight); + try std.testing.expect(p.cols[0].weight > w0); + try std.testing.expectEqual(v_left, p.panes[p.cols[0].panes[0]].?.vweight); + try std.testing.expectEqual(v_right, p.panes[p.cols[1].panes[0]].?.vweight); } test "a RIGHT-column corner's two axes clamp independently" { @@ -1666,8 +1666,8 @@ test "a RIGHT-column corner's two axes clamp independently" { // and the mirror: below the bottom at mid-width. y parks, x tracks again p.update(.{ .mouse = .{ .button = .left, .kind = .drag, .col = handle, .row = 999 } }); try std.testing.expectEqual(handle, p.drag.border_v.cur_x); - const a = p.rects[p.col_panes[1][0]]; - const b = p.rects[p.col_panes[1][1]]; + const a = p.rects[p.cols[1].panes[0]]; + const b = p.rects[p.cols[1].panes[1]]; try std.testing.expectEqual(clampBorderRow(a.y, a.h, b.h, 999, p.settings.tag_bottom), p.drag.border_v.cur_y); p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = handle, .row = 999 } }); } |
