resume with a new goroutine instead of busy wait

Related #461
This commit is contained in:
Gokcehan 2020-09-05 12:36:31 +03:00
parent f1f28018a6
commit ebf3bcc76b

21
ui.go
View File

@ -520,17 +520,22 @@ func newUI(screen tcell.Screen) *ui {
icons: parseIcons(), icons: parseIcons(),
} }
go func() { go ui.pollEvents()
var ev tcell.Event
for {
ev = ui.screen.PollEvent()
ui.evChan <- ev
}
}()
return ui return ui
} }
func (ui *ui) pollEvents() {
var ev tcell.Event
for {
ev = ui.screen.PollEvent()
if ev == nil {
return
}
ui.evChan <- ev
}
}
func (ui *ui) renew() { func (ui *ui) renew() {
wtot, htot := ui.screen.Size() wtot, htot := ui.screen.Size()
@ -1058,6 +1063,8 @@ func (ui *ui) resume() {
ui.screen = screen ui.screen = screen
go ui.pollEvents()
ui.renew() ui.renew()
} }