diff --git a/runtime/ui/app.go b/runtime/ui/app.go index 249a3aa1..6d07650a 100644 --- a/runtime/ui/app.go +++ b/runtime/ui/app.go @@ -2,6 +2,7 @@ package ui import ( "sync" + "syscall" "github.com/wagoodman/dive/dive/image" "github.com/wagoodman/dive/runtime/ui/key" @@ -135,6 +136,14 @@ func (a *app) quit() error { return gocui.ErrQuit } +// handle ctrl+z +func handle_ctrl_z(g *gocui.Gui, v *gocui.View) error { + gocui.Suspend() + syscall.Kill(syscall.Getpid(), syscall.SIGSTOP) + gocui.Resume() + return nil +} + // Run is the UI entrypoint. func Run(imageName string, analysis *image.AnalysisResult, treeStack filetree.Comparer) error { var err error @@ -150,6 +159,11 @@ func Run(imageName string, analysis *image.AnalysisResult, treeStack filetree.Co return err } + key, mod := gocui.MustParse("Ctrl+Z") + if err := g.SetKeybinding("", key, mod, handle_ctrl_z); err != nil { + return err + } + if err := g.MainLoop(); err != nil && err != gocui.ErrQuit { logrus.Error("main loop error: ", err) return err