Documentation ¶
Overview ¶
Package termutil provides structures and helper functions to work with terminal (state, sizes). Taken from docker-ce source code.
Index ¶
- Variables
- func Err() *os.File
- func In() *os.File
- func IsTTY() bool
- func MakeRaw() error
- func NewEscapeProxy(r io.Reader, escapeKeys []byte) io.Reader
- func Out() *os.File
- func Restore() error
- func SetWinsize(ws *Winsize) error
- func ToBytes(keys string) ([]byte, error)
- type EscapeError
- type State
- type Terminal
- func (t *Terminal) Close() error
- func (t *Terminal) Err() *os.File
- func (t *Terminal) GetState() (*Termios, error)
- func (t *Terminal) GetWinsize() (*Winsize, error)
- func (t *Terminal) In() *os.File
- func (t *Terminal) IsTTY() bool
- func (t *Terminal) MakeRaw() error
- func (t *Terminal) Out() *os.File
- func (t *Terminal) Restore() error
- func (t *Terminal) SetWinsize(ws *Winsize) error
- type Termios
- type Winsize
Constants ¶
This section is empty.
Variables ¶
var ASCII = []string{
"ctrl-@",
"ctrl-a",
"ctrl-b",
"ctrl-c",
"ctrl-d",
"ctrl-e",
"ctrl-f",
"ctrl-g",
"ctrl-h",
"ctrl-i",
"ctrl-j",
"ctrl-k",
"ctrl-l",
"ctrl-m",
"ctrl-n",
"ctrl-o",
"ctrl-p",
"ctrl-q",
"ctrl-r",
"ctrl-s",
"ctrl-t",
"ctrl-u",
"ctrl-v",
"ctrl-w",
"ctrl-x",
"ctrl-y",
"ctrl-z",
"ctrl-[",
"ctrl-\\",
"ctrl-]",
"ctrl-^",
"ctrl-_",
}
ASCII lists the possible supported ASCII key sequence nolint: gochecknoglobals
var ( // ErrInvalidState is returned if the state of the terminal is invalid. ErrInvalidState = errors.New("invalid terminal state") )
var ErrNoTTY = fmt.Errorf("not a TTY")
ErrNoTTY defines the errormessage to return when a terminal is not a tty
Functions ¶
func NewEscapeProxy ¶
NewEscapeProxy returns a new TTY proxy reader which wraps the given reader and detects when the specified escape keys are read, in which case the Read method will return an error of type EscapeError.
func SetWinsize ¶
SetWinsize sets the window size of a new terminal
Types ¶
type EscapeError ¶
type EscapeError struct{}
EscapeError is special error which returned by a TTY proxy reader's Read() method in case its detach escape sequence is read.
func (EscapeError) Error ¶
func (EscapeError) Error() string
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the state of the terminal.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal describes a terminal it stores file pointers to the in, out and error file handers and the state of the in and output
func NewTerminal ¶
NewTerminal returns a pointer to a new Terminal struct using the given in, out and err files as files for input, output and error handling.
func (*Terminal) GetState ¶
GetState returns the current state of the terminal the method is called on
func (*Terminal) GetWinsize ¶
GetWinsize returns the current window size of the terminal the method is called on
func (*Terminal) Out ¶
Out returns the pointer to the output of the terminal the method is called on
func (*Terminal) Restore ¶
Restore restores the terminal by setting the input and output state to nil
func (*Terminal) SetWinsize ¶
SetWinsize sets the window size of terminal the method is called on