terminal

package
v0.0.0-...-87adcba Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorBlack   = ColorValid + iota
	ColorMaroon  // 1
	ColorGreen   // 2
	ColorOlive   // 3
	ColorNavy    // 4
	ColorPurple  // 5
	ColorTeal    // 6
	ColorSilver  // 7
	ColorGray    // 8 //90
	ColorRed     // 9 //91
	ColorLime    // 10 //92
	ColorYellow  // 11 //93
	ColorBlue    // 12 //94
	ColorFuchsia // 13 //95
	ColorAqua    // 14 //96
	ColorWhite   // 15 //97
	Color16
	Color17
	Color18
	Color19
	Color20
	Color21
	Color22
	Color23
	Color24
	Color25
	Color26
	Color27
	Color28
	Color29
	Color30
	Color31
	Color32
	Color33
	Color34
	Color35
	Color36
	Color37
	Color38
	Color39
	Color40
	Color41
	Color42
	Color43
	Color44
	Color45
	Color46
	Color47
	Color48
	Color49
	Color50
	Color51
	Color52
	Color53
	Color54
	Color55
	Color56
	Color57
	Color58
	Color59
	Color60
	Color61
	Color62
	Color63
	Color64
	Color65
	Color66
	Color67
	Color68
	Color69
	Color70
	Color71
	Color72
	Color73
	Color74
	Color75
	Color76
	Color77
	Color78
	Color79
	Color80
	Color81
	Color82
	Color83
	Color84
	Color85
	Color86
	Color87
	Color88
	Color89
	Color90
	Color91
	Color92
	Color93
	Color94
	Color95
	Color96
	Color97
	Color98
	Color99
	Color100
	Color101
	Color102
	Color103
	Color104
	Color105
	Color106
	Color107
	Color108
	Color109
	Color110
	Color111
	Color112
	Color113
	Color114
	Color115
	Color116
	Color117
	Color118
	Color119
	Color120
	Color121
	Color122
	Color123
	Color124
	Color125
	Color126
	Color127
	Color128
	Color129
	Color130
	Color131
	Color132
	Color133
	Color134
	Color135
	Color136
	Color137
	Color138
	Color139
	Color140
	Color141
	Color142
	Color143
	Color144
	Color145
	Color146
	Color147
	Color148
	Color149
	Color150
	Color151
	Color152
	Color153
	Color154
	Color155
	Color156
	Color157
	Color158
	Color159
	Color160
	Color161
	Color162
	Color163
	Color164
	Color165
	Color166
	Color167
	Color168
	Color169
	Color170
	Color171
	Color172
	Color173
	Color174
	Color175
	Color176
	Color177
	Color178
	Color179
	Color180
	Color181
	Color182
	Color183
	Color184
	Color185
	Color186
	Color187
	Color188
	Color189
	Color190
	Color191
	Color192
	Color193
	Color194
	Color195
	Color196
	Color197
	Color198
	Color199
	Color200
	Color201
	Color202
	Color203
	Color204
	Color205
	Color206
	Color207
	Color208
	Color209
	Color210
	Color211
	Color212
	Color213
	Color214
	Color215
	Color216
	Color217
	Color218
	Color219
	Color220
	Color221
	Color222
	Color223
	Color224
	Color225
	Color226
	Color227
	Color228
	Color229
	Color230
	Color231
	Color232
	Color233
	Color234
	Color235
	Color236
	Color237
	Color238
	Color239
	Color240
	Color241
	Color242
	Color243
	Color244
	Color245
	Color246
	Color247
	Color248
	Color249
	Color250
	Color251
	Color252
	Color253
	Color254
	Color255
	ColorAliceBlue
	ColorAntiqueWhite
	ColorAquaMarine
	ColorAzure
	ColorBeige
	ColorBisque
	ColorBlanchedAlmond
	ColorBlueViolet
	ColorBrown
	ColorBurlyWood
	ColorCadetBlue
	ColorChartreuse
	ColorChocolate
	ColorCoral
	ColorCornflowerBlue
	ColorCornsilk
	ColorCrimson
	ColorDarkBlue
	ColorDarkCyan
	ColorDarkGoldenrod
	ColorDarkGray
	ColorDarkGreen
	ColorDarkKhaki
	ColorDarkMagenta
	ColorDarkOliveGreen
	ColorDarkOrange
	ColorDarkOrchid
	ColorDarkRed
	ColorDarkSalmon
	ColorDarkSeaGreen
	ColorDarkSlateBlue
	ColorDarkSlateGray
	ColorDarkTurquoise
	ColorDarkViolet
	ColorDeepPink
	ColorDeepSkyBlue
	ColorDimGray
	ColorDodgerBlue
	ColorFireBrick
	ColorFloralWhite
	ColorForestGreen
	ColorGainsboro
	ColorGhostWhite
	ColorGold
	ColorGoldenrod
	ColorGreenYellow
	ColorHoneydew
	ColorHotPink
	ColorIndianRed
	ColorIndigo
	ColorIvory
	ColorKhaki
	ColorLavender
	ColorLavenderBlush
	ColorLawnGreen
	ColorLemonChiffon
	ColorLightBlue
	ColorLightCoral
	ColorLightCyan
	ColorLightGoldenrodYellow
	ColorLightGray
	ColorLightGreen
	ColorLightPink
	ColorLightSalmon
	ColorLightSeaGreen
	ColorLightSkyBlue
	ColorLightSlateGray
	ColorLightSteelBlue
	ColorLightYellow
	ColorLimeGreen
	ColorLinen
	ColorMediumAquamarine
	ColorMediumBlue
	ColorMediumOrchid
	ColorMediumPurple
	ColorMediumSeaGreen
	ColorMediumSlateBlue
	ColorMediumSpringGreen
	ColorMediumTurquoise
	ColorMediumVioletRed
	ColorMidnightBlue
	ColorMintCream
	ColorMistyRose
	ColorMoccasin
	ColorNavajoWhite
	ColorOldLace
	ColorOliveDrab
	ColorOrange
	ColorOrangeRed
	ColorOrchid
	ColorPaleGoldenrod
	ColorPaleGreen
	ColorPaleTurquoise
	ColorPaleVioletRed
	ColorPapayaWhip
	ColorPeachPuff
	ColorPeru
	ColorPink
	ColorPlum
	ColorPowderBlue
	ColorRebeccaPurple
	ColorRosyBrown
	ColorRoyalBlue
	ColorSaddleBrown
	ColorSalmon
	ColorSandyBrown
	ColorSeaGreen
	ColorSeashell
	ColorSienna
	ColorSkyblue
	ColorSlateBlue
	ColorSlateGray
	ColorSnow
	ColorSpringGreen
	ColorSteelBlue
	ColorTan
	ColorThistle
	ColorTomato
	ColorTurquoise
	ColorViolet
	ColorWheat
	ColorWhiteSmoke
	ColorYellowGreen
)

