From fdc6a6b10a216af505f134cd7982bb83f228f124 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 23 Jan 2026 13:39:32 -0800 Subject: [PATCH] terminal/osc: semantic prompt 'B' --- src/terminal/osc/parsers/semantic_prompt2.zig | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/terminal/osc/parsers/semantic_prompt2.zig b/src/terminal/osc/parsers/semantic_prompt2.zig index 890fe714b..d2547abe4 100644 --- a/src/terminal/osc/parsers/semantic_prompt2.zig +++ b/src/terminal/osc/parsers/semantic_prompt2.zig @@ -10,6 +10,7 @@ pub const Command = union(enum) { fresh_line_new_prompt: Options, new_command: Options, prompt_start: Options, + end_prompt_start_input: Options, }; pub const Options = struct { @@ -100,6 +101,14 @@ pub fn parse(parser: *Parser, _: ?u8) ?*OSCCommand { parser.command.semantic_prompt.fresh_line_new_prompt.parse(&it); }, + 'B' => end_prompt: { + parser.command = .{ .semantic_prompt = .{ .end_prompt_start_input = .init } }; + if (data.len == 1) break :end_prompt; + if (data[1] != ';') break :valid; + var it = KVIterator.init(writer) catch break :valid; + parser.command.semantic_prompt.end_prompt_start_input.parse(&it); + }, + 'L' => { if (data.len > 1) break :valid; parser.command = .{ .semantic_prompt = .fresh_line }; @@ -526,3 +535,38 @@ test "OSC 133: new_command extra contents" { for (input) |ch| p.next(ch); try testing.expect(p.end(null) == null); } + +test "OSC 133: end_prompt_start_input" { + const testing = std.testing; + + var p: Parser = .init(null); + + const input = "133;B"; + for (input) |ch| p.next(ch); + + const cmd = p.end(null).?.*; + try testing.expect(cmd == .semantic_prompt); + try testing.expect(cmd.semantic_prompt == .end_prompt_start_input); +} + +test "OSC 133: end_prompt_start_input extra contents" { + const testing = std.testing; + + var p: Parser = .init(null); + const input = "133;Bextra"; + for (input) |ch| p.next(ch); + try testing.expect(p.end(null) == null); +} + +test "OSC 133: end_prompt_start_input with options" { + const testing = std.testing; + + var p: Parser = .init(null); + const input = "133;B;aid=foo"; + for (input) |ch| p.next(ch); + + const cmd = p.end(null).?.*; + try testing.expect(cmd == .semantic_prompt); + try testing.expect(cmd.semantic_prompt == .end_prompt_start_input); + try testing.expectEqualStrings("foo", cmd.semantic_prompt.end_prompt_start_input.aid.?); +}