terminfo

package
v2.13.8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 170

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

This section is empty.

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.

func TerminfoNames added in v2.10.0

func TerminfoNames() []string

Types

type Terminfo

type Terminfo struct {
	Name        string
	Aliases     []string
	Columns     int    // cols
	Lines       int    // lines
	Colors      int    // colors
	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
	PadChar     string // pad
	Mouse       string // kmous
	AltChars    string // acsc
	EnterAcs    string // smacs
	ExitAcs     string // rmacs
	EnableAcs   string // enacs

	StrikeThrough     string // smxx
	SetFgBg           string // setfgbg
	SetFgBgRGB        string // setfgbgrgb
	SetFgRGB          string // setfrgb
	SetBgRGB          string // setbrgb
	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
	DisableAutoMargin string // smam
	EnableAutoMargin  string // rmam
	XTermLike         bool   // (XT) has XTerm extensions
}

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 ...any) 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
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
k
l
p
r
s
sun
t
v
x

Jump to

Keyboard shortcuts

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