Note that the order of these options is important -- it follows the definitions used by ECMA and XTerm. Hence any further named colors must begin at a value not less than 256.

View Source
const (
	ColorGrey           = ColorGray
	ColorDimGrey        = ColorDimGray
	ColorDarkGrey       = ColorDarkGray
	ColorDarkSlateGrey  = ColorDarkSlateGray
	ColorLightGrey      = ColorLightGray
	ColorLightSlateGrey = ColorLightSlateGray
	ColorSlateGrey      = ColorSlateGray
)

These are aliases for the color gray, because some of us spell it as grey.

View Source
const (
	SaveLineUpperLimit = 50000

	SaveLinesRowsOption = 60
)
View Source
const (
	C0_BEL
	C0_CR
	C0_HT
	C0_SI
	C0_SO
	CSI_CBT
	CSI_CHA
	CSI_CHT
	CSI_CNL
	CSI_CPL
	CSI_CUB
	CSI_CUD
	CSI_CUF
	CSI_CUP
	CSI_CUU
	CSI_DCH
	CSI_DECIC
	CSI_DECDC
	CSI_privRM
	CSI_DECSCL
	CSI_DECSCUSR
	CSI_privSM
	CSI_DECSTBM
	CSI_DECSTR
	CSI_ECMA48_SL
	CSI_ECMA48_SR
	CSI_FocusIn
	CSI_FocusOut
	CSI_DL
	CSI_DSR
	CSI_ECH
	CSI_ED
	CSI_EL
	CSI_HPA
	CSI_HPR
	CSI_ICH
	CSI_IL
	CSI_priDA
	CSI_REP
	CSI_RM
	CSI_secDA
	CSI_SD
	CSI_SM
	CSI_SU
	CSI_SCORC
	CSI_SLRM_SCOSC
	CSI_SGR
	CSI_TBC
	CSI_VPA
	CSI_VPR
	CSI_XTMODKEYS
	CSI_XTWINOPS
	DCS_DECRQSS
	ESC_BI
	ESC_DCS
	ESC_DECALN
	ESC_DECANM
	ESC_DECKPAM
	ESC_DECKPNM
	ESC_DECRC
	ESC_DECSC
	ESC_DOCS_UTF8
	ESC_DOCS_ISO8859_1
	ESC_FI
	ESC_HTS
	ESC_IND
	ESC_LS1R
	ESC_LS2
	ESC_LS2R
	ESC_LS3
	ESC_LS3R
	ESC_NEL
	ESC_RI
	ESC_RIS
	ESC_SS2
	ESC_SS3
	Graphemes
	OSC_4
	OSC_52
	OSC_0_1_2
	OSC_10_11_12_17_19
	OSC_112
	VT52_EGM
	VT52_ID
)
View Source
const (
	USER_INPUT_GROUND = iota
	USER_INPUT_ESC
	USER_INPUT_SS3
)
View Source
const (
	InputState_Normal = iota
	InputState_Escape
	InputState_Escape_VT52
	InputState_Esc_Space
	InputState_Esc_Hash
	InputState_Esc_Pct
	InputState_Select_Charset
	InputState_CSI
	InputState_CSI_Priv
	InputState_CSI_Quote
	InputState_CSI_DblQuote
	InputState_CSI_Bang
	InputState_CSI_SPC
	InputState_CSI_GT
	InputState_DCS
	InputState_DCS_Esc
	InputState_OSC
	InputState_OSC_Esc
	InputState_VT52_CUP_Arg1
	InputState_VT52_CUP_Arg2
)
View Source
const (
	Bold charAttribute = iota + 1
	Faint
	Italic
	Underlined
	Blink
	RapidBlink // this one is added by SGR
	Inverse
	Invisible
)
View Source
const (
	MouseTrackingMode_Disable           MouseTrackingMode = 0
	MouseTrackingMode_X10_Compat                          = 9
	MouseTrackingMode_VT200                               = 1000
	MouseTrackingMode_VT200_HighLight                     = 1001
	MouseTrackingMode_VT200_ButtonEvent                   = 1002
	MouseTrackingMode_VT200_AnyEvent                      = 1003
)
View Source
const (
	MouseTrackingEnc_Default MouseTrackingEnc = 0
	MouseTrackingEnc_UTF8                     = 1005
	MouseTrackingEnc_SGR                      = 1006
	MouseTrackingEnc_URXVT                    = 1015
)
View Source
const (
	// ColorReset is used to indicate that the color should use the
	// vanilla terminal colors.  (Basically go back to the defaults.)
	ColorReset = ColorSpecial | iota
)

