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.

29 lines
734 B

  1. // Copyright 2013 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build darwin dragonfly freebsd netbsd openbsd
  5. package readline
  6. import (
  7. "syscall"
  8. "unsafe"
  9. )
  10. func getTermios(fd int) (*Termios, error) {
  11. termios := new(Termios)
  12. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCGETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
  13. if err != 0 {
  14. return nil, err
  15. }
  16. return termios, nil
  17. }
  18. func setTermios(fd int, termios *Termios) error {
  19. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCSETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
  20. if err != 0 {
  21. return err
  22. }
  23. return nil
  24. }