terminfo

package module
v0.0.0-...-fe57201 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 10 Imported by: 0

README

terminfo GoDoc

Simple little terminfo parsing package.

TODO

  • Testing

Documentation

Overview

Package terminfo implements reading terminfo files in pure go.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSmallFile  = errors.New("terminfo: file too small")
	ErrBadString  = errors.New("terminfo: bad string")
	ErrBigSection = errors.New("terminfo: section too big")
	ErrBadHeader  = errors.New("terminfo: bad header")
)

These are the decoding errors.

View Source
var ErrEmptyTerm = errors.New("terminfo: empty term name")

Returned when no name is provided to Load.

Functions

func Parm

func Parm(s string, p ...interface{}) string

Parm evaluates a terminfo parameterized string, such as caps.SetAForeground, and returns the result.

Types

type Terminfo

type Terminfo struct {
	Names      []string
	Bools      [caps.BoolCount]bool
	Numbers    [caps.NumberCount]int16
	Strings    [caps.StringCount]string
	ExtBools   map[string]bool
	ExtNumbers map[string]int16
	ExtStrings map[string]string
}

Terminfo describes a terminal's capabilities.

func Load

func Load(name string) (ti *Terminfo, err error)

Load follows the behavior described in terminfo(5) to find correct the terminfo file using the name, reads the file and then returns a Terminfo struct that describes the file.

func LoadEnv

func LoadEnv() (*Terminfo, error)

LoadEnv calls Load with the name as $TERM.

func (*Terminfo) Color

func (ti *Terminfo) Color(fg, bg int) (rv string)

Color takes a foreground and background color and returns string that sets them for this terminal. TODO redo with styles integer

func (*Terminfo) Goto

func (ti *Terminfo) Goto(row, col int) string

Goto 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) Parm

func (ti *Terminfo) Parm(i int, p ...interface{}) string

Parm calls the function Parm with the string in ti.Strings at i and the variadic arguments.

func (*Terminfo) Puts

func (ti *Terminfo) Puts(w io.Writer, s string, lines, baud int)

Puts emits the string to the writer, but expands inline padding indications (of the form $<[delay]> where [delay] is msec) to a suitable number of padding characters (usually null bytes) based upon the supplied baud. At high baud rates, more padding characters will be inserted.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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