mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
31 lines
572 B
Go
31 lines
572 B
Go
//go:build darwin || freebsd || openbsd || netbsd || dragonfly
|
|
|
|
package util
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
// IsTty checks if the given fd is a tty
|
|
func IsTty(arg any) bool {
|
|
fdsrc, ok := arg.(fder)
|
|
if !ok {
|
|
return false
|
|
}
|
|
fd := fdsrc.Fd()
|
|
|
|
var termios syscall.Termios
|
|
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCGETA), uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
|
return err == 0
|
|
}
|
|
|
|
// TtyReady checks if the tty is ready to go
|
|
func TtyReady() error {
|
|
return nil
|
|
}
|
|
|
|
// TtyTerm restores any state, if necessary
|
|
func TtyTerm() {
|
|
}
|