mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Merge pull request #389 from mitchellh/csi-p
terminal: CSI P must shift all remaining columns to right of cursor
This commit is contained in:
@ -1132,18 +1132,16 @@ pub fn eraseLine(
|
|||||||
/// scrolling region, it is adjusted down.
|
/// scrolling region, it is adjusted down.
|
||||||
///
|
///
|
||||||
/// Does not change the cursor position.
|
/// Does not change the cursor position.
|
||||||
pub fn deleteChars(self: *Terminal, count_req: usize) !void {
|
pub fn deleteChars(self: *Terminal, count: usize) !void {
|
||||||
const tracy = trace(@src());
|
const tracy = trace(@src());
|
||||||
defer tracy.end();
|
defer tracy.end();
|
||||||
|
|
||||||
// Count defaults to 1 and we can't delete more than we have remaining
|
|
||||||
// in the row.
|
|
||||||
const count = @min(self.cols - self.screen.cursor.x, count_req);
|
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
|
// We go from our cursor right to the end and either copy the cell
|
||||||
|
// "count" away or clear it.
|
||||||
const line = self.screen.getRow(.{ .active = self.screen.cursor.y });
|
const line = self.screen.getRow(.{ .active = self.screen.cursor.y });
|
||||||
for (0..count) |i| {
|
for (self.screen.cursor.x..self.cols) |x| {
|
||||||
const x = self.screen.cursor.x + i;
|
|
||||||
const copy_x = x + count;
|
const copy_x = x + count;
|
||||||
if (copy_x >= self.cols) {
|
if (copy_x >= self.cols) {
|
||||||
line.getCellPtr(x).* = self.screen.cursor.pen;
|
line.getCellPtr(x).* = self.screen.cursor.pen;
|
||||||
@ -2715,6 +2713,22 @@ test "Terminal: deleteChars more than line width" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Terminal: deleteChars should shift left" {
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
var t = try init(alloc, 5, 5);
|
||||||
|
defer t.deinit(alloc);
|
||||||
|
|
||||||
|
for ("ABCDE") |c| try t.print(c);
|
||||||
|
t.setCursorPos(1, 2);
|
||||||
|
|
||||||
|
try t.deleteChars(1);
|
||||||
|
{
|
||||||
|
var str = try t.plainString(testing.allocator);
|
||||||
|
defer testing.allocator.free(str);
|
||||||
|
try testing.expectEqualStrings("ACDE", str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/mitchellh/ghostty/issues/272
|
// https://github.com/mitchellh/ghostty/issues/272
|
||||||
// This is also tested in depth in screen resize tests but I want to keep
|
// This is also tested in depth in screen resize tests but I want to keep
|
||||||
// this test around to ensure we don't regress at multiple layers.
|
// this test around to ensure we don't regress at multiple layers.
|
||||||
|
Reference in New Issue
Block a user