Files
podman/vendor/github.com/buger/goterm/terminal_windows.go
dependabot[bot] 54cf0f05e3 Bump github.com/buger/goterm from 1.0.1 to 1.0.4
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>
2022-02-04 12:08:41 +00:00

41 lines
807 B
Go

//go:build windows
// +build windows
package goterm
import (
"errors"
"math"
"os"
"golang.org/x/sys/windows"
)
func getWinsize() (*winsize, error) {
ws := new(winsize)
fd := os.Stdout.Fd()
var info windows.ConsoleScreenBufferInfo
if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
return nil, err
}
ws.Col = uint16(info.Window.Right - info.Window.Left + 1)
ws.Row = uint16(info.Window.Bottom - info.Window.Top + 1)
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, windows.WSAEOPNOTSUPP) {
return math.MinInt32
}
return -1
}
return int(ws.Row)
}