mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-24 12:46:10 +03:00
feat: parse ConEmu OSC9;2
This commit is contained in:
@ -158,6 +158,11 @@ pub const Command = union(enum) {
|
||||
/// End a hyperlink (OSC 8)
|
||||
hyperlink_end: void,
|
||||
|
||||
/// Show GUI message Box (OSC 9;2)
|
||||
show_message_box: struct {
|
||||
content: []const u8,
|
||||
},
|
||||
|
||||
/// Set progress state (OSC 9;4)
|
||||
progress: struct {
|
||||
state: ProgressState,
|
||||
@ -353,6 +358,7 @@ pub const Parser = struct {
|
||||
osc_9,
|
||||
|
||||
// ConEmu specific substates
|
||||
conemu_message_box,
|
||||
conemu_progress_prestate,
|
||||
conemu_progress_state,
|
||||
conemu_progress_prevalue,
|
||||
@ -777,6 +783,9 @@ pub const Parser = struct {
|
||||
},
|
||||
|
||||
.osc_9 => switch (c) {
|
||||
'2' => {
|
||||
self.state = .conemu_message_box;
|
||||
},
|
||||
'4' => {
|
||||
self.state = .conemu_progress_prestate;
|
||||
},
|
||||
@ -788,6 +797,16 @@ pub const Parser = struct {
|
||||
else => self.showDesktopNotification(),
|
||||
},
|
||||
|
||||
.conemu_message_box => switch (c) {
|
||||
';' => {
|
||||
self.command = .{ .show_message_box = .{ .content = undefined } };
|
||||
self.temp_state = .{ .str = &self.command.show_message_box.content };
|
||||
self.buf_start = self.buf_idx;
|
||||
self.prepAllocableString();
|
||||
},
|
||||
else => self.state = .invalid,
|
||||
},
|
||||
|
||||
.conemu_progress_prestate => switch (c) {
|
||||
';' => {
|
||||
self.command = .{ .progress = .{
|
||||
@ -1662,6 +1681,19 @@ test "OSC: show desktop notification with title" {
|
||||
try testing.expectEqualStrings(cmd.show_desktop_notification.body, "Body");
|
||||
}
|
||||
|
||||
test "OSC: OSC9;2 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.content);
|
||||
}
|
||||
|
||||
test "OSC: OSC9 progress set" {
|
||||
const testing = std.testing;
|
||||
|
||||
|
@ -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});
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user