mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
eraseline sets SGR on all cells
This commit is contained in:
@ -550,7 +550,7 @@ pub fn eraseDisplay(self: *Window, mode: terminal.EraseDisplay) !void {
|
||||
}
|
||||
|
||||
pub fn eraseLine(self: *Window, mode: terminal.EraseLine) !void {
|
||||
try self.terminal.eraseLine(mode);
|
||||
try self.terminal.eraseLine(self.alloc, mode);
|
||||
}
|
||||
|
||||
pub fn deleteChars(self: *Window, count: usize) !void {
|
||||
|
@ -243,30 +243,26 @@ pub fn eraseDisplay(
|
||||
/// TODO: test
|
||||
pub fn eraseLine(
|
||||
self: *Terminal,
|
||||
alloc: Allocator,
|
||||
mode: csi.EraseLine,
|
||||
) !void {
|
||||
switch (mode) {
|
||||
.right => {
|
||||
// If our cursor is outside our screen, we can't erase anything.
|
||||
if (self.cursor.y >= self.screen.items.len) return;
|
||||
var line = &self.screen.items[self.cursor.y];
|
||||
|
||||
// If our cursor is outside our screen, we can't erase anything.
|
||||
if (self.cursor.x >= line.items.len) return;
|
||||
|
||||
for (line.items[self.cursor.x..line.items.len]) |*cell|
|
||||
var x: usize = self.cursor.x;
|
||||
while (x < self.cols) : (x += 1) {
|
||||
const cell = try self.getOrPutCell(alloc, x, self.cursor.y);
|
||||
cell.* = self.cursor.pen;
|
||||
cell.char = 0;
|
||||
}
|
||||
},
|
||||
|
||||
.left => {
|
||||
// If our cursor is outside our screen, we can't erase anything.
|
||||
if (self.cursor.y >= self.screen.items.len) return;
|
||||
var line = &self.screen.items[self.cursor.y];
|
||||
|
||||
// Clear up to our cursor
|
||||
const end = @minimum(line.items.len, self.cursor.x);
|
||||
for (line.items[0..end]) |*cell|
|
||||
var x: usize = self.cursor.x;
|
||||
while (x >= 0) : (x -= 1) {
|
||||
const cell = try self.getOrPutCell(alloc, x, self.cursor.y);
|
||||
cell.* = self.cursor.pen;
|
||||
cell.char = 0;
|
||||
}
|
||||
},
|
||||
|
||||
else => {
|
||||
|
Reference in New Issue
Block a user