From a53a1aafb9804e943bdcd720c2bb688ecb90a888 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 23 Oct 2026 11:12:56 -0300 Subject: Audit (colours, drawing): one Surface.tint, shared colour maths, the helix copies of hand-ported themes removed The 22 _helix themes that duplicate a hand-written port are gone; monokai, ayu_dark and nord stay, since others inherit from them. Co-Authored-By: Claude Opus 5.5 --- src/File.zig | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/File.zig') diff --git a/src/File.zig b/src/File.zig index 7e05ac9f..e92efaba 100644 --- a/src/File.zig +++ b/src/File.zig @@ -1929,16 +1929,6 @@ pub const DiffTints = struct { } }; -/// A diff row's tint: its ground from `x` to the pane's edge. -fn tintRow(s: *Surface, x: u16, y: u16, end: u16, bg: [3]u8) void { - var col = x; - while (col < end) : (col += 1) { - const cell = s.at(col, y); - cell.default = false; - cell.style.bg = .{ .rgb = bg }; - } -} - fn synStyle(p: *Pardes, sy: syntax.Syn) ?SynStyle { return switch (sy) { .none => null, @@ -2010,7 +2000,7 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes. if (tint) |t| if (prefix_width < tw) { // A +Diff line added or removed whole: faintly (hunks.zig). const whole = highlights[base - highlight_start] & syntax.diff_whole != 0; - if (row_tint or whole) tintRow(s, tx + @as(u16, @intCast(prefix_width)), body_y + vr, tx + tw, if (row_tint) t.bg else t.line_bg); + if (row_tint or whole) s.tint(tx + @as(u16, @intCast(prefix_width)), body_y + vr, tw -| @as(u16, @intCast(prefix_width)), if (row_tint) t.bg else t.line_bg, null); }; // A +Pager's own colours (pager.zig) on every row but one the diff // look tints: an added or removed line is drawn as pardes draws a @@ -2228,7 +2218,7 @@ pub fn recolorDiffOutput(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, t const view = maybe orelse continue; const base = @intFromPtr(rows[view.row].ptr) - flat_start - lo; const tint = if (base < styles.len) tints.forStyle(styles[base]) else null; - if (tint) |t| tintRow(s, tx, body_y + @as(u16, @intCast(vr)), tx + tw, t.bg); + if (tint) |t| s.tint(tx, body_y + @as(u16, @intCast(vr)), tw, t.bg, null); var c: usize = 0; var screen_c: usize = 0; while (c < line.len and screen_c < tw) { @@ -2310,12 +2300,9 @@ pub fn paintWordSelection( if (hi <= lo) continue; const c0 = @as(i32, prefix_width) + here.pad + displayOffset(pane, row, here.at, lo); const c1 = @as(i32, prefix_width) + here.pad + displayEndOffset(pane, row, here.at, hi - 1); - var col = @max(@as(i32, prefix_width), c0); - while (col <= c1 and col < @as(i32, tw)) : (col += 1) { - const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr))); - cell.default = false; - cell.style.bg = .{ .rgb = bg }; - } + const col = @max(@as(i32, prefix_width), c0); + const end = @min(c1 + 1, @as(i32, tw)); + if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, null); } } -- cgit v1.3