vt

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2025 The TCell Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package vt provides common definitions for VT derived terminals and applications. This includes the venerable VT100, XTerm, and newer emulators such as Kitty and the Windows Terminal.

Package vt provides common definitions for VT derived terminals and applications. This includes the venerable VT100, XTerm, and newer emulators such as Kitty and the Windows Terminal.

This package is still under development and direct access to any of the interfaces here is not guaranteed to be stable yet. Caveat emptor.

Index

Constants

View Source
const (
	Plain         = Attr(0)      // basic, plain style
	Bold          = Attr(1 << 0) // maybe double strike, or just brighter
	Blink         = Attr(1 << 1) // NB: many terminals do not support it
	Reverse       = Attr(1 << 2) // foreground and background reversed
	Dim           = Attr(1 << 3) // fainter, may also be lower alpha
	Italic        = Attr(1 << 4) // italicized
	StrikeThrough = Attr(1 << 5) // crossed-out
	Underline     = Attr(1 << 6) // any underline style
	Overline      = Attr(1 << 7) // rarely supported

	// Underline styles, always mixed with underline, only one can be selected
	PlainUnderline  = Underline
	DoubleUnderline = Underline | 1<<13
	CurlyUnderline  = Underline | 2<<13
	DottedUnderline = Underline | 3<<13
	DashedUnderline = Underline | 4<<13
	UnderlineMask   = Underline | 7<<13 // bits 13, 14, 15
)
View Source
const (
	MouseDisabled = MouseReporting(iota) // No mouse reports at all.
	MouseButtons                         // Report button events only.
	MouseDrag                            // Report drag events.
	MouseMotion                          // Report motion events (movement).
)
View Source
const (
	SteadyBlock = CursorStyle(iota) // The default
	SteadyBar
	SteadyUnderline
	BlinkingBlock     = SteadyBlock | blinkingCursor
	BlinkingBar       = SteadyBar | blinkingCursor
	BlinkingUnderline = SteadyUnderline | blinkingCursor
)
View Source
const (
	ModNone  = Modifier(0)
	ModShift = Modifier(1 << iota)
	ModCtrl
	ModAlt
	ModMeta
	ModHyper
	ModCapsLock
	ModNumLock
)
View Source
const (
	NoButton = Button(0)         // No buttons are pressed.
	Button1  = Button(1 << iota) // Usually left most button.
	Button2                      // Usually right most button.
	Button3                      // Usually middle button.
	Button4
	Button5
	Button6
	Button7
	Button8
	WheelUp    // Wheel motion up/away from user.
	WheelDown  // Wheel motion down/towards user.
	WheelLeft  // Wheel motion to left.
	WheelRight // Wheel motion to right.
)
View Source
const (
	KeyUTF          = Key(0x01) // virtual UTF-8 content
	KeyA            = Key(0x04)
	KeyB            = Key(0x05)
	KeyC            = Key(0x06)
	KeyD            = Key(0x07)
	KeyE            = Key(0x08)
	KeyF            = Key(0x09)
	KeyG            = Key(0x0A)
	KeyH            = Key(0x0B)
	KeyI            = Key(0x0C)
	KeyJ            = Key(0x0D)
	KeyK            = Key(0x0E)
	KeyL            = Key(0x0F)
	KeyM            = Key(0x10)
	KeyN            = Key(0x11)
	KeyO            = Key(0x12)
	KeyP            = Key(0x13)
	KeyQ            = Key(0x14)
	KeyR            = Key(0x15)
	KeyS            = Key(0x16)
	KeyT            = Key(0x17)
	KeyU            = Key(0x18)
	KeyV            = Key(0x19)
	KeyW            = Key(0x1A)
	KeyX            = Key(0x1B)
	KeyY            = Key(0x1C)
	KeyZ            = Key(0x1D)
	Key1            = Key(0x1E)
	Key2            = Key(0x1F)
	Key3            = Key(0x20)
	Key4            = Key(0x21)
	Key5            = Key(0x22)
	Key6            = Key(0x23)
	Key7            = Key(0x24)
	Key8            = Key(0x25)
	Key9            = Key(0x26)
	Key0            = Key(0x27)
	KeyEnter        = Key(0x28)
	KeyEsc          = Key(0x29)
	KeyBackspace    = Key(0x2a) // sometimes called delete
	KeyTab          = Key(0x2b)
	KeySpace        = Key(0x2c)
	KeyMinus        = Key(0x2d) // - and _
	KeyEqual        = Key(0x2e) // = and +
	KeyLBrace       = Key(0x2f) // [ and {
	KeyRBrace       = Key(0x30) // ] and }
	KeyBackslash    = Key(0x31) // \
	KeyIsoHash      = Key(0x32) // international only
	KeySemi         = Key(0x33) // ;
	KeyQuote        = Key(0x34) // ' and " aka apostrophe
	KeyGrave        = Key(0x35) // ` and ~
	KeyComma        = Key(0x36) // , and <
	KeyPeriod       = Key(0x37) // . and >
	KeySlash        = Key(0x38) // / and ?
	KeyCapsLock     = Key(0x39)
	KeyF1           = Key(0x3a)
	KeyF2           = Key(0x3b)
	KeyF3           = Key(0x3c)
	KeyF4           = Key(0x3d)
	KeyF5           = Key(0x3e)
	KeyF6           = Key(0x3f)
	KeyF7           = Key(0x40)
	KeyF8           = Key(0x41)
	KeyF9           = Key(0x42)
	KeyF10          = Key(0x43)
	KeyF11          = Key(0x44)
	KeyF12          = Key(0x45)
	KeyPrtScr       = Key(0x46)
	KeyScrLock      = Key(0x47)
	KeyPause        = Key(0x48)
	KeyInsert       = Key(0x49)
	KeyHome         = Key(0x4a)
	KeyPgUp         = Key(0x4b)
	KeyDelete       = Key(0x4c) // forward delete (DEL)
	KeyEnd          = Key(0x4d)
	KeyPgDn         = Key(0x4e)
	KeyRight        = Key(0x4f)
	KeyLeft         = Key(0x50)
	KeyDown         = Key(0x51)
	KeyUp           = Key(0x52)
	KeyNumLock      = Key(0x53) // also clear
	KeyPadDiv       = Key(0x54)
	KeyPadMul       = Key(0x55)
	KeyPadSub       = Key(0x56)
	KeyPadAdd       = Key(0x57)
	KeyPadEnter     = Key(0x58)
	KeyPad1         = Key(0x59) // also pad end
	KeyPad2         = Key(0x5a) // also pad down
	KeyPad3         = Key(0x5b) // also pad page down
	KeyPad4         = Key(0x5c) // also pad left
	KeyPad5         = Key(0x5d)
	KeyPad6         = Key(0x5e) // also pad right
	KeyPad7         = Key(0x5f) // also pad home
	KeyPad8         = Key(0x60) // also pad up
	KeyPad9         = Key(0x61) // also pad page up
	KeyPad0         = Key(0x62) // also pad insert
	KeyPadDec       = Key(0x63) // also pad delete
	KeyIsoBackSlash = Key(0x64) // international keyboards only
	KeyPadEqual     = Key(0x67)
	KeyF13          = Key(0x68)
	KeyF14          = Key(0x69)
	KeyF15          = Key(0x6a)
	KeyF16          = Key(0x6b)
	KeyF17          = Key(0x6c)
	KeyF18          = Key(0x6d)
	KeyF19          = Key(0x6e)
	KeyF20          = Key(0x6f)
	KeyF21          = Key(0x70)
	KeyF22          = Key(0x71)
	KeyF23          = Key(0x72)
	KeyF24          = Key(0x73)
	KeyMenu         = Key(0x76) // might also be 0x65, KeyApplication
	KeyPadComma     = Key(0x85)
	KeyPadEqSign    = Key(0x86)
	KeyIsoSlash     = Key(0x87) // also International 1
	KeyHiragana     = Key(0x88) // also International 2
	KeyYen          = Key(0x89) // found on JIS keyboards
	KeyConvert      = Key(0x8a)
	KeyNonConvert   = Key(0x8b)
	KeyAltErase     = Key(0x99) // e.g split space-erase bar
	KeySysReq       = Key(0x9a)
	KeyCancel       = Key(0x9b)
	KeyLCtrl        = Key(0xe0)
	KeyLShift       = Key(0xe1)
	KeyLAlt         = Key(0xe2)
	KeyLMeta        = Key(0xe3)
	KeyRCtrl        = Key(0xe4)
	KeyRShift       = Key(0xe5)
	KeyRAlt         = Key(0xe6)
	KeyRMeta        = Key(0xe7)
	KeyLHyper       = Key(0xff01) // software only, in reserved space
	KeyRHyper       = Key(0xff02) // software only, in reserved space
)
View Source
const (
	VkBack       = WinVK(0x08) // backspace
	VkTab        = WinVK(0x09)
	VkClear      = WinVK(0x0c)
	VkReturn     = WinVK(0x0d)
	VkShift      = WinVK(0x10)
	VkControl    = WinVK(0x11)
	VkMenu       = WinVK(0x12)
	VkPause      = WinVK(0x13)
	VkCapital    = WinVK(0x14) // caps lock
	VkKana       = WinVK(0x15)
	VkHangul     = WinVK(0x15)
	VkImeOn      = WinVK(0x16)
	VkJunja      = WinVK(0x17)
	VkFinal      = WinVK(0x18)
	VkKanji      = WinVK(0x19)
	VkImeOff     = WinVK(0x1a)
	VkEscape     = WinVK(0x1b)
	VkConvert    = WinVK(0x1c)
	VkNonConvert = WinVK(0x1d)
	VkAccept     = WinVK(0x1e)
	VkModeChange = WinVK(0x1f)
	VkSpace      = WinVK(0x20)
	VkPrior      = WinVK(0x21) // page up
	VkNext       = WinVK(0x22) // page down
	VkEnd        = WinVK(0x23)
	VkHome       = WinVK(0x24)
	VkLeft       = WinVK(0x25)
	VkUp         = WinVK(0x26)
	VkRight      = WinVK(0x27)
	VkDown       = WinVK(0x28)
	VkSelect     = WinVK(0x29)
	VkPrint      = WinVK(0x2a)
	VkExecute    = WinVK(0x2b)
	VkSnapshot   = WinVK(0x2c) // print screen
	VkInsert     = WinVK(0x2D)
	VkDelete     = WinVK(0x2E)
	VkHelp       = WinVK(0x2F)
	Vk0          = WinVK(0x30)
	Vk1          = WinVK(0x31)
	Vk2          = WinVK(0x32)
	Vk3          = WinVK(0x33)
	Vk4          = WinVK(0x34)
	Vk5          = WinVK(0x35)
	Vk6          = WinVK(0x36)
	Vk7          = WinVK(0x37)
	Vk8          = WinVK(0x38)
	Vk9          = WinVK(0x39)
	VkA          = WinVK(0x41)
	VkB          = WinVK(0x42)
	VkC          = WinVK(0x43)
	VkD          = WinVK(0x44)
	VkE          = WinVK(0x45)
	VkF          = WinVK(0x46)
	VkG          = WinVK(0x47)
	VkH          = WinVK(0x48)
	VkI          = WinVK(0x49)
	VkJ          = WinVK(0x4a)
	VkK          = WinVK(0x4b)
	VkL          = WinVK(0x4c)
	VkM          = WinVK(0x4d)
	VkN          = WinVK(0x4e)
	VkO          = WinVK(0x4f)
	VkP          = WinVK(0x50)
	VkQ          = WinVK(0x51)
	VkR          = WinVK(0x52)
	VkS          = WinVK(0x53)
	VkT          = WinVK(0x54)
	VkU          = WinVK(0x55)
	VkV          = WinVK(0x56)
	VkW          = WinVK(0x57)
	VkX          = WinVK(0x58)
	VkY          = WinVK(0x59)
	VkZ          = WinVK(0x5a)
	VkLWin       = WinVK(0x5b) // left meta
	VkRWin       = WinVK(0x5c) // right meta
	VkApps       = WinVK(0x5d) // menu key
	VkNumPad0    = WinVK(0x60)
	VkNumPad1    = WinVK(0x61)
	VkNumPad2    = WinVK(0x62)
	VkNumPad3    = WinVK(0x63)
	VkNumPad4    = WinVK(0x64)
	VkNumPad5    = WinVK(0x65)
	VkNumPad6    = WinVK(0x66)
	VkNumPad7    = WinVK(0x67)
	VkNumPad8    = WinVK(0x68)
	VkNumPad9    = WinVK(0x69)
	VkMultiply   = WinVK(0x6a) // pad multiply
	VkAdd        = WinVK(0x6b) // pad add
	VkSeparator  = WinVK(0x6c) // separator
	VkSubtract   = WinVK(0x6d) // pad subtract
	VkDecimal    = WinVK(0x6e) // pad decimal point
	VkDivide     = WinVK(0x6f) // pad divide
	VkF1         = WinVK(0x70)
	VkF2         = WinVK(0x71)
	VkF3         = WinVK(0x72)
	VkF4         = WinVK(0x73)
	VkF5         = WinVK(0x74)
	VkF6         = WinVK(0x75)
	VkF7         = WinVK(0x76)
	VkF8         = WinVK(0x77)
	VkF9         = WinVK(0x78)
	VkF10        = WinVK(0x79)
	VkF11        = WinVK(0x7a)
	VkF12        = WinVK(0x7b)
	VkF13        = WinVK(0x7c)
	VkF14        = WinVK(0x7d)
	VkF15        = WinVK(0x7e)
	VkF16        = WinVK(0x7f)
	VkF17        = WinVK(0x80)
	VkF18        = WinVK(0x81)
	VkF19        = WinVK(0x82)
	VkF20        = WinVK(0x83)
	VkF21        = WinVK(0x84)
	VkF22        = WinVK(0x85)
	VkF23        = WinVK(0x86)
	VkF24        = WinVK(0x87)
	VkNumLock    = WinVK(0x90)
	VkScroll     = WinVK(0x91) // scroll lock
	VkLShift     = WinVK(0xa0)
	VkRShift     = WinVK(0xa1)
	VkLControl   = WinVK(0xa2)
	VkRControl   = WinVK(0xa3)
	VkLMenu      = WinVK(0xa4) // left alt
	VkRMenu      = WinVK(0xa5) // right alt
	VkOem1       = WinVK(0xba) // ; and :
	VkOemPlus    = WinVK(0xbb) // = and +
	VkOemComma   = WinVK(0xbc) // , and <
	VkOemMinus   = WinVK(0xbd) // - and _
	VkOemPeriod  = WinVK(0xbe) // . and >
	VkOem2       = WinVK(0xbf) // / and ?
	VkOem3       = WinVK(0xc0) // ` and ~
	VkOem4       = WinVK(0xdb) // [ and {
	VkOem5       = WinVK(0xdc) // \ and |
	VkOem6       = WinVK(0xdd) // ] and }
	VkOem7       = WinVK(0xde) // ' and "
	VkOem8       = WinVK(0xdf) // right control for Canadian CSA
	VkOem102     = WinVK(0xe2) // ISO backslash
	VkPacket     = WinVK(0xe7)
)
View Source
const DeadRune = 0x101000

