diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-24 15:23:45 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-24 21:00:32 -0300 |
| commit | a9e33e52d789c7433da1da17a8c82093c9114243 (patch) | |
| tree | 0fb83bc2be369b5a36c86ce8173fb9114503528b /src/panes.zig | |
| parent | e28b0992e9cd8dcedea5ed435566277ee6a93d5b (diff) | |
| download | pardes-a9e33e52d789c7433da1da17a8c82093c9114243.tar.gz pardes-a9e33e52d789c7433da1da17a8c82093c9114243.zip | |
anim 7: what the probe found: the paced wait spins (asleep, the CPU's clock fell and an input's frame took 2-5x as long), a glide measures the core's line count first and emits only the rows it shows, a far jump paints only its view, a long line 16 KB round the caret, the caret's sideways scroll measured from the view's edge, a paint never joined on the loop nor asked while the view stands still, rewritten generated panes do not glide, pictures decode off the loop
Diffstat (limited to 'src/panes.zig')
| -rw-r--r-- | src/panes.zig | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/panes.zig b/src/panes.zig index 20618ccc..51710d08 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -619,14 +619,18 @@ pub const Pane = struct { const line = modal.lineSlice(f.content, @intCast(@max(0, pane.body.cur_row))); const raw_cur: usize = @intCast(@max(0, pane.body.cur_col)); const raw_scroll: usize = @intCast(@max(0, pane.hscroll)); - const cur = @as(i32, @intCast(File.rawDisplayCol(line, raw_cur))); - const visual_scroll = @as(i32, @intCast(File.rawDisplayCol(line, raw_scroll))); - var target = visual_scroll; - if (cur < visual_scroll + hmargin) - target = @max(0, cur - hmargin) - else if (cur > visual_scroll + w - 1 - hmargin) - target = cur - (w - 1 - hmargin); - if (target != visual_scroll) pane.hscroll = @intCast(File.rawAtDisplay(line, @intCast(target))); + // Measured from the view's left edge to the caret, never from the + // line's start: a 500 KB line was walked from byte 0 at every key + // (widths add, so the span alone is exact). + const apart = File.lineDisplayOffset(line, raw_scroll, raw_cur); + const back: ?i32 = if (apart < hmargin) hmargin else if (apart > w - 1 - hmargin) w - 1 - hmargin else null; + if (back) |cols| { + // The byte `cols` columns before the caret, looked for from a + // few bytes a column back (a grapheme is at most 4 a column). + const from = raw_cur -| @as(usize, @intCast(cols)) * 4; + const ahead = File.lineDisplayOffset(line, from, raw_cur) - cols; + pane.hscroll = @intCast(if (ahead <= 0) from else File.byteAtDisplayFrom(line, from, @intCast(ahead))); + } } } |
