mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
eraseDisplay honors sgr
This commit is contained in:
@ -207,29 +207,36 @@ pub fn eraseDisplay(
|
|||||||
) !void {
|
) !void {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
.complete => {
|
.complete => {
|
||||||
for (self.screen.items) |*line| line.deinit(alloc);
|
var y: usize = 0;
|
||||||
self.screen.clearRetainingCapacity();
|
while (y < self.rows) : (y += 1) {
|
||||||
|
var x: usize = 0;
|
||||||
|
while (x < self.cols) : (x += 1) {
|
||||||
|
const cell = try self.getOrPutCell(alloc, x, y);
|
||||||
|
cell.* = self.cursor.pen;
|
||||||
|
cell.char = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
.below => {
|
.below => {
|
||||||
// If our cursor is outside our screen, we can't erase anything.
|
// All lines to the right (including the cursor)
|
||||||
if (self.cursor.y >= self.screen.items.len) return;
|
var x: usize = self.cursor.x;
|
||||||
var line = &self.screen.items[self.cursor.y];
|
while (x < self.cols) : (x += 1) {
|
||||||
|
const cell = try self.getOrPutCell(alloc, x, self.cursor.y);
|
||||||
// Clear this line right (including the cursor)
|
cell.* = self.cursor.pen;
|
||||||
if (self.cursor.x < line.items.len) {
|
|
||||||
for (line.items[self.cursor.x..line.items.len]) |*cell|
|
|
||||||
cell.char = 0;
|
cell.char = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remaining lines are deallocated
|
// All lines below
|
||||||
if (self.cursor.y + 1 < self.screen.items.len) {
|
var y: usize = self.cursor.y + 1;
|
||||||
for (self.screen.items[self.cursor.y + 1 .. self.screen.items.len]) |*below|
|
while (y < self.rows) : (y += 1) {
|
||||||
below.deinit(alloc);
|
x = 0;
|
||||||
|
while (x < self.cols) : (x += 1) {
|
||||||
|
const cell = try self.getOrPutCell(alloc, x, y);
|
||||||
|
cell.* = self.cursor.pen;
|
||||||
|
cell.char = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shrink
|
|
||||||
self.screen.shrinkRetainingCapacity(self.cursor.y + 1);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
else => {
|
else => {
|
||||||
|
@ -48,7 +48,7 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
//log.debug("char: {}", .{c});
|
//log.debug("char: {}", .{c});
|
||||||
const actions = self.parser.next(c);
|
const actions = self.parser.next(c);
|
||||||
for (actions) |action_opt| {
|
for (actions) |action_opt| {
|
||||||
// if (action_opt) |action| log.info("action: {}", .{action});
|
if (action_opt) |action| log.info("action: {}", .{action});
|
||||||
switch (action_opt orelse continue) {
|
switch (action_opt orelse continue) {
|
||||||
.print => |p| if (@hasDecl(T, "print")) try self.handler.print(p),
|
.print => |p| if (@hasDecl(T, "print")) try self.handler.print(p),
|
||||||
.execute => |code| try self.execute(code),
|
.execute => |code| try self.execute(code),
|
||||||
|
Reference in New Issue
Block a user