aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/pkg/macos/foundation/character_set.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/pkg/macos/foundation/character_set.zig
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/pkg/macos/foundation/character_set.zig')
-rw-r--r--vendor/libghostty-vt/pkg/macos/foundation/character_set.zig49
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/pkg/macos/foundation/character_set.zig b/vendor/libghostty-vt/pkg/macos/foundation/character_set.zig
new file mode 100644
index 00000000..d80ca45d
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/macos/foundation/character_set.zig
@@ -0,0 +1,49 @@
+const std = @import("std");
+const assert = std.debug.assert;
+const Allocator = std.mem.Allocator;
+const foundation = @import("../foundation.zig");
+const c = @import("c.zig").c;
+
+pub const CharacterSet = opaque {
+ pub fn createWithCharactersInString(
+ str: *foundation.String,
+ ) Allocator.Error!*CharacterSet {
+ return @as(?*CharacterSet, @ptrFromInt(@intFromPtr(c.CFCharacterSetCreateWithCharactersInString(
+ null,
+ @ptrCast(str),
+ )))) orelse Allocator.Error.OutOfMemory;
+ }
+
+ pub fn createWithCharactersInRange(
+ range: foundation.Range,
+ ) Allocator.Error!*CharacterSet {
+ return @as(?*CharacterSet, @ptrFromInt(@intFromPtr(c.CFCharacterSetCreateWithCharactersInRange(
+ null,
+ @bitCast(range),
+ )))) orelse Allocator.Error.OutOfMemory;
+ }
+
+ pub fn release(self: *CharacterSet) void {
+ c.CFRelease(self);
+ }
+};
+
+test "character set" {
+ //const testing = std.testing;
+
+ const str = try foundation.String.createWithBytes("hello world", .ascii, false);
+ defer str.release();
+
+ const cs = try CharacterSet.createWithCharactersInString(str);
+ defer cs.release();
+}
+
+test "character set range" {
+ //const testing = std.testing;
+
+ const cs = try CharacterSet.createWithCharactersInRange(.{
+ .location = 'A',
+ .length = 1,
+ });
+ defer cs.release();
+}