Skip to content

Commit

Permalink
feat: add ctrl+z support
Browse files Browse the repository at this point in the history
  • Loading branch information
yurenchen000 authored and wagoodman committed Jul 6, 2023
1 parent a7dfbb7 commit 77c1104
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions runtime/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ui

import (
"sync"
"syscall"

"github.com/wagoodman/dive/dive/image"
"github.com/wagoodman/dive/runtime/ui/key"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 77c1104

Please sign in to comment.