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

16
main.go
View File

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