os specific ctrl-z (#1420)

This commit is contained in:
Bruce MacDonald 2023-12-11 10:48:14 -05:00 committed by GitHub
parent 5d4d2e2c60
commit 7a1b37ac64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 8 deletions

View file

@ -192,14 +192,7 @@ func (i *Instance) Readline() (string, error) {
case CharCtrlW:
buf.DeleteWord()
case CharCtrlZ:
if err := UnsetRawMode(fd, termios); err != nil {
return "", err
}
syscall.Kill(0, syscall.SIGSTOP)
// on resume...
return "", nil
return handleCharCtrlZ(fd, termios)
case CharEnter:
output := buf.String()
if output != "" {

18
readline/readline_unix.go Normal file
View file

@ -0,0 +1,18 @@
//go:build !windows
package readline
import (
"syscall"
)
func handleCharCtrlZ(fd int, termios *Termios) (string, error) {
if err := UnsetRawMode(fd, termios); err != nil {
return "", err
}
syscall.Kill(0, syscall.SIGSTOP)
// on resume...
return "", nil
}

View file

@ -0,0 +1,6 @@
package readline
func handleCharCtrlZ(fd int, state *State) (string, error) {
// not supported
return "", nil
}