terminal: OSC 133 B handling

This commit is contained in:
Mitchell Hashimoto
2026-01-24 14:05:04 -08:00
parent 3fa6320478
commit acd7a448e1
2 changed files with 22 additions and 0 deletions

View File

@@ -1070,6 +1070,7 @@ pub fn semanticPrompt(
) !void {
switch (cmd.action) {
.fresh_line => try self.semanticPromptFreshLine(),
.fresh_line_new_prompt => {
// "First do a fresh-line."
try self.semanticPromptFreshLine();
@@ -1092,6 +1093,12 @@ pub fn semanticPrompt(
// command but we don't yet handle these in any meaningful way.
},
.end_prompt_start_input => {
// End of prompt and start of user input, terminated by a OSC
// "133;C" or another prompt (OSC "133;P").
self.screens.active.cursor.semantic_content = .input;
},
else => {},
}
}

View File

@@ -933,3 +933,18 @@ test "semantic prompt fresh line new prompt" {
try s.nextSlice("\x1b]133;A;redraw=1\x07");
try testing.expect(t.flags.shell_redraws_prompt);
}
test "semantic prompt end prompt start input" {
var t: Terminal = try .init(testing.allocator, .{ .cols = 10, .rows = 10 });
defer t.deinit(testing.allocator);
var s: Stream = .initAlloc(testing.allocator, .init(&t));
defer s.deinit();
// Write some text and then send OSC 133;A (fresh_line_new_prompt)
try s.nextSlice("Hello");
try s.nextSlice("\x1b]133;A\x07");
try s.nextSlice("prompt$ ");
try s.nextSlice("\x1b]133;B\x07");
try testing.expectEqual(.input, t.screens.active.cursor.semantic_content);
}