2016-11-14 08:16:44 +01:00
|
|
|
// Copyright 2013 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// +build darwin dragonfly freebsd netbsd openbsd
|
|
|
|
|
|
|
|
package readline
|
|
|
|
|
2019-08-10 00:49:03 +02:00
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
"unsafe"
|
|
|
|
)
|
2016-11-14 08:16:44 +01:00
|
|
|
|
2019-08-10 00:49:03 +02:00
|
|
|
func getTermios(fd int) (*Termios, error) {
|
|
|
|
termios := new(Termios)
|
|
|
|
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCGETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
|
|
|
|
if err != 0 {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return termios, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func setTermios(fd int, termios *Termios) error {
|
|
|
|
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCSETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
|
|
|
|
if err != 0 {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|