summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchen <yurenchen@yeah.net>2023-05-02 14:07:27 +0800
committerAlex Goodman <wagoodman@users.noreply.github.com>2023-07-06 11:01:00 -0400
commit77c11047cfe7ccc6b3dc21ce52eaec835071d8c2 (patch)
tree1f18aa8a7f2addf3d61b925deaf1ba5bd58b32c7
parenta7dfbb7927314331bc839e916483a94b912ed2e7 (diff)
feat: add ctrl+z support
-rw-r--r--runtime/ui/app.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/ui/app.go b/runtime/ui/app.go
index 249a3aa..6d07650 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