|
@@ -128,21 +128,21 @@ func SetWinsize(fd uintptr, ws *Winsize) error {
|
|
|
}
|
|
|
|
|
|
// IsTerminal returns true if the given file descriptor is a terminal.
|
|
|
-func IsTerminal(fd int) bool {
|
|
|
+func IsTerminal(fd uintptr) bool {
|
|
|
var termios Termios
|
|
|
- _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(getTermios), uintptr(unsafe.Pointer(&termios)))
|
|
|
+ _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&termios)))
|
|
|
return err == 0
|
|
|
}
|
|
|
|
|
|
// Restore restores the terminal connected to the given file descriptor to a
|
|
|
// previous state.
|
|
|
-func Restore(fd int, state *State) error {
|
|
|
- _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(setTermios), uintptr(unsafe.Pointer(&state.termios)))
|
|
|
+func Restore(fd uintptr, state *State) error {
|
|
|
+ _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&state.termios)))
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
func SetRawTerminal() (*State, error) {
|
|
|
- oldState, err := MakeRaw(int(os.Stdin.Fd()))
|
|
|
+ oldState, err := MakeRaw(os.Stdin.Fd())
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -150,12 +150,12 @@ func SetRawTerminal() (*State, error) {
|
|
|
signal.Notify(c, os.Interrupt)
|
|
|
go func() {
|
|
|
_ = <-c
|
|
|
- Restore(int(os.Stdin.Fd()), oldState)
|
|
|
+ Restore(os.Stdin.Fd(), oldState)
|
|
|
os.Exit(0)
|
|
|
}()
|
|
|
return oldState, err
|
|
|
}
|
|
|
|
|
|
func RestoreTerminal(state *State) {
|
|
|
- Restore(int(os.Stdin.Fd()), state)
|
|
|
+ Restore(os.Stdin.Fd(), state)
|
|
|
}
|