term_bsd.go 564 B

1234567891011121314151617181920212223242526
  1. //go:build darwin || freebsd || netbsd || openbsd
  2. package readline
  3. import (
  4. "syscall"
  5. "unsafe"
  6. )
  7. func getTermios(fd uintptr) (*Termios, error) {
  8. termios := new(Termios)
  9. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, syscall.TIOCGETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
  10. if err != 0 {
  11. return nil, err
  12. }
  13. return termios, nil
  14. }
  15. func setTermios(fd uintptr, termios *Termios) error {
  16. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, syscall.TIOCSETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
  17. if err != 0 {
  18. return err
  19. }
  20. return nil
  21. }