소스 검색

handle ctrl+z

Michael Yang 1 년 전
부모
커밋
88620e983a
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      readline/readline.go

+ 9 - 0
readline/readline.go

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