summaryrefslogtreecommitdiff
path: root/build/patches/vaxis_render.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build/patches/vaxis_render.zig')
-rw-r--r--build/patches/vaxis_render.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/build/patches/vaxis_render.zig b/build/patches/vaxis_render.zig
new file mode 100644
index 00000000..b6c56f4e
--- /dev/null
+++ b/build/patches/vaxis_render.zig
@@ -0,0 +1,25 @@
+/// pardes's patch (its build.zig): a blank cell (a space, no underline,
+/// strike or reverse) that differs from the last frame's blank in its
+/// ink alone, which shows nowhere.
+inline fn blankInkOnly(last: *const InternalScreen.InternalCell, cell: *const Cell) bool {
+ if (!(cell.char.grapheme.len == 1 and cell.char.grapheme[0] == ' ')) return false;
+ if (last.default or cell.default) return false;
+ if (!(last.char.items.len == 1 and last.char.items[0] == ' ')) return false;
+ const s = cell.style;
+ if (s.reverse or s.strikethrough or s.ul_style != .off) return false;
+ if (!std.mem.eql(u8, last.uri.items, cell.link.uri)) return false;
+ // Field by field: Style.eql is slow, and this runs for every blank
+ // a scrolling shell moves.
+ const l = last.style;
+ return sameColor(l.bg, s.bg) and sameColor(l.ul, s.ul) and l.ul_style == s.ul_style and
+ l.bold == s.bold and l.dim == s.dim and l.italic == s.italic and l.blink == s.blink and
+ !l.reverse and !l.strikethrough and l.invisible == s.invisible;
+}
+
+inline fn sameColor(a: Cell.Color, b: Cell.Color) bool {
+ return switch (a) {
+ .default => b == .default,
+ .index => |i| b == .index and b.index == i,
+ .rgb => |rgb| b == .rgb and rgb[0] == b.rgb[0] and rgb[1] == b.rgb[1] and rgb[2] == b.rgb[2],
+ };
+}