remove vt prefixes

This commit is contained in:
Mitchell Hashimoto
2025-09-24 12:36:45 -07:00
parent 96e9053862
commit 37e238c2f6
4 changed files with 20 additions and 20 deletions

View File

@@ -3,9 +3,9 @@
int main() { int main() {
GhosttyOscParser parser; GhosttyOscParser parser;
if (ghostty_vt_osc_new(NULL, &parser) != GHOSTTY_VT_SUCCESS) { if (ghostty_osc_new(NULL, &parser) != GHOSTTY_SUCCESS) {
return 1; return 1;
} }
ghostty_vt_osc_free(parser); ghostty_osc_free(parser);
return 0; return 0;
} }

View File

@@ -37,10 +37,10 @@ typedef struct GhosttyOscParser *GhosttyOscParser;
*/ */
typedef enum { typedef enum {
/** Operation completed successfully */ /** Operation completed successfully */
GHOSTTY_VT_SUCCESS = 0, GHOSTTY_SUCCESS = 0,
/** Operation failed due to failed allocation */ /** Operation failed due to failed allocation */
GHOSTTY_VT_OUT_OF_MEMORY = -1, GHOSTTY_OUT_OF_MEMORY = -1,
} GhosttyVtResult; } GhosttyResult;
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Allocator Interface // Allocator Interface
@@ -131,7 +131,7 @@ typedef struct {
* @param ret_addr First return address of the allocation call stack (0 if not provided) * @param ret_addr First return address of the allocation call stack (0 if not provided)
*/ */
void (*free)(void *ctx, void *memory, size_t memory_len, uint8_t alignment, uintptr_t ret_addr); void (*free)(void *ctx, void *memory, size_t memory_len, uint8_t alignment, uintptr_t ret_addr);
} GhosttyVtAllocatorVtable; } GhosttyAllocatorVtable;
/** /**
* Custom memory allocator. * Custom memory allocator.
@@ -143,7 +143,7 @@ typedef struct {
* *
* Usage example: * Usage example:
* @code * @code
* GhosttyVtAllocator allocator = { * GhosttyAllocator allocator = {
* .vtable = &my_allocator_vtable, * .vtable = &my_allocator_vtable,
* .ctx = my_allocator_state * .ctx = my_allocator_state
* }; * };
@@ -161,8 +161,8 @@ typedef struct {
* Pointer to the allocator's vtable containing function pointers * Pointer to the allocator's vtable containing function pointers
* for memory operations (alloc, resize, remap, free). * for memory operations (alloc, resize, remap, free).
*/ */
const GhosttyVtAllocatorVtable *vtable; const GhosttyAllocatorVtable *vtable;
} GhosttyVtAllocator; } GhosttyAllocator;
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Functions // Functions
@@ -178,7 +178,7 @@ typedef struct {
* @param parser Pointer to store the created parser handle * @param parser Pointer to store the created parser handle
* @return GHOSTTY_VT_SUCCESS on success, or an error code on failure * @return GHOSTTY_VT_SUCCESS on success, or an error code on failure
*/ */
GhosttyVtResult ghostty_vt_osc_new(const GhosttyVtAllocator *allocator, GhosttyOscParser *parser); GhosttyResult ghostty_osc_new(const GhosttyAllocator *allocator, GhosttyOscParser *parser);
/** /**
* Free an OSC parser instance. * Free an OSC parser instance.
@@ -188,7 +188,7 @@ GhosttyVtResult ghostty_vt_osc_new(const GhosttyVtAllocator *allocator, GhosttyO
* *
* @param parser The parser handle to free (may be NULL) * @param parser The parser handle to free (may be NULL)
*/ */
void ghostty_vt_osc_free(GhosttyOscParser parser); void ghostty_osc_free(GhosttyOscParser parser);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -70,8 +70,8 @@ comptime {
// we want to reference the C API so that it gets exported. // we want to reference the C API so that it gets exported.
if (terminal.is_c_lib) { if (terminal.is_c_lib) {
const c = terminal.c_api; const c = terminal.c_api;
@export(&c.ghostty_vt_osc_new, .{ .name = "ghostty_vt_osc_new" }); @export(&c.osc_new, .{ .name = "ghostty_osc_new" });
@export(&c.ghostty_vt_osc_free, .{ .name = "ghostty_vt_osc_free" }); @export(&c.osc_free, .{ .name = "ghostty_osc_free" });
} }
} }

View File

@@ -6,7 +6,7 @@ const CAllocator = lib_alloc.Allocator;
const osc = @import("osc.zig"); const osc = @import("osc.zig");
/// C: GhosttyOscParser /// C: GhosttyOscParser
pub const GhosttyOscParser = *osc.Parser; pub const OscParser = *osc.Parser;
/// C: GhosttyResult /// C: GhosttyResult
pub const Result = enum(c_int) { pub const Result = enum(c_int) {
@@ -14,9 +14,9 @@ pub const Result = enum(c_int) {
out_of_memory = -1, out_of_memory = -1,
}; };
pub fn ghostty_vt_osc_new( pub fn osc_new(
alloc_: ?*const CAllocator, alloc_: ?*const CAllocator,
result: *GhosttyOscParser, result: *OscParser,
) callconv(.c) Result { ) callconv(.c) Result {
const alloc = lib_alloc.default(alloc_); const alloc = lib_alloc.default(alloc_);
const ptr = alloc.create(osc.Parser) catch const ptr = alloc.create(osc.Parser) catch
@@ -26,7 +26,7 @@ pub fn ghostty_vt_osc_new(
return .success; return .success;
} }
pub fn ghostty_vt_osc_free(parser: GhosttyOscParser) callconv(.c) void { pub fn osc_free(parser: OscParser) callconv(.c) void {
// C-built parsers always have an associated allocator. // C-built parsers always have an associated allocator.
const alloc = parser.alloc.?; const alloc = parser.alloc.?;
parser.deinit(); parser.deinit();
@@ -39,10 +39,10 @@ test {
test "osc" { test "osc" {
const testing = std.testing; const testing = std.testing;
var p: GhosttyOscParser = undefined; var p: OscParser = undefined;
try testing.expectEqual(Result.success, ghostty_vt_osc_new( try testing.expectEqual(Result.success, osc_new(
&lib_alloc.test_allocator, &lib_alloc.test_allocator,
&p, &p,
)); ));
ghostty_vt_osc_free(p); osc_free(p);
} }