Version: v0.6.0 Latest Latest

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

Go to latest
Published: May 25, 2016 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0



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



This section is empty.


View Source
var ASCII = []string{

ASCII list the possible supported ASCII key sequence

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


func DisableEcho

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

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

func IsTerminal(fd uintptr) bool

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

func RestoreTerminal

func RestoreTerminal(fd uintptr, state *State) error

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

func SetWinsize

func SetWinsize(fd uintptr, ws *Winsize) error

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

func StdStreams

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

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

func ToBytes added in v0.6.0

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

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


type State

type State struct {
	// contains filtered or unexported fields

State represents the state of the terminal.

func MakeRaw

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

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

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

func SetRawTerminal

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

SetRawTerminal puts the terminal connected to the given file descriptor into raw mode and returns the previous state.

type Termios

type Termios syscall.Termios

Termios is the Unix API for terminal I/O. It is passthgrouh for syscall.Termios in order to make it portable with other platforms where it is not available or handled differently.

type Winsize

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

Winsize represents the size of the terminal window.

func GetWinsize

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

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


Path Synopsis

Jump to

Keyboard shortcuts

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