term_bsd.go 574 B

12345678910111213141516171819202122232425
  1. //go:build darwin || freebsd || netbsd || openbsd
  2. package readline
  3. import (
  4. "syscall"
  5. "unsafe"
  6. )
  7. func getTermios(fd int) (*Termios, error) {
  8. termios := new(Termios)
  9. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(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 int, termios *Termios) error {
  16. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCSETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
  17. if err != 0 {
  18. return err
  19. }
  20. return nil
  21. }