mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 03:25:50 +00:00
terminal: OSC 133 B handling
This commit is contained in:
@@ -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 => {},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user