Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanUpdateStatus ¶
CanUpdateStatus returns true if status lines can be printed, the process output is not redirected to a file or pipe.
func IsProcessBackground ¶
IsProcessBackground reports whether the current process is running in the background. fd must be a file descriptor for the terminal.
func Quote ¶
Quote lines with funny characters in them, meaning control chars, newlines, tabs, anything else non-printable and invalid UTF-8.
This is intended to produce a string that does not mess up the terminal rather than produce an unambiguous quoted string.
func Truncate ¶
Truncate s to fit in width (number of terminal cells) w. If w is negative, returns the empty string.
func WrapStdio ¶
func WrapStdio(term *Terminal) (stdout, stderr io.WriteCloser)
WrapStdio returns line-buffering replacements for os.Stdout and os.Stderr. On Close, the remaining bytes are written, followed by a line break.
Types ¶
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal is used to write messages and display status lines which can be updated. When the output is redirected to a file, the status lines are not printed.
func New ¶
New returns a new Terminal for wr. A goroutine is started to update the terminal. It is terminated when ctx is cancelled. When wr is redirected to a file (e.g. via shell output redirection) or is just an io.Writer (not the open *os.File for stdout), no status lines are printed. The status lines and normal output (via Print/Printf) are written to wr, error messages are written to errWriter. If disableStatus is set to true, no status messages are printed even if the terminal supports it.
func (*Terminal) CanUpdateStatus ¶
CanUpdateStatus return whether the status output is updated in place.