diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-04 19:22:04 +0300 |
|---|---|---|
| committer | Can Celik <ogulcancelik@gmail.com> | 2026-04-05 01:23:06 +0300 |
| commit | 41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch) | |
| tree | 3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/pkg/macos/foundation/character_set.zig | |
| parent | 55c138263e190a1e79d4b997bfb9397306c0ec1f (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.zig | 49 |
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(); +} |
