dockertest: Index | Files | Directories

package term

import ""

Package term provides structures and helper functions to work with terminal (state, sizes).


Package Files

ascii.go proxy.go tc.go term.go termios_linux.go winsize.go


var ASCII = []string{

ASCII list the possible supported ASCII key sequence

var (
    // ErrInvalidState is returned if the state of the terminal is invalid.
    ErrInvalidState = errors.New("Invalid terminal state")

func DisableEcho Uses

func DisableEcho(fd uintptr, state *State) error

DisableEcho applies the specified state to the terminal connected to the file descriptor, with echo disabled.

func GetFdInfo Uses

func GetFdInfo(in interface{}) (uintptr, bool)

GetFdInfo returns the file descriptor for an os.File and indicates whether the file represents a terminal.

func IsTerminal Uses

func IsTerminal(fd uintptr) bool

IsTerminal returns true if the given file descriptor is a terminal.

func NewEscapeProxy Uses

func NewEscapeProxy(r io.Reader, escapeKeys []byte) io.Reader

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 RestoreTerminal Uses

func RestoreTerminal(fd uintptr, state *State) error

RestoreTerminal restores the terminal connected to the given file descriptor to a previous state.

func SetWinsize Uses

func SetWinsize(fd uintptr, ws *Winsize) error

SetWinsize tries to set the specified window size for the specified file descriptor.

func StdStreams Uses

func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer)

StdStreams returns the standard streams (stdin, stdout, stderr).

func ToBytes Uses

func ToBytes(keys string) ([]byte, error)

ToBytes converts a string representing a suite of key-sequence to the corresponding ASCII code.

type EscapeError Uses

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 Uses

func (EscapeError) Error() string

type State Uses

type State struct {
    // contains filtered or unexported fields

State represents the state of the terminal.

func MakeRaw Uses

func MakeRaw(fd uintptr) (*State, error)

MakeRaw put the terminal connected to the given file descriptor into raw mode and returns the previous state of the terminal so that it can be restored.

func SaveState Uses

func SaveState(fd uintptr) (*State, error)

SaveState saves the state of the terminal connected to the given file descriptor.

func SetRawTerminal Uses

func SetRawTerminal(fd uintptr) (*State, error)

SetRawTerminal puts the terminal connected to the given file descriptor into raw mode and returns the previous state. On UNIX, this puts both the input and output into raw mode. On Windows, it only puts the input into raw mode.

func SetRawTerminalOutput Uses

func SetRawTerminalOutput(fd uintptr) (*State, error)

SetRawTerminalOutput puts the output of terminal connected to the given file descriptor into raw mode. On UNIX, this does nothing and returns nil for the state. On Windows, it disables LF -> CRLF translation.

type Termios Uses

type Termios unix.Termios

Termios is the Unix API for terminal I/O.

type Winsize Uses

type Winsize struct {
    Height uint16
    Width  uint16
    // contains filtered or unexported fields

Winsize represents the size of the terminal window.

func GetWinsize Uses

func GetWinsize(fd uintptr) (*Winsize, error)

GetWinsize returns the window size based on the specified file descriptor.



Package term imports 9 packages (graph) and is imported by 1 packages. Updated 2018-04-11. Refresh now. Tools for package owners.