mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
macos/text: more APIs
This commit is contained in:
@ -11,6 +11,17 @@ pub const URL = opaque {
|
||||
) orelse error.OutOfMemory;
|
||||
}
|
||||
|
||||
pub fn createStringByReplacingPercentEscapes(
|
||||
str: *foundation.String,
|
||||
escape: *foundation.String,
|
||||
) Allocator.Error!*foundation.String {
|
||||
return CFURLCreateStringByReplacingPercentEscapes(
|
||||
null,
|
||||
str,
|
||||
escape,
|
||||
) orelse return error.OutOfMemory;
|
||||
}
|
||||
|
||||
pub fn release(self: *URL) void {
|
||||
foundation.CFRelease(self);
|
||||
}
|
||||
@ -25,6 +36,11 @@ pub const URL = opaque {
|
||||
base_url: ?*const anyopaque,
|
||||
) ?*URL;
|
||||
pub extern "c" fn CFURLCopyPath(*URL) ?*foundation.String;
|
||||
pub extern "c" fn CFURLCreateStringByReplacingPercentEscapes(
|
||||
allocator: ?*anyopaque,
|
||||
original: *const anyopaque,
|
||||
escape: *const anyopaque,
|
||||
) ?*foundation.String;
|
||||
};
|
||||
|
||||
test {
|
||||
|
@ -43,7 +43,28 @@ test "collection" {
|
||||
// const name = desc.copyAttribute(.name);
|
||||
// defer name.release();
|
||||
// const cstr = name.cstring(&buf, .utf8).?;
|
||||
// std.log.warn("i={d} v={s}", .{ i, cstr });
|
||||
//
|
||||
// var buf2: [128]u8 = undefined;
|
||||
// const url = desc.copyAttribute(.url);
|
||||
// defer url.release();
|
||||
// const path = path: {
|
||||
// const blank = try foundation.String.createWithBytes("", .utf8, false);
|
||||
// defer blank.release();
|
||||
//
|
||||
// const path = url.copyPath() orelse break :path "<no path>";
|
||||
// defer path.release();
|
||||
//
|
||||
// const decoded = try foundation.URL.createStringByReplacingPercentEscapes(
|
||||
// path,
|
||||
// blank,
|
||||
// );
|
||||
// defer decoded.release();
|
||||
//
|
||||
// break :path decoded.cstring(&buf2, .utf8) orelse
|
||||
// "<path cannot be converted to string>";
|
||||
// };
|
||||
//
|
||||
// std.log.warn("i={d} name={s} path={s}", .{ i, cstr, path });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
Reference in New Issue
Block a user