diff --git a/examples/tui.zig b/examples/tui.zig index 7a73d49..4329aa7 100644 --- a/examples/tui.zig +++ b/examples/tui.zig @@ -131,6 +131,8 @@ pub fn main() !void { switch (e) { .tui => { view = tui_view; + // NOTE: report potentially new screen size + view.handle(.{ .resize = renderer.size }); }, } }, diff --git a/src/render.zig b/src/render.zig index e689a82..df17247 100644 --- a/src/render.zig +++ b/src/render.zig @@ -19,13 +19,16 @@ pub fn Direct(comptime fullscreen: bool) type { _ = log; _ = fullscreen; return struct { + size: Size, + pub fn resize(this: *@This(), size: Size) void { - _ = this; - _ = size; + this.size = size; } pub fn clear(this: *@This(), size: Size) !void { _ = this; + // NOTE: clear on the entire screen may introduce too much overhead and could instead clear the entire screen instead. + // - it could also then try to optimize for further *clear* calls, that result in pretty much a nop? -> how to identify those clear calls? // TODO: this should instead by dynamic and correct of size (terminal could be too large currently) std.debug.assert(1028 > size.cols); var buf: [1028]u8 = undefined;