Special colors.

View Source
const (
	DEVICE_ID = "64;1;9;15;21;22c"
)

* 64 - VT420 family * 1 - 132 columns * 9 - National Replacement Character-sets * 15 - DEC technical set * 21 - horizontal scrolling * 22 - color

Variables

View Source
var ColorNames = map[string]Color{}/* 146 elements not displayed */

ColorNames holds the written names of colors. Useful to present a list of recognized named colors.

View Source
var ColorValues = map[Color]int32{}/* 379 elements not displayed */

ColorValues maps color constants to their RGB values.

Functions

func Abs

func Abs[T constraints.Signed | constraints.Float](x T) T

func LookupTerminfo

func LookupTerminfo(name string) (ti *terminfo.Terminfo, e error)

LookupTerminfo attempts to find a definition for the named $TERM falling back to attempting to parse the output from infocmp.

func LowerBound

func LowerBound(array []int, target int) int

func RemoveIndex

func RemoveIndex(s []int, index int) []int

Types

type ActOn

type ActOn interface {
	Handle(emu *Emulator)
}

type Cell

type Cell struct {
	// contains filtered or unexported fields
}

contents saved in strings.Builder * Don't set the fields directly * * Cell is comparable

func (*Cell) Append

func (c *Cell) Append(r rune)

append to the contents

func (*Cell) Clear

func (c *Cell) Clear()

clear contents

func (*Cell) ContentsMatch

func (c *Cell) ContentsMatch(x Cell) bool

func (*Cell) Empty

func (c *Cell) Empty() bool

return true is the contents is "".

func (*Cell) GetContents

func (c *Cell) GetContents() string

func (Cell) GetRenditions

func (c Cell) GetRenditions() Renditions

func (*Cell) GetWidth

func (c *Cell) GetWidth() int

return cell grapheme width: 0,1,2

func (Cell) IsBlank

func (c Cell) IsBlank() bool

return true if the contents is "" or " " or non-break space(\uC2A0).

func (*Cell) IsDoubleWidth

func (c *Cell) IsDoubleWidth() bool

func (*Cell) IsDoubleWidthCont

func (c *Cell) IsDoubleWidthCont() bool

func (Cell) IsEarlyWrap

func (c Cell) IsEarlyWrap() bool

func (*Cell) Reset2

func (c *Cell) Reset2(attrs Cell)

reset cell with specified renditions TODO : the default contents is " "?

func (*Cell) SetContents

func (c *Cell) SetContents(chs []rune)

replace the contents

func (*Cell) SetDoubleWidth

func (c *Cell) SetDoubleWidth(value bool)

func (*Cell) SetDoubleWidthCont

func (c *Cell) SetDoubleWidthCont(value bool)

func (*Cell) SetEarlyWrap

func (c *Cell) SetEarlyWrap(v bool)

func (*Cell) SetRenditions

func (c *Cell) SetRenditions(r Renditions)

func (*Cell) SetUnderline

func (c *Cell) SetUnderline(underline bool)

func (Cell) String

func (c Cell) String() string

type CharsetState

type CharsetState struct {
	// contains filtered or unexported fields
}

only in vtMode, charset is enabled, otherwise UTF-8 is choosed.

func (*CharsetState) Equal

func (cs *CharsetState) Equal(x *CharsetState) bool

type ColMode

type ColMode uint8
type DrawState struct {
	width            int
	height           int
	cursorCol        int
	cursorRow        int
	cursorColor      Color
	combiningCharCol int
	combiningCharRow int

	defaultTabs bool
	tabs        []bool

	scrollingRegionTopRow    int
	scrollingRegionBottomRow int
	renditions               Renditions
	save                     SavedCursor

	// public fields
	NextPrintWillWrap bool

	// DEC private mode
	OriginMode                bool // two possiible value: ScrollingRegion(true), Absolute(false)
	AutoWrapMode              bool // true/false
	CursorVisible             bool // true/false
	ReverseVideo              bool // two possible value: Reverse(true), Normal(false)
	BracketedPaste            bool // true/false
	MouseReportingMode        int  // replace it with MouseTrackingMode
	MouseFocusEvent           bool // replace it with MouseTrackingState.focusEventMode
	MouseAlternateScroll      bool // rename to altScrollMode
	MouseEncodingMode         int  // replace it with MouseTrackingEnc
	ApplicationModeCursorKeys bool // =cursorKeyMode two possible value : Application(true), ANSI(false)
	mouseTrk                  MouseTrackingState
	altSendsEscape            bool

	// ANSI mode
	keyboardLocked  bool
	InsertMode      bool // true/false
	localEcho       bool
	autoNewlineMode bool

	// added for vt400 compatibility
	compatLevel         CompatibilityLevel // VT52, VT100, VT400
	altScreenBufferMode bool               // Alternate Screen Buffer support: default false
	columnMode          ColMode            // column mode 80 or 132, just for compatibility
	horizMarginMode     bool               // left and right margins support
	hMargin             int                // left margins
	nColsEff            int                // right margins
	bkspSendsDel        bool               // backspace send delete

	savedCursorSCO SavedCursorSCO // SCO console cursor state
}
const (
	ColMode_C80 ColMode = iota
	ColMode_C132
)