DeadRune is used internally to create a rune to represent a dead key. While any numbers can be used from this point on, the expectation is that this will be added to a smaller rune (such as an ASCII character) This rune value a bit inside the supplementary private use area B, in an attempt to minimize the chance of any conflicting use (for example nerd fonts.)

Variables

View Source
var BaseStyle = &styleStruct{}
View Source
var KeyboardANSI = &Layout{
	Name: "US",

	Base: nil,

	Virtual: map[Key]WinVK{
		KeyEsc:          VkEscape,
		KeyF1:           VkF1,
		KeyF2:           VkF2,
		KeyF3:           VkF3,
		KeyF4:           VkF4,
		KeyF5:           VkF5,
		KeyF6:           VkF6,
		KeyF7:           VkF7,
		KeyF8:           VkF8,
		KeyF9:           VkF9,
		KeyF10:          VkF10,
		KeyF11:          VkF11,
		KeyF12:          VkF12,
		KeyF13:          VkF13,
		KeyF14:          VkF14,
		KeyF15:          VkF15,
		KeyF16:          VkF16,
		KeyF17:          VkF17,
		KeyF18:          VkF18,
		KeyF19:          VkF19,
		KeyF20:          VkF20,
		KeyF21:          VkF21,
		KeyF22:          VkF22,
		KeyF23:          VkF23,
		KeyF24:          VkF24,
		KeyPrtScr:       VkSnapshot,
		KeyScrLock:      VkScroll,
		KeyPause:        VkPause,
		KeyInsert:       VkInsert,
		KeyDelete:       VkDelete,
		KeyHome:         VkHome,
		KeyEnd:          VkEnd,
		KeyPgUp:         VkPrior,
		KeyPgDn:         VkNext,
		KeyLeft:         VkLeft,
		KeyRight:        VkRight,
		KeyUp:           VkUp,
		KeyDown:         VkDown,
		KeyNumLock:      VkNumLock,
		KeyCapsLock:     VkCapital,
		KeyLShift:       VkLShift,
		KeyLCtrl:        VkLControl,
		KeyLMeta:        VkLWin,
		KeyLAlt:         VkLMenu,
		KeyRShift:       VkRShift,
		KeyRCtrl:        VkRControl,
		KeyRMeta:        VkRWin,
		KeyRAlt:         VkRMenu,
		KeyMenu:         VkApps,
		KeyConvert:      VkConvert,
		KeyNonConvert:   VkNonConvert,
		KeyBackspace:    VkBack,
		KeyEnter:        VkReturn,
		KeySpace:        VkSpace,
		KeyTab:          VkTab,
		Key1:            Vk1,
		Key2:            Vk2,
		Key3:            Vk3,
		Key4:            Vk4,
		Key5:            Vk5,
		Key6:            Vk6,
		Key7:            Vk7,
		Key8:            Vk8,
		Key9:            Vk9,
		Key0:            Vk0,
		KeyA:            VkA,
		KeyB:            VkB,
		KeyC:            VkC,
		KeyD:            VkD,
		KeyE:            VkE,
		KeyF:            VkF,
		KeyG:            VkG,
		KeyH:            VkH,
		KeyI:            VkI,
		KeyJ:            VkJ,
		KeyK:            VkK,
		KeyL:            VkL,
		KeyM:            VkM,
		KeyN:            VkN,
		KeyO:            VkO,
		KeyP:            VkP,
		KeyQ:            VkQ,
		KeyR:            VkR,
		KeyS:            VkS,
		KeyT:            VkT,
		KeyU:            VkU,
		KeyV:            VkV,
		KeyW:            VkW,
		KeyX:            VkX,
		KeyY:            VkY,
		KeyZ:            VkZ,
		KeyPadMul:       VkMultiply,
		KeyPadAdd:       VkAdd,
		KeyPadSub:       VkSubtract,
		KeyPadDiv:       VkDivide,
		KeyEqual:        VkOemPlus,
		KeyComma:        VkOemComma,
		KeyMinus:        VkOemMinus,
		KeyPeriod:       VkOemPeriod,
		KeySlash:        VkOem2,
		KeyGrave:        VkOem3,
		KeyLBrace:       VkOem4,
		KeyBackslash:    VkOem5,
		KeyRBrace:       VkOem6,
		KeyQuote:        VkOem7,
		KeyIsoBackSlash: VkOem102,
		KeyPad0:         VkInsert,
		KeyPad1:         VkEnd,
		KeyPad2:         VkDown,
		KeyPad3:         VkNext,
		KeyPad4:         VkLeft,
		KeyPad5:         VkClear,
		KeyPad6:         VkRight,
		KeyPad7:         VkHome,
		KeyPad8:         VkUp,
		KeyPad9:         VkPrior,
		KeyPadDec:       VkDelete,
	},
	Maps: []ModifierMap{

		{
			Mask: ModCtrl,
			Mod:  ModNone,
			Map: map[Key]rune{
				KeyTab:       '\t',
				KeyEnter:     '\r',
				KeyBackspace: '\b',
				KeyEsc:       '\x1b',
				KeySpace:     ' ',
				KeyPadEnter:  '\r',
			},
		},

		{
			Mask: ModCtrl | ModShift,
			Mod:  ModCtrl,
			Map: map[Key]rune{
				KeyTab:       '\t',
				KeyEnter:     '\n',
				KeyBackspace: '\x7f',
				KeyEsc:       '\x1b',
				KeySpace:     ' ',
				KeyPadEnter:  '\n',
			},
		},

		{
			Mod:  ModNone,
			Mask: ModAlt,
			Map:  KeysPadOps,
		},

		{
			Mask: ModNumLock,
			Mod:  ModNumLock,
			Map:  KeysPadDigits,
		},

		{
			Mask: ModShift | ModCtrl,
			Mod:  ModNone,
			Map:  KeysDigits,
		},

		{
			Mask: ModShift | ModCtrl,
			Mod:  ModShift,
			Map: map[Key]rune{
				Key1: '!',
				Key2: '@',
				Key3: '#',
				Key4: '$',
				Key5: '%',
				Key6: '^',
				Key7: '&',
				Key8: '*',
				Key9: '(',
				Key0: ')',
			},
		},

		{
			Mask: ModCtrl | ModShift,
			Mod:  ModCtrl | ModShift,
			Map: map[Key]rune{
				Key2:     0,
				Key6:     '\x1e',
				KeyMinus: '\x1f',
			},
		},

		{
			Mask: ModShift | ModCtrl | ModCapsLock,
			Mod:  ModNone,
			Map:  KeysUsLower,
		},

		{
			Mask: ModShift | ModCtrl | ModCapsLock,
			Mod:  ModShift,
			Map:  KeysUsUpper,
		},

		{
			Mask: ModShift | ModCtrl | ModCapsLock,
			Mod:  ModCapsLock,
			Map:  KeysUsUpper,
		},

		{
			Mask: ModShift | ModCtrl | ModCapsLock,
			Mod:  ModCapsLock | ModShift,
			Map:  KeysUsLower,
		},

		{
			Mask: ModShift | ModCtrl,
			Mod:  ModNone,
			Map: map[Key]rune{
				KeySemi:         ';',
				KeyEqual:        '=',
				KeyComma:        ',',
				KeyMinus:        '-',
				KeyPeriod:       '.',
				KeySlash:        '/',
				KeyGrave:        '`',
				KeyLBrace:       '[',
				KeyBackslash:    '\\',
				KeyRBrace:       ']',
				KeyQuote:        '\'',
				KeyIsoBackSlash: '\\',
			},
		},

		{
			Mask: ModShift | ModCtrl,
			Mod:  ModShift,
			Map: map[Key]rune{
				KeySemi:         ':',
				KeyEqual:        '+',
				KeyComma:        '<',
				KeyMinus:        '_',
				KeyPeriod:       '>',
				KeySlash:        '?',
				KeyGrave:        '~',
				KeyLBrace:       '{',
				KeyBackslash:    '|',
				KeyRBrace:       '}',
				KeyQuote:        '"',
				KeyIsoBackSlash: '|',
			},
		},

		{
			Mask: ModShift | ModCtrl,
			Mod:  ModCtrl,
			Map: map[Key]rune{
				KeyLBrace:       '\x1b',
				KeyBackslash:    '\x1c',
				KeyRBrace:       '\x1d',
				KeyIsoBackSlash: '\x1c',
			},
		},
	},
	Modifiers: map[Key]Modifier{
		KeyLShift: ModShift,
		KeyRShift: ModShift,
		KeyLCtrl:  ModCtrl,
		KeyRCtrl:  ModCtrl,
		KeyLAlt:   ModAlt,
		KeyRAlt:   ModAlt,
		KeyRMeta:  ModMeta,
		KeyLMeta:  ModMeta,
		KeyRHyper: ModHyper,
		KeyLHyper: ModHyper,
	},
	Locking: map[Key]Modifier{
		KeyNumLock:  ModNumLock,
		KeyCapsLock: ModCapsLock,
	},
}

