From eee837f69b19a6da03222733f1da63df318a8c0d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 10 May 2022 11:57:42 -0700 Subject: [PATCH] osc: prompt_end --- src/terminal/osc.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/terminal/osc.zig b/src/terminal/osc.zig index 52881f4dc..52c120c86 100644 --- a/src/terminal/osc.zig +++ b/src/terminal/osc.zig @@ -28,6 +28,10 @@ pub const Command = union(enum) { aid: ?[]const u8 = null, }, + /// End of prompt and start of user input, terminated by a OSC "133;C" + /// or another prompt (OSC "133;P"). + prompt_end: void, + /// End of current command. /// /// The exit-code need not be specified if if there are no options, @@ -162,6 +166,12 @@ pub const Parser = struct { self.complete = true; }, + 'B' => { + self.state = .semantic_option_start; + self.command = .{ .prompt_end = .{} }; + self.complete = true; + }, + 'D' => { self.state = .semantic_exit_code_start; self.command = .{ .end_of_command = .{} }; @@ -331,3 +341,15 @@ test "OSC: end_of_command with exit code" { try testing.expect(cmd == .end_of_command); try testing.expectEqual(@as(u8, 25), cmd.end_of_command.exit_code.?); } + +test "OSC: prompt_end" { + const testing = std.testing; + + var p: Parser = .{}; + + const input = "133;B"; + for (input) |ch| p.next(ch); + + const cmd = p.end().?; + try testing.expect(cmd == .prompt_end); +}