#287 Display hotkeys to detach from the container

This commit is contained in:
glendsoza 2022-12-10 18:32:59 +05:30
parent 17fcdb2b20
commit 6bd5a6099b
2 changed files with 10 additions and 4 deletions

View file

@ -409,7 +409,7 @@ func (gui *Gui) handleContainerAttach(g *gocui.Gui, v *gocui.View) error {
return gui.createErrorPanel(err.Error())
}
return gui.runSubprocess(c)
return gui.runSubprocessWithMessage (c, "By default, to detach from the container press ctrl-p then ctrl-q")
}
func (gui *Gui) handlePruneContainers() error {

View file

@ -13,6 +13,10 @@ import (
)
func (gui *Gui) runSubprocess(cmd *exec.Cmd) error {
return gui.runSubprocessWithMessage(cmd, "")
}
func (gui *Gui) runSubprocessWithMessage(cmd *exec.Cmd, msg string) error {
gui.Mutexes.SubprocessMutex.Lock()
defer gui.Mutexes.SubprocessMutex.Unlock()
@ -22,7 +26,7 @@ func (gui *Gui) runSubprocess(cmd *exec.Cmd) error {
gui.PauseBackgroundThreads = true
gui.runCommand(cmd)
gui.runCommand(cmd, msg)
if err := gui.g.Resume(); err != nil {
return gui.createErrorPanel(err.Error())
@ -33,7 +37,7 @@ func (gui *Gui) runSubprocess(cmd *exec.Cmd) error {
return nil
}
func (gui *Gui) runCommand(cmd *exec.Cmd) {
func (gui *Gui) runCommand(cmd *exec.Cmd, msg string) {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stdout
cmd.Stdin = os.Stdin
@ -51,7 +55,9 @@ func (gui *Gui) runCommand(cmd *exec.Cmd) {
}()
fmt.Fprintf(os.Stdout, "\n%s\n\n", utils.ColoredString("+ "+strings.Join(cmd.Args, " "), color.FgBlue))
if msg != "" {
fmt.Fprintf(os.Stdout, "\n%s\n\n", utils.ColoredString(msg, color.FgGreen))
}
if err := cmd.Run(); err != nil {
// not handling the error explicitly because usually we're going to see it
// in the output anyway