type Color

type Color uint64

https://github.com/gdamore/tcell/blob/master/color.go https://www.ditig.com/256-colors-cheat-sheet

Color represents a color. The low numeric values are the same as used by ECMA-48, and beyond that XTerm. A 24-bit RGB value may be used by adding in the ColorIsRGB flag. For Color names we use the W3C approved color names.

We use a 64-bit integer to allow future expansion if we want to add an 8-bit alpha, while still leaving us some room for extra options.

Note that on various terminals colors may be approximated however, or not supported at all. If no suitable representation for a color is known, the library will simply not set any color, deferring to whatever default attributes the terminal uses.

const (
	// ColorDefault is used to leave the Color unchanged from whatever
	// system or terminal default may exist.  It's also the zero value.
	ColorDefault Color = 0

	// ColorValid is used to indicate the color value is actually
	// valid (initialized).  This is useful to permit the zero value
	// to be treated as the default.
	ColorValid Color = 1 << 32

	// ColorIsRGB is used to indicate that the numeric value is not
	// a known color constant, but rather an RGB value.  The lower
	// order 3 bytes are RGB.
	ColorIsRGB Color = 1 << 33

	// ColorSpecial is a flag used to indicate that the values have
	// special meaning, and live outside of the color space(s).
	ColorSpecial Color = 1 << 34
)

func GetColor

func GetColor(name string) Color

GetColor creates a Color from a color name (W3C name). A hex value may be supplied as a string in the format "#ffffff".

func NewHexColor

func NewHexColor(v int32) Color

NewHexColor returns a color using the given 24-bit RGB value.

func NewRGBColor

func NewRGBColor(r, g, b int32) Color

NewRGBColor returns a new color with the given red, green, and blue values. Each value must be represented in the range 0-255.

func PaletteColor

func PaletteColor(index int) Color

PaletteColor creates a color based on the palette index.

func (Color) Hex

func (c Color) Hex() int32

Hex returns the color's hexadecimal RGB 24-bit value with each component consisting of a single byte, ala R << 16 | G << 8 | B. If the color is unknown or unset, -1 is returned.

func (Color) Index

func (c Color) Index() int

return the index of palette color, for RGB color return -1

func (Color) IsRGB

func (c Color) IsRGB() bool

IsRGB is true if the color is an RGB specific value.

func (Color) Name

func (c Color) Name() []string

lookup the color name slice if applicable, return nil if not applicable.

func (Color) RGB

func (c Color) RGB() (int32, int32, int32)

RGB returns the red, green, and blue components of the color, with each component represented as a value 0-255. In the event that the color cannot be broken up (not set usually), -1 is returned for each value.

func (Color) String

func (c Color) String() (name string)

return the string representation according to RGB specification as per XParseColor. for example: Color(0xBA55D3).String() returns "rgb:0x00BA/0x0055/0x00D3", for invalid Color, return empty string.

func (Color) TrueColor

func (c Color) TrueColor() Color

TrueColor returns the true color (RGB) version of the provided color. This is useful for ensuring color accuracy when using named colors. This will override terminal theme colors.

func (Color) Valid

func (c Color) Valid() bool

Valid indicates the color is a valid value (has been set).

type CompatibilityLevel

type CompatibilityLevel uint8
type DrawState struct {
	width            int
	height           int
	cursorCol        int
	cursorRow        int
	cursorColor      Color
	combiningCharCol int
	combiningCharRow int

	defaultTabs bool
	tabs        []bool

	scrollingRegionTopRow    int
	scrollingRegionBottomRow int
	renditions               Renditions
	save                     SavedCursor

	// public fields
	NextPrintWillWrap bool

	// DEC private mode
	OriginMode                bool // two possiible value: ScrollingRegion(true), Absolute(false)
	AutoWrapMode              bool // true/false
	CursorVisible             bool // true/false
	ReverseVideo              bool // two possible value: Reverse(true), Normal(false)
	BracketedPaste            bool // true/false
	MouseReportingMode        int  // replace it with MouseTrackingMode
	MouseFocusEvent           bool // replace it with MouseTrackingState.focusEventMode
	MouseAlternateScroll      bool // rename to altScrollMode
	MouseEncodingMode         int  // replace it with MouseTrackingEnc
	ApplicationModeCursorKeys bool // =cursorKeyMode two possible value : Application(true), ANSI(false)
	mouseTrk                  MouseTrackingState
	altSendsEscape            bool

	// ANSI mode
	keyboardLocked  bool
	InsertMode      bool // true/false
	localEcho       bool
	autoNewlineMode bool

	// added for vt400 compatibility
	compatLevel         CompatibilityLevel // VT52, VT100, VT400
	altScreenBufferMode bool               // Alternate Screen Buffer support: default false
	columnMode          ColMode            // column mode 80 or 132, just for compatibility
	horizMarginMode     bool               // left and right margins support
	hMargin             int                // left margins
	nColsEff            int                // right margins
	bkspSendsDel        bool               // backspace send delete

	savedCursorSCO SavedCursorSCO // SCO console cursor state
}
const (
	CompatLevel_Unused CompatibilityLevel = iota
	CompatLevel_VT52
	CompatLevel_VT100
	CompatLevel_VT400
)

