Skip to content

Commit

Permalink
fix: move terminal size check
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesrocket committed Jun 19, 2024
1 parent 387eae0 commit 4351094
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ fn animation(core: *Core, handler: *Handler) !void {
std.time.sleep(FRAME);
}

if (core.width < 4 or core.height < 2) {
std.log.warn("Insufficient terminal dimensions: W {}, H {}", .{ core.width, core.height });
core.active = false;
}

while (core.active) {
try printCells(core, handler, mode, rand);
}
Expand Down Expand Up @@ -301,12 +306,6 @@ pub fn main() !void {
core.width = tb.tb_width();
core.height = tb.tb_height();

if (core.width < 4 or core.height < 2) {
_ = tb.tb_shutdown();
std.debug.print("Insufficient terminal dimensions: W {}, H {}\nExiting\n", .{ core.width, core.height });
std.process.exit(0);
}

{
const t_h = try std.Thread.spawn(.{}, Handler.run, .{ &handler, &core });
defer t_h.join();
Expand Down

0 comments on commit 4351094

Please sign in to comment.