mod(renderer): dynamic clear of size for widgets to improve render performance
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 35s

This commit is contained in:
2024-11-13 15:07:26 +01:00
parent 80459a51b1
commit 270ca9b1be
4 changed files with 39 additions and 14 deletions

View File

@@ -128,12 +128,19 @@ pub fn Direct(comptime _: bool) type {
_ = this;
_ = size;
}
pub fn clear(this: *@This(), size: Size) !void {
_ = this;
const anchor = size.anchor;
// NOTE: clear entire screen for the first content (derived from the anchor being at the very left-top)
if (anchor.col == 1 and anchor.row == 1) {
try terminal.clearScreen();
std.debug.assert(1028 > size.cols);
var buf: [1028]u8 = undefined;
@memset(buf[0..], ' ');
for (0..size.rows) |r| {
const row: u16 = @truncate(r);
try terminal.setCursorPosition(.{
.col = size.anchor.col,
.row = size.anchor.row + row,
});
_ = try terminal.write(buf[0..size.cols]);
}
}