From 71bbdd8487293080175eb963a233dbfa68cedc9b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 6 Feb 2024 20:45:08 -0600 Subject: [PATCH] added patch from user for ctrl-z Signed-off-by: Jeff Carr --- keybindings.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/keybindings.go b/keybindings.go index b126479..a4f33dc 100644 --- a/keybindings.go +++ b/keybindings.go @@ -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