terminfo

package
v2.5.4-0...-0e5909b Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

This package represents the parent for all terminals.

In older versions of tcell we had (a couple of) different external file formats for the terminal database. Those are now removed. All terminal definitions are supplied by one of two methods:

  1. Compiled Go code

  2. For systems with terminfo and infocmp, dynamically generated at runtime.

The Go code can be generated using the mkinfo utility in this directory. The database entry should be generated into a package in a directory named as the first character of the package name. (This permits us to group them all without having a huge directory of little packages.)

It may be desirable to add new packages to the extended package, or -- rarely -- the base package.

Applications which want to have the large set of terminal descriptions built into the binary can simply import the extended package. Otherwise a smaller reasonable default set (the base package) will be included instead.

Documentation

Index

Constants

View Source
const (
	ModifiersNone  = 0
	ModifiersXTerm = 1
)

Variables

View Source
var (
	// ErrTermNotFound indicates that a suitable terminal entry could
	// not be found.  This can result from either not having TERM set,
	// or from the TERM failing to support certain minimal functionality,
	// in particular absolute cursor addressability (the cup capability)
	// is required.  For example, legacy "adm3" lacks this capability,
	// whereas the slightly newer "adm3a" supports it.  This failure
	// occurs most often with "dumb".
	ErrTermNotFound = errors.New("terminal entry not found")
)

Functions

func AddTerminfo

func AddTerminfo(t *Terminfo)

AddTerminfo can be called to register a new Terminfo entry.

Types

type Terminfo

