mirror of
https://github.com/containers/podman.git
synced 2025-08-06 03:19:52 +08:00
![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [github.com/buger/goterm](https://github.com/buger/goterm) from 1.0.1 to 1.0.4. - [Release notes](https://github.com/buger/goterm/releases) - [Commits](https://github.com/buger/goterm/compare/v1.0.1...v1.0.4) --- updated-dependencies: - dependency-name: github.com/buger/goterm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
37 lines
676 B
Go
37 lines
676 B
Go
//go:build !windows && !plan9 && !solaris
|
|
// +build !windows,!plan9,!solaris
|
|
|
|
package goterm
|
|
|
|
import (
|
|
"errors"
|
|
"math"
|
|
"os"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func getWinsize() (*unix.Winsize, error) {
|
|
|
|
ws, err := unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ)
|
|
if err != nil {
|
|
return nil, os.NewSyscallError("GetWinsize", err)
|
|
}
|
|
|
|
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)
|
|
}
|