terminfo

package
v0.0.0-...-863c820 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package terminfo contains a simple and incomplete implementation of the terminfo database. Information was taken from the ncurses manpages term(5) and terminfo(5). Currently, only the string capabilities for special keys and for functions without parameters are actually used. Colors are still done with ANSI escape sequences. Other special features that are not (yet?) supported are reading from ~/.terminfo, the TERMINFO_DIRS variable, Berkeley database format and extended capabilities.

It is currently in the process of evolving out of termbox, and will become more complete over time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SearchPath

func SearchPath() []string

SearchPath returns candidate file paths to try to load from; this follows the behaviour described in terminfo(5) as distributed by ncurses.

Types

type FuncCode

type FuncCode uint8

FuncCode indexes Terminfo.Funcs

const (
	FuncEnterCA FuncCode = iota + 1
	FuncExitCA
	FuncShowCursor
	FuncHideCursor
	FuncClearScreen
	FuncSGR0
	FuncUnderline
	FuncBold
	FuncBlink
	FuncReverse
	FuncEnterKeypad
	FuncExitKeypad
	FuncEnterMouse
	FuncExitMouse
)

These constants provide convenient aliases for accessing function strings.

type KeyCode

type KeyCode uint8

KeyCode indexes Terminfo.Keys

const (
	KeyF1 KeyCode = iota + 1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyInsert
	KeyDelete
	KeyHome
	KeyEnd
	KeyPageUp
	KeyPageDown
	KeyUp
	KeyDown
	KeyLeft
	KeyRight
)

These constants provide convenient aliases for accessing key strings.

type Terminfo

type Terminfo struct {
	Name  string
	Keys  [maxKeys]string
	Funcs [maxFuncs]string
}

Terminfo describes how to interact with a terminal.

func GetBuiltin

func GetBuiltin(term string) (*Terminfo, error)

GetBuiltin returns a named builtin Terminfo.

func Load

func Load(term string) (*Terminfo, error)

Load Terminfo for the given terminal name. Unless you know better, you want to pass the value of os.Getenv("TERM")`. No default is currently provided, so an error will be returned for the empty string. Loaded Terminfo is cached on success, and the same value returned next time. Some builtins are provided for common terminals, and will be used if reading from the terminfo database fails.

func (Terminfo) FuncMap

func (info Terminfo) FuncMap() map[string]string

FuncMap builds and returns a string-string map of the control sequence functions defined for callers that are more interested in flexibility than performance.

func (Terminfo) KeyMap

func (info Terminfo) KeyMap() map[string]string

KeyMap builds and returns a string-string map of the key control sequences defined for callers that are more interested in flexibility than performance.

func (*Terminfo) ReadFrom

func (ti *Terminfo) ReadFrom(rs io.ReadSeeker) error

ReadFrom reads terminfo data from the given io.ReadSeeker, returning any read error.

TODO should we return an `nRead int` too so that TermInfo implements io.ReaderFrom?

Jump to

Keyboard shortcuts

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