close termbox during skipping commands

Mentioned in #8.
This commit is contained in:
Gokcehan 2016-08-27 00:20:08 +03:00
parent d9583187e5
commit df6c23769f
2 changed files with 4 additions and 17 deletions

13
app.go
View File

@ -84,9 +84,9 @@ func (app *App) exportVars() {
// This function is used to run a command in shell. Following modes are used:
//
// Prefix Wait Async Stdin/Stdout/Stderr UI action (before/after)
// $ No No Yes Do nothing and then sync
// ! Yes No Yes pause and then resume
// Prefix Wait Async Stdin/Stdout/Stderr UI action
// $ No No Yes Pause and then resume
// ! Yes No Yes Pause and then resume
// & No Yes No Do nothing
//
// Waiting async commands are not used for now.
@ -104,17 +104,12 @@ func (app *App) runShell(s string, args []string, wait bool, async bool) {
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
}
if wait {
app.ui.pause()
defer app.ui.resume()
} else {
defer app.ui.sync()
defer app.nav.renew(app.ui.wins[0].h)
}
defer app.nav.renew(app.ui.wins[0].h)
var err error
if async {
err = cmd.Start()

8
ui.go
View File

@ -490,14 +490,6 @@ func (ui *UI) sync() {
if err := termbox.Sync(); err != nil {
log.Printf("syncing termbox: %s", err)
}
termbox.SetCursor(0, 0)
termbox.HideCursor()
// TODO: is there an easier way to clear residual escape codes?
termbox.Close()
if err := termbox.Init(); err != nil {
log.Fatalf("initializing termbox: %s", err)
}
}
func (ui *UI) showMenu(b *bytes.Buffer) {