type Cursor

type Cursor struct {
	// contains filtered or unexported fields
}

type CursorKeyMode

type CursorKeyMode uint8
type DrawState struct {
	width            int
	height           int
	cursorCol        int
	cursorRow        int
	cursorColor      Color
	combiningCharCol int
	combiningCharRow int

	defaultTabs bool
	tabs        []bool

	scrollingRegionTopRow    int
	scrollingRegionBottomRow int
	renditions               Renditions
	save                     SavedCursor

	// public fields
	NextPrintWillWrap bool

	// DEC private mode
	OriginMode                bool // two possiible value: ScrollingRegion(true), Absolute(false)
	AutoWrapMode              bool // true/false
	CursorVisible             bool // true/false
	ReverseVideo              bool // two possible value: Reverse(true), Normal(false)
	BracketedPaste            bool // true/false
	MouseReportingMode        int  // replace it with MouseTrackingMode
	MouseFocusEvent           bool // replace it with MouseTrackingState.focusEventMode
	MouseAlternateScroll      bool // rename to altScrollMode
	MouseEncodingMode         int  // replace it with MouseTrackingEnc
	ApplicationModeCursorKeys bool // =cursorKeyMode two possible value : Application(true), ANSI(false)
	mouseTrk                  MouseTrackingState
	altSendsEscape            bool

	// ANSI mode
	keyboardLocked  bool
	InsertMode      bool // true/false
	localEcho       bool
	autoNewlineMode bool

	// added for vt400 compatibility
	compatLevel         CompatibilityLevel // VT52, VT100, VT400
	altScreenBufferMode bool               // Alternate Screen Buffer support: default false
	columnMode          ColMode            // column mode 80 or 132, just for compatibility
	horizMarginMode     bool               // left and right margins support
	hMargin             int                // left margins
	nColsEff            int                // right margins
	bkspSendsDel        bool               // backspace send delete

	savedCursorSCO SavedCursorSCO // SCO console cursor state
}
const (
	CursorKeyMode_ANSI CursorKeyMode = iota
	CursorKeyMode_Application
)

type CursorStyle

type CursorStyle uint
const (
	CursorStyle_Hidden CursorStyle = iota
	CursorStyle_FillBlock
	CursorStyle_HollowBlock
)
const (
	CursorStyle_BlinkBlock CursorStyle = iota
	CursorStyle_SteadyBlock
	CursorStyle_BlinkUnderline
	CursorStyle_SteadyUnderline
	CursorStyle_BlinkBar
	CursorStyle_SteadyBar
	CursorStyle_Invalid
)

Set cursor style (DECSCUSR), VT520.

Ps = 0  ⇒  blinking block.
Ps = 1  ⇒  blinking block (default).
Ps = 2  ⇒  steady block.
Ps = 3  ⇒  blinking underline.
Ps = 4  ⇒  steady underline.
Ps = 5  ⇒  blinking bar, xterm.
Ps = 6  ⇒  steady bar, xterm.

type Damage

type Damage struct {
	// contains filtered or unexported fields
}

type Display

type Display struct {
	// contains filtered or unexported fields
}

* The following are some interesting questions I asked several month ago. As I know terminfo * and terminal better, the answter is more clear and confident than before. * * do we need to package the the terminfo DB into application? * - yes, mosh-server depends on ncurses-terminfo-base and ncurses-libs * how to read terminfo DB? through ncurses lib or directly? * - yes the answer is read through tcell. * how to operate terminal? through direct escape sequence or through terminfo DB? * how to replace the following functions? setupterm(), tigetnum(), tigetstr(), tigetflag()

func NewDisplay

func NewDisplay(useEnvironment bool) (d *Display, e error)

https://github.com/gdamore/tcell the successor of termbox-go https://cs.opensource.google/go/x/term/+/master:README.md apk add mandoc man-pages ncurses-doc apk add ncurses-terminfo apk add ncurses-terminfo-base apk add ncurses https://ishuah.com/2021/03/10/build-a-terminal-emulator-in-100-lines-of-go/

use TERM environment var to initialize display, if useEnvironment is true.

func (*Display) Clone

func (d *Display) Clone() *Display

func (*Display) Close

func (d *Display) Close() string

func (*Display) NewFrame

func (d *Display) NewFrame(initialized bool, oldE, newE *Emulator) string

compare two terminals and generate mix (grapheme and control sequence) sequence to rebuild the new terminal from the old one.

- initialized: if false, it will redraw the whole terminal, otherwise only changed part. - oldE: the old terminal state. - newE: the new terminal state.

func (*Display) Open

func (d *Display) Open() string

type Emulator

type Emulator struct {
	// contains filtered or unexported fields
}

func NewEmulator3

func NewEmulator3(nCols, nRows, saveLines int) *Emulator

func (*Emulator) Clone

func (emu *Emulator) Clone() *Emulator

