diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 01:43:24 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 01:43:40 -0300 |
| commit | ed05c825102ebce7cd1e314226a1c88b8658baef (patch) | |
| tree | 41957f9fb7c5df11389d7872079c6494f47af5ce /core/panes.zig | |
| parent | 0252c830daf6184a9faefa32a7d1f384f5a86b94 (diff) | |
| parent | 59b6ac1bae9cb6720252e1c3e1cc9d4f3a8ab3b1 (diff) | |
| download | pardes-ed05c825102ebce7cd1e314226a1c88b8658baef.tar.gz pardes-ed05c825102ebce7cd1e314226a1c88b8658baef.zip | |
integration: the tree to install next: a view scrolls by ROWS: `main` (pardes-merge66, 0252c830daf6, installed 2026-11-24 01:22) and pardes-row-scroll-3 (`wkxsvmun` on `kyntorlp`, `rymstysv`, `qwssppvo`, on pardes-merge65: a view's top is (line, row within the line's own wrapped rows): a notch is one row through a wrapped line and a wrapped description of the layer, the margin, PageDown/PageUp, `gt`/`gb`, `gw`, `blankRows` and a Look's centring count rows; the wire 35); no conflict; REMOVED HERE: `core/walk.zig.orig`, a patch's leftover that `pvwuwnlk` had added; EXPECTED in its gate and ruled: corpus frame 76 differs (the margin counts rows: the new picture stands) and ten perf counts over tree7 (P85: the view now draws the rows the cursor is on in a wrapped line: deep-sel; the cursor's row found in long lines); its gate: .scratch/sketch/reorg/merge67, the numbers in PARDES.md
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/panes.zig')
| -rw-r--r-- | core/panes.zig | 64 |
1 files changed, 18 insertions, 46 deletions
diff --git a/core/panes.zig b/core/panes.zig index 02ee805f..08d91df5 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -31,7 +31,7 @@ pub const Pane = struct { /// it (views.zig). (The 9P server's part of `fs` says so in its type.) pub const replica = .{ .local = .{ "pv", "pv_known" }, - .derived = .{ "wrap_line", "wrap_col", "wrap_pad", "wrap_n", "body_wrapped", "context_rows", "body_rows", "body_visible_rows", "context_row_limit", "geometry_key", "geometry_len", "notices", "pan" }, + .derived = .{ "wrap_line", "wrap_col", "wrap_pad", "wrap_n", "body_wrapped", "context_rows", "body_rows", "body_visible_rows", "context_row_limit", "geometry_key", "geometry_len", "top_skip", "notices", "pan" }, .len = .{ .{ "msg", "msg_len" }, .{ "msg_older", "msg_older_len" }, .{ "question", "question_len" }, .{ "shell_tail", "shell_tail_len" }, .{ "sel_snap", "nsel_snap" } }, // A picture's memory is its own allocator's (a dump loaded makes // it there). @@ -309,6 +309,11 @@ pub const Pane = struct { wrap_n: u16 = 0, /// A row map also exists for sticky headers when soft wrapping is off. body_wrapped: bool = false, + /// Where the view's top is inside its line's rows (File.Top) for the + /// geometry of `key`: the row it is and the bytes of the line before + /// it, found by the geometry's walk or by the step that put the top + /// there; a frame's text starts there with no walk again. + top_skip: struct { key: u64 = 0, row: u32 = 0, at: usize = 0 } = .{}, context_rows: u16 = 0, body_rows: u16 = 0, body_visible_rows: u16 = 0, @@ -636,15 +641,11 @@ pub const Pane = struct { return .{ .row = -1, .at = 0 }; } - pub fn scrollBy(pane: *Pane, delta: i32) void { - if (pane.file) |*f| { - const max: i64 = @intCast(File.nlines(pane.gpa, f) -| 1); - const n = std.math.clamp(@as(i64, @intCast(f.scroll)) + delta, 0, max); - const next: usize = @intCast(n); - if (next != f.scroll) { - f.scroll = next; - f.syntax_dirty = true; - } + /// The view moved `delta` rows: a file's through its lines' wrapped + /// rows (File.Top), a terminal's through its history. + pub fn scrollBy(pane: *Pane, tab: u16, delta: i32) void { + if (pane.file != null) { + _ = File.scrollRows(tab, pane, delta); } else if (pane.addon == null) { // the vt scrolls in SHELL rows; convert through the edit buffer. // The alternate screen has no history (ghostty's scrolls none): @@ -668,43 +669,14 @@ pub const Pane = struct { } pub fn ensureCursorVisible(pane: *Pane, tab: u16) void { - File.geometry(tab, pane); - const off = pane.scroll(); - var in_context = false; - // The map is the view's as it is now (File.geometry): an ancestor is - // pinned only in the view it was found for. - if (pane.context_rows < pane.wrap_n and pane.wrap_line[pane.context_rows] == off) { - for (pane.wrap_line[0..pane.context_rows]) |row| { - if (row == pane.body.cur_row) { - in_context = true; - break; - } - } - } - // Scrolloff is measured in the ordinary body, excluding sticky rows. - var margin: i32 = @min(config.scroll_off, @divTrunc(@as(i32, pane.rows) - 1, 2)); - var last = off + @as(i32, pane.rows) - 1; - const visible_rows = if (pane.body_visible_rows > 0) @min(pane.wrap_n, pane.body_visible_rows) else pane.wrap_n; - if (pane.context_rows < visible_rows) { - const lines_shown = pane.wrap_line[visible_rows - 1] - pane.wrap_line[pane.context_rows]; - last = off + lines_shown; - margin = @min(margin, @divTrunc(@max(0, lines_shown), 2)); - } - if (!in_context) { - if (pane.follow_edges != 0 and (pane.body.cur_row < off or pane.body.cur_row > last)) pane.follow_crossed = true; + if (pane.file != null) File.show(tab, pane, pane.body.cur_row, pane.body.cur_col, config.scroll_off) else { + // A terminal's rows are its lines. + const off = pane.scroll(); + const margin: i32 = @min(config.scroll_off, @divTrunc(@as(i32, pane.rows) - 1, 2)); + const last = off + @as(i32, pane.rows) - 1; if (pane.body.cur_row < off + margin) { - if (pane.follow_edges & 1 == 0) pane.scrollBy(pane.body.cur_row - margin - off); - } else if (pane.body.cur_row > last - margin and pane.follow_edges & 2 == 0) { - var to = pane.body.cur_row + margin; - if (pane.file) |*f| { - // The margin only reveals text: a pane its whole text - // fits in never scrolls for it. A longer one keeps - // helix's clamp at the buffer's last line. - const lines: i32 = @intCast(File.nlines(pane.gpa, f)); - to = @min(to, if (off == 0 and pane.textFits()) @max(pane.body.cur_row, lines - 1 - @intFromBool(std.mem.endsWith(u8, f.content, "\n"))) else lines - 1); - } - pane.scrollBy(@max(0, to - last)); - } + pane.scrollBy(tab, pane.body.cur_row - margin - off); + } else if (pane.body.cur_row > last - margin) pane.scrollBy(tab, pane.body.cur_row + margin - last); } if (pane.file) |f| { if (pane.body_wrapped) return; |
