Add config color palette C bindings

C bindings to expose the color palette to Swift for macOS.
This commit is contained in:
Friedrich Stoltzfus 2025-04-25 14:10:35 -04:00
parent 4e91d11a60
commit 77f5fc34f1
2 changed files with 23 additions and 0 deletions

View File

@ -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,

View File

@ -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,