KeyboardANSI is the base PC keyboard used in ANSI (US) systems.

View Source
var KeysDigits = map[Key]rune{
	Key1: '1',
	Key2: '2',
	Key3: '3',
	Key4: '4',
	Key5: '5',
	Key6: '6',
	Key7: '7',
	Key8: '8',
	Key9: '9',
	Key0: '0',
}

KeysDigits is a map of number keys to corresponding digits.

View Source
var KeysPadDigits = map[Key]rune{
	KeyPad0:   '0',
	KeyPad1:   '1',
	KeyPad2:   '2',
	KeyPad3:   '3',
	KeyPad4:   '4',
	KeyPad5:   '5',
	KeyPad6:   '6',
	KeyPad7:   '7',
	KeyPad8:   '8',
	KeyPad9:   '9',
	KeyPadDec: '.',
}

KeysPadDigits is a map of the digits on the numeric keypad, when num lock is engaged.

View Source
var KeysPadOps = map[Key]rune{
	KeyPadMul: '*',
	KeyPadAdd: '+',
	KeyPadSub: '-',
	KeyPadDiv: '/',
}
View Source
var KeysUsLower = map[Key]rune{
	KeyA: 'a',
	KeyB: 'b',
	KeyC: 'c',
	KeyD: 'd',
	KeyE: 'e',
	KeyF: 'f',
	KeyG: 'g',
	KeyH: 'h',
	KeyI: 'i',
	KeyJ: 'j',
	KeyK: 'k',
	KeyL: 'l',
	KeyM: 'm',
	KeyN: 'n',
	KeyO: 'o',
	KeyP: 'p',
	KeyQ: 'q',
	KeyR: 'r',
	KeyS: 's',
	KeyT: 't',
	KeyU: 'u',
	KeyV: 'v',
	KeyW: 'w',
	KeyX: 'x',
	KeyY: 'y',
	KeyZ: 'z',
}

