summaryrefslogtreecommitdiff
path: root/build/patches
diff options
context:
space:
mode:
Diffstat (limited to 'build/patches')
-rw-r--r--build/patches/ghostty_kitty.zig15
-rw-r--r--build/patches/mvzr_budget.zig4
-rw-r--r--build/patches/vaxis_parser.zig13
-rw-r--r--build/patches/vaxis_render.zig25
4 files changed, 57 insertions, 0 deletions
diff --git a/build/patches/ghostty_kitty.zig b/build/patches/ghostty_kitty.zig
new file mode 100644
index 00000000..a86d62d3
--- /dev/null
+++ b/build/patches/ghostty_kitty.zig
@@ -0,0 +1,15 @@
+/// pardes (build.zig): `path`, opened for reading only once it is known
+/// to be a regular file. Elsewhere than Linux, a stat by path first.
+fn pardesOpenRegular(io: std.Io, path: []const u8) !std.Io.File {
+ if (comptime builtin.target.os.tag != .linux) {
+ if ((try std.Io.Dir.cwd().statFile(io, path, .{})).kind != .file) return error.NotRegularFile;
+ return std.Io.Dir.cwd().openFile(io, path, .{});
+ }
+ const probe = try std.Io.Dir.cwd().openFile(io, path, .{ .path_only = true });
+ defer probe.close(io);
+ const stat = try probe.stat(io);
+ if (stat.kind != .file) return error.NotRegularFile;
+ var buf: [32]u8 = undefined;
+ const same = std.fmt.bufPrint(&buf, "/proc/self/fd/{d}", .{probe.handle}) catch unreachable;
+ return std.Io.Dir.cwd().openFile(io, same, .{});
+}
diff --git a/build/patches/mvzr_budget.zig b/build/patches/mvzr_budget.zig
new file mode 100644
index 00000000..e1d14c12
--- /dev/null
+++ b/build/patches/mvzr_budget.zig
@@ -0,0 +1,4 @@
+/// pardes's patch (its build.zig): matchPattern entries left before a
+/// match gives up, and whether one did. Set by the caller per search.
+pub threadlocal var steps_left: u64 = std.math.maxInt(u64);
+pub threadlocal var exhausted: bool = false;
diff --git a/build/patches/vaxis_parser.zig b/build/patches/vaxis_parser.zig
new file mode 100644
index 00000000..90b09025
--- /dev/null
+++ b/build/patches/vaxis_parser.zig
@@ -0,0 +1,13 @@
+/// pardes's patch (its build.zig): whether `CSI ... R` answers a cursor
+/// position query. Only `CSI 1 ; mods R` with mods past 1 is a modified F3
+/// (a bare F3 is `SS3 R`); a report has another row, or col 1 (mods 1).
+fn cursorReport(sequence: []const u8) bool {
+ const params = sequence[2 .. sequence.len - 1];
+ if (params.len > 0 and params[0] == '?') return true;
+ var fields = std.mem.splitScalar(u8, params, ';');
+ const row = fields.first();
+ const col = fields.next() orelse return false;
+ if (fields.next() != null or row.len == 0 or col.len == 0) return false;
+ for (params) |c| if (c != ';' and !std.ascii.isDigit(c)) return false;
+ return !std.mem.eql(u8, row, "1") or std.mem.eql(u8, col, "1");
+}
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],
+ };
+}