You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
564 B
26 lines
564 B
3 weeks ago
|
//go:build darwin || freebsd || netbsd || openbsd
|
||
|
|
||
|
package readline
|
||
|
|
||
|
import (
|
||
|
"syscall"
|
||
|
"unsafe"
|
||
|
)
|
||
|
|
||
|
func getTermios(fd uintptr) (*Termios, error) {
|
||
|
termios := new(Termios)
|
||
|
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, syscall.TIOCGETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
|
||
|
if err != 0 {
|
||
|
return nil, err
|
||
|
}
|
||
|
return termios, nil
|
||
|
}
|
||
|
|
||
|
func setTermios(fd uintptr, termios *Termios) error {
|
||
|
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, syscall.TIOCSETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
|
||
|
if err != 0 {
|
||
|
return err
|
||
|
}
|
||
|
return nil
|
||
|
}
|