aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go')
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go
index 3fb8b7d75..e836cec3a 100644
--- a/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go
+++ b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go
@@ -2,8 +2,21 @@
package cwriter
-import "fmt"
+import (
+ "fmt"
+
+ "golang.org/x/sys/unix"
+)
func (w *Writer) clearLines() {
fmt.Fprintf(w.out, cuuAndEd, w.lineCount)
}
+
+// GetSize returns the dimensions of the given terminal.
+func GetSize(fd uintptr) (width, height int, err error) {
+ ws, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ)
+ if err != nil {
+ return -1, -1, err
+ }
+ return int(ws.Col), int(ws.Row), nil
+}