mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-01 07:28:37 +00:00
lib-vt: expose command type enum
This commit is contained in:
@@ -81,19 +81,6 @@ typedef enum {
|
||||
GHOSTTY_OSC_COMMAND_CONEMU_GUIMACRO = 20,
|
||||
} GhosttyOscCommandType;
|
||||
|
||||
/**
|
||||
* OSC command data types. The values returned are documented
|
||||
* on each type.
|
||||
* */
|
||||
typedef enum {
|
||||
/**
|
||||
* The window title string.
|
||||
*
|
||||
* Type: const char*
|
||||
* */
|
||||
GHOSTTY_OSC_DATA_WINDOW_TITLE,
|
||||
} GhosttyOscCommandData;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Allocator Interface
|
||||
|
||||
@@ -317,9 +304,17 @@ void ghostty_osc_next(GhosttyOscParser parser, uint8_t byte);
|
||||
*/
|
||||
GhosttyOscCommand ghostty_osc_end(GhosttyOscParser parser, uint8_t terminator);
|
||||
|
||||
// TODO
|
||||
// GhosttyOscCommandType ghostty_osc_command_type(GhosttyOscCommand command);
|
||||
// bool ghostty_osc_command_data(GhosttyOscCommand command, GhosttyOscCommandData, void *result);
|
||||
/**
|
||||
* Get the type of an OSC command.
|
||||
*
|
||||
* Returns the type identifier for the given OSC command. This can be used
|
||||
* to determine what kind of command was parsed and what data might be
|
||||
* available from it.
|
||||
*
|
||||
* @param command The OSC command handle to query (may be NULL)
|
||||
* @return The command type, or GHOSTTY_OSC_COMMAND_INVALID if command is NULL
|
||||
*/
|
||||
GhosttyOscCommandType ghostty_osc_command_type(GhosttyOscCommand command);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -75,6 +75,7 @@ comptime {
|
||||
@export(&c.osc_next, .{ .name = "ghostty_osc_next" });
|
||||
@export(&c.osc_reset, .{ .name = "ghostty_osc_reset" });
|
||||
@export(&c.osc_end, .{ .name = "ghostty_osc_end" });
|
||||
@export(&c.osc_command_type, .{ .name = "ghostty_osc_command_type" });
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@ pub const osc_free = osc.free;
|
||||
pub const osc_reset = osc.reset;
|
||||
pub const osc_next = osc.next;
|
||||
pub const osc_end = osc.end;
|
||||
pub const osc_command_type = osc.commandType;
|
||||
|
||||
test {
|
||||
_ = osc;
|
||||
|
@@ -44,7 +44,12 @@ pub fn end(parser_: Parser, terminator: u8) callconv(.c) Command {
|
||||
return parser_.?.end(terminator);
|
||||
}
|
||||
|
||||
test "osc" {
|
||||
pub fn commandType(command_: Command) callconv(.c) osc.Command.Key {
|
||||
const command = command_ orelse return .invalid;
|
||||
return command.*;
|
||||
}
|
||||
|
||||
test "alloc" {
|
||||
const testing = std.testing;
|
||||
var p: Parser = undefined;
|
||||
try testing.expectEqual(Result.success, new(
|
||||
@@ -53,3 +58,24 @@ test "osc" {
|
||||
));
|
||||
free(p);
|
||||
}
|
||||
|
||||
test "command type null" {
|
||||
const testing = std.testing;
|
||||
try testing.expectEqual(.invalid, commandType(null));
|
||||
}
|
||||
|
||||
test "command type" {
|
||||
const testing = std.testing;
|
||||
var p: Parser = undefined;
|
||||
try testing.expectEqual(Result.success, new(
|
||||
&lib_alloc.test_allocator,
|
||||
&p,
|
||||
));
|
||||
defer free(p);
|
||||
|
||||
p.next('0');
|
||||
p.next(';');
|
||||
p.next('a');
|
||||
const cmd = p.end(0);
|
||||
try testing.expectEqual(.change_window_title, commandType(cmd));
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ pub const isSafePaste = sanitize.isSafePaste;
|
||||
|
||||
/// This is set to true when we're building the C library.
|
||||
pub const is_c_lib = @import("build_options.zig").is_c_lib;
|
||||
pub const c_api = @import("c/main.zig");
|
||||
pub const c_api = if (is_c_lib) @import("c/main.zig") else void;
|
||||
|
||||
test {
|
||||
@import("std").testing.refAllDecls(@This());
|
||||
|
Reference in New Issue
Block a user