From 4f5b4e6dbfed097414a8c19bd64855a4ba7075d3 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Fri, 4 Sep 2020 18:25:40 +0300 Subject: [PATCH] remove manual escape delaying mechanism Related #459 --- ui.go | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/ui.go b/ui.go index 03682ec..50fc313 100644 --- a/ui.go +++ b/ui.go @@ -453,52 +453,19 @@ func newUI(screen tcell.Screen) *ui { msgWin: newWin(wtot, 1, 0, htot-1), menuWin: newWin(wtot, 1, 0, htot-2), keyChan: make(chan string, 1000), + evChan: make(chan tcell.Event), styles: parseStyles(), icons: parseIcons(), } - evQueue := make(chan tcell.Event) go func() { var ev tcell.Event for { ev = ui.screen.PollEvent() - evQueue <- ev + ui.evChan <- ev } }() - evChan := make(chan tcell.Event) - go func() { - for { - ev := <-evQueue - // .(type) can't be used outside a switch - switch tev := ev.(type) { - case *tcell.EventKey: - // tcell.KeyESC is one of the few cases we don't need Rune() for - if tev.Key() == tcell.KeyESC { - select { - case ev2 := <-evQueue: - switch tev2 := ev2.(type) { - case *tcell.EventKey: - evChan <- tcell.NewEventKey(tev2.Key(), tev2.Rune(), tcell.ModAlt) - default: - evChan <- ev2 - } - - if ev2 == nil { - return - } - - continue - case <-time.After(100 * time.Millisecond): - } - } - } - evChan <- ev - } - }() - - ui.evChan = evChan - return ui }