diff --git a/cwriter/writer.go b/cwriter/writer.go index 1fd9d95..1de453a 100644 --- a/cwriter/writer.go +++ b/cwriter/writer.go @@ -2,8 +2,8 @@ import ( "bytes" + "fmt" "io" - "fmt" ) // ESC is the ASCII code for escape character @@ -48,3 +48,7 @@ func (w *Writer) Write(b []byte) (n int, err error) { return w.buf.Write(b) } + +func (w *Writer) WriteString(s string) (n int, err error) { + return w.buf.WriteString(s) +} diff --git a/cwriter/writer_posix.go b/cwriter/writer_posix.go index cd166e0..c6a1551 100644 --- a/cwriter/writer_posix.go +++ b/cwriter/writer_posix.go @@ -4,18 +4,18 @@ import ( "fmt" + "strings" "syscall" "unsafe" - "strings" ) func (w *Writer) clearLines() { fmt.Fprint(w.out, strings.Repeat(clearCursorAndLine, w.lineCount)) } -// GetTermSize returns the dimensions of the given terminal. +// TermSize returns the dimensions of the given terminal. // the code is stolen from "golang.org/x/crypto/ssh/terminal" -func GetTermSize() (width, height int, err error) { +func TermSize() (width, height int, err error) { var dimensions [4]uint16 if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(syscall.Stdout), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0); err != 0 {