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/Core.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/Core.zig')
| -rw-r--r-- | src/Core.zig | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/src/Core.zig b/src/Core.zig index fa39f884..8d88fcbd 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -105,16 +105,12 @@ reserved_slots: [MAX_PANES]bool = @splat(false), retired_panes: RetiredPanes = .{}, // layout: columns own x by weight; panes own y by vweight within a column. ncol: usize = 0, -col_weight: [MAX_COLS]u64 = @splat(column_weight_unit), -// Zeroed, not undefined: a digest takes the whole of it, a release -// build's heap leaves its unused slots whatever was there before, and -// two replicas must agree on them (src/replica.zig). -col_panes: [MAX_COLS][MAX_PANES]usize = @splat(@splat(0)), -col_n: [MAX_COLS]usize = @splat(0), +cols: [MAX_COLS]Column = @splat(.{}), /// Each column's tag and the workspace's: Texts like a pane's tag, with -/// no prefix, showing a default until someone edits them. +/// no prefix, showing a default until someone edits them. Not the +/// Column's: a view opened takes the live one's columns (views.open) but +/// tags of its own. col_tags: [MAX_COLS]Text = @splat(.{ .what = .column }), -col_serial: [MAX_COLS]u32 = @splat(0), next_column_serial: u32 = 1, /// The finder column, where query panes stack with SearchPlace column /// (Finder.zig). @@ -609,11 +605,11 @@ fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes { _ = try p.newShell(2, ""); for (p.panes[0..3]) |slot| slot.?.greet = true; p.ncol = 2; - p.col_n[0] = 2; - p.col_panes[0][0] = 0; - p.col_panes[0][1] = 1; - p.col_n[1] = 1; - p.col_panes[1][0] = 2; + p.cols[0].n = 2; + p.cols[0].panes[0] = 0; + p.cols[0].panes[1] = 1; + p.cols[1].n = 1; + p.cols[1].panes[0] = 2; }, .shell => { _ = try p.newShell(0, ""); @@ -646,8 +642,8 @@ fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes { /// The layout every single-pane boot starts from. fn oneColumn(p: *Pardes) void { p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; + p.cols[0].n = 1; + p.cols[0].panes[0] = 0; } /// The recent list's own allocator: it is kept best effort (a file not @@ -2089,6 +2085,20 @@ pub const PendingWrite = struct { bytes: []u8, off: usize = 0 }; /// The session layouts `init` can put on screen. One name each, so choosing /// between them reads as a choice instead of a chain of ifs over four options. +/// A column (acme's Column, cols.c): its panes top to bottom, its share of +/// the width and its serial. Its tag is the session's `col_tags`, and its +/// place on screen (`col_x`, `col_w`) is worked out each sync, as a pane's +/// rect is. +pub const Column = struct { + // Zeroed, not undefined: a digest takes the whole of it, a release + // build's heap leaves its unused slots whatever was there before, and + // two replicas must agree on them (src/replica.zig). + panes: [MAX_PANES]usize = @splat(0), + n: usize = 0, + weight: u64 = column_weight_unit, + serial: u32 = 0, +}; + pub const Boot = enum { /// the document named on the command line, or the pane explaining why not document, @@ -3564,13 +3574,13 @@ test "column tag first-cell execution keeps New local to the clicked column" { layout.newScratchIn(p, 0, layout.activeColumn(p).?); p.sync(); for (0..2) |column| { - p.active = p.col_panes[1 - column][0]; + p.active = p.cols[1 - column].panes[0]; p.presented(); - const before = p.col_n; + const before = p.cols; p.update(.{ .mouse = .{ .button = .middle, .kind = .press, .col = p.col_x[column] + TAG_TEXT_INSET, .row = TOPBAR_H } }); p.update(.{ .mouse = .{ .button = .middle, .kind = .release, .col = p.col_x[column] + TAG_TEXT_INSET, .row = TOPBAR_H } }); - try std.testing.expectEqual(before[column] + 1, p.col_n[column]); - try std.testing.expectEqual(before[1 - column], p.col_n[1 - column]); + try std.testing.expectEqual(before[column].n + 1, p.cols[column].n); + try std.testing.expectEqual(before[1 - column].n, p.cols[1 - column].n); try std.testing.expectEqual(column, layout.findPane(p, p.active).?.col); } try std.testing.expectEqualStrings("untouched\n", p.panes[0].?.file.?.content); @@ -3653,8 +3663,8 @@ test "argv naming nothing boots an errors pane rather than failing the launch" { // One pane, filling the window, and it is an OUTPUT pane rather than the // shell a bare `pardes` boots: the answer is the whole screen. try std.testing.expectEqual(@as(u8, 1), p.ncol); - try std.testing.expectEqual(@as(usize, 1), p.col_n[0]); - try std.testing.expectEqual(@as(usize, 0), p.col_panes[0][0]); + try std.testing.expectEqual(@as(usize, 1), p.cols[0].n); + try std.testing.expectEqual(@as(usize, 0), p.cols[0].panes[0]); try std.testing.expectEqual(@as(usize, 0), p.active); for (p.panes[1..]) |slot| try std.testing.expect(slot == null); const pane = p.panes[0].?; @@ -3752,22 +3762,22 @@ test "the bare tty startup opens a text pane under the shell, unfocused" { // One column, shell on top in raw mode, an empty text pane under it. try std.testing.expectEqual(@as(usize, 1), p.ncol); - try std.testing.expectEqual(@as(usize, 2), p.col_n[0]); - const shell = p.panes[p.col_panes[0][0]].?; - const scratch = p.panes[p.col_panes[0][1]].?; + try std.testing.expectEqual(@as(usize, 2), p.cols[0].n); + const shell = p.panes[p.cols[0].panes[0]].?; + const scratch = p.panes[p.cols[0].panes[1]].?; try std.testing.expect(shell.isTerminal()); try std.testing.expectEqual(Text.Mode.tty, shell.body.mode); try std.testing.expect(!scratch.isTerminal()); try std.testing.expectEqualStrings("", scratch.file.?.content); // ...and the shell keeps the keyboard. - try std.testing.expectEqual(p.col_panes[0][0], p.active); + try std.testing.expectEqual(p.cols[0].panes[0], p.active); // Unnamed, it is the bare shell every test asks for. const plain = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer plain.deinit(); try std.testing.expectEqual(Boot.tty_shell, plain.boot); - try std.testing.expectEqual(@as(usize, 1), plain.col_n[0]); + try std.testing.expectEqual(@as(usize, 1), plain.cols[0].n); } test "tty output follows only from the bottom" { |
