From 8e1526a71a74447cbba9f5487ef72d9feccfc0ed Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 21:19:37 -0300 Subject: Band, sync, draw, layout, mouse, File: the text stays put under the band: out of rest a tag keeps exactly its rows at rest, and its head's rows past them and the band under it are drawn over the top rows of its body, which never moves, wraps or resizes for them (UX DESIGN I1, on the user's "the other editors when there's new ui on top of the text it doesn't scroll ... I think we should do that, no?"); THE OLD WAY: the band pushed the body down (Pardes.sync grew `tag_rows` by `band_rows` and the head's rows), so every row of the text jumped by the band's height on SPC Down, Help, `:`, the registers, a rolled level of three rows, and back on Esc, while a terminal's and a kind's band was a second path drawn over its body (Band.over, Band.shownRows); THE CHANGE: Band.covered (from the state alone, as takes is) says where a tag out of rest is drawn: its head's rows, the band under them (as many as the pane has; a picker's keeping D6's body under it), and `over`, those past the tag's own rows; sync keeps the tag's rows at rest (the terminal special case is every pane's now) and puts `over` in the pane's view (SessionView.covered) for File.show; draw.render draws the host's tag and band after every body, one path for every pane, the grip's column beside the covered rows on the tag's ground, a caret under them hidden until rest; layout.floorRows borrows for a level, Help, `:` or the registers only the rows its head and band need (a picker and code actions keep D6's 60 % / 6 rows; a terminal's and a kind's size stay their user's); mouse.bandPoint gives a covered row to the band (a head's row over the body: B2/B3 on its word as on the tag's first row, B1 nothing); File.show counts the covered rows like the context rows, so what a state shows (a prompt's current hit, C-r's) is put in the rows left visible, a target already there not moved; TagState's rolled level of a terminal takes its three rows too (over the pty, which keeps its size); `band_rows` goes from Pane and PaneView (the dump: SessionView.covered and Pick.previewed come); W1'S READING (I1 is silent on a landing near a file's top): a picker's preview starts under its band (Pick.previewing: from the first place it shows in its landing pane, the band takes its rows from that body, as before), since Find lands on line 1 and a band over the body's top hid the file's first eleven lines and the landing line; before its first row, and after Esc, the pane's own text is where it was; the GUI's tag rule goes under the head's rows as under the band's (gui.zig paneDecor); TESTS (FIRST, where the old behaviour was asserted, inverted): Band.zig "SPC Down unrolls ... drawn over the top rows of the body, which stays where it was" (was "the body pushed down and never drawn over"), "out of rest the body stays where it was ..." (a rolled level, SPC Down, Help, `:`, the registers and a picker before it previews: every row of text under the rows drawn over it on its screen row at rest, the same first row, size and scroll; Esc leaves the body's rows as at rest), "a level's band covers what it needs ..." (no borrow where head and band fit, exactly head + band where they do not), "a covered row belongs to the band ..." (B1 on a band row over the body moves the level's cursor, on a head's row over it touches no body); Pick.zig "a picker's preview starts under its band ..." (in a reading pane: its text stays before the first row; line 60 at ⌈visible/3⌉ under the band, line 1 on the row right under it; Esc: its own text where it was); Prompt.zig "a search's current hit under C-r's band is put in the rows the band leaves the body ..."; the tests that read `band_rows` read Band.covered; body_layer's D10 test: `g`'s first-line target is under the rolled level's rows now (I2's named cost); GOLDENS re-recorded, every moved row: leader (spc, unmapped: the one line of cmds.txt stays on row 3 under the level's second row instead of row 5, the caret on it hidden), find (nomatch, topbar: a picker with nothing to preview leaves here.txt's line 1 on row 3 under the band instead of row 8; cancel: row 8 no longer listed as changed), ttyhelp (leaderworks: Help's band over the +Help pane's text, whose rows 10-20 keep the previous snap's text instead of moving down seven rows); a user saw the text jump on every SPC Down, Help, `:` with rows, registers Down and a rolled level wider than its tag; core-test 1115/1287 (172 skipped: +3), shell-test 1335/1338 (3 skipped: +3), pane-test 183/184, behaviour-test 280/280 and --replay 20 seeds 0 failures, process-test 0 of 147 failed (3 skipped; 3 goldens re-recorded), term-test 17/17, kitty-test 45/45; the dump fuzz at 40,000 join seeds and 40,000 + 1,779 image seeds 11/11; the soak `replicas -- --clients 5 --rtt 30,80,207`: diverged 0, unequal 0, quiet checks 580/0 480/0 675/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak; load 1.2 to 10.9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/File.zig | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'core/File.zig') diff --git a/core/File.zig b/core/File.zig index 41cc025f..0f9178ac 100644 --- a/core/File.zig +++ b/core/File.zig @@ -2059,6 +2059,22 @@ fn shownNow(pane: *const Pane) u16 { return @max(1, if (pane.wrap_n == 0) pane.rows else visible -| pane.context_rows); } +/// The rows of `pane`'s map its tag out of rest draws over (UX DESIGN I1, +/// `view.covered` grid rows from the body's top): its context rows at the +/// tagline's height where the geometry stacks them so, the rest at the +/// body's. +pub fn coveredRows(pane: *const Pane) u16 { + const v = pane.view; + if (v.covered == 0) return 0; + const bh: usize = @max(1, v.body_h); + const th: usize = std.math.clamp(v.tagline_h, 1, bh); + const px = @as(usize, v.covered) * bh; + const compact: usize = if (pane.context_row_limit != null) pane.context_rows else 0; + const rows = if (compact * th >= px) (px + th - 1) / th else compact + (px - compact * th + bh - 1) / bh; + // A damaged dump's covered rows are any: never past a u16's. + return @intCast(@min(rows, std.math.maxInt(u16))); +} + /// The view moved when line `line_at`'s row that shows its byte `col` is /// out of the body's margins (`margin_rows` rows, helix's scrolloff, at /// most half of it): by the rows that show the line's rows whole inside @@ -2068,17 +2084,22 @@ pub fn show(tab: u16, pane: *Pane, line_at: i32, col: i32, margin_rows: i64) voi const f = &pane.file.?; geometry(tab, pane); const t = topNow(tab, pane); + // Its rows a tag out of rest draws over (UX DESIGN I1): what a state + // shows goes under them, as under the context rows; the bottom stays. + const covered: u16 = coveredRows(pane); + const hidden: i64 = covered -| pane.context_rows; // The line held at the top (a sticky context row): as it is. if (pane.context_rows < pane.wrap_n and pane.wrap_line[pane.context_rows] == t.line) { - for (pane.wrap_line[0..pane.context_rows]) |row| if (row == line_at) return; + for (pane.wrap_line[@min(covered, pane.context_rows)..pane.context_rows]) |row| if (row == line_at) return; } - const body: i64 = shownNow(pane); + const full: i64 = shownNow(pane); + const body: i64 = @max(1, full - hidden); const margin: i64 = @min(margin_rows, @divTrunc(body - 1, 2)); // The row in the body (the map's, made just now), or none: the line is // above the top, or below the map. Inside the band the view stays, and // no line is walked (a key's step, nearly always). - const mapped: i64 = pane.wrapRow(tab, line_at, col).row - @as(i64, pane.context_rows); - const row: ?i64 = if (mapped >= 0 and mapped < @max(pane.wrap_n, pane.rows) -| pane.context_rows) mapped else null; + const mapped: i64 = pane.wrapRow(tab, line_at, col).row - @as(i64, pane.context_rows) - hidden; + const row: ?i64 = if (mapped >= -hidden and mapped < @as(i64, @max(pane.wrap_n, pane.rows) -| pane.context_rows) - hidden) mapped else null; if (row) |r| if (r >= margin and r <= body - 1 - margin) return; const line: usize = @intCast(@max(0, line_at)); // The line walked once and no further than the view needs (`Bound`: a @@ -2097,7 +2118,7 @@ pub fn show(tab: u16, pane: *Pane, line_at: i32, col: i32, margin_rows: i64) voi const whole = at.rows <= body - 2 * margin; if (if (row) |r| r < margin else line <= t.line) { if (pane.follow_edges & 1 != 0) return; - setTop(pane, walkKnown(tab, pane, .{ .line = line, .row = if (whole) 0 else at.row }, -margin, known).to); + setTop(pane, walkKnown(tab, pane, .{ .line = line, .row = if (whole) 0 else at.row }, -margin - hidden, known).to); } else if (if (row) |r| r > body - 1 - margin else true) { if (pane.follow_edges & 2 != 0) return; // The margin only reveals text: a pane its whole text fits in @@ -2108,7 +2129,7 @@ pub fn show(tab: u16, pane: *Pane, line_at: i32, col: i32, margin_rows: i64) voi const stop = @max(line, nlines(pane.gpa, f) -| 1 -| @intFromBool(std.mem.endsWith(u8, f.content, "\n"))); if (past.line > stop) past = .{ .line = stop, .row = lineRows(tab, pane, stop) - 1 }; } - setTop(pane, walkKnown(tab, pane, past, -(body - 1), known).to); + setTop(pane, walkKnown(tab, pane, past, -(full - 1), known).to); } } -- cgit v1.3