config: add C API ghostty_config_get to read configuration values

This commit is contained in:
Mitchell Hashimoto
2023-09-10 18:45:02 -07:00
parent b14ba8c022
commit 2820db55be
6 changed files with 119 additions and 2 deletions

View File

@@ -4,6 +4,8 @@ const inputpkg = @import("../input.zig");
const global = &@import("../main.zig").state;
const Config = @import("Config.zig");
const c_get = @import("c_get.zig");
const Key = @import("key.zig").Key;
const log = std.log.scoped(.config);
@@ -78,6 +80,16 @@ export fn ghostty_config_finalize(self: *Config) void {
};
}
export fn ghostty_config_get(
self: *Config,
ptr: *anyopaque,
key_str: [*]const u8,
len: usize,
) bool {
const key = std.meta.stringToEnum(Key, key_str[0..len]) orelse return false;
return c_get.get(self, key, ptr);
}
export fn ghostty_config_trigger(
self: *Config,
str: [*]const u8,