diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 18:00:35 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 18:20:56 -0300 |
| commit | b1fb4242c0ab52767df1b8e155edcf2692f37873 (patch) | |
| tree | c5e10602471c331a0d462a35072d883d65140933 /core/Query.zig | |
| parent | dde58f770995dcbc929708048a6e0f390c70f8af (diff) | |
| download | pardes-b1fb4242c0ab52767df1b8e155edcf2692f37873.tar.gz pardes-b1fb4242c0ab52767df1b8e155edcf2692f37873.zip | |
scroll: a view's top is a line and a row within that line's own wrapped rows, and a scroll moves it by rows (P62, round 3, on the layer's new model where the `Changes` layer's lines are lines of the buffer): a wheel's notch, the glide, PageDown/PageUp, zj/zk, Ctrl-d/u, zt/zz/zb and the margin (`scroll_off` now ROWS) go a row at a time through a line wrapped over many rows and through a long description line of the layer, where the base jumped all of a wrapped line's rows at once (the user, 2026-11-23: "the scroll view jumps around near deleted lines on the diff view"; one-row deleted lines were cured by the layer's second step, a wrapped one was not): TESTS FIRST: core/jj.zig "a view scrolls by rows through a line wrapped over 12 rows and a change's description wrapped over several (a line of the layer): ..." (a notch is one row down the whole text and back, the notches the text's rows exactly; PageDown/PageUp a page of rows; zj/zk one; a held j and k keep the cursor's row `scroll_off` rows inside the body) failing on the base at notch 21 (line 20's 12 rows crossed at once), and "a client wheels its session's view a row a notch into a change's description wrapped over several rows ..., agreeing at every notch; a client joined over that view loads its row"; kept from round 1: core/replica.zig's join over a view scrolled into a wrapped line (with a rollback and a dump) and the explorer of a view's rows (30 seeds), dev/gui's glide a row a notch; THE CHANGE, taken from pardes-row-scroll (`xrxmqlnw`) and -2 (`xxzmwnvq`) without their ghost-row "blocks" (a block is now just a line's own rows): `File.State.scroll_row` and `views.PaneView.scroll_row` in the generic walk (digested, dumped, copied; a dump of 34 loads at its lines' first rows), the wire 35; core/File.zig `Top`, `rowIn`/`rowWalked` (a line's rows as fillBody wraps them, `guideOf` shared), `rowOf`, `lineRows`, `top`/`setTop`, `walkRows`/`walkKnown`, `rowsTo`, `rowsOf` (off the map where it holds the line), `mapFresh`, `scrollRows`, `shownRows` (the geometry laid out first), `show` (a cursor's or a result's row inside the band, the line's rows whole when they fit), `textRowLine`, fillBody's skip to the top's row walked once a geometry (`Pane.top_skip`, derived), the geometry's key with `scroll_row` and stored as what the map was made from; the one-row fact `State.widest` (`Widest`, an upper bound kept by the index's own vector passes `countLines`/`fillLines`) so a view whose lines are each one row walks nothing (`oneRow`: line arithmetic, checked against the walk in Debug); `fitEnd` a vector of printable ASCII at a time; the callers in rows: panes.zig `scrollBy(tab, delta)` and `ensureCursorVisible` (a file's through `File.show`), the wheel and the rail and the edge scroll (mouse.zig), Ctrl-d/u (normal.zig `halfPageMove`), zt/zz/zb, Ctrl-f/b and PgUp/PgDn (Text.zig `scrollViewMove`), Look's reveal and centring, Places' `goTo`/`restore`, Query's `showCurrent`/`caretTo`, the frames' `Region.row` and the glide (dev/glide.zig, the window's `topOf`); test/perf.zig's checks by (line, row) and its seek at a line's first row; Debug in the workspace: core-test 963/1129 (166 skipped), shell-test 1172/1175 (3 skipped)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Query.zig')
| -rw-r--r-- | core/Query.zig | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/core/Query.zig b/core/Query.zig index 228cdd0e..92a3d9f2 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -344,7 +344,7 @@ pub fn toLineOne(p: *Pardes, id: usize) void { t.cur_pinned = true; rp.query.?.seen_row = 0; edit.enterInsert(p.editor(), t, .line_end, 1) catch |err| return p.reportError(.at(id), "query", err); - showCurrent(rp); + showCurrent(p.settings.tab, rp); } /// The rows' state for a new question: nothing found yet. @@ -456,7 +456,7 @@ fn makeAllRows(p: *Pardes, id: usize) !void { // The current one: the first hit row, until a step moves it. if (q.current == null or q.current.? >= q.items.items.len) q.current = firstHit(q); countCurrent(q); - showCurrent(rp); + showCurrent(p.settings.tab, rp); } /// The names the query matches, best first, `Names.max_rows` of them: each @@ -528,7 +528,7 @@ fn makeNameRows(p: *Pardes, id: usize) !void { // The best is current until a step or a click moves it. q.current = if (shown > 0) 0 else null; countCurrent(q); - showCurrent(rp); + showCurrent(p.settings.tab, rp); if (q.current == null) blankPreview(p, id) else showTarget(p, id); } @@ -1151,7 +1151,7 @@ fn showPlacesCurrent(p: *Pardes, id: usize) void { }; // Stepped out of the window the live rows are: made again around it. if (q.current == null and set.current != null and !q.frozen and set.from == rp.serial) q.made_gen = std.math.maxInt(u64); - showCurrent(rp); + showCurrent(p.settings.tab, rp); } fn firstHit(q: *const Query) ?usize { @@ -1226,7 +1226,7 @@ fn makeGrepRows(p: *Pardes, id: usize, full: bool) !void { q.more = p.stream.busyFor(rp.serial); q.current = current orelse firstHit(q); countGrepCurrent(q); - showCurrent(rp); + showCurrent(p.settings.tab, rp); if (q.current == null) blankPreview(p, id) else if (!shown) showTarget(p, id); } @@ -1317,7 +1317,7 @@ pub fn fillList(p: *Pardes, owner_id: usize, source: Source, rows: []const u8) v if (t.mode == .insert) edit.exitInsert(p.editor(), t); t.vsel.active = false; t.nsel = 0; - caretTo(rp, q.current orelse 0); + caretTo(p.settings.tab, rp, q.current orelse 0); showTarget(p, qid); } @@ -1438,7 +1438,7 @@ fn makeListRows(p: *Pardes, id: usize, pat: []const u8) !void { } } countCurrent(q); - showCurrent(rp); + showCurrent(p.settings.tab, rp); } // ---- the current row ---- @@ -1447,7 +1447,7 @@ fn makeListRows(p: *Pardes, id: usize, pat: []const u8) !void { /// elsewhere, line 1 kept when it can be. Its mark is `paint`'s, drawn /// from `current`: no selection, so no click, sweep or chord clears it and /// no B2 or B3 borrows it. -fn showCurrent(rp: *Pane) void { +fn showCurrent(tab: u16, rp: *Pane) void { const q = rp.query orelse return; if (rp.body.cur_row != 0 and rp.focus == .body) return; const c = q.current orelse return; @@ -1455,24 +1455,19 @@ fn showCurrent(rp: *Pane) void { // Typed into, line 1 stays in view whatever the current row: what you // type is never scrolled away (the live rows start just before the // current one, so it sits under line 1). Frozen, the row is scrolled to. - if (!q.frozen) { - if (rp.scroll() != 0) rp.scrollBy(-rp.scroll()); - return; - } - const off = rp.scroll(); - const shown = off + @as(i32, rp.rows) - 1; - if (r > shown) rp.scrollBy(r - shown) else if (r < off) rp.scrollBy(r - off); + if (rp.file == null) return; + if (!q.frozen) return panes.File.setTop(rp, .{ .line = 0 }); + panes.File.show(tab, rp, r, 0, 0); } /// The caret on item `i`'s row, the row in view. -fn caretTo(rp: *Pane, i: usize) void { +fn caretTo(tab: u16, rp: *Pane, i: usize) void { const r: i32 = @intCast(i + 1); rp.body.cur_row = r; rp.body.cur_col = 0; rp.body.cur_pinned = true; rp.query.?.seen_row = r; - const off = rp.scroll(); - if (r >= off + @as(i32, rp.rows)) rp.scrollBy(r - off - @as(i32, rp.rows) + 1) else if (r < off) rp.scrollBy(r - off); + if (rp.file != null) panes.File.show(tab, rp, r, 0, 0); } /// The first of pane `tp`'s places on line `line` (1-based), if any. @@ -1503,7 +1498,7 @@ fn setCurrent(p: *Pardes, id: usize, i: usize, show: bool) void { if (tp.places.from == rp.serial and tp.serial == q.owner) q.k = hi + 1 else countCurrent(q); } else countCurrent(q); } else countCurrent(q) else countCurrent(q); - showCurrent(rp); + showCurrent(p.settings.tab, rp); if (show) showTarget(p, id); } @@ -1562,6 +1557,7 @@ fn blankPreview(p: *Pardes, qid: usize) void { File.setContent(p, f, empty); f.saved_revision = f.revision; f.scroll = 0; + f.scroll_row = 0; } /// Where the current row points, shown with the keyboard left where it is: @@ -1679,6 +1675,7 @@ fn displayPreview(p: *Pardes, qid: usize, path: []const u8, at: look.Spot) void File.setContent(p, f, bytes); f.saved_revision = f.revision; f.scroll = 0; + f.scroll_row = 0; f.syntax_dirty = true; pane.hscroll = 0; // another file: its own places, found below @@ -1688,6 +1685,7 @@ fn displayPreview(p: *Pardes, qid: usize, path: []const u8, at: look.Spot) void look.clearNavigationSelection(p, pane); if (at.line == 0 or at.line > File.nlines(p.gpa, f)) { f.scroll = 0; + f.scroll_row = 0; f.syntax_dirty = true; pane.body.cur_row = 0; pane.body.cur_col = 0; @@ -1907,7 +1905,7 @@ pub fn cancel(p: *Pardes, id: usize) void { q.frozen = true; rp.body.cur_row = 0; rp.body.cur_col = 0; - showCurrent(rp); + showCurrent(p.settings.tab, rp); // Its places again, as Enter left them. if (q.source == .text) if (owner_id) |oid| if (parse(q.asked)) |a| { const owner = p.panes[oid].?; @@ -1973,7 +1971,7 @@ pub fn key(p: *Pardes, id: usize, k: Key) bool { // The caret on the rows goes to the current row, as j and k // would have taken it there. if (t.cur_row != 0) if (q.current) |c| { - caretTo(rp, c); + caretTo(p.settings.tab, rp, c); }; return true; } |
