diff options
Diffstat (limited to 'build/patches')
| -rw-r--r-- | build/patches/ghostty_kitty.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/build/patches/ghostty_kitty.zig b/build/patches/ghostty_kitty.zig index a86d62d3..870c51e1 100644 --- a/build/patches/ghostty_kitty.zig +++ b/build/patches/ghostty_kitty.zig @@ -13,3 +13,24 @@ fn pardesOpenRegular(io: std.Io, path: []const u8) !std.Io.File { const same = std.fmt.bufPrint(&buf, "/proc/self/fd/{d}", .{probe.handle}) catch unreachable; return std.Io.Dir.cwd().openFile(io, same, .{}); } + +/// pardes (build.zig): a medium's read as ghostty makes it, handed to the +/// host's `LoadingImage.read_medium`: its bytes, the caller's. +const PardesMedium = struct { + loading: *LoadingImage, + io: std.Io, + alloc: Allocator, + t: command.Transmission, + path: []const u8, + + fn read(ctx: *const anyopaque) LoadingImage.MediumError![]u8 { + const m: *const PardesMedium = @ptrCast(@alignCast(ctx)); + switch (m.t.medium) { + .direct => unreachable, // read by the caller + .file => try m.loading.readFile(.file, m.io, m.alloc, m.t, m.path), + .temporary_file => try m.loading.readFile(.temporary_file, m.io, m.alloc, m.t, m.path), + .shared_memory => try m.loading.readSharedMemory(m.io, m.alloc, m.t, m.path), + } + return m.loading.data.toOwnedSlice(m.alloc); + } +}; |
