apply fix for terminal issue

This commit is contained in:
kayos 2021-07-11 18:46:37 -07:00
parent 82a9122745
commit b9ab36ebe2
2 changed files with 7 additions and 5 deletions

View File

@ -25,5 +25,5 @@ func SetRaw(fd int) error {
n.Cc[syscall.VMIN] = 1
n.Cc[syscall.VTIME] = 0
return termios.Tcsetattr(uintptr(fd), termios.TCSANOW, (*unix.Termios)(n))
return termios.Tcsetattr(uintptr(fd), termios.TCSANOW, (*unix.Termios)(&n))
}

View File

@ -10,16 +10,18 @@ import (
)
var (
saveTermios *unix.Termios
saveTermios unix.Termios
saveTermiosFD int
saveTermiosOnce sync.Once
)
func getOriginalTermios(fd int) (*unix.Termios, error) {
func getOriginalTermios(fd int) (unix.Termios, error) {
var err error
saveTermiosOnce.Do(func() {
saveTermiosFD = fd
saveTermios, err = termios.Tcgetattr(uintptr(fd))
var saveTermiosPtr *unix.Termios
saveTermiosPtr, err = termios.Tcgetattr(uintptr(fd))
saveTermios = *saveTermiosPtr
})
return saveTermios, err
}
@ -30,5 +32,5 @@ func Restore() error {
if err != nil {
return err
}
return termios.Tcsetattr(uintptr(saveTermiosFD), termios.TCSANOW, o)
return termios.Tcsetattr(uintptr(saveTermiosFD), termios.TCSANOW, &o)
}