package termfo
import "zgo.at/termfo"
Index ¶
- type Event
- type Terminfo
- func New(term string) (*Terminfo, error)
- func (ti Terminfo) FindKey(b []byte) (keys.Key, int)
- func (ti Terminfo) FindKeys(fp io.Reader) <-chan Event
- func (ti Terminfo) Get(c *caps.Cap, args ...int) string
- func (ti Terminfo) Put(w io.Writer, c *caps.Cap, args ...int)
- func (ti Terminfo) String() string
- func (ti Terminfo) Supports(c *caps.Cap) bool
Types ¶
type Event ¶
type Event struct { Key keys.Key // Processed key that was pressed. Seq []byte // Unprocessed text; only usedful for debugging really. Err error // Error; only set for read errors. }
Event sent by FindKeys.
type Terminfo ¶
type Terminfo struct { Name string // Main name as listed in the terminfo file. Desc string // Some textual description. Aliases []string // Aliases for this terminal. Location string // Where it was loaded from; path or "builtin". Bools map[*caps.Cap]struct{} // Boolean capabilities. Numbers map[*caps.Cap]int32 // Number capabilities. Strings map[*caps.Cap]string // String capabilities. // Capabilities listed in the "extended" section. The values are in the // Bools, Numbers, and Strings maps. Extended []*caps.Cap // The default format uses int16, but the "extended number format" uses // int32. This lists the integer size as 2 or 4. IntSize int // List of keys, as sequence → Key mapping. e.g. "\x1b[OP" → KeyF1. // // This contains all key_* capabilities, plus a few generated ones for // modifier keys and such. Keys map[string]keys.Key }
Terminfo describes the terminfo database for a single terminal.
func New ¶
New reads the terminfo for term. If term is an empty string then the value of the TERM environment variable is used.
It tries to load a terminfo file according to these rules:
Use the path in TERMINFO if it's set and don't search any other locations.
Try built-in ones unless set NO_BUILTIN_TERMINFO is set.
Try ~/.terminfo/ as the database path.
Look in the paths listed in TERMINFO_DIRS.
Look in /lib/terminfo/
Look in /usr/share/terminfo/
These are the same rules as ncurses, except that step 2 was added.
TODO: curses allows setting a different path at compile-time; we can use infocmp -D to get this. Probably want to add this as step 7(?)
func (Terminfo) FindKey ¶
Find the first valid keypress in s.
Returns the key and number of bytes processed. On errors it will return UnknownSequence and the length of the string.
func (Terminfo) FindKeys ¶
FindKeys finds all keys in the given reader (usually stdin) and sends them in the channel.
Any read error will send an Event with Err set and it will stop reading keys.
func (Terminfo) Get ¶
Get a capability.
func (Terminfo) Put ¶
func (Terminfo) String ¶
func (Terminfo) Supports ¶
Supports reports if this terminal supports the given capability.
Source Files ¶
load.go param.go termfo.go
Directories ¶
Path | Synopsis |
---|---|
caps | Package caps contains a list of all terminfo capabilities. |
cmd | |
cmd/termfo | Program termfo prints information about the terminfo database. |
cmd/termfo/internal | |
keys | |
scaps | Package scaps contains a list of all terminfo capabilities. |
- Version
- v0.0.0-20240522162355-df5e07d67a5a (latest)
- Published
- May 22, 2024
- Platform
- linux/amd64
- Imports
- 14 packages
- Last checked
- 6 days ago –
Tools for package owners.