Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TerminalSize ¶
Returns the terminal's number of columns and rows. If something goes wrong, err will be non-nil, but also with reasonable fallback values of (80, 24). In other words, the error can often be discarded.
Types ¶
type LineReserver ¶
type LineReserver struct {
// contains filtered or unexported fields
}
Reserves a line at the bottom of the terminal, while normal stdout and stderr goes above it. It does not play well any other prints using carriage returns.
A side-effect of the implementation is that anything printed that doesn't have a newline in it gets buffered instead of printed immediately.
func NewLineReserver ¶
func NewLineReserver() (*LineReserver, error)
Takes control of stdout and stderr in order to reserve the last line of the terminal, which can be set with Set().
func (*LineReserver) Refresh ¶
func (lr *LineReserver) Refresh()
Prints the reserved line again, updating the line if it was changed since last time. Note that if something was buffered (i.e. something printed without a newline in it), a newline will be appended to avoid erasing what was in the buffer.
func (*LineReserver) Release ¶
func (lr *LineReserver) Release()
Clears the reserved line and restores control to stdout and stderr.
func (*LineReserver) Set ¶
func (lr *LineReserver) Set(line string)
Sets the reserved line to the desired string.