Documentation ¶
Overview ¶
Package terminal is a vt10x terminal emulation backend, influenced largely by st, rxvt, xterm, and iTerm as reference. Use it for terminal muxing, a terminal emulation frontend, or wherever else you need terminal emulation.
In development, but very usable.
Index ¶
- func ResizePty(pty *os.File, cols, rows int) error
- type ChangeFlag
- type Color
- type ModeFlag
- type State
- func (t *State) Cell(x, y int) (ch rune, fg Color, bg Color)
- func (t *State) Changed(change ChangeFlag) bool
- func (t *State) Cursor() (int, int)
- func (t *State) CursorVisible() bool
- func (t *State) Lock()
- func (t *State) Mode(mode ModeFlag) bool
- func (t *State) Size() (rows int, cols int)
- func (t *State) String() string
- func (t *State) Title() string
- func (t *State) Unlock()
- type VT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChangeFlag ¶
type ChangeFlag uint32
ChangeFlag represents possible state changes of the terminal.
const ( ChangedScreen ChangeFlag = 1 << iota ChangedTitle )
Terminal changes to occur in VT.ReadState
type Color ¶
type Color uint16
Color maps to the ANSI colors [0, 16) and the xterm colors [16, 256).
const ( Black Color = iota Red Green Yellow Blue Magenta Cyan LightGrey DarkGrey LightRed LightGreen LightYellow LightBlue LightMagenta LightCyan White )
ANSI color values
Default colors are potentially distinct to allow for special behavior. For example, a transparent background. Otherwise, the simple case is to map default colors to another color.
type ModeFlag ¶
type ModeFlag uint32
ModeFlag represents various terminal mode states.
const ( ModeWrap ModeFlag = 1 << iota ModeInsert ModeAppKeypad ModeAltScreen ModeCRLF ModeMouseButton ModeMouseMotion ModeReverse ModeKeyboardLock ModeHide ModeEcho ModeAppCursor ModeMouseSgr Mode8bit ModeBlink ModeFBlink ModeFocus ModeMouseX10 ModeMouseMany ModeMouseMask = ModeMouseButton | ModeMouseMotion | ModeMouseX10 | ModeMouseMany )
Terminal modes
type State ¶
State represents the terminal emulation state. Use Lock/Unlock methods to synchronize data access with VT.
func NewVT10XConsole ¶
NewVT10XConsole returns a new expect.Console that multiplexes the Stdin/Stdout to a VT10X terminal, allowing Console to interact with an application sending ANSI escape sequences.
func (*State) Cell ¶
Cell returns the character code, foreground color, and background color at position (x, y) relative to the top left of the terminal.
func (*State) Changed ¶
func (t *State) Changed(change ChangeFlag) bool
Changed returns true if change has occured.
func (*State) CursorVisible ¶
CursorVisible returns the visible state of the cursor.
type VT ¶
type VT struct {
// contains filtered or unexported fields
}
VT represents the virtual terminal emulator.
func Create ¶
func Create(state *State, rwc io.ReadWriteCloser) (*VT, error)
Create initializes a virtual terminal emulator with the target state and io.ReadWriteCloser input.
func (*VT) Parse ¶
Parse blocks on read on pty or io.ReadCloser, then parses sequences until buffer empties. State is locked as soon as first rune is read, and unlocked when buffer is empty. TODO: add tests for expected blocking behavior