diff options
Diffstat (limited to 'core/File.zig')
| -rw-r--r-- | core/File.zig | 75 |
1 files changed, 34 insertions, 41 deletions
diff --git a/core/File.zig b/core/File.zig index f7d6bced..6e44f85e 100644 --- a/core/File.zig +++ b/core/File.zig @@ -1777,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. @@ -1814,24 +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; - // The number, a blank, then the lanes (laneCells). - var digit: usize = prefix.len - 1 - laneCells(pane); - 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 @@ -1877,38 +1880,28 @@ fn fillBody(tab: u16, dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_w /// 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). /// -/// 3. changes (`Changes [revset]`, jj.zig): while `revset` is set, a -/// lane a pinned change 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. +/// 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 { - pub const replica = .{ .len = .{.{ "revset", "revset_len" }} }; ink: bool = true, - /// The changes this view pins (jj's revset), none while empty; what jj - /// answered for them is the pane's (`Pane.changes`). - revset: [revset_max]u8 = undefined, - revset_len: u8 = 0, - /// The cells its lanes take while it pins any, 0 while it pins none - /// (laneCells): set as it pins them, 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. + /// 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 const revset_max = 64; - - pub fn pinned(l: *const Layers) []const u8 { - return l.revset[0..l.revset_len]; - } - - /// One word while it pins nothing: a digest walks every view's layers - /// of every pane (field by field it cost a step 0.1 to 0.7% more). pub fn digest(l: *const Layers, h: *pardes.walk.Hasher) void { - h.update(&.{ @intFromBool(l.ink), l.revset_len, l.lanes }); - if (l.revset_len > 0) h.update(l.pinned()); + h.update(&.{ @intFromBool(l.ink), l.lanes }); } }; |
