diff --git a/cwriter/writer.go b/cwriter/writer.go index c068877..7d15717 100644 --- a/cwriter/writer.go +++ b/cwriter/writer.go @@ -43,7 +43,10 @@ func (w *Writer) Flush(lineCount int) (err error) { // some terminals interpret clear 0 lines as clear 1 if w.lineCount > 0 { - w.clearLines() + err = w.clearLines() + if err != nil { + return + } } w.lineCount = lineCount _, err = w.buf.WriteTo(w.out) @@ -75,8 +78,9 @@ return tw, err } -func (w *Writer) ansiCuuAndEd() { +func (w *Writer) ansiCuuAndEd() (err error) { buf := make([]byte, 8) buf = strconv.AppendInt(buf[:copy(buf, escOpen)], int64(w.lineCount), 10) - w.out.Write(append(buf, cuuAndEd...)) + _, err = w.out.Write(append(buf, cuuAndEd...)) + return } diff --git a/cwriter/writer_posix.go b/cwriter/writer_posix.go index 7c7947b..da4b215 100644 --- a/cwriter/writer_posix.go +++ b/cwriter/writer_posix.go @@ -6,8 +6,8 @@ "golang.org/x/sys/unix" ) -func (w *Writer) clearLines() { - w.ansiCuuAndEd() +func (w *Writer) clearLines() error { + return w.ansiCuuAndEd() } // GetSize returns the dimensions of the given terminal.