termstatus

package module
v0.0.0-...-7ac38f2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2021 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsProcessBackground

func IsProcessBackground(fd uintptr) bool

IsProcessBackground reports whether the current process is running in the background. fd must be a file descriptor for the terminal.

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

func New(wr io.Writer, errWriter io.Writer, disableStatus bool) *Terminal

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

func (t *Terminal) CanUpdateStatus() bool

CanUpdateStatus return whether the status output is updated in place.

func (*Terminal) Error

func (t *Terminal) Error(line string)

Error writes an error to the terminal.

func (*Terminal) Errorf

func (t *Terminal) Errorf(msg string, args ...interface{})

Errorf uses fmt.Sprintf to write an error line to the terminal.

func (*Terminal) Print

func (t *Terminal) Print(line string)

Print writes a line to the terminal.

func (*Terminal) Printf

func (t *Terminal) Printf(msg string, args ...interface{})

Printf uses fmt.Sprintf to write a line to the terminal.

func (*Terminal) Run

func (t *Terminal) Run(ctx context.Context)

Run updates the screen. It should be run in a separate goroutine. When ctx is cancelled, the status lines are cleanly removed.

func (*Terminal) SetStatus

func (t *Terminal) SetStatus(lines []string)

SetStatus updates the status lines.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL