info

package
v0.0.0-...-d3199ed Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

Rearranged from this package.

Documentation

Index

Constants

View Source
const (
	None  = 0
	XTerm = 1
)
View Source
const (
	Debug = true // if set to false, the compiler will cleanup/remove the lines inside functions
)

Variables

View Source
var (
	// NotFound 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".
	NotFound = errors.New("terminal entry not found")
)

Functions

func AddTerminfo

func AddTerminfo(t *Term)

AddTerminfo can be called to register a new Term entry.

func RemoveAllInfos

func RemoveAllInfos()

RemoveAllInfos clears up some RAM after we've got what we needed (our Commander)

Types

type Commander

type Commander struct {
	Colors  int // colors
	Columns int // cols
	Lines   int // lines

	PadChar       string
	SetFg         string // setaf
	SetBg         string // setab
	SetFgBg       string // setfgbg
	SetFgBgRGB    string // setfgbgrgb
	SetFgRGB      string // setfrgb
	SetBgRGB      string // setbrgb
	SetCursor     string // cup
	EnterAcs      string // smacs
	ExitAcs       string // rmacs
	AltChars      string // acsc
	Clear         string // clear
	HideCursor    string // civis
	ShowCursor    string // cnorm
	EnterCA       string
	EnableAcs     string
	AttrOff       string
	ExitCA        string
	ExitKeypad    string
	Bold          string
	Underline     string
	Reverse       string
	Blink         string
	Dim           string
	Italic        string
	StrikeThrough string
	ResetFgBg     string
	EnableMouse   string
	DisableMouse  string
	HasMouse      bool
	HasHideCursor bool
	// contains filtered or unexported fields
}

func NewCommander

func NewCommander(ti *Term) *Commander

func (*Commander) GoTo

func (t *Commander) GoTo(w io.Writer, hash int)

GoTo for addressing the cursor at the given row and column - but using the hash of that position

func (*Commander) MakeGoToCache

func (t *Commander) MakeGoToCache(size *term.Size, hashFn func(column, row int) int)

MakeGoToCache - caches goto commands

func (*Commander) PutAttrOff

func (t *Commander) PutAttrOff(w io.Writer)
func (t *Commander) PutBlink(w io.Writer)

func (*Commander) PutBold

func (t *Commander) PutBold(w io.Writer)

func (*Commander) PutClear

func (t *Commander) PutClear(w io.Writer)

func (*Commander) PutDim

func (t *Commander) PutDim(w io.Writer)

func (*Commander) PutDisableMouse

func (t *Commander) PutDisableMouse(w io.Writer)

func (*Commander) PutEnableAcs

func (t *Commander) PutEnableAcs(w io.Writer)

func (*Commander) PutEnableMouse

func (t *Commander) PutEnableMouse(w io.Writer)

func (*Commander) PutEnterCA

func (t *Commander) PutEnterCA(w io.Writer)

func (*Commander) PutExitCA

func (t *Commander) PutExitCA(w io.Writer)

func (*Commander) PutExitKeypad

func (t *Commander) PutExitKeypad(w io.Writer)

func (*Commander) PutHideCursor

func (t *Commander) PutHideCursor(w io.Writer)

func (*Commander) PutItalic

func (t *Commander) PutItalic(w io.Writer)

func (*Commander) PutResetFgBg

func (t *Commander) PutResetFgBg(w io.Writer)

func (*Commander) PutReverse

func (t *Commander) PutReverse(w io.Writer)

func (*Commander) PutShowCursor

func (t *Commander) PutShowCursor(w io.Writer)

func (*Commander) PutStrikeThrough

func (t *Commander) PutStrikeThrough(w io.Writer)

func (*Commander) PutUnderline

func (t *Commander) PutUnderline(w io.Writer)

func (*Commander) TColor

func (t *Commander) 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 (*Commander) TParam

func (t *Commander) TParam(s string, ints ...int) string

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

func (*Commander) WriteBothColors

func (t *Commander) WriteBothColors(w io.Writer, fg, bg color.Color, isDelighted bool)

func (*Commander) WriteBytes

func (t *Commander) WriteBytes(w io.Writer, s []byte) error

WriteString 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 info string indicates this isn't needed by specifying npc - no padding). All Term based strings should be emitted using this function.

func (*Commander) WriteColor

func (t *Commander) WriteColor(w io.Writer, c color.Color, isForeground, isDelighted bool)

func (*Commander) WriteString

func (t *Commander) WriteString(w io.Writer, s string) error

WriteString 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 info string indicates this isn't needed by specifying npc - no padding). All Term based strings should be emitted using this function.

type Term

type Term struct {
	Columns      int // cols
	Width        int
	Lines        int // lines
	Height       int
	Colors       int // colors
	Modifiers    int
	Name         string
	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
	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
	MouseMode    string // XM
	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
	Aliases         []string
	TrueColor       bool // true if the terminal supports direct color
}

Term represents a info entry. Note that we use friendly names in Go, but when we write out JSON, we use the same names as info. The name, aliases and smous, rmous fields do not come from info directly.

func LookupTerminfo

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

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

Jump to

Keyboard shortcuts

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