Documentation
¶
Overview ¶
Package tcell provides a lower-level, portable API for building programs that interact with terminals or consoles. It works with both common (and many uncommon!) terminals or terminal emulators, and Windows console implementations.
It provides support for up to 256 colors, text attributes, and box drawing elements. A database of terminals built from a real terminfo database is provided, along with code to generate new database entries.
Tcell offers very rich support for mice, dependent upon the terminal of course. (Windows, XTerm, and iTerm 2 are known to work very well.)
If the environment is not Unicode by default, such as an ISO8859 based locale or GB18030, Tcell can convert input and outupt, so that your terminal can operate in whatever locale is most convenient, while the application program can just assume "everything is UTF-8". Reasonable defaults are used for updating characters to something suitable for display. Unicode box drawing characters will be converted to use the alternate character set of your terminal, if native conversions are not available. If no ACS is available, then some ASCII fallbacks will be used.
A rich set of keycodes is supported, with support for up to 65 function keys, and various other special keys.
Index ¶
- Constants
- Variables
- func AddTerminfo(t *Terminfo)
- func ClearCells(c []Cell, style Style)
- func GetEncoding(name string) encoding.Encoding
- func InvalidateCells(c []Cell)
- func RegisterEncoding(name string, enc encoding.Encoding)
- type AttrMask
- type ButtonMask
- type Cell
- type Color
- type Event
- type EventError
- type EventInterrupt
- type EventKey
- type EventMouse
- type EventResize
- type Key
- type ModMask
- type Screen
- type SimCell
- type SimulationScreen
- type Style
- func (s Style) Background(c Color) Style
- func (s Style) Blink(on bool) Style
- func (s Style) Bold(on bool) Style
- func (s Style) Decompose() (fg Color, bg Color, attr AttrMask)
- func (s Style) Dim(on bool) Style
- func (s Style) Foreground(c Color) Style
- func (s Style) Normal() Style
- func (s Style) Reverse(on bool) Style
- func (s Style) Underline(on bool) Style
- type Terminfo
Constants ¶
const ( KeyBackspace = KeyBS KeyTab = KeyTAB KeyEsc = KeyESC KeyEscape = KeyESC KeyEnter = KeyCR KeySpace = KeySP KeyBackspace2 = KeyDEL // This is delete back, not forward )
const ( RuneSterling = '£' RuneDArrow = '↓' RuneLArrow = '←' RuneRArrow = '→' RuneUArrow = '↑' RuneBullet = '·' RuneBoard = '░' RuneCkBoard = '▒' RuneDegree = '°' RuneDiamond = '◆' RuneGEqual = '≥' RunePi = 'π' RuneHLine = '─' RuneLantern = '§' RunePlus = '┼' RuneLEqual = '≤' RuneLLCorner = '└' RuneLRCorner = '┘' RuneNEqual = '≠' RunePlMinus = '±' RuneS1 = '⎺' RuneS3 = '⎻' RuneS7 = '⎼' RuneS9 = '⎽' RuneBlock = '█' RuneTTee = '┬' RuneRTee = '┤' RuneLTee = '├' RuneBTee = '┴' RuneULCorner = '┌' RuneURCorner = '┐' RuneVLine = '│' )
Variables ¶
var ( ErrNoDatabase = errors.New("terminal database not found") ErrTermNotFound = errors.New("terminal entry not found") )
Functions ¶
func AddTerminfo ¶
func AddTerminfo(t *Terminfo)
AddTerminfo can be called to register a new Terminfo entry.
func ClearCells ¶
ClearCells clears the entire set of cells, making them all whitespace with the provided attribute.
func GetEncoding ¶
GetEncoding is used by Screen implementors who want to locate an encoding for the given character set name. Note that this will return nil for either the Unicode (UTF-8) or ASCII encodings, since we don't use encodings for them but instead have our own native methods.
func InvalidateCells ¶
func InvalidateCells(c []Cell)
InvalidateCells marks all cells in the array dirty.
func RegisterEncoding ¶
We extract only the $codeset part, which will usually be something like UTF-8 or ISO8859-15 or KOI8-R. Note that if the locale is either "POSIX" or "C", then we assume US-ASCII (the POSIX 'portable character set' and assume all other characters are somehow invalid.)
On Windows systems, the Console is assumed to be UTF-16LE. As we communicate with the console subsystem using UTF-16LE, no conversions are necessary. So none of this is required for Windows systems.
Modern POSIX systems and terminal emulators may use UTF-8, and for those systems, this API is also unnecessary. For example, Darwin (MacOS X) and modern Linux running modern xterm generally will out of the box without any of this. Use of UTF-8 is recommended when possible, as it saves quite a lot processing overhead.
Note that some encodings are quite large (for example GB18030 which is a superset of Unicode) and so the application size can be expected ot increase quite a bit as each encoding is added. The East Asian encodings have been seen to add 100-200K per encoding to the application size.
Types ¶
type AttrMask ¶
type AttrMask int
AttrMask represents a mask of text attributes, apart from color. Note that support for attributes may vary widely across terminals.
type ButtonMask ¶
type ButtonMask int16
BtnMask is a mask of mouse buttons.
const ( // Button1 is usually the left mouse button. Button1 ButtonMask = 1 << iota // Button2 is usually the middle mouse button, for three button mice. Button2 // Button3 is usually the right mouse button on 2 or 3 button mice. Button3 Button4 Button5 Button6 Button7 Button8 // WheelUp indicates the wheel being moved up, away from the user. WheelUp // WheelDown indicates the wheel being moved down, towards the user. WheelDown WheelLeft WheelRight )
const ButtonNone ButtonMask = 0
type Cell ¶
Cell represents a single character cell. This is primarily intended for use by Screen implementors.
func ResizeCells ¶
ResizeCells is used to create a new cells array, with different dimensions, while preserving the original contents. The returned array may be the same as the original, if we can reuse it. Hence, the old array should no longer be used by the caller after this call. The cells will be marked dirty so that they can be redrawn.
func (*Cell) PutChar ¶
PutChar writes a single rune into the cells location. The rune should be a a normal (not combining) printable character.
func (*Cell) PutChars ¶
PutChars is a handy way to write runes to the Cell, without changing its style. The first rune should be a printable non-zero width value, and subsequent values may be combining marks.
func (*Cell) PutStyle ¶
PutStyle changes the style of the given Cell, without altering the character content.
func (*Cell) SetCell ¶
SetCell writes the contents into the cell. It ensures that at most one nonzero width rune is present in the Ch array (and if any zero width runes are present without a non-zero one, then a space is inserted), and updates the Dirty bit if the contents are different than they were.
type Color ¶
type Color int16
Color represents a color. Colors numeric values are taken from the XTerm 256 color map, except that they are offset by one, to allow 0 to indicate the default (unset) color.
const ( // ColorDefault is used to leave the Color unchanged from whatever // system or teminal default may exist. ColorDefault Color = iota ColorBlack ColorRed ColorGreen ColorYellow ColorBlue ColorMagenta ColorCyan ColorWhite ColorGrey ColorBrightRed ColorBrightGreen ColorBrightYellow ColorBrightBlue ColorBrightMagenta ColorBrightCyan ColorBrightWhite )
type EventError ¶
type EventError struct {
// contains filtered or unexported fields
}
func NewEventError ¶
func NewEventError(err error) *EventError
func (*EventError) Error ¶
func (ev *EventError) Error() string
func (*EventError) When ¶
func (ev *EventError) When() time.Time
type EventInterrupt ¶
type EventInterrupt struct {
// contains filtered or unexported fields
}
EventInterrupt is a generic wakeup event. Its can be used to to request a redraw. It can carry an arbitrary payload, as well.
func NewEventInterrupt ¶
func NewEventInterrupt(data interface{}) *EventInterrupt
func (*EventInterrupt) Data ¶
func (ev *EventInterrupt) Data() interface{}
func (*EventInterrupt) When ¶
func (ev *EventInterrupt) When() time.Time
type EventKey ¶
type EventKey struct {
// contains filtered or unexported fields
}
EventKey represents a key press. Usually this is a key press followed by a key release, but since terminal programs don't have a way to report key release events, we usually get just one event. If a key is held down then the terminal may synthesize repeated key presses at some predefined rate. We have no control over that, nor visibility into it.
In some cases, we can have a modifier key, such as ModAlt, that can be generated with a key press. (This usually is represented by having the high bit set, or in some cases, by sending an ESC prior to the rune.)
If the value of Key() is KeyRune, then the actual key value will be available with the Rune() method. This will be the case for most keys. In most situations, the modifiers will not be set. For example, if the rune is 'A', this will be reported without the ModShift bit set, since really can't tell if the Shift key was pressed (it might have been CAPSLOCK, or a terminal that only can send capitals, or keyboard with separate capital letters from lower case letters).
Generally, terminal applications have far less visibility into keyboard activity than graphical applications. Hence, they should avoid depending overly much on availability of modifiers, or the availability of any specific keys.
func NewEventKey ¶
NewEventKey attempts to create a suitable event. It parses the various ASCII control sequences if KeyRune is passed for Key, but if the caller has more precise information it should set that specifically. Callers that aren't sure about modifier state (most) should just pass ModNone.
func (*EventKey) Key ¶
Key returns a virtual key code. We use this to identify specific key codes, such as KeyEnter, etc. Most control and function keys are reported with unique Key values. Normal alphanumeric and punctuation keys will generally return KeyRune here; the specific key can be further decoded using the Rune() function.
func (*EventKey) Mod ¶
ModMask returns the modifiers that were present with the key press. Note that not all platforms and terminals support this equally well, and some cases we will not not know for sure. Hence, applications should avoid using this in most circumstances.
func (*EventKey) Name ¶
Name returns a printable value or the key stroke. This can be used when printing the event, for example.
type EventMouse ¶
type EventMouse struct {
// contains filtered or unexported fields
}
EventMouse is a mouse event. It is sent on either mouse up or mouse down events. It is also sent on mouse motion events - if the terminal supports it. We make every effort to ensure that mouse release events are delivered. Hence, click drag can be identified by a motion event with the mouse down, without any intervening button release.
Mouse wheel events, when reported, may appear on their own as individual impulses; that is, there will normally not be a release event delivered for mouse wheel movements.
Most terminals cannot report the state of more than one button at a time -- and many cannot report motion events. (Windows consoles, modern XTerm, and modern emulators like iTerm2, are known to support this well, though.)
Applications can inspect the time between events to figure out double clicks and such.
func NewEventMouse ¶
func NewEventMouse(x, y int, btn ButtonMask, mod ModMask) *EventMouse
NewEventMouse is used to create a new mouse event. Applications shouldn't need to use this; its mostly for screen implementors.
func (*EventMouse) Buttons ¶
func (ev *EventMouse) Buttons() ButtonMask
ButtonMask returns the list of buttons that were pressed.
func (*EventMouse) Modifiers ¶
func (ev *EventMouse) Modifiers() ModMask
Modifiers returns a list of keyboard modifiers that were pressed with the mouse button(s).
func (*EventMouse) Position ¶
func (ev *EventMouse) Position() (int, int)
Position returns the mouse position in character cells. The origin 0, 0 is at the upper left corner.
func (*EventMouse) When ¶
func (ev *EventMouse) When() time.Time
type EventResize ¶
type EventResize struct {
// contains filtered or unexported fields
}
EventResize is sent when the window size changes.
func NewEventResize ¶
func NewEventResize(width, height int) *EventResize
func (*EventResize) Size ¶
func (ev *EventResize) Size() (int, int)
func (*EventResize) When ¶
func (ev *EventResize) When() time.Time
type Key ¶
type Key int16
Key is a generic value for representing keys, and especially special keys (function keys, cursor movement keys, etc.) For normal keys, like ASCII letters, we use KeyRune, and then expect the application to inspect the Rune() member of the EventKey.
const ( KeyRune Key = iota + 256 KeyUp KeyDown KeyRight KeyLeft KeyUpLeft KeyUpRight KeyDownLeft KeyDownRight KeyCenter KeyPgUp KeyPgDn KeyHome KeyEnd KeyInsert KeyDelete KeyHelp KeyExit KeyClear KeyCancel KeyPrint KeyPause KeyBacktab KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyF13 KeyF14 KeyF15 KeyF16 KeyF17 KeyF18 KeyF19 KeyF20 KeyF21 KeyF22 KeyF23 KeyF24 KeyF25 KeyF26 KeyF27 KeyF28 KeyF29 KeyF30 KeyF31 KeyF32 KeyF33 KeyF34 KeyF35 KeyF36 KeyF37 KeyF38 KeyF39 KeyF40 KeyF41 KeyF42 KeyF43 KeyF44 KeyF45 KeyF46 KeyF47 KeyF48 KeyF49 KeyF50 KeyF51 KeyF52 KeyF53 KeyF54 KeyF55 KeyF56 KeyF57 KeyF58 KeyF59 KeyF60 KeyF61 KeyF62 KeyF63 KeyF64 )
const ( KeyCtrlSpace Key = iota KeyCtrlA KeyCtrlB KeyCtrlC KeyCtrlD KeyCtrlE KeyCtrlF KeyCtrlG KeyCtrlH KeyCtrlI KeyCtrlJ KeyCtrlK KeyCtrlL KeyCtrlM KeyCtrlN KeyCtrlO KeyCtrlP KeyCtrlQ KeyCtrlR KeyCtrlS KeyCtrlT KeyCtrlU KeyCtrlV KeyCtrlW KeyCtrlX KeyCtrlY KeyCtrlZ KeyCtrlLeftSq // Escape KeyCtrlBackslash KeyCtrlRightSq KeyCtrlCarat KeyCtrlUnderscore )
const ( KeyNUL Key = iota KeySOH KeySTX KeyETX KeyEOT KeyENQ KeyACK KeyBEL KeyBS KeyTAB KeyLF KeyVT KeyFF KeyCR KeySO KeySI KeyDLE KeyDC1 KeyDC2 KeyDC3 KeyDC4 KeyNAK KeySYN KeyETB KeyCAN KeyEM KeySUB KeyESC KeyFS KeyGS KeyRS KeyUS KeySP KeyDEL Key = 0x7F )
These are the defined ASCII values for key codes. They generally match with KeyCtrl values.
type ModMask ¶
type ModMask int16
ModMask is a mask of modifier keys. Note that it will not always be possible to report modifier keys.
const ModNone ModMask = 0
type Screen ¶
type Screen interface {
// Init initializes the screen for use.
Init() error
// Fini finalizes the screen also releasing resources.
Fini()
// Clear erases the screen. The contents of any screen buffers
// will also be cleared. This has the logical effect of
// filling the screen with spaces, using the global default style.
Clear()
// SetCell sets the cell at the given location.
// The ch list contains at most one rune of width > 0, and the
// runes with zero width (combining marks) must follow the first
// non-zero width character. (If only combining marks are present,
// a space character will be filled in.)
//
// Note that double wide runes occupy two cells, and attempts to
// place a character at the immediately adjacent cell will have
// undefined effects. Double wide runes that are printed in the
// last column will be replaced with a single width space on output.
//
// SetCell may change the cursor location. Callers should explictly
// save and restore cursor state if neccesary. The cursor visibility
// is not affected, so callers probably should hide the cursor when
// calling this.
//
// Note that the results will not be visible until either Show() or
// Sync() are called.
SetCell(x int, y int, style Style, ch ...rune)
// PutCell stores the contents of the given cell at the given location.
// The Dirty flag on the stored cell is set to true if the contents
// do not match.
PutCell(x, y int, cell *Cell)
// GetCell returns the contents of the given cell. If the coordinates
// are out of range, then nil will be returned for the rune array.
// This will also be the case if no content has been written to that
// location. Note that the returned Cell object is a copy, and
// modifications made will not change the display.
GetCell(x, y int) *Cell
// SetStyle sets the default style to use when clearing the screen
// or when StyleDefault is specified. If it is also StyleDefault,
// then whatever system/terminal default is relevant will be used.
SetStyle(style Style)
// ShowCursor is used to display the cursor at a given location.
// If the coordinates -1, -1 are given or are otherwise outside the
// dimensions of the screen, the cursor will be hidden.
ShowCursor(x int, y int)
// HideCursor is used to hide the cursor. Its an alias for
// ShowCursor(-1, -1).
HideCursor()
// Size returns the screen size as width, height. This changes in
// response to a call to Clear or Flush.
Size() (int, int)
// PollEvent waits for events to arrive. Main application loops
// must spin on this to prevent the application from stalling.
// Furthermore, this will return nil if the Screen is finalized.
PollEvent() Event
// PostEvent posts an event into the event stream.
PostEvent(Event)
// EnableMouse enables the mouse. (If your terminal supports it.)
EnableMouse()
// DisableMouse disables the mouse.
DisableMouse()
// Colors returns the number of colors. All colors are assumed to
// use the ANSI color map. If a terminal is monochrome, it will
// return 0.
Colors() int
// Show takes any output that was deferred due to buffering, and
// flushes it to the physical display. It does so in the most
// efficient and least visually disruptive manner possible.
Show()
// Sync works like Show(), but it updates every visible cell on the
// physical display, assuming that it is not synchronized with any
// internal model. This may be both expensive and visually jarring,
// so it should only be used when believed to actually be necessary.
// Typically this is called as a result of a user-requested redraw
// (e.g. to clear up on screen corruption caused by some other program),
// or during a resize event.
Sync()
// CharacterSet() returns information about the character set.
// This isn't the full locale, but it does give us the input/ouput
// character set. Note that this is just for diagnostic purposes,
// we normally translate input/output to/from UTF-8, regardless of
// what the user's environment is.
CharacterSet() string
}
Screen represents the physical (or emulated) screen. This can be a terminal window or a physical console. Platforms implement this differerently.
func NewConsoleScreen ¶
func NewTerminfoScreen ¶
NewTerminfoScreen returns a Screen that uses the stock TTY interface and POSIX termios, combined with a terminfo description taken from the $TERM environment variable. It returns an error if the terminal is not supported for any reason.
For terminals that do not support dynamic resize events, the $LINES $COLUMNS environment variables can be set to the actual window size, otherwise defaults taken from the terminal database are used.
type SimCell ¶
type SimCell struct {
// Bytes is the actual character bytes. Normally this is
// rune data, but it could be be data in another encoding system.
Bytes []byte
// Style is the style used to display the data.
Style Style
// Runes is the list of runes, unadulterated, in UTF-8.
Runes []rune
}
SimCell represents a simulated screen cell. The purpose of this is to track on screen content.
type SimulationScreen ¶
type SimulationScreen interface {
// InjectKeyBytes injects a stream of bytes corresponding to
// the native encoding (see charset). It turns true if the entire
// set of bytes were processed and delivered as KeyEvents, false
// if any bytes were not fully understood. Any bytes that are not
// fully converted are discarded.
InjectKeyBytes(buf []byte) bool
// InjectKey injects a key event. The rune is a UTF-8 rune, post
// any translation.
InjectKey(key Key, r rune, mod ModMask)
// InjectMouse injects a mouse event.
InjectMouse(x, y int, buttons ButtonMask, mod ModMask)
// Resize resizes the underlying physical screen. It also causes
// a resize event to be injected during the next Show() or Sync().
// A new physical contents array will be allocated (with data from
// the old copied), so any prior value obtained with GetContents
// won't be used anymore
Resize(width, height int)
// GetContents returns screen contents as an array of
// cells, along with the physical width & height. Note that the
// physical contents will be used until the next time Resize()
// is called.
GetContents() (cells []SimCell, width int, height int)
// GetCursor returns the cursor details.
GetCursor() (x int, y int, visible bool)
Screen
}
SimulationScreen represents a screen simulation. This is intended to be a superset of normal Screens, but also adds some important interfaces for testing.
func NewSimulationScreen ¶
func NewSimulationScreen(charset string) SimulationScreen
NewSimulationScreen returns a SimulationScreen. Note that SimulationScreen is also a Screen.
type Style ¶
type Style int64
Style represents a complete text style, including both foreground and background color. We encode it in a 64-bit int for efficiency. The coding is (MSB): <16b rsvd><16b attr><16b fgcolor><16b bgcolor>. This gives 16bit color options, if it ever becomes truly necessary. However, applications must not rely on this encoding.
Note that not all terminals can display all colors or attributes, and many might have specific incompatibilities between specific attributes and color combinations.
const StyleDefault Style = 0
func (Style) Background ¶
Background returns a new style based on s, with the background color set as requested. ColorDefault can be used to select the global default.
func (Style) Blink ¶
Blink returns a new style based on s, with the blink attribute set as requested.
func (Style) Decompose ¶
Decompose breaks a style up, returning the foreground, background, and other attributes.
func (Style) Foreground ¶
Foreground returns a new style based on s, with the foreground color set as requested. ColorDefault can be used to select the global default.
type Terminfo ¶
type Terminfo struct {
Name string `json:"name"`
Aliases []string `json:"aliases,omitempty"`
Columns int `json:"cols,omitempty"` // cols
Lines int `json:"lines,omitempty"` // lines
Colors int `json:"colors,omitempty"` // colors
Bell string `json:"bell,omitempty"` // bell
Clear string `json:"clear,omitempty"` // clear
EnterCA string `json:"smcup,omitempty"` // smcup
ExitCA string `json:"rmcup,omitempty"` // rmcup
ShowCursor string `json:"cnorm,omitempty"` // cnorm
HideCursor string `json:"civis,omitempty"` // civis
AttrOff string `json:"sgr0,omitempty"` // sgr0
Underline string `json:"smul,omitempty"` // smul
Bold string `json:"bold,omitempty"` // bold
Blink string `json:"blink,omitempty"` // blink
Reverse string `json:"rev,omitempty"` // rev
Dim string `json:"dim,omitempty"` // dim
EnterKeypad string `json:"smkx,omitempty"` // smkx
ExitKeypad string `json:"rmkx,omitempty"` // rmkx
SetFg string `json:"setaf,omitempty"` // setaf
SetBg string `json:"setbg,omitempty"` // setab
SetCursor string `json:"cup,omitempty"` // cup
CursorBack1 string `json:"cub1,omitempty"` // cub1
CursorUp1 string `json:"cuu1,omitempty"` // cuu1
PadChar string `json:"pad,omitempty"` // pad
KeyBackspace string `json:"kbs,omitempty"` // kbs
KeyF1 string `json:"kf1,omitempty"` // kf1
KeyF2 string `json:"kf2,omitempty"` // kf2
KeyF3 string `json:"kf3,omitempty"` // kf3
KeyF4 string `json:"kf4,omitempty"` // kf4
KeyF5 string `json:"kf5,omitempty"` // kf5
KeyF6 string `json:"kf6,omitempty"` // kf6
KeyF7 string `json:"kf7,omitempty"` // kf7
KeyF8 string `json:"kf8,omitempty"` // kf8
KeyF9 string `json:"kf9,omitempty"` // kf9
KeyF10 string `json:"kf10,omitempty"` // kf10
KeyF11 string `json:"kf11,omitempty"` // kf11
KeyF12 string `json:"kf12,omitempty"` // kf12
KeyF13 string `json:"kf13,omitempty"` // kf13
KeyF14 string `json:"kf14,omitempty"` // kf14
KeyF15 string `json:"kf15,omitempty"` // kf15
KeyF16 string `json:"kf16,omitempty"` // kf16
KeyF17 string `json:"kf17,omitempty"` // kf17
KeyF18 string `json:"kf18,omitempty"` // kf18
KeyF19 string `json:"kf19,omitempty"` // kf19
KeyF20 string `json:"kf20,omitempty"` // kf20
KeyF21 string `json:"kf21,omitempty"` // kf21
KeyF22 string `json:"kf22,omitempty"` // kf22
KeyF23 string `json:"kf23,omitempty"` // kf23
KeyF24 string `json:"kf24,omitempty"` // kf24
KeyF25 string `json:"kf25,omitempty"` // kf25
KeyF26 string `json:"kf26,omitempty"` // kf26
KeyF27 string `json:"kf27,omitempty"` // kf27
KeyF28 string `json:"kf28,omitempty"` // kf28
KeyF29 string `json:"kf29,omitempty"` // kf29
KeyF30 string `json:"kf30,omitempty"` // kf30
KeyF31 string `json:"kf31,omitempty"` // kf31
KeyF32 string `json:"kf32,omitempty"` // kf32
KeyF33 string `json:"kf33,omitempty"` // kf33
KeyF34 string `json:"kf34,omitempty"` // kf34
KeyF35 string `json:"kf35,omitempty"` // kf35
KeyF36 string `json:"kf36,omitempty"` // kf36
KeyF37 string `json:"kf37,omitempty"` // kf37
KeyF38 string `json:"kf38,omitempty"` // kf38
KeyF39 string `json:"kf39,omitempty"` // kf39
KeyF40 string `json:"kf40,omitempty"` // kf40
KeyF41 string `json:"kf41,omitempty"` // kf41
KeyF42 string `json:"kf42,omitempty"` // kf42
KeyF43 string `json:"kf43,omitempty"` // kf43
KeyF44 string `json:"kf44,omitempty"` // kf44
KeyF45 string `json:"kf45,omitempty"` // kf45
KeyF46 string `json:"kf46,omitempty"` // kf46
KeyF47 string `json:"kf47,omitempty"` // kf47
KeyF48 string `json:"kf48,omitempty"` // kf48
KeyF49 string `json:"kf49,omitempty"` // kf49
KeyF50 string `json:"kf50,omitempty"` // kf50
KeyF51 string `json:"kf51,omitempty"` // kf51
KeyF52 string `json:"kf52,omitempty"` // kf52
KeyF53 string `json:"kf53,omitempty"` // kf53
KeyF54 string `json:"kf54,omitempty"` // kf54
KeyF55 string `json:"kf55,omitempty"` // kf55
KeyF56 string `json:"kf56,omitempty"` // kf56
KeyF57 string `json:"kf57,omitempty"` // kf57
KeyF58 string `json:"kf58,omitempty"` // kf58
KeyF59 string `json:"kf59,omitempty"` // kf59
KeyF60 string `json:"kf60,omitempty"` // kf60
KeyF61 string `json:"kf61,omitempty"` // kf61
KeyF62 string `json:"kf62,omitempty"` // kf62
KeyF63 string `json:"kf63,omitempty"` // kf63
KeyF64 string `json:"kf64,omitempty"` // kf64
KeyInsert string `json:"kich,omitempty"` // kich1
KeyDelete string `json:"kdch,omitempty"` // kdch1
KeyHome string `json:"khome,omitempty"` // khome
KeyEnd string `json:"kend,omitempty"` // kend
KeyHelp string `json:"khlp,omitempty"` // khlp
KeyPgUp string `json:"kpp,omitempty"` // kpp
KeyPgDn string `json:"knp,omitempty"` // knp
KeyUp string `json:"kcuu1,omitempty"` // kcuu1
KeyDown string `json:"kcud1,omitempty"` // kcud1
KeyLeft string `json:"kcub1,omitempty"` // kcub1
KeyRight string `json:"kcuf1,omitempty"` // kcuf1
KeyBacktab string `json:"kcbt,omitempty"` // kcbt
KeyExit string `json:"kext,omitempty"` // kext
KeyClear string `json:"kclr,omitempty"` // kclr
KeyPrint string `json:"kprt,omitempty"` // kprt
KeyCancel string `json:"kcan,omitempty"` // kcan
Mouse string `json:"kmous,omitempty"` // kmous
MouseMode string `json:"XM,omitempty"` // XM
AltChars string `json:"acsc,omitempty"` // acsc
EnterAcs string `json:"smacs,omitempty"` // smacs
ExitAcs string `json:"rmacs,omitempty"` // rmacs
}
Terminfo represents a terminfo entry. Note that we use friendly names in Go, but when we write out JSON, we use the same names as terminfo. The name, aliases and smous, rmous fields do not come from terminfo directly.
func LookupTerminfo ¶
LookupTerminfo attemps to find a definition for the named $TERM. It first looks in the builtin database, which should cover just about everyone. If it can't find one there, then it will attempt to read one from the JSON file located in either $TCELLDB, or in this package's source directory. (XXX: Perhaps move that to $HOME/.tcelldb or somesuch instead? What about somewhere in /etc?)
func (*Terminfo) TColor ¶
Color returns a string corresponding to the given foreground and background colors. Either fg or bg can be set to -1 to elide.
func (*Terminfo) TGoto ¶
TGoto returns a string suitable for addressing the cursor at the given row and column. The origin 0, 0 is in the upper left corner of the screen.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
boxes just displays random colored boxes on your terminal screen.
|
boxes just displays random colored boxes on your terminal screen. |
|
Package termbox is a compatibility layer to allow tcells to emulate the github.com/nsf/termbox package.
|
Package termbox is a compatibility layer to allow tcells to emulate the github.com/nsf/termbox package. |