Documentation ¶
Overview ¶
Package iolive Created by RTT. Author: teocci@yandex.com on 2021-Sep-02 Package iolive provides a writer that live updates the terminal. It provides a buffered io.Writer that is flushed at a timed interval.
Package iolive Created by RTT. Author: teocci@yandex.com on 2021-Sep-02
Index ¶
Constants ¶
const ESC = 27
ESC is the ASCII code for escape character
Variables ¶
var ( // RefreshInterval is the default refresh interval to update the ui RefreshInterval = time.Millisecond // Out is the default output writer for the Writer Out = io.Writer(os.Stdout) // ErrClosedPipe is the error returned when trying to writer is not listening ErrClosedPipe = errors.New("iolive: read/write on closed pipe") )
Functions ¶
This section is empty.
Types ¶
type Writer ¶
type Writer struct { // Out is the writer to write to Out io.Writer // RefreshInterval is the time the UI should refresh RefreshInterval time.Duration // contains filtered or unexported fields }
Writer is a buffered the writer that updates the terminal. The contents of writer will be flushed on a timed interval or when Flush is called.
func (*Writer) Bypass ¶
Bypass creates an io.Writer which allows non-buffered output to be written to the underlying output
func (*Writer) Flush ¶
Flush writes to the out and resets the buffer. It should be called after the last call to Write to ensure that any data buffered in the Writer is written to output. Any incomplete escape sequence at the end is considered complete for formatting purposes. An error is returned if the contents of the buffer cannot be written to the underlying output stream
func (*Writer) Listen ¶
func (w *Writer) Listen()
Listen listens for updates to the writer's buffer and flushes to the out provided. It blocks the runtime.