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

15
ui.go
View File

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