type Terminfo struct {
	Name         string
	Aliases      []string
	Columns      int    // cols
	Lines        int    // lines
	Colors       int    // colors
	Bell         string // bell
	Clear        string // clear
	EnterCA      string // smcup
	ExitCA       string // rmcup
	ShowCursor   string // cnorm
	HideCursor   string // civis
	AttrOff      string // sgr0
	Underline    string // smul
	Bold         string // bold
	Blink        string // blink
	Reverse      string // rev
	Dim          string // dim
	Italic       string // sitm
	EnterKeypad  string // smkx
	ExitKeypad   string // rmkx
	SetFg        string // setaf
	SetBg        string // setab
	ResetFgBg    string // op
	SetCursor    string // cup
	CursorBack1  string // cub1
	CursorUp1    string // cuu1
	PadChar      string // pad
	KeyBackspace string // kbs
	KeyF1        string // kf1
	KeyF2        string // kf2
	KeyF3        string // kf3
	KeyF4        string // kf4
	KeyF5        string // kf5
	KeyF6        string // kf6
	KeyF7        string // kf7
	KeyF8        string // kf8
	KeyF9        string // kf9
	KeyF10       string // kf10
	KeyF11       string // kf11
	KeyF12       string // kf12
	KeyF13       string // kf13
	KeyF14       string // kf14
	KeyF15       string // kf15
	KeyF16       string // kf16
	KeyF17       string // kf17
	KeyF18       string // kf18
	KeyF19       string // kf19
	KeyF20       string // kf20
	KeyF21       string // kf21
	KeyF22       string // kf22
	KeyF23       string // kf23
	KeyF24       string // kf24
	KeyF25       string // kf25
	KeyF26       string // kf26
	KeyF27       string // kf27
	KeyF28       string // kf28
	KeyF29       string // kf29
	KeyF30       string // kf30
	KeyF31       string // kf31
	KeyF32       string // kf32
	KeyF33       string // kf33
	KeyF34       string // kf34
	KeyF35       string // kf35
	KeyF36       string // kf36
	KeyF37       string // kf37
	KeyF38       string // kf38
	KeyF39       string // kf39
	KeyF40       string // kf40
	KeyF41       string // kf41
	KeyF42       string // kf42
	KeyF43       string // kf43
	KeyF44       string // kf44
	KeyF45       string // kf45
	KeyF46       string // kf46
	KeyF47       string // kf47
	KeyF48       string // kf48
	KeyF49       string // kf49
	KeyF50       string // kf50
	KeyF51       string // kf51
	KeyF52       string // kf52
	KeyF53       string // kf53
	KeyF54       string // kf54
	KeyF55       string // kf55
	KeyF56       string // kf56
	KeyF57       string // kf57
	KeyF58       string // kf58
	KeyF59       string // kf59
	KeyF60       string // kf60
	KeyF61       string // kf61
	KeyF62       string // kf62
	KeyF63       string // kf63
	KeyF64       string // kf64
	KeyInsert    string // kich1
	KeyDelete    string // kdch1
	KeyHome      string // khome
	KeyEnd       string // kend
	KeyHelp      string // khlp
	KeyPgUp      string // kpp
	KeyPgDn      string // knp
	KeyUp        string // kcuu1
	KeyDown      string // kcud1
	KeyLeft      string // kcub1
	KeyRight     string // kcuf1
	KeyBacktab   string // kcbt
	KeyExit      string // kext
	KeyClear     string // kclr
	KeyPrint     string // kprt
	KeyCancel    string // kcan
	Mouse        string // kmous
	AltChars     string // acsc
	EnterAcs     string // smacs
	ExitAcs      string // rmacs
	EnableAcs    string // enacs
	KeyShfRight  string // kRIT
	KeyShfLeft   string // kLFT
	KeyShfHome   string // kHOM
	KeyShfEnd    string // kEND
	KeyShfInsert string // kIC
	KeyShfDelete string // kDC

	StrikeThrough           string // smxx
	SetFgBg                 string // setfgbg
	SetFgBgRGB              string // setfgbgrgb
	SetFgRGB                string // setfrgb
	SetBgRGB                string // setbrgb
	KeyShfUp                string // shift-up
	KeyShfDown              string // shift-down
	KeyShfPgUp              string // shift-kpp
	KeyShfPgDn              string // shift-knp
	KeyCtrlUp               string // ctrl-up
	KeyCtrlDown             string // ctrl-left
	KeyCtrlRight            string // ctrl-right
	KeyCtrlLeft             string // ctrl-left
	KeyMetaUp               string // meta-up
	KeyMetaDown             string // meta-left
	KeyMetaRight            string // meta-right
	KeyMetaLeft             string // meta-left
	KeyAltUp                string // alt-up
	KeyAltDown              string // alt-left
	KeyAltRight             string // alt-right
	KeyAltLeft              string // alt-left
	KeyCtrlHome             string
	KeyCtrlEnd              string
	KeyMetaHome             string
	KeyMetaEnd              string
	KeyAltHome              string
	KeyAltEnd               string
	KeyAltShfUp             string
	KeyAltShfDown           string
	KeyAltShfLeft           string
	KeyAltShfRight          string
	KeyMetaShfUp            string
	KeyMetaShfDown          string
	KeyMetaShfLeft          string
	KeyMetaShfRight         string
	KeyCtrlShfUp            string
	KeyCtrlShfDown          string
	KeyCtrlShfLeft          string
	KeyCtrlShfRight         string
	KeyCtrlShfHome          string
	KeyCtrlShfEnd           string
	KeyAltShfHome           string
	KeyAltShfEnd            string
	KeyMetaShfHome          string
	KeyMetaShfEnd           string
	EnablePaste             string // bracketed paste mode
	DisablePaste            string
	PasteStart              string
	PasteEnd                string
	Modifiers               int
	InsertChar              string // string to insert a character (ich1)
	AutoMargin              bool   // true if writing to last cell in line advances
	TrueColor               bool   // true if the terminal supports direct color
	CursorDefault           string
	CursorBlinkingBlock     string
	CursorSteadyBlock       string
	CursorBlinkingUnderline string
	CursorSteadyUnderline   string
	CursorBlinkingBar       string
	CursorSteadyBar         string
	EnterUrl                string
	ExitUrl                 string
	SetWindowSize           string
}

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

func LookupTerminfo(name string) (*Terminfo, error)

LookupTerminfo attempts to find a definition for the named $TERM.

func (*Terminfo) TColor

func (t *Terminfo) TColor(fi, bi int) string

TColor 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

func (t *Terminfo) TGoto(col, row int) string

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.

func (*Terminfo) TParm

func (t *Terminfo) TParm(s string, p ...interface{}) string

TParm takes a terminfo parameterized string, such as setaf or cup, and evaluates the string, and returns the result with the parameter applied.

func (*Terminfo) TPuts

func (t *Terminfo) TPuts(w io.Writer, s string)

TPuts emits the string to the writer, but expands inline padding indications (of the form $<[delay]> where [delay] is msec) to a suitable time (unless the terminfo string indicates this isn't needed by specifying npc - no padding). All Terminfo based strings should be emitted using this function.

Directories

Path Synopsis
a
b
Package base contains the base terminal descriptions that are likely to be needed by any stock application.
Package base contains the base terminal descriptions that are likely to be needed by any stock application.
c
d
e
Package extended contains an extended set of terminal descriptions.
Package extended contains an extended set of terminal descriptions.
f
g
h
k
l
p
r
s
sun
t
v
w
x

Jump to

Keyboard shortcuts

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