KeysUsLower is a list of lower case key maps.

View Source
var KeysUsUpper = map[Key]rune{
	KeyA: 'A',
	KeyB: 'B',
	KeyC: 'C',
	KeyD: 'D',
	KeyE: 'E',
	KeyF: 'F',
	KeyG: 'G',
	KeyH: 'H',
	KeyI: 'I',
	KeyJ: 'J',
	KeyK: 'K',
	KeyL: 'L',
	KeyM: 'M',
	KeyN: 'N',
	KeyO: 'O',
	KeyP: 'P',
	KeyQ: 'Q',
	KeyR: 'R',
	KeyS: 'S',
	KeyT: 'T',
	KeyU: 'U',
	KeyV: 'V',
	KeyW: 'W',
	KeyX: 'X',
	KeyY: 'Y',
	KeyZ: 'Z',
}

KeysUsUpper is a list of upper case key maps.

Functions

func Layouts added in v3.1.2

func Layouts() []string

Layouts returns a list of all known layout names.

func RegisterLayout added in v3.1.2

func RegisterLayout(km *Layout)

RegisterLayout registers the given layout.

Types

type AdvancedKeyboard added in v3.1.2

type AdvancedKeyboard interface {
	SetKeyboardMode(KeyboardMode) error
	GetKeyboardMode() KeyboardMode
}

