Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kardolus
GitHub Repository: kardolus/chatgpt-cli
Path: blob/main/vendor/github.com/chzyer/readline/term_nosyscall6.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 aix os400 solaris
6
7
package readline
8
9
import "golang.org/x/sys/unix"
10
11
// GetSize returns the dimensions of the given terminal.
12
func GetSize(fd int) (int, int, error) {
13
ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)
14
if err != nil {
15
return 0, 0, err
16
}
17
return int(ws.Col), int(ws.Row), nil
18
}
19
20
type Termios unix.Termios
21
22
func getTermios(fd int) (*Termios, error) {
23
termios, err := unix.IoctlGetTermios(fd, unix.TCGETS)
24
if err != nil {
25
return nil, err
26
}
27
return (*Termios)(termios), nil
28
}
29
30
func setTermios(fd int, termios *Termios) error {
31
return unix.IoctlSetTermios(fd, unix.TCSETSF, (*unix.Termios)(termios))
32
}
33
34