Calendar only scrolls automatically if viewing the current month

This commit is contained in:
Sasha Koshka 2022-11-28 17:21:28 -05:00
parent a71fb3de4b
commit b819da0419
1 changed files with 11 additions and 5 deletions

16
main.go
View File

@ -123,15 +123,21 @@ func tick () {
time.Sleep(time.Second)
drawMutex.Lock()
pageSize := columns * rows
within :=
currentMonth >= viewingMonth &&
currentMonth < viewingMonth + pageSize
newMonth := canonMonth(time.Now())
if currentMonth != newMonth {
currentMonth = newMonth
pageSize := columns * rows
if currentMonth < viewingMonth {
viewingMonth -= pageSize
} else if currentMonth >= viewingMonth + pageSize {
viewingMonth += pageSize
if within {
if currentMonth < viewingMonth {
viewingMonth -= pageSize
} else if currentMonth >= viewingMonth + pageSize {
viewingMonth += pageSize
}
}
application.Clear()