aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/terminal/sys.zig
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-07 18:29:21 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-07 18:29:21 +0300
commitdcfe11a7588fcd42471159453810abc9b7720a57 (patch)
treec32a77266028e73ca2382b96c96f8438a5fcd621 /vendor/libghostty-vt/src/terminal/sys.zig
parent2dfed860103c4e4505ac7f25def9fe37da1e1e6a (diff)
build: update libghostty-vt vendor
vendor ghostty 063ac3e and remove the musl libc++ link workaround. expose the new selection formatter and hyperlink uri apis for follow-up rendering work. add manual artifact validation for static linux builds.
Diffstat (limited to 'vendor/libghostty-vt/src/terminal/sys.zig')
-rw-r--r--vendor/libghostty-vt/src/terminal/sys.zig54
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/terminal/sys.zig b/vendor/libghostty-vt/src/terminal/sys.zig
new file mode 100644
index 00000000..f0c64da5
--- /dev/null
+++ b/vendor/libghostty-vt/src/terminal/sys.zig
@@ -0,0 +1,54 @@
+//! System interface for the terminal package.
+//!
+//! This provides runtime-swappable function pointers for operations that
+//! depend on external implementations (e.g. image decoding). Each function
+//! pointer is initialized with a default implementation if available.
+//!
+//! This exists so that the terminal package doesn't have hard dependencies
+//! on specific libraries and enables embedders of the terminal package to
+//! swap out implementations as needed at startup to provide their own
+//! implementations.
+const std = @import("std");
+const Allocator = std.mem.Allocator;
+const build_options = @import("terminal_options");
+
+/// Decode PNG data into RGBA pixels. If null, PNG decoding is unsupported
+/// and the exact semantics are up to callers. For example, the Kitty Graphics
+/// Protocol will work but cannot accept PNG images.
+pub var decode_png: ?DecodePngFn = png: {
+ if (build_options.artifact == .lib) break :png null;
+ break :png &decodePngWuffs;
+};
+
+pub const DecodeError = Allocator.Error || error{InvalidData};
+pub const DecodePngFn = *const fn (Allocator, []const u8) DecodeError!Image;
+
+/// The result of decoding an image. The caller owns the returned data
+/// and must free it with the same allocator that was passed to the
+/// decode function.
+pub const Image = struct {
+ width: u32,
+ height: u32,
+ data: []u8,
+};
+
+fn decodePngWuffs(
+ alloc: Allocator,
+ data: []const u8,
+) DecodeError!Image {
+ const wuffs = @import("wuffs");
+ const result = wuffs.png.decode(
+ alloc,
+ data,
+ ) catch |err| switch (err) {
+ error.WuffsError => return error.InvalidData,
+ error.OutOfMemory => return error.OutOfMemory,
+ error.Overflow => return error.InvalidData,
+ };
+
+ return .{
+ .width = result.width,
+ .height = result.height,
+ .data = result.data,
+ };
+}