Codebase list golang-github-vbauerster-mpb / 7a06650
cwriter change: GetTermSize to TermSize Vladimir Bauer 8 years ago
2 changed file(s) with 8 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
11
22 import (
33 "bytes"
4 "fmt"
45 "io"
5 "fmt"
66 )
77
88 // ESC is the ASCII code for escape character
4747 func (w *Writer) Write(b []byte) (n int, err error) {
4848 return w.buf.Write(b)
4949 }
50
51 func (w *Writer) WriteString(s string) (n int, err error) {
52 return w.buf.WriteString(s)
53 }
33
44 import (
55 "fmt"
6 "strings"
67 "syscall"
78 "unsafe"
8 "strings"
99 )
1010
1111 func (w *Writer) clearLines() {
1212 fmt.Fprint(w.out, strings.Repeat(clearCursorAndLine, w.lineCount))
1313 }
1414
15 // GetTermSize returns the dimensions of the given terminal.
15 // TermSize returns the dimensions of the given terminal.
1616 // the code is stolen from "golang.org/x/crypto/ssh/terminal"
17 func GetTermSize() (width, height int, err error) {
17 func TermSize() (width, height int, err error) {
1818 var dimensions [4]uint16
1919
2020 if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(syscall.Stdout), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0); err != 0 {