mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-27 01:21:39 +00:00
osc: parse the Kitty desktop notification protocol (OSC 99)
This includes only parsing of the OSC. You cannot use OSC 99 to send notifications. Uses lazy parsing of the metadata modelled on the new OSC 133 behavior.
This commit is contained in:
committed by
Mitchell Hashimoto
parent
819b241dec
commit
c67a1db991
@@ -159,6 +159,9 @@ pub const Command = union(Key) {
|
||||
/// Kitty drag and drop protocol (OSC 72)
|
||||
kitty_dnd_protocol: KittyDndProtocol,
|
||||
|
||||
/// Kitty desktop notifications (OSC 99)
|
||||
kitty_desktop_notification: parsers.kitty_desktop_notification.OSC,
|
||||
|
||||
/// OSC 3008. Hierarchical context signalling (UAPI spec).
|
||||
/// https://uapi-group.org/specifications/specs/osc_context/
|
||||
context_signal: parsers.context_signal.Command,
|
||||
@@ -198,6 +201,7 @@ pub const Command = union(Key) {
|
||||
"kitty_text_sizing",
|
||||
"kitty_clipboard_protocol",
|
||||
"kitty_dnd_protocol",
|
||||
"kitty_desktop_notification",
|
||||
"context_signal",
|
||||
},
|
||||
);
|
||||
@@ -364,6 +368,7 @@ pub const Parser = struct {
|
||||
@"66",
|
||||
@"72",
|
||||
@"77",
|
||||
@"99",
|
||||
@"104",
|
||||
@"110",
|
||||
@"111",
|
||||
@@ -444,6 +449,7 @@ pub const Parser = struct {
|
||||
.kitty_text_sizing,
|
||||
.kitty_clipboard_protocol,
|
||||
.kitty_dnd_protocol,
|
||||
.kitty_desktop_notification,
|
||||
.context_signal,
|
||||
=> {},
|
||||
}
|
||||
@@ -783,11 +789,24 @@ pub const Parser = struct {
|
||||
else => self.state = .invalid,
|
||||
},
|
||||
|
||||
.@"9",
|
||||
=> switch (c) {
|
||||
';' => self.captureTrailing(.fixed),
|
||||
'9' => self.state = .@"99",
|
||||
else => self.state = .invalid,
|
||||
},
|
||||
|
||||
.@"99",
|
||||
=> switch (c) {
|
||||
// OSC 99 can be up to 4096 bytes fully encoded.
|
||||
';' => self.captureTrailing(.allocating),
|
||||
else => self.state = .invalid,
|
||||
},
|
||||
|
||||
.@"0",
|
||||
.@"22",
|
||||
.@"777",
|
||||
.@"8",
|
||||
.@"9",
|
||||
=> switch (c) {
|
||||
';' => self.captureTrailing(.fixed),
|
||||
else => self.state = .invalid,
|
||||
@@ -868,6 +887,8 @@ pub const Parser = struct {
|
||||
|
||||
.@"77" => null,
|
||||
|
||||
.@"99" => parsers.kitty_desktop_notification.parse(self, terminator_ch),
|
||||
|
||||
.@"133" => parsers.semantic_prompt.parse(self, terminator_ch),
|
||||
|
||||
.@"552" => null,
|
||||
|
||||
@@ -10,6 +10,7 @@ pub const iterm2 = @import("parsers/iterm2.zig");
|
||||
pub const kitty_clipboard_protocol = @import("parsers/kitty_clipboard_protocol.zig");
|
||||
pub const kitty_color = @import("parsers/kitty_color.zig");
|
||||
pub const kitty_dnd_protocol = @import("parsers/kitty_dnd_protocol.zig");
|
||||
pub const kitty_desktop_notification = @import("parsers/kitty_desktop_notification.zig");
|
||||
pub const kitty_text_sizing = @import("parsers/kitty_text_sizing.zig");
|
||||
pub const mouse_shape = @import("parsers/mouse_shape.zig");
|
||||
pub const osc9 = @import("parsers/osc9.zig");
|
||||
|
||||
1293
src/terminal/osc/parsers/kitty_desktop_notification.zig
Normal file
1293
src/terminal/osc/parsers/kitty_desktop_notification.zig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2570,6 +2570,7 @@ pub fn Stream(comptime H: type) type {
|
||||
.conemu_run_process,
|
||||
.kitty_text_sizing,
|
||||
.kitty_dnd_protocol,
|
||||
.kitty_desktop_notification,
|
||||
.context_signal,
|
||||
=> {
|
||||
log.debug("unimplemented OSC callback: {}", .{cmd});
|
||||
|
||||
Reference in New Issue
Block a user