diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 94910e970..28bfc9b90 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -74,6 +74,11 @@ pub fn rowIterator(self: *const Screen) RowIterator { return .{ .screen = self, .index = 0 }; } +/// Get the visible portion of the screen. +pub fn getVisible(self: Screen) []Cell { + return self.storage; +} + /// Get a single row by index (0-indexed). pub fn getRow(self: Screen, idx: usize) Row { // Get the index of the first byte of the the row at index. diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index c6599ef4d..00dda19d7 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -223,15 +223,8 @@ pub fn eraseDisplay( ) !void { switch (mode) { .complete => { - var y: usize = 0; - 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; - } - } + const all = self.screen.getVisible(); + std.mem.set(Screen.Cell, all, self.cursor.pen); }, .below => {