summaryrefslogtreecommitdiff
path: root/vendor/github.com/buger/goterm/terminal_sysioctl.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/buger/goterm/terminal_sysioctl.go')
-rw-r--r--vendor/github.com/buger/goterm/terminal_sysioctl.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/vendor/github.com/buger/goterm/terminal_sysioctl.go b/vendor/github.com/buger/goterm/terminal_sysioctl.go
index 33148ede0..8b48b405c 100644
--- a/vendor/github.com/buger/goterm/terminal_sysioctl.go
+++ b/vendor/github.com/buger/goterm/terminal_sysioctl.go
@@ -1,8 +1,11 @@
+//go:build !windows && !plan9 && !solaris
// +build !windows,!plan9,!solaris
package goterm
import (
+ "errors"
+ "math"
"os"
"golang.org/x/sys/unix"
@@ -17,3 +20,17 @@ func getWinsize() (*unix.Winsize, error) {
return ws, nil
}
+
+// Height gets console height
+func Height() int {
+ ws, err := getWinsize()
+ if err != nil {
+ // returns math.MinInt32 if we could not retrieve the height of console window,
+ // like VSCode debugging console
+ if errors.Is(err, unix.EOPNOTSUPP) {
+ return math.MinInt32
+ }
+ return -1
+ }
+ return int(ws.Row)
+}