type AnsiMode added in v3.1.0

type AnsiMode int

AnsiMode are modes standardized in ECMA-48. They use CSI-h and CSI-l (no question mark).

const (
	AmKeyboardAction AnsiMode = 2  // Lock the keyboard.
	AmInsertReplace  AnsiMode = 4  // Insert or replace characters when a new character is added.
	AmSendReceive    AnsiMode = 12 // XON or XOFF.
	AmNewLineMode    AnsiMode = 20 // If true, LF emits CR as well, and Return sends both CR and LF.
)

func (AnsiMode) Disable added in v3.1.0

func (pm AnsiMode) Disable() string

Disable returns the string used to disable this ANSI mode.

func (AnsiMode) Enable added in v3.1.0

func (pm AnsiMode) Enable() string

Enable returns the string used to enable this ANSI mode.

func (AnsiMode) Query added in v3.1.0

func (pm AnsiMode) Query() string

Query returns the string used to query the state of this ANSI mode.

func (AnsiMode) Reply added in v3.1.0

func (pm AnsiMode) Reply(status ModeStatus) string

Reply returns a string representing a query reply for the given mode and status.

type Attr added in v3.0.6

type Attr uint16

Attr is a synthetic combination of display attributes for cells, apart from color which is handled separately.

type Backend added in v3.0.6

type Backend interface {

	// GetPrivateMode returns the status of a given private mode.
	GetPrivateMode(PrivateMode) ModeStatus

	// SetPrivateMode sets a private mode to the given status.
	// If either value is invalid, this should simply ignore the operation.
	SetPrivateMode(PrivateMode, ModeStatus) error

	// GetSize returns the size of the terminal in characters.
	// The X and Y are counts, so the bottom right cell should be at coordinate (X-1, Y-1).
	GetSize() Coord

	// Colors returns the number of colors this terminal can support.  For direct color,
	// return 1<<24. The XTerm palette is assumed. Monochrome terminals should return 0.
	Colors() int

	// Put content at the given location. The string in the cell might be a grapheme cluster, and the width can be
	// 0, 1, or 2.  The backend should try to optimize by keeping style and last coordinates if needed.
	// A graphical backend could use this and be completely stateless.
	Put(Coord, Cell)

	// GetPosition returns the cursor position.
	GetPosition() Coord

	// SetPosition sets the cursor position. If the position is out of bounds,
	// it should be clipped to the window size.
	SetPosition(Coord)

	// Reset resets the terminal to default state.
	Reset()

	// RaiseResize is called by the emulation layer when it has completed its own internal resizing.
	// The backend is responsible for sending a signal (if needed) to child processes as part of this
	// function.  (The emulation layer knows nothing of child processes.)
	RaiseResize()

	// Buffering is called by the emulator to indicate that the backend should buffer contents because
	// multiple updates are taking place.  This should be treated in addition to mode 2026, if the backend
	// supports it.  (Mode 2026 should only be supported by the backend if it actually supports true
	// double buffering.)
	Buffering(bool)

	// SetCursor is used to set the current cursor style.  If the backend does not support changing
	// the cursor shape, it should implement at least hidden, steady, and blinking (typically as a block).
	SetCursor(CursorStyle)
}

Backend describes the backend of a terminal. This can be used to create a real emulator, while allowing the processor front end to handle the common details of parsing escape sequences, the state machine, and so forth. Backends support a limited set of common functionality, including a cursor. They only need to support writing at the cursor.

type BaseKey added in v3.1.2

type BaseKey rune

BaseKey is the Kitty protocol base key. These are kitty's representation of a scan code. As the Kitty protocol is likely the extended keyboard protocol we care about, we use this as the primary reporting mechanism. (It also helps that this may provide an easier fallback for implementations that don't have raw scan codes and are willing to assume an ANSI layout.)

func (BaseKey) Shifted added in v3.1.2

func (bk BaseKey) Shifted() rune

type Beeper added in v3.0.6

type Beeper interface {
	Beep()
}

Beeper can be implemented by a backend to indicate it can ring the bell or beep. This is typically done in response to a 0x07 bell.

type Blitter added in v3.1.0

type Blitter interface {
	Blit(src, dst, dim Coord)
}

Blitter implements a cell-level blit, where a rectangular range of cells is copied from one location to another. The source and destination may overlap. The old locations will remain unchanged except of course or cells overwritten by the blit. The content will also be clipped to the visible dimensions.

type Button added in v3.1.0

type Button int

Button is the mouse button pressed or released.

type Cell added in v3.1.0

type Cell struct {
	C string // Content, it will be a grapheme cluster
	S Style  // Style, a pointer is used efficiency
	W int    // Display width (0, 1, or 2)
}

