"git@developer.sourcefind.cn:zhaoyu6/sglang.git" did not exist on "dfce9269216a170a617437190b7d3049ee388b94"
term_bsd.go 564 Bytes
Newer Older
mashun1's avatar
v1  
mashun1 committed
1
2
3
4
5
6
7
8
9
//go:build darwin || freebsd || netbsd || openbsd

package readline

import (
	"syscall"
	"unsafe"
)

xuxzh1's avatar
init  
xuxzh1 committed
10
func getTermios(fd uintptr) (*Termios, error) {
mashun1's avatar
v1  
mashun1 committed
11
	termios := new(Termios)
xuxzh1's avatar
init  
xuxzh1 committed
12
	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, syscall.TIOCGETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
mashun1's avatar
v1  
mashun1 committed
13
14
15
16
17
18
	if err != 0 {
		return nil, err
	}
	return termios, nil
}

xuxzh1's avatar
init  
xuxzh1 committed
19
20
func setTermios(fd uintptr, termios *Termios) error {
	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, syscall.TIOCSETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
mashun1's avatar
v1  
mashun1 committed
21
22
23
24
25
	if err != 0 {
		return err
	}
	return nil
}