diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-27 23:06:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 95a3a1bb822e583988bfe0f312d0ef219b27a454 (patch) | |
| tree | 95306e8d3f36f8af05b3ea919f6cdef1e94a028b /test/hxdiff.zig | |
| parent | c8f0c25a854b8e169db08a84d1fdcd915a70aaa0 (diff) | |
| download | pardes-95a3a1bb822e583988bfe0f312d0ef219b27a454.tar.gz pardes-95a3a1bb822e583988bfe0f312d0ef219b27a454.zip | |
Give a pane's body its own Text holding the cursor, selections, mode and undo
acme keeps what edits a text in its Text (dat.h:171-190) and the window
holds a body and a tag of that type. The cursor, the selections, the modal
state and the edit-buffer undo move off Pane into Text.zig, Pane holds
them as its body, and the edit and normal-mode operations take the Text
they edit. Nothing changes in behaviour; this is the step that lets the
tag become a second Text.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/hxdiff.zig')
| -rw-r--r-- | test/hxdiff.zig | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/test/hxdiff.zig b/test/hxdiff.zig index e79a6bb6..627bbac3 100644 --- a/test/hxdiff.zig +++ b/test/hxdiff.zig @@ -397,9 +397,9 @@ fn runCase(arena: std.mem.Allocator, case: Case, pane_kind: []const u8) !Result core.update(.{ .key = .{ .cp = core.opts.tty_toggle, .ctrl = true } }); pump(core); if (core.panes[core.active]) |pane| { - pane.cur_row = 0; - pane.cur_col = 0; - pane.cur_pinned = true; + pane.body.cur_row = 0; + pane.body.cur_col = 0; + pane.body.cur_pinned = true; } } else fatal("case {s}: unknown pane {s}", .{ case.name, pane_kind }); @@ -488,7 +488,7 @@ fn runCase(arena: std.mem.Allocator, case: Case, pane_kind: []const u8) !Result // the cursor's empty row below the output (see Pardes.shellRows), so // its line list is exactly a file content's — join it and you have the // same bytes, trailing newline included, with nothing to patch up. - const lines = try pardes.edit.paneCursorLines(core, pane); + const lines = try pardes.edit.paneCursorLines(core, &pane.body); var text_len: usize = if (lines.len == 0) 0 else lines.len - 1; for (lines) |ln| text_len = std.math.add(usize, text_len, ln.len) catch return error.OutOfMemory; const joined = try arena.alloc(u8, text_len); @@ -503,28 +503,28 @@ fn runCase(arena: std.mem.Allocator, case: Case, pane_kind: []const u8) !Result } text = joined; } - var anchor: Pos = .{ .row = pane.cur_row, .col = pane.cur_col }; - if (pane.vsel.active) { - anchor = .{ .row = pane.vsel.row, .col = pane.vsel.col }; - } else if (pane.msel.active) { + var anchor: Pos = .{ .row = pane.body.cur_row, .col = pane.body.cur_col }; + if (pane.body.vsel.active) { + anchor = .{ .row = pane.body.vsel.row, .col = pane.body.vsel.col }; + } else if (pane.body.msel.active) { // line selection: the far end (the r0/r1 not holding the cursor), col 0 - anchor = .{ .row = if (pane.cur_row == pane.msel.r1) pane.msel.r0 else pane.msel.r1, .col = 0 }; + anchor = .{ .row = if (pane.body.cur_row == pane.body.msel.r1) pane.body.msel.r0 else pane.body.msel.r1, .col = 0 }; } // mode "select" ONLY while v-extend is on (helix keeps x/%/mi selections - // in normal mode); pane.mode itself never holds a select state - const mode = if (pane.mode == .normal and pane.select) "select" else @tagName(pane.mode); + // in normal mode); pane.body.mode itself never holds a select state + const mode = if (pane.body.mode == .normal and pane.body.select) "select" else @tagName(pane.body.mode); // multiple cursors: the primary (cur_row/cur_col + the anchor above) and - // pane.sels, slotted together in document order. pane.sels is already + // pane.body.sels, slotted together in document order. pane.body.sels is already // ordered, so the primary is the only one that needs placing. var sels: ?[]const Sel = null; var primary: ?usize = null; - if (pane.nsel > 0) { - const out = try arena.alloc(Sel, @as(usize, pane.nsel) + 1); + if (pane.body.nsel > 0) { + const out = try arena.alloc(Sel, @as(usize, pane.body.nsel) + 1); var out_len: usize = 0; - const prim: Sel = .{ .cursor = .{ .row = pane.cur_row, .col = pane.cur_col }, .anchor = anchor }; + const prim: Sel = .{ .cursor = .{ .row = pane.body.cur_row, .col = pane.body.cur_col }, .anchor = anchor }; const pr_row = @min(prim.cursor.row, prim.anchor.row); const pr_col = if (prim.cursor.row == prim.anchor.row) @min(prim.cursor.col, prim.anchor.col) else if (prim.cursor.row < prim.anchor.row) prim.cursor.col else prim.anchor.col; - for (pane.sels[0..pane.nsel]) |s| { + for (pane.body.sels[0..pane.body.nsel]) |s| { const s_row = @min(s.row, s.arow); const s_col = if (s.row == s.arow) @min(s.col, s.acol) else if (s.row < s.arow) s.col else s.acol; if (primary == null and (pr_row < s_row or (pr_row == s_row and pr_col <= s_col))) { @@ -545,7 +545,7 @@ fn runCase(arena: std.mem.Allocator, case: Case, pane_kind: []const u8) !Result .name = case.name, .text = try arena.dupe(u8, text), .mode = mode, - .cursor = .{ .row = pane.cur_row, .col = pane.cur_col }, + .cursor = .{ .row = pane.body.cur_row, .col = pane.body.cur_col }, .anchor = anchor, .sels = sels, .primary = primary, |