Cell is a representation of a display cell. Most consumers will not need this. Note, this is not the simplest possible representation, and a 256x256 cell display is going to need about 3MB to store it all, but it's simple, and adequate to retain pretty much all of what we need for Unicode. We could save some memory by using explicit struct pointers and by eliminating grapheme cluster support, but modern users expect these features.

type Clipboard added in v3.1.2

type Clipboard interface {

	// SetClipboard sets the contents of the clipboard.
	SetClipboard([]byte)

	// GetClipboard gets the contents of the clipboard.
	// It will return nil if the operation is not supported.
	// An empty clipboard will be []byte{}
	GetClipboard() []byte
}

Clipboard implements a clipboard or copy buffer for copy/paste activity. The backend may prevent sending clipboard data by returning an empty string for the clipboard. Frequently this is done for security reasons.

type Col

type Col int

Col indicates a column number (x position). We use zero based indices.

type Coord

type Coord struct {
	X Col // Column number, or X position.
	Y Row // Row number, or Y position.
}

Coord indicates a coordinate. This can also be used for window sizes.

type CursorStyle added in v3.1.2

type CursorStyle byte

CursorStyle represents the style of cursor, and covers the shape, whether it blinks, and whether it is visible. Cursor color is handled separately, if at all.

func (cs CursorStyle) Blink() CursorStyle

func (CursorStyle) Hide added in v3.1.2

func (cs CursorStyle) Hide() CursorStyle

func (CursorStyle) IsBlinking added in v3.1.2

func (cs CursorStyle) IsBlinking() bool

func (CursorStyle) IsVisible added in v3.1.2

func (cs CursorStyle) IsVisible() bool

func (CursorStyle) Show added in v3.1.2

func (cs CursorStyle) Show() CursorStyle

func (CursorStyle) Steady added in v3.1.2

func (cs CursorStyle) Steady() CursorStyle

type DeadKey added in v3.1.2

type DeadKey struct {
	Next map[rune]DeadKey // Next corresponds to the next key in the sequence for dead keys
	U    rune             // U is the rune that should be emitted on completion of the sequence.
}

DeadKey is what happens when a dead key is pressed. Either it starts an unresolved sequence, (in which case Next will be non-nil), or it resolves to a final rune (in which case U will be non-zero) This is also sometimes called a composed key sequence.

type Emulator added in v3.0.6

type Emulator interface {
	// SetId sets our identity.
	SetId(name string, version string)

	// SendRaw sends raw data to the consumer.  This bypasses the normal encoding,
	// so it should be used with caution.
	SendRaw([]byte)

	// KeyEvent injects a keyboard event into the emulator, which will ultimately
	// result in data being sent via SendRaw.
	KeyEvent(ev KeyEvent)

	// ResizeEvent is called by a backend when the terminal has resized
	// This will send in-band resize notifications if the client has requested them.
	ResizeEvent(Coord)

	// MouseEvent is called by a backend to report mouse activity.
	MouseEvent(ev MouseEvent)

	// FocusEvent is called by a backend to report that focus is gained (true) or lost (false).
	FocusEvent(bool)

	// Drain waits until any queued but not processed input has finished processing.
	// It also wakes the reader.
	Drain() error

	// Start starts processing.
	Start() error

	// Stop stops processing.
	Stop() error

	// Reader reads data from the emulator.  These are bytes that would be transmitted
	// to a remote party.
	io.Reader

	// Writer writes data to the emulator.  These are commands that the emulator should process.
	io.Writer
}

Emulator is a terminal emulator API. It implements the state machinery (escape parsing and so forth) associated with being a terminal emulator. The backend handles rendering the content, and some low level details.

NOTE: This is not a committed interface yet, its entirely a work in progress.

func NewEmulator added in v3.0.6

func NewEmulator(be Backend) Emulator

NewEmulator creates an emulator instance on top of the given backend. The input is relative to the emulator, so it receives data from the host, whereas the emulator sends data to the application through the output.

type Key added in v3.1.2

type Key uint16

Key represents the key code for a key. These are largely taken from the HID specification page 0x07, although there are gaps and some inconsistencies. We chose this specification because it covers all keyboards we are likely to see in practice. Note that the zero value is reserved and will never be assigned a valid key. A number of keys are from UNIX keyboards (e.g. Sun type 6 keyboards), and we do not explicitly support these because none of the common reporting protocols have a way to report them. Instead these should probably be mapped higher functions (F13 and up), if you're facing this. These are key locations on a US keyboard. For example on AZERTY layout KeyQ corresponds to a key that has a printed "A", but is in the upper left position (below the digits.)

func (Key) KittyBase added in v3.1.2

func (k Key) KittyBase() BaseKey

KittyBase returns the corresponding Kitty "base" key for the given USB cod. If no corresponding value can be found, then zero is returned. Note that some keys (such as F1) are valid, and recognized by Kitty, but do not use the base key encoding because they use another reporting format.

func (Key) ScanCode added in v3.1.2

func (k Key) ScanCode() ScanCode

ScanCode returns the corresponding Windows Scan Code (not a VK!) for the given key. (Virtual keys should be determined by the host OS using the current keyboard layout.)

type KeyEvent added in v3.1.0

type KeyEvent struct {
	Down   bool     // true if event is for key down event
	Repeat int      // if > 1, a repeat count
	Key    Key      // Key symbol.
	Base   BaseKey  // base key code (physical key, e.g 'a'), may be zero if same as code
	VK     WinVK    // Windows virtual key. 0 for none, or if not known.
	SC     ScanCode // Windows scan code. 0 for none, or if not known.
	Mod    Modifier // modifiers
	Utf    string   // if non-empty, the unicode content for this
}

KeyEvent is a key event.

type KeyboardMode added in v3.1.2

type KeyboardMode byte
const (
	KeyboardLegacy KeyboardMode = 1 << iota // KeyboardLegacy uses simple reporting in the VT220 fashion
	KeyboardWin32                           // Win32 input mode, reports both key release and press, includes scan codes and vk
	KeyboardKitty                           // Kitty simple protocol, only disambiguation
	KeyboardEvents                          // Kitty keyboard but reports events (press, release, repeat)
)

type KeyboardState added in v3.1.2

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

KeyboardState represents the current state of the keyboard. A zero initialized value is ready for use. Note that emulators that get the associated events from their operating system do not need to make use of this, but this structure makes it possible to build an emulator with a keyboard layout that is not known to the operating system.

func (*KeyboardState) Pressed added in v3.1.2

func (ks *KeyboardState) Pressed(k Key) *KeyEvent

