mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
Merge pull request #950 from mitchellh/osc1
terminal: implement OSC 1 (change icon) and ignore it
This commit is contained in:
@ -22,6 +22,12 @@ pub const Command = union(enum) {
|
||||
/// as latin1.
|
||||
change_window_title: []const u8,
|
||||
|
||||
/// Set the icon of the terminal window. The name of the icon is not
|
||||
/// well defined, so this is currently ignored by Ghostty at the time
|
||||
/// of writing this. We just parse it so that we don't get parse errors
|
||||
/// in the log.
|
||||
change_window_icon: []const u8,
|
||||
|
||||
/// First do a fresh-line. Then start a new command, and enter prompt mode:
|
||||
/// Subsequent text (until a OSC "133;B" or OSC "133;I" command) is a
|
||||
/// prompt string (as if followed by OSC 133;P;k=i\007). Note: I've noticed
|
||||
@ -343,6 +349,13 @@ pub const Parser = struct {
|
||||
},
|
||||
|
||||
.@"1" => switch (c) {
|
||||
';' => {
|
||||
self.command = .{ .change_window_icon = undefined };
|
||||
|
||||
self.state = .string;
|
||||
self.temp_state = .{ .str = &self.command.change_window_icon };
|
||||
self.buf_start = self.buf_idx;
|
||||
},
|
||||
'0' => self.state = .@"10",
|
||||
'1' => self.state = .@"11",
|
||||
'2' => self.state = .@"12",
|
||||
@ -894,6 +907,19 @@ test "OSC: change_window_title with utf8" {
|
||||
try testing.expectEqualStrings("— ‐", cmd.change_window_title);
|
||||
}
|
||||
|
||||
test "OSC: change_window_icon" {
|
||||
const testing = std.testing;
|
||||
|
||||
var p: Parser = .{};
|
||||
p.next('1');
|
||||
p.next(';');
|
||||
p.next('a');
|
||||
p.next('b');
|
||||
const cmd = p.end(null).?;
|
||||
try testing.expect(cmd == .change_window_icon);
|
||||
try testing.expectEqualStrings("ab", cmd.change_window_icon);
|
||||
}
|
||||
|
||||
test "OSC: prompt_start" {
|
||||
const testing = std.testing;
|
||||
|
||||
|
@ -993,6 +993,10 @@ pub fn Stream(comptime Handler: type) type {
|
||||
} else log.warn("unimplemented OSC callback: {}", .{cmd});
|
||||
},
|
||||
|
||||
.change_window_icon => |icon| {
|
||||
log.info("OSC 1 (change icon) received and ignored icon={s}", .{icon});
|
||||
},
|
||||
|
||||
.clipboard_contents => |clip| {
|
||||
if (@hasDecl(T, "clipboardContents")) {
|
||||
try self.handler.clipboardContents(clip.kind, clip.data);
|
||||
|
Reference in New Issue
Block a user