new readline library (#847)

This commit is contained in:
Patrick Devine
2023-10-25 16:41:18 -07:00
committed by GitHub
parent 49443e7da5
commit deeac961bb
11 changed files with 972 additions and 86 deletions

24
readline/term_bsd.go Normal file
View File

@@ -0,0 +1,24 @@
// go build darwin dragonfly freebsd netbsd openbsd
package readline
import (
"syscall"
"unsafe"
)
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
}