func (*Emulator) Equal

func (emu *Emulator) Equal(x *Emulator) bool

func (*Emulator) EqualTrace

func (emu *Emulator) EqualTrace(x *Emulator) bool

TODO remove this after finish test.

func (*Emulator) GetCell

func (emu *Emulator) GetCell(posY, posX int) Cell

func (*Emulator) GetCellPtr

func (emu *Emulator) GetCellPtr(posY, posX int) *Cell

func (*Emulator) GetCursorCol

func (emu *Emulator) GetCursorCol() int

get current cursor column

func (*Emulator) GetCursorRow

func (emu *Emulator) GetCursorRow() int

get current cursor row

func (*Emulator) GetFramebuffer

func (emu *Emulator) GetFramebuffer() *Framebuffer

func (*Emulator) GetHeight

func (emu *Emulator) GetHeight() int

get active area height

func (*Emulator) GetIconLabel

func (emu *Emulator) GetIconLabel() string

func (*Emulator) GetParser

func (emu *Emulator) GetParser() *Parser

func (*Emulator) GetRenditions

func (emu *Emulator) GetRenditions() (rnd Renditions)

func (*Emulator) GetSaveLines

func (emu *Emulator) GetSaveLines() int

func (*Emulator) GetWidth

func (emu *Emulator) GetWidth() int

get active area width

func (*Emulator) GetWindowTitle

func (emu *Emulator) GetWindowTitle() string

func (*Emulator) HandleLargeStream

func (emu *Emulator) HandleLargeStream(seq string) (diff, remains string)

parse and handle the stream together. counting occupied rows, if ring buffer is full, pause the process and return the remains stream.

func (*Emulator) HandleStream

func (emu *Emulator) HandleStream(seq string) (hds []*Handler, diff string)

parse and handle the stream together.

func (*Emulator) MoveCursor

func (emu *Emulator) MoveCursor(posY, posX int)

move cursor to specified position

func (*Emulator) PrefixWindowTitle

func (emu *Emulator) PrefixWindowTitle(prefix string)

func (*Emulator) ReadOctetsToHost

func (emu *Emulator) ReadOctetsToHost() string

return the terminal feedback, clean feedback buffer.

func (*Emulator) SetCursorVisible

func (emu *Emulator) SetCursorVisible(visible bool)

func (*Emulator) SetLastRows

func (emu *Emulator) SetLastRows(x int)

type FrameState

type FrameState struct {
	// contains filtered or unexported fields
}

type Framebuffer

type Framebuffer struct {
	// contains filtered or unexported fields
}

support both (scrollable) normal screen buffer and alternate screen buffer

func NewFramebuffer2

func NewFramebuffer2(nCols, nRows int) Framebuffer

create a framebuffer, with zero saveLines.

func NewFramebuffer3

func NewFramebuffer3(nCols, nRows, saveLines int) (fb Framebuffer, marginTop int, marginBottom int)

create a framebuffer according to the specified nCols, nRows and saveLines. saveLines: for alternate screen buffer default is 0, for normal screen buffer the default is 500, max 50000 return the framebuffer and external marginTop,marginBottom.

func (*Framebuffer) Equal

func (fb *Framebuffer) Equal(x *Framebuffer) bool

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is the outcome of parsering input, it can be used to perform control sequence on emulator.

func (*Handler) GetCh

func (h *Handler) GetCh() rune

func (*Handler) GetId

func (h *Handler) GetId() int

type KeypadMode

type KeypadMode uint8
type DrawState struct {
	width            int
	height           int
	cursorCol        int
	cursorRow        int
	cursorColor      Color
	combiningCharCol int
	combiningCharRow int

	defaultTabs bool
	tabs        []bool

	scrollingRegionTopRow    int
	scrollingRegionBottomRow int
	renditions               Renditions
	save                     SavedCursor

	// public fields
	NextPrintWillWrap bool

	// DEC private mode
	OriginMode                bool // two possiible value: ScrollingRegion(true), Absolute(false)
	AutoWrapMode              bool // true/false
	CursorVisible             bool // true/false
	ReverseVideo              bool // two possible value: Reverse(true), Normal(false)
	BracketedPaste            bool // true/false
	MouseReportingMode        int  // replace it with MouseTrackingMode
	MouseFocusEvent           bool // replace it with MouseTrackingState.focusEventMode
	MouseAlternateScroll      bool // rename to altScrollMode
	MouseEncodingMode         int  // replace it with MouseTrackingEnc
	ApplicationModeCursorKeys bool // =cursorKeyMode two possible value : Application(true), ANSI(false)
	mouseTrk                  MouseTrackingState
	altSendsEscape            bool

	// ANSI mode
	keyboardLocked  bool
	InsertMode      bool // true/false
	localEcho       bool
	autoNewlineMode bool

	// added for vt400 compatibility
	compatLevel         CompatibilityLevel // VT52, VT100, VT400
	altScreenBufferMode bool               // Alternate Screen Buffer support: default false
	columnMode          ColMode            // column mode 80 or 132, just for compatibility
	horizMarginMode     bool               // left and right margins support
	hMargin             int                // left margins
	nColsEff            int                // right margins
	bkspSendsDel        bool               // backspace send delete

	savedCursorSCO SavedCursorSCO // SCO console cursor state
}
const (
	KeypadMode_Normal KeypadMode = iota
	KeypadMode_Application
)

