Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kardolus
GitHub Repository: kardolus/chatgpt-cli
Path: blob/main/vendor/github.com/chzyer/readline/term_bsd.go
2875 views
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
5
// +build darwin dragonfly freebsd netbsd openbsd
6
7
package readline
8
9
import (
10
"syscall"
11
"unsafe"
12
)
13
14
func getTermios(fd int) (*Termios, error) {
15
termios := new(Termios)
16
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCGETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
17
if err != 0 {
18
return nil, err
19
}
20
return termios, nil
21
}
22
23
func setTermios(fd int, termios *Termios) error {
24
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCSETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0)
25
if err != 0 {
26
return err
27
}
28
return nil
29
}
30
31