Pressed should be called when a given key is depressed.

func (*KeyboardState) Released added in v3.1.2

func (ks *KeyboardState) Released(k Key) *KeyEvent

Released should be called when a given key is Released.

func (*KeyboardState) SetLayout added in v3.1.2

func (ks *KeyboardState) SetLayout(km *Layout)

SetLayout sets the layout this keyboard should use. This also resets the keyboard state.

type Layout added in v3.1.2

type Layout struct {
	// Name is the name of the keyboard layout.
	// We prefer to use the same names that Microsoft uses for keyboard layouts.
	Name string

	// Base is a base keyboard layout, so that we can simplify by only
	// overriding keys we are are handling differently.
	Base *Layout

	// DeadKeys maps specific starting keys, to an emitted rune.
	// The keys should a rune value starting with DeadRune.
	DeadKeys map[rune]DeadKey

	// Locking are modifiers that toggle a locked state like NumLock or CapsLock.
	Locking map[Key]Modifier

	// Modifiers toggle a state, but only while the key is depressed.
	Modifiers map[Key]Modifier

	// Virtual maps keys to virtual keys.
	Virtual map[Key]WinVK

	// Maps is the list of key maps by modifier and mask.
	// Use more specific masks first - for example NumLock
	// mask might contain only the masks for the number keypad,
	// and that should be listed before the maps for the rest
	// of the keyboard.  The algorithm searches for the first
	// match, not the best match.
	Maps []ModifierMap
}

Layout is a structure that represents a keyboard layout. Applications or users may implement their own layouts by registering an instance of this.

func GetLayout added in v3.1.2

func GetLayout(name string) *Layout

GetLayout returns a keyboard layout for the given name. The layout must have been previously registered with RegisterLayout. (Builtin layouts do this as a consequence of importing the layout.)

func (*Layout) KeyToUTF added in v3.1.2

func (km *Layout) KeyToUTF(k Key, m Modifier) rune

type MockBackend added in v3.1.0

type MockBackend interface {
	Backend

	// GetCell returns the cell at the given position, or an empty cell if the
	// position is out of the bounds of the window.
	GetCell(Coord) Cell

	// Bells counts the number of bells rung.
	Bells() int

	// GetTitle gets the current window title.
	GetTitle() string

	// SetSize is used to resize the window.
	// Newly added cells are empty, and content in old cells that out of range is lost.
	SetSize(Coord)

	// GetCursor is used to obtain the current cursor style.
	GetCursor() CursorStyle

	// SetClipboard sets the clipboard contents (copy buffer).
	SetClipboard([]byte)

	// GetClipboard returns the clipboard (copy buffer).
	GetClipboard() []byte
}

MockBackend provides additional mock-specific capabilities on top of Backend. This is meant to facilitate test cases

func NewMockBackend added in v3.1.0

func NewMockBackend(options ...MockOpt) MockBackend

NewMockBackend returns a MockBackend modified by the given options. The default is a fully featured 256-color backend with initial size 80x24.

type MockOpt added in v3.1.0

type MockOpt interface{ SetMockOpt(mb *mockBackend) }

MockOpt is an interface by which options can change the behavior of the mocked terminal. This is intended to permit easier testing.

type MockOptColors added in v3.1.0

type MockOptColors int

MockOptColors changes the number of colors the terminal supports.

func (MockOptColors) SetMockOpt added in v3.1.0

func (o MockOptColors) SetMockOpt(mb *mockBackend)

type MockOptNoBlit added in v3.1.0

type MockOptNoBlit struct{}

MockOptNoBlit suppresses the blitter interface.

func (MockOptNoBlit) SetMockOpt added in v3.1.0

func (MockOptNoBlit) SetMockOpt(mb *mockBackend)

type MockOptSize added in v3.1.0

type MockOptSize Coord

MockOptSize changes the default terminal size, which is normally 80x24.

func (MockOptSize) SetMockOpt added in v3.1.0

func (o MockOptSize) SetMockOpt(mb *mockBackend)

type MockTerm added in v3.1.0

type MockTerm interface {
	tty.Tty

	// Pos reports the current cursor position.
	Pos() Coord

	// GetCell returns the cell at the given coordinates.
	// The coordinates must be valid.
	GetCell(Coord) Cell

	// Bells returns the number of times the bell has been rung.
	Bells() int

	// Inject a keyboard event - this is a full event, and bypasses
	// the layout and keyboard state processor.
	KeyEvent(KeyEvent)

	// Inject a key press
	KeyPress(Key)

	// Inject a key release
	KeyRelease(Key)

	// Inject one or more key press and releases.
	// The keys are pressed in the order, and released in reverse order.
	// Thus modifiers should be listed first.  This should not be used
	// to simulate typing a sequence (e.g. a word), but if you wanted to
	// test say N-Key rollover you could do that here.
	KeyTap(...Key)

	// Inject a mouse event.
	MouseEvent(MouseEvent)

	// Inject a focus event.
	FocusEvent(bool)

	// GetTitle obtains the current window title.
	GetTitle() string

	// SetSize is used to resize the terminal.
	SetSize(Coord)

	// SendRaw is used to send raw data to the application.
	// This is mostly intended to facilitate fuzz testing the application.
	SendRaw([]byte)

	// Backend returns the backend (used for testing).
	Backend() MockBackend

	// SetLayout sets the keyboard layout to use.
	// If not specified, a US standard ANSI keyboard will be assumed.
	SetLayout(*Layout)
}

MockTerm is a mock terminal (emulator). It can be used to test the emulator itself, or to test applications (or tcell) that uses the terminal. It also implements the Tty interface used by tcell itself.

func NewMockTerm added in v3.1.0

func NewMockTerm(opts ...MockOpt) MockTerm

NewMockTerm gives a mock terminal emulator.

type ModeStatus

type ModeStatus int

ModeStatus represents the status of the mode.

const (
	ModeNA        ModeStatus = 0 // Mode is not supported (or unknown)
	ModeOn        ModeStatus = 1 // Mode is on (e.g. via CSI-h)
	ModeOff       ModeStatus = 2 // Mode is off (e.g. via CSI-l)
	ModeOnLocked  ModeStatus = 3 // Mode is hardwired on
	ModeOffLocked ModeStatus = 4 // Mode is hardwired off
)

func (ModeStatus) Changeable

func (ms ModeStatus) Changeable() bool

Changeable indicates that the mode may be changed.

type Modifier added in v3.0.6

type Modifier int

type ModifierMap added in v3.1.2

