From 4e40e32f5977093bb14c6ceb1cc1105b6731b12a Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 5 Aug 2024 18:33:22 +0200 Subject: [PATCH] Slightly refactor resolution check Signed-off-by: AnErrupTion --- src/main.zig | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main.zig b/src/main.zig index 2ef4965..0089ec8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -347,18 +347,11 @@ pub fn main() !void { const width: usize = @intCast(termbox.tb_width()); const height: usize = @intCast(termbox.tb_height()); - if (width != buffer.width) { + if (width != buffer.width or height != buffer.height) { + // If it did change, then update the cell buffer, reallocate the current animation's buffers, and force a draw update + buffer.width = width; - resolution_changed = true; - } - - if (height != buffer.height) { buffer.height = height; - resolution_changed = true; - } - - // If it did change, then update the cell buffer, reallocate the current animation's buffers, and force a draw update - if (resolution_changed) { buffer.buffer = termbox.tb_cell_buffer(); switch (config.animation) { @@ -372,6 +365,7 @@ pub fn main() !void { } update = true; + resolution_changed = true; } }