diff options
Diffstat (limited to 'core/File.zig')
| -rw-r--r-- | core/File.zig | 33 |
1 files changed, 27 insertions, 6 deletions
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); } } |
