diff --git a/src/terminal/osc.zig b/src/terminal/osc.zig index 19d8212a0..a66e9d8d3 100644 --- a/src/terminal/osc.zig +++ b/src/terminal/osc.zig @@ -158,6 +158,9 @@ pub const Command = union(enum) { /// End a hyperlink (OSC 8) hyperlink_end: void, + /// Show GUI message Box (OSC 9;2) + show_message_box: []const u8, + /// Set progress state (OSC 9;4) progress: struct { state: ProgressState, @@ -353,6 +356,7 @@ pub const Parser = struct { osc_9, // ConEmu specific substates + conemu_message_box, conemu_progress_prestate, conemu_progress_state, conemu_progress_prevalue, @@ -777,6 +781,9 @@ pub const Parser = struct { }, .osc_9 => switch (c) { + '2' => { + self.state = .conemu_message_box; + }, '4' => { self.state = .conemu_progress_prestate; }, @@ -788,6 +795,17 @@ pub const Parser = struct { else => self.showDesktopNotification(), }, + .conemu_message_box => switch (c) { + ';' => { + self.command = .{ .show_message_box = undefined }; + self.temp_state = .{ .str = &self.command.show_message_box }; + self.buf_start = self.buf_idx; + self.complete = true; + self.prepAllocableString(); + }, + else => self.state = .invalid, + }, + .conemu_progress_prestate => switch (c) { ';' => { self.command = .{ .progress = .{ @@ -1662,6 +1680,57 @@ test "OSC: show desktop notification with title" { try testing.expectEqualStrings(cmd.show_desktop_notification.body, "Body"); } +test "OSC: conemu message box" { + const testing = std.testing; + + var p: Parser = .{}; + + const input = "9;2;hello world"; + for (input) |ch| p.next(ch); + + const cmd = p.end('\x1b').?; + try testing.expect(cmd == .show_message_box); + try testing.expectEqualStrings("hello world", cmd.show_message_box); +} + +test "OSC: conemu message box invalid input" { + const testing = std.testing; + + var p: Parser = .{}; + + const input = "9;2"; + for (input) |ch| p.next(ch); + + const cmd = p.end('\x1b'); + try testing.expect(cmd == null); +} + +test "OSC: conemu message box empty message" { + const testing = std.testing; + + var p: Parser = .{}; + + const input = "9;2;"; + for (input) |ch| p.next(ch); + + const cmd = p.end('\x1b').?; + try testing.expect(cmd == .show_message_box); + try testing.expectEqualStrings("", cmd.show_message_box); +} + +test "OSC: conemu message box spaces only message" { + const testing = std.testing; + + var p: Parser = .{}; + + const input = "9;2; "; + for (input) |ch| p.next(ch); + + const cmd = p.end('\x1b').?; + try testing.expect(cmd == .show_message_box); + try testing.expectEqualStrings(" ", cmd.show_message_box); +} + test "OSC: OSC9 progress set" { const testing = std.testing; diff --git a/src/terminal/stream.zig b/src/terminal/stream.zig index a4a32e169..5e0752fc9 100644 --- a/src/terminal/stream.zig +++ b/src/terminal/stream.zig @@ -1605,7 +1605,7 @@ pub fn Stream(comptime Handler: type) type { } else log.warn("unimplemented OSC callback: {}", .{cmd}); }, - .progress => { + .progress, .show_message_box => { log.warn("unimplemented OSC callback: {}", .{cmd}); }, }