From 95a3a1bb822e583988bfe0f312d0ef219b27a454 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 23:06:11 -0300 Subject: 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 --- src/pdf_view.zig | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/pdf_view.zig') diff --git a/src/pdf_view.zig b/src/pdf_view.zig index 721dac5a..92a05618 100644 --- a/src/pdf_view.zig +++ b/src/pdf_view.zig @@ -1911,7 +1911,7 @@ pub fn openPane( errdefer state.deinit(core.pdf_gpa); const pane = try core.newDocPane(id); pane.pdf = state; - pane.cur_pinned = true; + pane.body.cur_pinned = true; if (filesystem.localPath(path) != null) core.emit(.{ .watch = .{ .pane = @intCast(id), .on = true } }); return pane; } @@ -1967,15 +1967,15 @@ fn refreshCleanSections(core: *pardes.Pardes, state: *State) void { File.setContent(core, file, content); const rows = File.lineCount(file.content); file.scroll = @min(file.scroll, rows - 1); - const row = @min(@as(usize, @intCast(@max(0, result.cur_row))), rows - 1); - result.cur_row = @intCast(row); - result.cur_col = @intCast(@min( - @as(usize, @intCast(@max(0, result.cur_col))), + const row = @min(@as(usize, @intCast(@max(0, result.body.cur_row))), rows - 1); + result.body.cur_row = @intCast(row); + result.body.cur_col = @intCast(@min( + @as(usize, @intCast(@max(0, result.body.cur_col))), modal.lineSlice(file.content, row).len, )); - result.msel.active = false; - result.vsel.active = false; - result.nsel = 0; + result.body.msel.active = false; + result.body.vsel.active = false; + result.body.nsel = 0; state.sections_output.?.revision = file.revision; } @@ -2003,11 +2003,11 @@ fn rearmCleanSections( if (file.revision != remembered.revision) return false; file.scroll = 0; - result.cur_row = 0; - result.cur_col = 0; - result.msel.active = false; - result.vsel.active = false; - result.nsel = 0; + result.body.cur_row = 0; + result.body.cur_col = 0; + result.body.msel.active = false; + result.body.vsel.active = false; + result.body.nsel = 0; pane.search_pane = remembered.pane; pane.search_row = null; look.armLookWalk(core, remembered.pane); @@ -2110,11 +2110,11 @@ pub fn lookSection( } pub fn resetPageChrome(pane: *pardes.Pane) void { - pane.cur_row = 0; - pane.cur_col = 0; - pane.vsel.active = false; - pane.msel.active = false; - pane.nsel = 0; + pane.body.cur_row = 0; + pane.body.cur_col = 0; + pane.body.vsel.active = false; + pane.body.msel.active = false; + pane.body.nsel = 0; } pub fn activatePage( @@ -2454,12 +2454,12 @@ pub fn pointerRelease( const dragged = grid_selection.c0 != grid_selection.c1 or grid_selection.r0 != grid_selection.r1; if (!dragged) state.clearSelection(core.pdf_gpa); - pane.cur_pinned = true; - pane.mode = .normal; - pane.msel.active = false; - pane.vsel.active = false; - pane.normal.clear(); - pane.nsel = 0; + pane.body.cur_pinned = true; + pane.body.mode = .normal; + pane.body.msel.active = false; + pane.body.vsel.active = false; + pane.body.normal.clear(); + pane.body.nsel = 0; state.clearDrag(); return .{}; } -- cgit v1.3