summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-03-03 14:20:25 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-03-03 14:20:25 +1100
commitf68166e85883fbeb61dde72e74e18a9317ef449b (patch)
treec656aa93e115ab05f51e6f6dd881d7a030311d33 /vendor
parent8925b161a75aed3162292c2ed0e2c0135fd91a54 (diff)
bump gocui to stop polling events after closing the gui when switching to a subprocess
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/jesseduffield/gocui/gui.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go
index 41599a9be..1dcb237b7 100644
--- a/vendor/github.com/jesseduffield/gocui/gui.go
+++ b/vendor/github.com/jesseduffield/gocui/gui.go
@@ -49,6 +49,7 @@ type Gui struct {
keybindings []*keybinding
maxX, maxY int
outputMode OutputMode
+ stop chan struct{}
// BgColor and FgColor allow to configure the background and foreground
// colors of the GUI.
@@ -92,6 +93,8 @@ func NewGui(mode OutputMode, supportOverlaps bool) (*Gui, error) {
g.outputMode = mode
termbox.SetOutputMode(termbox.OutputMode(mode))
+ g.stop = make(chan struct{}, 0)
+
g.tbEvents = make(chan termbox.Event, 20)
g.userEvents = make(chan userEvent, 20)
@@ -110,6 +113,9 @@ func NewGui(mode OutputMode, supportOverlaps bool) (*Gui, error) {
// Close finalizes the library. It should be called after a successful
// initialization and when gocui is not needed anymore.
func (g *Gui) Close() {
+ go func() {
+ g.stop <- struct{}{}
+ }()
termbox.Close()
}
@@ -371,9 +377,15 @@ func (g *Gui) MainLoop() error {
if err := g.flush(); err != nil {
return err
}
+
go func() {
for {
- g.tbEvents <- termbox.PollEvent()
+ select {
+ case <-g.stop:
+ return
+ default:
+ g.tbEvents <- termbox.PollEvent()
+ }
}
}()