Documentation ¶
Overview ¶
Package term provides provides structures and helper functions to work with terminal (state, sizes).
Index ¶
- Constants
- Variables
- func DisableEcho(fd uintptr, state *State) error
- func GetFdInfo(in interface{}) (uintptr, bool)
- func IsTerminal(fd uintptr) bool
- func RestoreTerminal(fd uintptr, state *State) error
- func SetWinsize(fd uintptr, ws *Winsize) error
- func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer)
- type State
- type Termios
- type Winsize
Constants ¶
const ( IGNBRK = syscall.IGNBRK PARMRK = syscall.PARMRK INLCR = syscall.INLCR IGNCR = syscall.IGNCR ECHONL = syscall.ECHONL CSIZE = syscall.CSIZE ICRNL = syscall.ICRNL ISTRIP = syscall.ISTRIP PARENB = syscall.PARENB ECHO = syscall.ECHO ICANON = syscall.ICANON ISIG = syscall.ISIG IXON = syscall.IXON BRKINT = syscall.BRKINT INPCK = syscall.INPCK OPOST = syscall.OPOST CS8 = syscall.CS8 IEXTEN = syscall.IEXTEN )
Termios magic numbers, passthrough to the ones defined in syscall.
Variables ¶
var ( // ErrInvalidState is returned if the state of the terminal is invalid. ErrInvalidState = errors.New("Invalid terminal state") )
Functions ¶
func DisableEcho ¶
DisableEcho applies the specified state to the terminal connected to the file descriptor, with echo disabled.
func GetFdInfo ¶
GetFdInfo returns the file descriptor for an os.File and indicates whether the file represents a terminal.
func IsTerminal ¶
IsTerminal returns true if the given file descriptor is a terminal.
func RestoreTerminal ¶
RestoreTerminal restores the terminal connected to the given file descriptor to a previous state.
func SetWinsize ¶
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).
Types ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the state of the terminal.
func MakeRaw ¶
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 SetRawTerminal ¶
SetRawTerminal puts the terminal connected to the given file descriptor into raw mode and returns the previous state.