mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
terminal/new: decaln manages memory
This commit is contained in:
@ -1723,8 +1723,6 @@ pub fn eraseDisplay(
|
|||||||
///
|
///
|
||||||
/// Sets the cursor to the top left corner.
|
/// Sets the cursor to the top left corner.
|
||||||
pub fn decaln(self: *Terminal) !void {
|
pub fn decaln(self: *Terminal) !void {
|
||||||
// TODO: erase display to gc graphemes, styles
|
|
||||||
|
|
||||||
// Clear our stylistic attributes. This is the only thing that can
|
// Clear our stylistic attributes. This is the only thing that can
|
||||||
// fail so we do it first so we can undo it.
|
// fail so we do it first so we can undo it.
|
||||||
const old_style = self.screen.cursor.style;
|
const old_style = self.screen.cursor.style;
|
||||||
@ -1751,24 +1749,27 @@ pub fn decaln(self: *Terminal) !void {
|
|||||||
// Move our cursor to the top-left
|
// Move our cursor to the top-left
|
||||||
self.setCursorPos(1, 1);
|
self.setCursorPos(1, 1);
|
||||||
|
|
||||||
// Fill with Es, does not move cursor.
|
// Erase the display which will deallocate graphames, styles, etc.
|
||||||
// TODO: cursor across pages
|
self.eraseDisplay(.complete, false);
|
||||||
var page = &self.screen.cursor.page_offset.page.data;
|
|
||||||
const rows: [*]Row = @ptrCast(self.screen.cursor.page_row);
|
|
||||||
for (0..self.rows) |y| {
|
|
||||||
const row: *Row = @ptrCast(rows + y);
|
|
||||||
const cells = page.getCells(row);
|
|
||||||
@memset(cells, .{
|
|
||||||
.content_tag = .codepoint,
|
|
||||||
.content = .{ .codepoint = 'E' },
|
|
||||||
.style_id = self.screen.cursor.style_id,
|
|
||||||
.protected = self.screen.cursor.protected,
|
|
||||||
});
|
|
||||||
|
|
||||||
// If we have a ref-counted style, increase
|
// Fill with Es, does not move cursor.
|
||||||
if (self.screen.cursor.style_ref) |ref| {
|
var it = self.screen.pages.rowChunkIterator(.{ .active = .{} }, null);
|
||||||
ref.* += @intCast(cells.len);
|
while (it.next()) |chunk| {
|
||||||
row.styled = true;
|
for (chunk.rows()) |*row| {
|
||||||
|
const cells_multi: [*]Cell = row.cells.ptr(chunk.page.data.memory);
|
||||||
|
const cells = cells_multi[0..self.cols];
|
||||||
|
@memset(cells, .{
|
||||||
|
.content_tag = .codepoint,
|
||||||
|
.content = .{ .codepoint = 'E' },
|
||||||
|
.style_id = self.screen.cursor.style_id,
|
||||||
|
.protected = self.screen.cursor.protected,
|
||||||
|
});
|
||||||
|
|
||||||
|
// If we have a ref-counted style, increase
|
||||||
|
if (self.screen.cursor.style_ref) |ref| {
|
||||||
|
ref.* += @intCast(cells.len);
|
||||||
|
row.styled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user