diff --git a/cwriter/writer.go b/cwriter/writer.go index 85c052c..35136de 100644 --- a/cwriter/writer.go +++ b/cwriter/writer.go @@ -16,19 +16,6 @@ // ErrNotTTY not a TeleTYpewriter error. var ErrNotTTY = errors.New("not a terminal") - -// Writer is a buffered terminal writer, which moves cursor N lines up -// on each flush except the first one, where N is a number of lines of -// a previous flush. -type Writer struct { - *bytes.Buffer - out io.Writer - ew escWriter - lines int //nolint:unused - fd int - terminal bool - termSize func(int) (int, int, error) -} // New returns a new Writer with defaults. func New(out io.Writer) *Writer { diff --git a/cwriter/writer_posix.go b/cwriter/writer_posix.go index f896c7b..e80d757 100644 --- a/cwriter/writer_posix.go +++ b/cwriter/writer_posix.go @@ -3,8 +3,23 @@ package cwriter import ( + "bytes" + "io" + "golang.org/x/sys/unix" ) + +// Writer is a buffered terminal writer, which moves cursor N lines up +// on each flush except the first one, where N is a number of lines of +// a previous flush. +type Writer struct { + *bytes.Buffer + out io.Writer + ew escWriter + fd int + terminal bool + termSize func(int) (int, int, error) +} // Flush flushes the underlying buffer. // It's caller's responsibility to pass correct number of lines. diff --git a/cwriter/writer_windows.go b/cwriter/writer_windows.go index 77b67c6..44293f2 100644 --- a/cwriter/writer_windows.go +++ b/cwriter/writer_windows.go @@ -3,6 +3,8 @@ package cwriter import ( + "bytes" + "io" "unsafe" "golang.org/x/sys/windows" @@ -14,6 +16,19 @@ procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition") procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW") ) + +// Writer is a buffered terminal writer, which moves cursor N lines up +// on each flush except the first one, where N is a number of lines of +// a previous flush. +type Writer struct { + *bytes.Buffer + out io.Writer + ew escWriter + lines int + fd int + terminal bool + termSize func(int) (int, int, error) +} // Flush flushes the underlying buffer. // It's caller's responsibility to pass correct number of lines.