diff options
Diffstat (limited to 'build/patches.zig')
| -rw-r--r-- | build/patches.zig | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/build/patches.zig b/build/patches.zig index 3d956d26..7c7b2d60 100644 --- a/build/patches.zig +++ b/build/patches.zig @@ -213,8 +213,45 @@ pub fn zstbi(b: *std.Build, patch: *std.Build.Step.Compile, zstbi_dep: *std.Buil /// - an image may be no larger than a screen's storage /// (TerminalImages.storage_limit) rather than ghostty's 400 MB, which a /// program could make pardes read and hold before refusing it. +/// - a medium's bytes (t=f, t=t, t=s) are had through `read_medium` when +/// the host sets one, which is handed ghostty's own read: pardes makes +/// that read a recorded answer, so a session reads a file once (deletes +/// a temporary file, unlinks shared memory, once) and every replica of +/// it is handed the same bytes or the same failure, never reading its +/// own machine (core/Term.zig `media`; docs/ghostty-kitty-medium.md). const ghostty_kitty = [_]Edit{ .{ + .old = " /// Initialize a chunked immage from the first image transmission.\n", + .new = + \\ /// pardes (build/patches.zig): how a file's, a temporary file's or + \\ /// shared memory's bytes are had: `read(ctx)` is ghostty's own read + \\ /// (which deletes a temporary file and unlinks shared memory), its + \\ /// bytes `alloc`'s; null, it is made as it is. + \\ pub var read_medium: ?*const fn (ctx: *const anyopaque, read: *const fn (ctx: *const anyopaque) MediumError![]u8, alloc: Allocator) MediumError![]u8 = null; + \\ pub const MediumError = error{ OutOfMemory, InvalidData, UnsupportedMedium, DimensionsTooLarge, TemporaryFileNotInTempDir, TemporaryFileNotNamedCorrectly }; + \\ + \\ /// Initialize a chunked immage from the first image transmission. + \\ + , + }, + .{ + .old = + \\ switch (t.medium) { + \\ .direct => unreachable, // handled above + \\ .file => try result.readFile(.file, io, alloc, t, cmd.data), + \\ .temporary_file => try result.readFile(.temporary_file, io, alloc, t, cmd.data), + \\ .shared_memory => try result.readSharedMemory(io, alloc, t, cmd.data), + \\ } + \\ + , + .new = + \\ // pardes (build/patches.zig): through the host's `read_medium`. + \\ const medium: PardesMedium = .{ .loading = &result, .io = io, .alloc = alloc, .t = t, .path = cmd.data }; + \\ result.data = .fromOwnedSlice(if (read_medium) |read| try read(&medium, PardesMedium.read, alloc) else try PardesMedium.read(&medium)); + \\ + , + }, + .{ .old = "const max_size = 400 * 1024 * 1024; // 400MB", .new = "const max_size = 64 * 1024 * 1024; // pardes (build.zig): a screen's storage, TerminalImages.storage_limit", }, |
