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>
This commit is contained in:
dependabot[bot]
2022-02-04 12:08:41 +00:00
committed by GitHub
parent 608b6142ed
commit 54cf0f05e3
8 changed files with 49 additions and 13 deletions

View File

@@ -1 +1,2 @@
*.swp
.idea

View File

@@ -199,15 +199,6 @@ func Width() int {
return int(ws.Col)
}
// Height gets console height
func Height() int {
ws, err := getWinsize()
if err != nil {
return -1
}
return int(ws.Row)
}
// CurrentHeight gets current height. Line count in Screen buffer.
func CurrentHeight() int {
return strings.Count(Screen.String(), "\n")

View File

@@ -1,3 +1,4 @@
//go:build plan9 || solaris
// +build plan9 solaris
package goterm
@@ -10,3 +11,12 @@ func getWinsize() (*winsize, error) {
return ws, nil
}
// Height gets console height
func Height() int {
ws, err := getWinsize()
if err != nil {
return -1
}
return int(ws.Row)
}

View File

@@ -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)
}

View File

@@ -1,8 +1,11 @@
//go:build windows
// +build windows
package goterm
import (
"errors"
"math"
"os"
"golang.org/x/sys/windows"
@@ -21,3 +24,17 @@ func getWinsize() (*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, windows.WSAEOPNOTSUPP) {
return math.MinInt32
}
return -1
}
return int(ws.Row)
}