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

26
readline/term_linux.go Normal file
View File

@@ -0,0 +1,26 @@
package readline
import (
"syscall"
"unsafe"
)
const tcgets = 0x5401
const tcsets = 0x5402
func getTermios(fd int) (*Termios, error) {
termios := new(Termios)
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), tcgets, 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), tcsets, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
if err != 0 {
return err
}
return nil
}