Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kardolus
GitHub Repository: kardolus/chatgpt-cli
Path: blob/main/vendor/github.com/chzyer/readline/term_unix.go
2875 views
1
// Copyright 2011 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 linux,!appengine netbsd openbsd
6
7
package readline
8
9
import (
10
"syscall"
11
"unsafe"
12
)
13
14
type Termios syscall.Termios
15
16
// GetSize returns the dimensions of the given terminal.
17
func GetSize(fd int) (int, int, error) {
18
var dimensions [4]uint16
19
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0)
20
if err != 0 {
21
return 0, 0, err
22
}
23
return int(dimensions[1]), int(dimensions[0]), nil
24
}
25
26