periods
Vladimir Bauer
6 years ago
| 9 | 9 | "golang.org/x/crypto/ssh/terminal" |
| 10 | 10 | ) |
| 11 | 11 | |
| 12 | // NotATTY not a TeleTYpewriter error | |
| 12 | // NotATTY not a TeleTYpewriter error. | |
| 13 | 13 | var NotATTY = errors.New("not a terminal") |
| 14 | 14 | |
| 15 | 15 | var cuuAndEd = fmt.Sprintf("%c[%%dA%[1]c[J", 27) |
| 24 | 24 | isTerminal bool |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | // New returns a new Writer with defaults | |
| 27 | // New returns a new Writer with defaults. | |
| 28 | 28 | func New(out io.Writer) *Writer { |
| 29 | 29 | w := &Writer{out: out} |
| 30 | 30 | if f, ok := out.(*os.File); ok { |
| 34 | 34 | return w |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | // Flush flushes the underlying buffer | |
| 37 | // Flush flushes the underlying buffer. | |
| 38 | 38 | func (w *Writer) Flush(lineCount int) (err error) { |
| 39 | 39 | if w.lineCount > 0 { |
| 40 | 40 | w.clearLines() |
| 44 | 44 | return |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | // Write appends the contents of p to the underlying buffer | |
| 47 | // Write appends the contents of p to the underlying buffer. | |
| 48 | 48 | func (w *Writer) Write(p []byte) (n int, err error) { |
| 49 | 49 | return w.buf.Write(p) |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | // WriteString writes string to the underlying buffer | |
| 52 | // WriteString writes string to the underlying buffer. | |
| 53 | 53 | func (w *Writer) WriteString(s string) (n int, err error) { |
| 54 | 54 | return w.buf.WriteString(s) |
| 55 | 55 | } |