added patch from user for ctrl-z

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-06 20:45:08 -06:00
parent 6b8ff221a8
commit 71bbdd8487
1 changed files with 16 additions and 0 deletions

View File

@ -5,15 +5,31 @@
package main
import (
"syscall"
"github.com/awesome-gocui/gocui"
"go.wit.com/log"
)
// handle ctrl+z
func handle_ctrl_z(g *gocui.Gui, v *gocui.View) error {
gocui.Suspend()
log.Info("got ctrl+z")
syscall.Kill(syscall.Getpid(), syscall.SIGSTOP)
gocui.Resume()
return nil
}
func defaultKeybindings(g *gocui.Gui) error {
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
return err
}
// setup ctrl+z
keyForced, modForced := gocui.MustParse("ctrl+z")
if err := g.SetKeybinding("", keyForced, modForced, handle_ctrl_z); err != nil {
log.Error(err)
}
for _, n := range []string{"but1", "but2", "help", "but3"} {
if err := g.SetKeybinding(n, gocui.MouseLeft, gocui.ModNone, showMsg); err != nil {
return err