From 394c8f9b9d92fc73238432e83d87a5b1506315c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20Kapri=C5=A1?= Date: Tue, 30 Nov 2021 07:53:27 +0100 Subject: [PATCH] Make monthsWide and monthsHigh global variables --- Main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Main.go b/Main.go index 22a9263..6cfed50 100644 --- a/Main.go +++ b/Main.go @@ -34,6 +34,10 @@ var ( defStyle tcell.Style todayStyle tcell.Style selStyle tcell.Style + + monthsWide int + monthsHigh int + monthsDrawn int ) var ( @@ -125,9 +129,9 @@ func drawWall() { wrappedText("Екран је премали за календар.", wall, defStyle) return } - monthsWide := (w - 2*smallGap + largeGap) / (maxMonthWidth + largeGap) - monthsHigh := (h - smallGap - titleHeight) / (maxMonthHeight + smallGap) - monthsDrawn := min(monthsHigh*monthsWide, 12) // TODO: izraziti 12 drugacije?? + monthsWide = (w - 2*smallGap + largeGap) / (maxMonthWidth + largeGap) + monthsHigh = (h - smallGap - titleHeight) / (maxMonthHeight + smallGap) + monthsDrawn = min(monthsHigh*monthsWide, 12) startingMonth := time.Month((int(selTime.Month())-1)/monthsDrawn*monthsDrawn + 1) endingMonth := time.Month(min(12, int(startingMonth)+monthsDrawn-1))