From 13e9dadbb164d74e98cb7c09787d83fcdc2d036e Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 19 Jan 2024 13:16:53 -0600 Subject: [PATCH] window: implement fill Signed-off-by: Tim Culverhouse --- src/Window.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Window.zig b/src/Window.zig index 3321bb3..6a8ab0b 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -67,12 +67,18 @@ pub fn writeCell(self: Window, col: usize, row: usize, cell: Cell) void { self.screen.writeCell(col + self.x_off, row + self.y_off, cell); } +/// fills the window with the default cell pub fn clear(self: Window) void { + self.fill(.{}); +} + +/// fills the window with the provided cell +pub fn fill(self: Window, cell: Cell) void { var row: usize = self.y_off; while (row < (self.height + self.y_off)) : (row += 1) { var col: usize = self.x_off; while (col < (self.width + self.x_off)) : (col += 1) { - self.screen.writeCell(col, row, .{}); + self.screen.writeCell(col, row, cell); } } }