mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 17:26:09 +03:00
termio/exec: clear screen should erase rows and shift up
This commit is contained in:
@ -1871,12 +1871,10 @@ pub fn eraseRows(
|
|||||||
const old_dst = dst.*;
|
const old_dst = dst.*;
|
||||||
dst.* = src.*;
|
dst.* = src.*;
|
||||||
src.* = old_dst;
|
src.* = old_dst;
|
||||||
}
|
|
||||||
|
|
||||||
// We don't even bother deleting the data in the swapped rows
|
// Clear the old data in case we reuse these cells.
|
||||||
// because erasing in this way yields a page that likely will never
|
chunk.page.data.clearCells(src, 0, chunk.page.data.size.cols);
|
||||||
// be written to again (its in the past) or it will grow and the
|
}
|
||||||
// terminal erase will automatically erase the data.
|
|
||||||
|
|
||||||
// Update any tracked pins to shift their y. If it was in the erased
|
// Update any tracked pins to shift their y. If it was in the erased
|
||||||
// row then we move it to the top of this page.
|
// row then we move it to the top of this page.
|
||||||
|
@ -2395,6 +2395,35 @@ test "Screen eraseRows history with more lines" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Screen eraseRows active partial" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try Screen.init(alloc, 5, 5, 0);
|
||||||
|
defer s.deinit();
|
||||||
|
|
||||||
|
try s.testWriteString("1\n2\n3");
|
||||||
|
|
||||||
|
{
|
||||||
|
const str = try s.dumpStringAlloc(alloc, .{ .active = .{} });
|
||||||
|
defer alloc.free(str);
|
||||||
|
try testing.expectEqualStrings("1\n2\n3", str);
|
||||||
|
}
|
||||||
|
|
||||||
|
s.eraseRows(.{ .active = .{} }, .{ .active = .{ .y = 1 } });
|
||||||
|
|
||||||
|
{
|
||||||
|
const str = try s.dumpStringAlloc(alloc, .{ .active = .{} });
|
||||||
|
defer alloc.free(str);
|
||||||
|
try testing.expectEqualStrings("3", str);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const str = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||||
|
defer alloc.free(str);
|
||||||
|
try testing.expectEqualStrings("3", str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test "Screen: clearPrompt" {
|
test "Screen: clearPrompt" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
@ -479,10 +479,9 @@ pub fn clearScreen(self: *Exec, history: bool) !void {
|
|||||||
// If we're not at a prompt, we just delete above the cursor.
|
// If we're not at a prompt, we just delete above the cursor.
|
||||||
if (!self.terminal.cursorIsAtPrompt()) {
|
if (!self.terminal.cursorIsAtPrompt()) {
|
||||||
if (self.terminal.screen.cursor.y > 0) {
|
if (self.terminal.screen.cursor.y > 0) {
|
||||||
self.terminal.screen.clearRows(
|
self.terminal.screen.eraseRows(
|
||||||
.{ .active = .{ .y = 0 } },
|
.{ .active = .{ .y = 0 } },
|
||||||
.{ .active = .{ .y = self.terminal.screen.cursor.y - 1 } },
|
.{ .active = .{ .y = self.terminal.screen.cursor.y - 1 } },
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user