Codebase list golang-github-vbauerster-mpb / c232068
refactoring: lineCount => lines Vladimir Bauer 4 years ago
2 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
3131
3232 func BenchmarkWithCopy(b *testing.B) {
3333 w := New(ioutil.Discard)
34 w.lineCount = 4
34 w.lines = 4
3535 for i := 0; i < b.N; i++ {
3636 w.ansiCuuAndEd()
3737 }
2121 type Writer struct {
2222 out io.Writer
2323 buf bytes.Buffer
24 lineCount int
24 lines int
2525 fd int
2626 isTerminal bool
2727 }
3737 }
3838
3939 // Flush flushes the underlying buffer.
40 func (w *Writer) Flush(lineCount int) (err error) {
40 func (w *Writer) Flush(lines int) (err error) {
4141 // some terminals interpret 'cursor up 0' as 'cursor up 1'
42 if w.lineCount > 0 {
42 if w.lines > 0 {
4343 err = w.clearLines()
4444 if err != nil {
4545 return
4646 }
4747 }
48 w.lineCount = lineCount
48 w.lines = lines
4949 _, err = w.buf.WriteTo(w.out)
5050 return
5151 }
7777
7878 func (w *Writer) ansiCuuAndEd() (err error) {
7979 buf := make([]byte, 8)
80 buf = strconv.AppendInt(buf[:copy(buf, escOpen)], int64(w.lineCount), 10)
80 buf = strconv.AppendInt(buf[:copy(buf, escOpen)], int64(w.lines), 10)
8181 _, err = w.out.Write(append(buf, cuuAndEd...))
8282 return
8383 }