mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-31 04:39:01 +00:00
terminal: share progress state enum
This commit is contained in:
@@ -121,7 +121,10 @@ pub fn checkGhosttyHEnum(
|
||||
|
||||
if (@hasDecl(c, expected_name)) {
|
||||
std.testing.expectEqual(field.value, @field(c, expected_name)) catch |e| {
|
||||
std.log.err(@typeName(T) ++ " key " ++ field.name ++ " does not have the same backing int as " ++ expected_name, .{});
|
||||
std.log.err(
|
||||
"{s} key {s} does not have the same backing int as " ++ expected_name,
|
||||
.{ @typeName(T), field.name },
|
||||
);
|
||||
return e;
|
||||
};
|
||||
|
||||
|
||||
@@ -92,16 +92,8 @@ pub const DesktopNotification = extern struct {
|
||||
body: lib.String,
|
||||
};
|
||||
|
||||
/// State of a terminal progress report.
|
||||
///
|
||||
/// C: GhosttyTerminalProgressState
|
||||
pub const ProgressState = enum(c_int) {
|
||||
remove = 0,
|
||||
set = 1,
|
||||
@"error" = 2,
|
||||
indeterminate = 3,
|
||||
pause = 4,
|
||||
};
|
||||
pub const ProgressState = osc.Command.ProgressReport.State;
|
||||
|
||||
/// A progress report emitted by the running program.
|
||||
///
|
||||
|
||||
@@ -203,19 +203,16 @@ pub const Command = union(Key) {
|
||||
);
|
||||
|
||||
pub const ProgressReport = struct {
|
||||
pub const State = enum(c_int) {
|
||||
remove,
|
||||
set,
|
||||
@"error",
|
||||
indeterminate,
|
||||
pause,
|
||||
|
||||
test "ghostty.h Command.ProgressReport.State" {
|
||||
if (comptime build_options.artifact == .lib) return error.SkipZigTest;
|
||||
try lib.checkGhosttyHEnum(State, "GHOSTTY_PROGRESS_STATE_");
|
||||
}
|
||||
const state_keys = &.{
|
||||
"remove",
|
||||
"set",
|
||||
"error",
|
||||
"indeterminate",
|
||||
"pause",
|
||||
};
|
||||
|
||||
pub const State = LibEnum(lib.target, state_keys);
|
||||
|
||||
state: State,
|
||||
progress: ?u8 = null,
|
||||
|
||||
@@ -235,6 +232,12 @@ pub const Command = union(Key) {
|
||||
)) else -1,
|
||||
};
|
||||
}
|
||||
|
||||
test "ghostty.h Command.ProgressReport.State" {
|
||||
if (comptime build_options.artifact == .lib) return error.SkipZigTest;
|
||||
const CState = LibEnum(.c, state_keys);
|
||||
try lib.checkGhosttyHEnum(CState, "GHOSTTY_PROGRESS_STATE_");
|
||||
}
|
||||
};
|
||||
|
||||
comptime {
|
||||
|
||||
Reference in New Issue
Block a user