Flush should be called when refreshing the current display.
()
| 55 | |
| 56 | // Flush should be called when refreshing the current display. |
| 57 | func (w *Writer) Flush() error { |
| 58 | if w.buf.Len() == 0 { |
| 59 | return nil |
| 60 | } |
| 61 | |
| 62 | if err := w.clearLines(); err != nil { |
| 63 | return err |
| 64 | } |
| 65 | w.lines = countLines(w.buf.String()) |
| 66 | |
| 67 | if _, err := w.w.Write(w.buf.Bytes()); err != nil { |
| 68 | return err |
| 69 | } |
| 70 | |
| 71 | w.buf.Reset() |
| 72 | return nil |
| 73 | } |
| 74 | |
| 75 | // TODO(stevvooe): The following are system specific. Break these out if we |
| 76 | // decide to build this package further. |