type MouseTrackingEnc

type MouseTrackingEnc uint16
type DrawState struct {
	width            int
	height           int
	cursorCol        int
	cursorRow        int
	cursorColor      Color
	combiningCharCol int
	combiningCharRow int

	defaultTabs bool
	tabs        []bool

	scrollingRegionTopRow    int
	scrollingRegionBottomRow int
	renditions               Renditions
	save                     SavedCursor

	// public fields
	NextPrintWillWrap bool

	// DEC private mode
	OriginMode                bool // two possiible value: ScrollingRegion(true), Absolute(false)
	AutoWrapMode              bool // true/false
	CursorVisible             bool // true/false
	ReverseVideo              bool // two possible value: Reverse(true), Normal(false)
	BracketedPaste            bool // true/false
	MouseReportingMode        int  // replace it with MouseTrackingMode
	MouseFocusEvent           bool // replace it with MouseTrackingState.focusEventMode
	MouseAlternateScroll      bool // rename to altScrollMode
	MouseEncodingMode         int  // replace it with MouseTrackingEnc
	ApplicationModeCursorKeys bool // =cursorKeyMode two possible value : Application(true), ANSI(false)
	mouseTrk                  MouseTrackingState
	altSendsEscape            bool

	// ANSI mode
	keyboardLocked  bool
	InsertMode      bool // true/false
	localEcho       bool
	autoNewlineMode bool

	// added for vt400 compatibility
	compatLevel         CompatibilityLevel // VT52, VT100, VT400
	altScreenBufferMode bool               // Alternate Screen Buffer support: default false
	columnMode          ColMode            // column mode 80 or 132, just for compatibility
	horizMarginMode     bool               // left and right margins support
	hMargin             int                // left margins
	nColsEff            int                // right margins
	bkspSendsDel        bool               // backspace send delete

	savedCursorSCO SavedCursorSCO // SCO console cursor state
}

type MouseTrackingMode

type MouseTrackingMode uint16
type DrawState struct {
	width            int
	height           int
	cursorCol        int
	cursorRow        int
	cursorColor      Color
	combiningCharCol int
	combiningCharRow int

	defaultTabs bool
	tabs        []bool

	scrollingRegionTopRow    int
	scrollingRegionBottomRow int
	renditions               Renditions
	save                     SavedCursor

	// public fields
	NextPrintWillWrap bool

	// DEC private mode
	OriginMode                bool // two possiible value: ScrollingRegion(true), Absolute(false)
	AutoWrapMode              bool // true/false
	CursorVisible             bool // true/false
	ReverseVideo              bool // two possible value: Reverse(true), Normal(false)
	BracketedPaste            bool // true/false
	MouseReportingMode        int  // replace it with MouseTrackingMode
	MouseFocusEvent           bool // replace it with MouseTrackingState.focusEventMode
	MouseAlternateScroll      bool // rename to altScrollMode
	MouseEncodingMode         int  // replace it with MouseTrackingEnc
	ApplicationModeCursorKeys bool // =cursorKeyMode two possible value : Application(true), ANSI(false)
	mouseTrk                  MouseTrackingState
	altSendsEscape            bool

	// ANSI mode
	keyboardLocked  bool
	InsertMode      bool // true/false
	localEcho       bool
	autoNewlineMode bool

	// added for vt400 compatibility
	compatLevel         CompatibilityLevel // VT52, VT100, VT400
	altScreenBufferMode bool               // Alternate Screen Buffer support: default false
	columnMode          ColMode            // column mode 80 or 132, just for compatibility
	horizMarginMode     bool               // left and right margins support
	hMargin             int                // left margins
	nColsEff            int                // right margins
	bkspSendsDel        bool               // backspace send delete

	savedCursorSCO SavedCursorSCO // SCO console cursor state
}

type MouseTrackingState

type MouseTrackingState struct {
	// contains filtered or unexported fields
}

check resetScreen() for default value

type OriginMode

type OriginMode uint8
type DrawState struct {
	width            int
	height           int
	cursorCol        int
	cursorRow        int
	cursorColor      Color
	combiningCharCol int
	combiningCharRow int

	defaultTabs bool
	tabs        []bool

	scrollingRegionTopRow    int
	scrollingRegionBottomRow int
	renditions               Renditions
	save                     SavedCursor

	// public fields
	NextPrintWillWrap bool

	// DEC private mode
	OriginMode                bool // two possiible value: ScrollingRegion(true), Absolute(false)
	AutoWrapMode              bool // true/false
	CursorVisible             bool // true/false
	ReverseVideo              bool // two possible value: Reverse(true), Normal(false)
	BracketedPaste            bool // true/false
	MouseReportingMode        int  // replace it with MouseTrackingMode
	MouseFocusEvent           bool // replace it with MouseTrackingState.focusEventMode
	MouseAlternateScroll      bool // rename to altScrollMode
	MouseEncodingMode         int  // replace it with MouseTrackingEnc
	ApplicationModeCursorKeys bool // =cursorKeyMode two possible value : Application(true), ANSI(false)
	mouseTrk                  MouseTrackingState
	altSendsEscape            bool

	// ANSI mode
	keyboardLocked  bool
	InsertMode      bool // true/false
	localEcho       bool
	autoNewlineMode bool

	// added for vt400 compatibility
	compatLevel         CompatibilityLevel // VT52, VT100, VT400
	altScreenBufferMode bool               // Alternate Screen Buffer support: default false
	columnMode          ColMode            // column mode 80 or 132, just for compatibility
	horizMarginMode     bool               // left and right margins support
	hMargin             int                // left margins
	nColsEff            int                // right margins
	bkspSendsDel        bool               // backspace send delete

	savedCursorSCO SavedCursorSCO // SCO console cursor state
}
const (
	OriginMode_Absolute OriginMode = iota
	OriginMode_ScrollingRegion
)

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser() *Parser

