From 642ebcf077621b3a674ccae2b8efffecab58b4b4 Mon Sep 17 00:00:00 2001 From: shy Date: Thu, 8 Apr 2021 12:32:37 +0200 Subject: [PATCH] Don't panic at tiny screen sizes. --- src/layout.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/layout.rs b/src/layout.rs index 2fd6f09..e9bb1d6 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -69,11 +69,11 @@ impl Layout { // Compute the position of various elements based on the size of the // terminal. fn compute(&mut self, display_hours: bool) { - let middle: u16 = self.height / 2 - 1; - - // Prevent integer overflow on very low screen sizes. + // Prevent integer overflow at very low screen sizes. if self.width < MIN_WIDTH || self.height < MIN_HEIGHT { return; } + let middle: u16 = self.height / 2 - 1; + if display_hours { // Seconds digits. self.clock_sec.col = (self.width + self.roster_width) / 2 + DIGIT_WIDTH + 6;