From e8ce48c8d92b57928fc79fceba2dedbce63672d0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 24 Jun 2022 09:57:07 -0700 Subject: [PATCH] erase display above --- src/terminal/Terminal.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 6c93206ea..68080637e 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -284,6 +284,27 @@ pub fn eraseDisplay( } }, + .above => { + // Erase to the left (including the cursor) + var x: usize = 0; + while (x <= self.cursor.x) : (x += 1) { + const cell = try self.getOrPutCell(alloc, x, self.cursor.y); + cell.* = self.cursor.pen; + cell.char = 0; + } + + // All lines above + var y: usize = 0; + while (y < self.cursor.y) : (y += 1) { + x = 0; + while (x < self.cols) : (x += 1) { + const cell = try self.getOrPutCell(alloc, x, y); + cell.* = self.cursor.pen; + cell.char = 0; + } + } + }, + else => { log.err("unimplemented display mode: {}", .{mode}); @panic("unimplemented");