diff --git a/src/lib/enum.zig b/src/lib/enum.zig index bfc86bbf7..8a1bbb1fb 100644 --- a/src/lib/enum.zig +++ b/src/lib/enum.zig @@ -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; }; diff --git a/src/terminal/c/terminal.zig b/src/terminal/c/terminal.zig index f900d1c0d..8b16b0280 100644 --- a/src/terminal/c/terminal.zig +++ b/src/terminal/c/terminal.zig @@ -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. /// diff --git a/src/terminal/osc.zig b/src/terminal/osc.zig index 26ce12672..e3d323915 100644 --- a/src/terminal/osc.zig +++ b/src/terminal/osc.zig @@ -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 {