From 1e8e80ed7b2114682d1ed37a5f2fe7486a404464 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 10 May 2022 14:12:35 -0700 Subject: [PATCH] osc: change window title with code 2 --- src/terminal/osc.zig | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/terminal/osc.zig b/src/terminal/osc.zig index 1cff9821e..4321edd82 100644 --- a/src/terminal/osc.zig +++ b/src/terminal/osc.zig @@ -98,6 +98,7 @@ pub const Parser = struct { @"11", @"13", @"133", + @"2", // We're in a semantic prompt OSC command but we aren't sure // what the command is yet, i.e. `133;` @@ -138,6 +139,7 @@ pub const Parser = struct { .empty => switch (c) { '0' => self.state = .@"0", '1' => self.state = .@"1", + '2' => self.state = .@"2", else => self.state = .invalid, }, @@ -177,6 +179,17 @@ pub const Parser = struct { else => self.state = .invalid, }, + .@"2" => switch (c) { + ';' => { + self.command = .{ .change_window_title = undefined }; + + self.state = .string; + self.temp_state = .{ .str = &self.command.change_window_title }; + self.buf_start = self.buf_idx; + }, + else => self.state = .invalid, + }, + .semantic_prompt => switch (c) { 'A' => { self.state = .semantic_option_start; @@ -310,6 +323,19 @@ test "OSC: change_window_title" { try testing.expectEqualStrings("ab", cmd.change_window_title); } +test "OSC: change_window_title with 2" { + const testing = std.testing; + + var p: Parser = .{}; + p.next('2'); + p.next(';'); + p.next('a'); + p.next('b'); + const cmd = p.end().?; + try testing.expect(cmd == .change_window_title); + try testing.expectEqualStrings("ab", cmd.change_window_title); +} + test "OSC: prompt_start" { const testing = std.testing;