type ModifierMap struct {
	Mod    Modifier     // Mod is the modifiers that should be set to match, after applying Mask.
	Mask   Modifier     // Mask is the set of modifiers that are considered when matching.
	Invert bool         // Invert changes the matching sense via a logical NOT.
	Map    map[Key]rune // Map is the mapping from Key to specific rune when this map matches.
}

ModifierMap is a map that represents keys that generate runes in various shift states (modifier states). A layout may have many of these, and they are searched until a match is fine.

type MouseEvent added in v3.1.0

type MouseEvent struct {
	Position Coord    // Location of pointer.
	Button   Button   // Buttons pressed.
	Down     bool     // True on press, false on release.
	Motion   bool     // True if mouse moved at least once cell.
	Mod      Modifier // Modifiers (for modified click).
}

MouseEvent reports a single mouse event. Only a single button may be reported for a given event. The application will have to keep state. As buttons are never pressed exactly simultaneously, the backend will send chords as a series of presses followed by a series of releases.

type MouseReporting added in v3.1.0

type MouseReporting int

MouseReporting determines what mouse events the backend reports.

type Mouser added in v3.1.0

type Mouser interface {
	SetMouse(MouseReporting)
}

Mouser adds support configuring mouse reporting. We also assume that a mouse reporter can report focus events.

type PrivateMode

type PrivateMode int

PrivateMode describes a DEC Private Mode.

const (
	PmAppCursor        PrivateMode = 1    // Application cursor keys.
	PmVT52             PrivateMode = 2    // Clear to enable VT52 compatibility (not supported).
	PmColumns          PrivateMode = 3    // Set to enable 132 columns, reset for 80 columns.
	PmScrolling        PrivateMode = 4    // Smooth scrolling (jump by default).
	PmScreen           PrivateMode = 5    // Set to reverse dark and light on screen.
	PmOrigin           PrivateMode = 6    // Coordinates are relative to margins.
	PmAutoMargin       PrivateMode = 7    // Automatically wrap at margin.
	PmAutoRepeat       PrivateMode = 8    // Enable automatic key repeat.
	PmMouseX10         PrivateMode = 9    // Legacy (X10) mouse reporting.
	PmBlinkCursor      PrivateMode = 12   // Blinking (on) or steady (off) cursor.
	PmPrintFF          PrivateMode = 18   // Print form feed after printing screen.
	PmPrintExtent      PrivateMode = 19   // Print full screen (on) or scrolling region (off).
	PmShowCursor       PrivateMode = 25   // Show the cursor (default on).
	PmCharSet          PrivateMode = 42   // Enable national (on) or multinational (off) character sets.
	PmLeftRightMargin  PrivateMode = 69   // Enable left and right margins
	PmMouseButton      PrivateMode = 1000 // Report mouse button events.
	PmMouseDrag        PrivateMode = 1002 // Report mouse motion events when button depressed, requires PmMouseButton.
	PmMouseMotion      PrivateMode = 1003 // Report mouse motion events, requires PmMouseButton.
	PmFocusReports     PrivateMode = 1004 // Send focus gained or lost reports.
	PmMouseSgr         PrivateMode = 1006 // Use SGR sequences for mouse reports.
	PmMouseSgrPixel    PrivateMode = 1016 // Use SGR sequences for mouse reports, using pixel-level coordinates.
	PmAltScreen        PrivateMode = 1049 // 47 and 1047 are alternates, but we use 1049
	PmBracketedPaste   PrivateMode = 2004 // Bracket pasted text with bracketed paste escape sequences.
	PmSyncOutput       PrivateMode = 2026 // Buffer output when enabled, updating screen when reset.
	PmGraphemeClusters PrivateMode = 2027 // Support for grapheme cluster handling.
	PmResizeReports    PrivateMode = 2048 // Send in-band resize reports.
	PmWin32Input       PrivateMode = 9001 // Use Win32-Input-Mode for keyboard reports
)

func (PrivateMode) Disable

func (pm PrivateMode) Disable() string

Disable returns the string used to disable this private mode.

func (PrivateMode) Enable

func (pm PrivateMode) Enable() string

Enable returns the string used to enable this private mode.

func (PrivateMode) Query

func (pm PrivateMode) Query() string

Query returns the string used to query the state of this private mode.

func (PrivateMode) Reply

func (pm PrivateMode) Reply(status ModeStatus) string

Reply returns a string representing a query reply for the given mode and status.

type Resizer added in v3.0.6

type Resizer interface {
	// NotifyResize registers a channel to be posted to if the window size changes.
	NotifyResize(chan<- bool)
}

Resizer adds notifications when the window size changes.

type Row

type Row int

Row indicates a row number (y position). We use zero based indices, although the VT standard mostly communicates using 1-based offsets.

type ScanCode added in v3.1.2

type ScanCode uint16

ScanCode is the scan code used by Windows for a key. These are physical key locations, and every physical should have a exactly one mapping here.

type Style added in v3.1.0

type Style interface {
	Fg() color.Color              // Fg returns the foreground color.
	Bg() color.Color              // Bg returns the background color.
	Uc() color.Color              // Uc returns the underline color.k
	Attr() Attr                   // Attr returns the associated attributes.
	Url() (string, string)        // Url returns the URL and associated id if one was set.
	WithFg(color.Color) Style     // WithFg creates a new style with the foreground
	WithBg(color.Color) Style     // WithBg creates a new style with the background.
	WithUc(color.Color) Style     // WithUc creates a new style with the underline color
	WithAttr(Attr) Style          // WithAttr creates a new style with the attributes.
	WithUrl(string, string) Style // WithLink creates a new style with the URL and id.
	Equal(Style) bool             // Equal returns true if the styles are the same.
}

Style represents the styling of a cell. This is an interface to prevent direct modification.

type Titler added in v3.0.6

type Titler interface {
	// SetWindowTitle only changes the window title.
	SetWindowTitle(string)
}

Titler adds support for setting the window title. (Typically this is OSC2.) Note that for security reasons we only support setting this. We don't bother with icon titles, since few terminal emulators support it, and it would be hard for us to do this in any portable fashion.

type WinVK added in v3.1.2

type WinVK rune

WinVK represents a windows virtual key code. These are similar to base keys, but a multiple scanned key codes may result in the same virtual key. This can also be sensitive to the keyboard layout.

Directories

Path Synopsis
layouts
all
Package all is used to import all keyboard layouts.
Package all is used to import all keyboard layouts.
us

Jump to

Keyboard shortcuts

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