Make monthsWide and monthsHigh global variables

This commit is contained in:
Petar Kapriš 2021-11-30 07:53:27 +01:00 committed by Петар Каприш
parent 9dd937ad68
commit 394c8f9b9d

10
Main.go
View file

@ -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))