term

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: GPL-3.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Size added in v0.34.0

func Size() (width, height int)

Size returns the width and height of the terminal session

Types

type Recorder added in v0.34.0

type Recorder struct {
	// contains filtered or unexported fields
}

func NewRecorder added in v0.34.0

func NewRecorder(output io.Writer) (*Recorder, error)

func (*Recorder) Close added in v0.34.0

func (recorder *Recorder) Close() error

type RemoteTerm

type RemoteTerm struct {
	// contains filtered or unexported fields
}

RemoteTerm is used to send terminal output remotely

func NewRemoteTerm

func NewRemoteTerm(client *remote.Client) *RemoteTerm

NewRemoteTerm creates a new RemoteTerm based on a remote.Client

func (*RemoteTerm) Write

func (t *RemoteTerm) Write(p []byte) (n int, err error)

Write terminal data remotely

type Terminal added in v0.34.0

type Terminal struct {
	// contains filtered or unexported fields
}

Terminal gives access to the standard terminal input/output

func Get added in v0.34.0

func Get() *Terminal

Get returns the default terminal. It will be initialized on first use with NewTerminal() if not set before. Ideally we should pass the terminal where we need it, but Get() can be safely used until the refactoring is finished.

func NewTerminal added in v0.34.0

func NewTerminal(options ...TerminalOption) *Terminal

func Set added in v0.34.0

func Set(t *Terminal) *Terminal

Set stores the default terminal, and returns the terminal reference for chaining.

func (*Terminal) AskYesNo added in v0.34.0

func (t *Terminal) AskYesNo(message string, defaultAnswer bool) bool

AskYesNo prompts the user for a message asking for a yes/no answer

func (*Terminal) FlushAllOutput added in v0.34.0

func (t *Terminal) FlushAllOutput()

FlushAllOutput flushes all buffered output (if supported by the underlying Writer).

func (*Terminal) Print added in v0.34.0

func (t *Terminal) Print(a ...any) (n int, err error)

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*Terminal) Printf added in v0.34.0

func (t *Terminal) Printf(format string, a ...any) (n int, err error)

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func (*Terminal) Println added in v0.34.0

func (t *Terminal) Println(a ...any) (n int, err error)

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func (*Terminal) ReadPassword added in v0.34.0

func (t *Terminal) ReadPassword() (string, error)

ReadPassword reads a password without echoing it to the terminal.

func (*Terminal) Scanln added in v0.34.0

func (t *Terminal) Scanln(a ...any) (n int, err error)

func (*Terminal) Stderr added in v0.34.0

func (t *Terminal) Stderr() io.Writer

func (*Terminal) StderrIsTerminal added in v0.34.0

func (t *Terminal) StderrIsTerminal() bool

StderrIsTerminal returns true as stderr is a terminal session

func (*Terminal) Stdout added in v0.34.0

func (t *Terminal) Stdout() io.Writer

func (*Terminal) StdoutIsTerminal added in v0.34.0

func (t *Terminal) StdoutIsTerminal() bool

StdoutIsTerminal returns true as stdout is a terminal session

func (*Terminal) Write added in v0.34.0

func (t *Terminal) Write(p []byte) (n int, err error)

Write implements the io.Writer interface, writing to the terminal's stdout.

type TerminalOption added in v0.34.0

type TerminalOption func(t *Terminal)

func WithColors added in v0.34.0

func WithColors(enable bool) TerminalOption

func WithNoStderr added in v0.34.0

func WithNoStderr() TerminalOption

func WithNoStdin added in v0.34.0

func WithNoStdin() TerminalOption

func WithNoStdout added in v0.34.0

func WithNoStdout() TerminalOption

func WithStderr added in v0.34.0

func WithStderr(stderr io.Writer) TerminalOption

func WithStderrCopy added in v0.34.0

func WithStderrCopy(w io.Writer) TerminalOption

func WithStderrRecorder added in v0.34.0

func WithStderrRecorder(recorder *Recorder) TerminalOption

func WithStdin added in v0.34.0

func WithStdin(stdin io.Reader) TerminalOption

func WithStdout added in v0.34.0

func WithStdout(stdout io.Writer) TerminalOption

func WithStdoutCopy added in v0.34.0

func WithStdoutCopy(w io.Writer) TerminalOption

WithStdoutCopy creates a copy of everything sent to Stdout to `copy` writer. Colorisation is independent: the Stdout writer can display colors while the copy to a non terminal won't display colors.

func WithStdoutRecorder added in v0.34.0

func WithStdoutRecorder(recorder *Recorder) TerminalOption

Jump to

Keyboard shortcuts

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