From 77f5fc34f119aa8bcfd31636056b14e46f4a84ba Mon Sep 17 00:00:00 2001 From: Friedrich Stoltzfus Date: Fri, 25 Apr 2025 14:10:35 -0400 Subject: [PATCH] Add config color palette C bindings C bindings to expose the color palette to Swift for macOS. --- include/ghostty.h | 5 +++++ src/config/Config.zig | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/ghostty.h b/include/ghostty.h index 3db280c93..f7504eb7e 100644 --- a/include/ghostty.h +++ b/include/ghostty.h @@ -357,6 +357,11 @@ typedef struct { size_t len; } ghostty_config_color_list_s; +// config.Palette +typedef struct { + ghostty_config_color_s colors[256]; +} ghostty_config_palette_s; + // apprt.Target.Key typedef enum { GHOSTTY_TARGET_APP, diff --git a/src/config/Config.zig b/src/config/Config.zig index f71e0972d..196409762 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -3930,6 +3930,24 @@ pub const Palette = struct { /// The actual value that is updated as we parse. value: terminal.color.Palette = terminal.color.default, + /// ghostty_config_palette_s + pub const C = extern struct { + colors: [265]Color.C, + }; + + pub fn cval(self: Self) Palette.C { + var result: Palette.C = undefined; + for (self.value, 0..) |color, i| { + result.colors[i] = Color.C{ + .r = color.r, + .g = color.g, + .b = color.b, + }; + } + + return result; + } + pub fn parseCLI( self: *Self, input: ?[]const u8,