From 61a10f5cc7a3eb048d64cf271b5440e564ca6d5b Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 8 Jun 2019 14:01:48 +1000 Subject: [PATCH] return to the same panel after switching to a subprocess --- pkg/gui/containers_panel.go | 2 -- pkg/gui/layout.go | 7 ++++--- pkg/gui/subprocess.go | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/gui/containers_panel.go b/pkg/gui/containers_panel.go index 23bb96dd..f008ddeb 100644 --- a/pkg/gui/containers_panel.go +++ b/pkg/gui/containers_panel.go @@ -211,7 +211,6 @@ func (gui *Gui) renderLogsForTTYContainer(container *commands.Container) error { gui.clearMainView() command := utils.ApplyTemplate(gui.Config.UserConfig.CommandTemplates.ContainerTTYLogs, container) - gui.Log.Warn(command) cmd := gui.OSCommand.RunCustomCommand(command) // for some reason just saying cmd.Stdout = mainView does not work here as it does for non-tty containers, so we feed it through line by line @@ -226,7 +225,6 @@ func (gui *Gui) renderLogsForTTYContainer(container *commands.Container) error { for s.Scan() { // I might put a check on the stopped channel here. Would mean more code duplication though mainView.Write(append(s.Bytes(), '\n')) - gui.Log.Warn(s.Text()) } }() diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index de98b0c6..eb2126d6 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -222,11 +222,12 @@ func (gui *Gui) layout(g *gocui.Gui) error { } if gui.g.CurrentView() == nil { - if _, err := gui.g.SetCurrentView(gui.getContainersView().Name()); err != nil { - return err + v, err := gui.g.View(gui.State.PreviousView) + if err != nil { + v = gui.getServicesView() } - if err := gui.switchFocus(gui.g, nil, gui.getServicesView()); err != nil { + if err := gui.switchFocus(gui.g, nil, v); err != nil { return err } } diff --git a/pkg/gui/subprocess.go b/pkg/gui/subprocess.go index 28f005d2..5098e8ea 100644 --- a/pkg/gui/subprocess.go +++ b/pkg/gui/subprocess.go @@ -33,6 +33,8 @@ func (gui *Gui) RunWithSubprocesses() error { } func (gui *Gui) runCommand() error { + gui.State.PreviousView = gui.currentViewName() + gui.SubProcess.Stdout = os.Stdout gui.SubProcess.Stderr = os.Stdout gui.SubProcess.Stdin = os.Stdin