aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/config/key.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/src/config/key.zig
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/src/config/key.zig')
-rw-r--r--vendor/libghostty-vt/src/config/key.zig57
1 files changed, 57 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/config/key.zig b/vendor/libghostty-vt/src/config/key.zig
new file mode 100644
index 00000000..5709e207
--- /dev/null
+++ b/vendor/libghostty-vt/src/config/key.zig
@@ -0,0 +1,57 @@
+const std = @import("std");
+const Config = @import("Config.zig");
+
+/// Key is an enum of all the available configuration keys. This is used
+/// when paired with diff to determine what fields have changed in a config,
+/// amongst other things.
+pub const Key = key: {
+ const field_infos = std.meta.fields(Config);
+ var enumFields: [field_infos.len]std.builtin.Type.EnumField = undefined;
+ var i: usize = 0;
+ for (field_infos) |field| {
+ // Ignore fields starting with "_" since they're internal and
+ // not copied ever.
+ if (field.name[0] == '_') continue;
+
+ enumFields[i] = .{
+ .name = field.name,
+ .value = i,
+ };
+ i += 1;
+ }
+
+ var decls = [_]std.builtin.Type.Declaration{};
+ break :key @Type(.{
+ .@"enum" = .{
+ .tag_type = std.math.IntFittingRange(0, field_infos.len - 1),
+ .fields = enumFields[0..i],
+ .decls = &decls,
+ .is_exhaustive = true,
+ },
+ });
+};
+
+/// Returns the value type for a key
+pub fn Value(comptime key: Key) type {
+ const field = comptime field: {
+ @setEvalBranchQuota(100_000);
+
+ const fields = std.meta.fields(Config);
+ for (fields) |field| {
+ if (@field(Key, field.name) == key) {
+ break :field field;
+ }
+ }
+
+ unreachable;
+ };
+
+ return field.type;
+}
+
+test "Value" {
+ const testing = std.testing;
+
+ try testing.expectEqual(Config.RepeatableString, Value(.@"font-family"));
+ try testing.expectEqual(?bool, Value(.@"cursor-style-blink"));
+}