Calendar only scrolls automatically if viewing the current month
This commit is contained in:
parent
a71fb3de4b
commit
b819da0419
8
main.go
8
main.go
@ -123,16 +123,22 @@ 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()
|
||||||
redraw()
|
redraw()
|
||||||
|
Loading…
Reference in New Issue
Block a user