mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-17 21:12:39 +00:00
terminal: OSC 133 N
This commit is contained in:
@@ -1093,6 +1093,19 @@ pub fn semanticPrompt(
|
||||
// command but we don't yet handle these in any meaningful way.
|
||||
},
|
||||
|
||||
.new_command => {
|
||||
// Same as OSC "133;A" but may first implicitly terminate a
|
||||
// previous command: if the options specify an aid and there
|
||||
// is an active (open) command with matching aid, finish the
|
||||
// innermost such command (as well as any other commands
|
||||
// nested more deeply). If no aid is specified, treat as an
|
||||
// aid whose value is the empty string.
|
||||
try self.semanticPrompt(.{
|
||||
.action = .fresh_line_new_prompt,
|
||||
.options_unvalidated = cmd.options_unvalidated,
|
||||
});
|
||||
},
|
||||
|
||||
.prompt_start => {
|
||||
// Explicit start of prompt. Optional after an A or N command.
|
||||
// The k (kind) option specifies the type of prompt:
|
||||
|
||||
@@ -967,3 +967,35 @@ test "semantic prompt prompt_start" {
|
||||
try testing.expectEqual(@as(usize, 5), t.screens.active.cursor.x);
|
||||
try testing.expectEqual(@as(usize, 0), t.screens.active.cursor.y);
|
||||
}
|
||||
|
||||
test "semantic prompt new_command" {
|
||||
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
|
||||
try s.nextSlice("Hello");
|
||||
try s.nextSlice("\x1b]133;N\x07");
|
||||
|
||||
// Should behave like fresh_line_new_prompt - cursor moves to column 0
|
||||
// on next line since we had content
|
||||
try testing.expectEqual(@as(usize, 0), t.screens.active.cursor.x);
|
||||
try testing.expectEqual(@as(usize, 1), t.screens.active.cursor.y);
|
||||
try testing.expectEqual(.prompt, t.screens.active.cursor.semantic_content);
|
||||
}
|
||||
|
||||
test "semantic prompt new_command at column zero" {
|
||||
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();
|
||||
|
||||
// OSC 133;N when already at column 0 should stay on same line
|
||||
try s.nextSlice("\x1b]133;N\x07");
|
||||
try testing.expectEqual(@as(usize, 0), t.screens.active.cursor.x);
|
||||
try testing.expectEqual(@as(usize, 0), t.screens.active.cursor.y);
|
||||
try testing.expectEqual(.prompt, t.screens.active.cursor.semantic_content);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user