Codebase list golang-github-vbauerster-mpb / 3d6f96f
clearLines may err Vladimir Bauer 5 years ago
2 changed file(s) with 9 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
4242 func (w *Writer) Flush(lineCount int) (err error) {
4343 // some terminals interpret clear 0 lines as clear 1
4444 if w.lineCount > 0 {
45 w.clearLines()
45 err = w.clearLines()
46 if err != nil {
47 return
48 }
4649 }
4750 w.lineCount = lineCount
4851 _, err = w.buf.WriteTo(w.out)
7477 return tw, err
7578 }
7679
77 func (w *Writer) ansiCuuAndEd() {
80 func (w *Writer) ansiCuuAndEd() (err error) {
7881 buf := make([]byte, 8)
7982 buf = strconv.AppendInt(buf[:copy(buf, escOpen)], int64(w.lineCount), 10)
80 w.out.Write(append(buf, cuuAndEd...))
83 _, err = w.out.Write(append(buf, cuuAndEd...))
84 return
8185 }
55 "golang.org/x/sys/unix"
66 )
77
8 func (w *Writer) clearLines() {
9 w.ansiCuuAndEd()
8 func (w *Writer) clearLines() error {
9 return w.ansiCuuAndEd()
1010 }
1111
1212 // GetSize returns the dimensions of the given terminal.