summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-08-14 08:33:40 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-08-14 08:33:40 +1000
commit047892962a8f4f2f5acfb5e16ec9a14415316308 (patch)
tree7850b508e3ffbde1c004aca28293c78699e3bc53 /pkg/gui/gui.go
parentd4f4b46a1f3a0d5aa2f430be931874dedc715ee2 (diff)
centralise subprocess code to gui.go
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r--pkg/gui/gui.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index c607ba79e..9cd7d35e6 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -6,7 +6,9 @@ import (
// "io/ioutil"
"errors"
+ "io/ioutil"
"log"
+ "os"
"os/exec"
"runtime"
"strings"
@@ -31,7 +33,7 @@ var (
// Gui wraps the gocui Gui object which handles rendering and events
type Gui struct {
- Gui *gocui.Gui
+ g *gocui.Gui
Log *logrus.Logger
GitCommand *commands.GitCommand
OSCommand *commands.OSCommand
@@ -309,6 +311,8 @@ func (gui *Gui) Run() error {
}
defer g.Close()
+ gui.g = g // TODO: always use gui.g rather than passing g around everywhere
+
g.FgColor = gocui.ColorDefault
gui.goEvery(g, time.Second*60, gui.fetch)
@@ -334,7 +338,13 @@ func (gui *Gui) RunWithSubprocesses() {
if err == gocui.ErrQuit {
break
} else if err == ErrSubProcess {
+ gui.SubProcess.Stdin = os.Stdin
+ gui.SubProcess.Stdout = os.Stdout
+ gui.SubProcess.Stderr = os.Stderr
gui.SubProcess.Run()
+ gui.SubProcess.Stdout = ioutil.Discard
+ gui.SubProcess.Stderr = ioutil.Discard
+ gui.SubProcess.Stdin = nil
gui.SubProcess = nil
} else {
log.Panicln(err)