func (*Parser) ProcessInput

func (p *Parser) ProcessInput(chs ...rune) (hd *Handler)

process each rune. must apply the UTF-8 decoder to the incoming byte stream before interpreting any control characters. ref: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

func (*Parser) ResetInput

func (p *Parser) ResetInput()

type Point

type Point struct {
	// contains filtered or unexported fields
}

func (Point) String

func (p Point) String() string

type Rect

type Rect struct {
	// contains filtered or unexported fields
}

func NewRect

func NewRect() (rect *Rect)

func NewRect4

func NewRect4(x1, y1, x2, y2 int) (rect *Rect)

func (*Rect) String

func (rect *Rect) String() string

type Renditions

type Renditions struct {
	// contains filtered or unexported fields
}

Renditions determines the foreground and background color and character attribute. it is comparable. default background/foreground is ColorDefault

func NewRenditions

func NewRenditions(attribute int) (rend Renditions)

create rendition based on colorAttr parameter. This method can only be used to set 16-color set.

func (*Renditions) ClearAttributes

func (rend *Renditions) ClearAttributes()

func (*Renditions) GetAttributes

func (r *Renditions) GetAttributes(attr charAttribute) (value, ok bool)

func (*Renditions) SGR

func (rend *Renditions) SGR() string

generate SGR sequence based on Renditions CSI Pm m Character Attributes (SGR). https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_

func (*Renditions) SetAttributes

func (r *Renditions) SetAttributes(attr charAttribute, value bool)

func (*Renditions) SetBackgroundColor

func (rend *Renditions) SetBackgroundColor(index int)

set the ANSI background indexed color. The index start from 0. represent ANSI standard color.

func (*Renditions) SetBgColor

func (rend *Renditions) SetBgColor(r, g, b int)

set the RGB background color

func (*Renditions) SetFgColor

func (rend *Renditions) SetFgColor(r, g, b int)

set the RGB foreground color

func (*Renditions) SetForegroundColor

func (rend *Renditions) SetForegroundColor(index int)

set the ANSI foreground indexed color. The index start from 0. represent ANSI standard color.

type Resize

type Resize struct {
	Width  int
	Height int
}

func (Resize) Handle

func (r Resize) Handle(emu *Emulator)

type SavedCursor_DEC

type SavedCursor_DEC struct {
	SavedCursor_SCO
	// contains filtered or unexported fields
}

type SavedCursor_SCO

type SavedCursor_SCO struct {
	// contains filtered or unexported fields
}

type SelectSnapTo

type SelectSnapTo uint8
type DrawState struct {
	width            int
	height           int
	cursorCol        int
	cursorRow        int
	cursorColor      Color
	combiningCharCol int
	combiningCharRow int

	defaultTabs bool
	tabs        []bool

	scrollingRegionTopRow    int
	scrollingRegionBottomRow int
	renditions               Renditions
	save                     SavedCursor

	// public fields
	NextPrintWillWrap bool

	// DEC private mode
	OriginMode                bool // two possiible value: ScrollingRegion(true), Absolute(false)
	AutoWrapMode              bool // true/false
	CursorVisible             bool // true/false
	ReverseVideo              bool // two possible value: Reverse(true), Normal(false)
	BracketedPaste            bool // true/false
	MouseReportingMode        int  // replace it with MouseTrackingMode
	MouseFocusEvent           bool // replace it with MouseTrackingState.focusEventMode
	MouseAlternateScroll      bool // rename to altScrollMode
	MouseEncodingMode         int  // replace it with MouseTrackingEnc
	ApplicationModeCursorKeys bool // =cursorKeyMode two possible value : Application(true), ANSI(false)
	mouseTrk                  MouseTrackingState
	altSendsEscape            bool

	// ANSI mode
	keyboardLocked  bool
	InsertMode      bool // true/false
	localEcho       bool
	autoNewlineMode bool

	// added for vt400 compatibility
	compatLevel         CompatibilityLevel // VT52, VT100, VT400
	altScreenBufferMode bool               // Alternate Screen Buffer support: default false
	columnMode          ColMode            // column mode 80 or 132, just for compatibility
	horizMarginMode     bool               // left and right margins support
	hMargin             int                // left margins
	nColsEff            int                // right margins
	bkspSendsDel        bool               // backspace send delete

	savedCursorSCO SavedCursorSCO // SCO console cursor state
}
const (
	SelectSnapTo_Char SelectSnapTo = iota
	SelectSnapTo_Word
	SelectSnapTo_Line
	SelectSnapTo_COUNT
)

type UserByte

type UserByte struct {
	Chs []rune
}

func (UserByte) Handle

func (u UserByte) Handle(emu *Emulator)

type UserInput

type UserInput struct {
	// contains filtered or unexported fields
}

the default state is USER_INPUT_GROUND = 0

Jump to

Keyboard shortcuts

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