diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 17:23:40 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 17:23:40 -0300 |
| commit | 3dc3e796a9b69ec35a8a920aa12f3e04e61a0ab5 (patch) | |
| tree | a62c9dd534adb640fca44b963503c93549efe821 /core/File.zig | |
| parent | bf813d0a06eb57bc8db0abcfe3dbb1f3e12f5834 (diff) | |
| parent | 8152cf383c8296be29e80175b57e40f8d41049bf (diff) | |
| download | pardes-3dc3e796a9b69ec35a8a920aa12f3e04e61a0ab5.tar.gz pardes-3dc3e796a9b69ec35a8a920aa12f3e04e61a0ab5.zip | |
integration: `Changes` and its lanes on the gathered line: pardes-merge52 (`pnmtmksv`: plain mode fixed, the narrow view rule, the soak's own faults) and pardes-layers-3 (`xzmopyqr` on `pvtvmpzx`, on pardes-merge50: `Changes [revset]` pins a revset's changes on a file's pane: a lane a change after the line number, nested ones a level to the right on their rows only, a line added whole green across; with it off nothing is paid: the revset and jj's answers are the session's, a view holds one bit (P45): the 121 counts within 0.1%); no conflict; core-test 898/1058 (160 skipped), shell-test 1100/1103; its gate: .scratch/sketch/reorg/merge53, the numbers in PARDES.md (2026-11-21)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/File.zig')
| -rw-r--r-- | core/File.zig | 72 |
1 files changed, 50 insertions, 22 deletions
diff --git a/core/File.zig b/core/File.zig index 450e4ec9..6e44f85e 100644 --- a/core/File.zig +++ b/core/File.zig @@ -372,7 +372,13 @@ pub fn gutterWidth(pane: *const Pane) u16 { var lines = if (file.line_starts.len > 0) file.line_starts.len else lineCount(file.content); var digits: u16 = 1; while (lines >= 10) : (lines /= 10) digits += 1; - return @max(config.PREFIX_W, digits + 1); + return @max(config.PREFIX_W, digits + 1) + laneCells(pane); +} + +/// The cells the changes' lanes take after the line number in this view +/// (File.Layers), none while it pins no changes. +pub fn laneCells(pane: *const Pane) u16 { + return pane.layers.lanes; } /// Convert between rendered cells and UTF-8 byte columns. Tag rows always @@ -1756,7 +1762,7 @@ fn geometryKey(pane: *const Pane, f: *const State) u64 { if (f.output) |o| pardes.walk.digest(Output.Origin, &o.from) else 0, std.hash.Wyhash.hash(0, f.path), f.tree_context, f.context.revision orelse 0, f.context.declarations.len, f.line_starts.len, t.revision orelse 0, t.list.items.len, pane.view.wrap, pane.view.layered, pane.view.body_h, pane.view.tagline_h, - pane.view.rect_h, + pane.view.rect_h, laneCells(pane), }; // One hash of them laid out as words: every reader of the map asks for // this key, a hundred times a frame. @@ -1771,6 +1777,8 @@ fn geometryKey(pane: *const Pane, f: *const State) u64 { fn fillBody(tab: u16, dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_wrap: bool) usize { if (record_wrap) pane.wrap_n = 0; const prefix_width = gutterWidth(pane); + // Where a number ends: a blank, then the lanes (laneCells), after it. + const number_end = prefix_width -| laneCells(pane) -| 1; const total = nlines(pane.gpa, f); // The slot after the text's last newline, found once: every numbered // row below asks whether it is that one. @@ -1808,23 +1816,25 @@ fn fillBody(tab: u16, dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_w pane.wrap_n = @intCast(i + 1); } if (row < total) { - var lbuf: [@max(config.PREFIX_W, 32)]u8 = undefined; - const prefix = lbuf[0..prefix_width]; - @memset(prefix, ' '); - if (at == 0 and prefix.len > 0) { - var lineno = row + 1; - var digit: usize = prefix.len - 1; - if (row == end_slot) { - prefix[digit - 1] = '~'; - } else while (true) { - digit -= 1; - prefix[digit] = '0' + @as(u8, @intCast(lineno % 10)); - lineno /= 10; - if (lineno == 0) break; + // The number only where the text is wanted: a geometry pass (no + // `dst`, a hundred a frame) counts its cells and nothing more. + if (dst) |out| { + const prefix = out[written..][0..prefix_width]; + @memset(prefix, ' '); + if (at == 0 and prefix.len > 0) { + var lineno = row + 1; + var digit: usize = number_end; + if (row == end_slot) { + prefix[digit - 1] = '~'; + } else while (true) { + digit -= 1; + prefix[digit] = '0' + @as(u8, @intCast(lineno % 10)); + lineno /= 10; + if (lineno == 0) break; + } } } - if (dst) |out| @memcpy(out[written..][0..prefix.len], prefix); - written += prefix.len; + written += prefix_width; if (dst) |out| @memcpy(out[written..][0..guide.len], guide); written += guide.len; // A table row's pads are blanks before their bytes: the row @@ -1868,13 +1878,31 @@ fn fillBody(tab: u16, dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_w /// made without the language's ink: highlightDiffPlain). /// /// Both are painted in recolorSyntax's one walk over the cells, each where -/// it says (one walk per painter cost a frame a sixth more). Ruled, not -/// built (PARDES.md "Changes on the source view"): 3. changes: a lane after -/// the line number, a line added whole green across it, a changed line's -/// words tinted, ghost rows for what the shown revision has not; 4. churn: -/// a heat lane after the number and a strip by the scroll thumb. +/// it says (one walk per painter cost a frame a sixth more). +/// +/// 3. changes (`Changes [revset]`, jj.zig): while `lanes` is set, a +/// lane each of the pane's pinned changes after the line number (the +/// gutter `lanes` cells wider), a line one added whole green across +/// it (jj.paint). Ruled, not built (PARDES.md "Changes on the source +/// view"): a changed line's words tinted, ghost rows for what the +/// shown revision has not. +/// 4. churn, ruled, not built: a heat lane after the number and a strip +/// by the scroll thumb. +/// +/// Two bytes, hashed in one update: a digest takes every view's of every +/// pane at every step. pub const Layers = struct { ink: bool = true, + /// Whether this view shows the pane's pinned changes (`Pardes.changes`: + /// the revset and jj's answers are the pane's), as the cells their + /// lanes take (laneCells), 0 while it does not: set from the view's + /// frontend, in a window two, which its strips of pixels fill one and + /// a half of (Surface.Lane), in a terminal three, a glyph each. + lanes: u8 = 0, + + pub fn digest(l: *const Layers, h: *pardes.walk.Hasher) void { + h.update(&.{ @intFromBool(l.ink), l.lanes }); + } }; pub const SynStyle = struct { fg: [3]u8, bold: bool }; |
