key

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: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Shift = "Shift"
	Alt   = "Alt"
	Ctrl  = "Ctrl"
	Meta  = "Meta"

	EnterStr          = "Enter"
	BackspaceStr      = "Backspace"
	TabStr            = "Tab"
	BackTabStr        = "Backtab"
	EscStr            = "Esc"
	Backspace2Str     = "Backspace2"
	DeleteStr         = "Delete"
	InsertStr         = "Insert"
	UpStr             = "Up"
	DownStr           = "Down"
	LeftStr           = "Left"
	RightStr          = "Right"
	HomeStr           = "Home"
	EndStr            = "End"
	UpLeftStr         = "UpLeft"
	UpRightStr        = "UpRight"
	DownLeftStr       = "DownLeft"
	DownRightStr      = "DownRight"
	CenterStr         = "Center"
	PgDnStr           = "PgDn"
	PgUpStr           = "PgUp"
	ClearStr          = "Clear"
	ExitStr           = "Exit"
	CancelStr         = "Cancel"
	PauseStr          = "Pause"
	PrintStr          = "Print"
	F1Str             = "F1"
	F2Str             = "F2"
	F3Str             = "F3"
	F4Str             = "F4"
	F5Str             = "F5"
	F6Str             = "F6"
	F7Str             = "F7"
	F8Str             = "F8"
	F9Str             = "F9"
	F10Str            = "F10"
	F11Str            = "F11"
	F12Str            = "F12"
	CtrlAStr          = "Ctrl-A"
	CtrlBStr          = "Ctrl-B"
	CtrlCStr          = "Ctrl-C"
	CtrlDStr          = "Ctrl-D"
	CtrlEStr          = "Ctrl-E"
	CtrlFStr          = "Ctrl-F"
	CtrlGStr          = "Ctrl-G"
	CtrlJStr          = "Ctrl-J"
	CtrlKStr          = "Ctrl-K"
	CtrlLStr          = "Ctrl-L"
	CtrlNStr          = "Ctrl-N"
	CtrlOStr          = "Ctrl-O"
	CtrlPStr          = "Ctrl-P"
	CtrlQStr          = "Ctrl-Q"
	CtrlRStr          = "Ctrl-R"
	CtrlSStr          = "Ctrl-S"
	CtrlTStr          = "Ctrl-T"
	CtrlUStr          = "Ctrl-U"
	CtrlVStr          = "Ctrl-V"
	CtrlWStr          = "Ctrl-W"
	CtrlXStr          = "Ctrl-X"
	CtrlYStr          = "Ctrl-Y"
	CtrlZStr          = "Ctrl-Z"
	CtrlSpaceStr      = "Ctrl-Space"
	CtrlUnderscoreStr = "Ctrl-_"
	CtrlRightSqStr    = "Ctrl-]"
	CtrlBackslashStr  = "Ctrl-\\"
	CtrlCaratStr      = "Ctrl-^"
)
View Source
const (
	ModShift term.ModMask = 1 << iota
	ModCtrl
	ModAlt
	ModMeta
	ModNone term.ModMask = 0
)

These are the modifiers keys that can be sent either with a key press, or a mouse event. Note that as of now, due to the confusion associated with Meta, and the lack of support for it on many/most platforms, the current implementations never use it. Instead, they use ModAlt, even for events that could possibly have been distinguished from ModAlt.

View Source
const (
	Rune term.Key = iota + 256
	Up
	Down
	Right
	Left
	UpLeft
	UpRight
	DownLeft
	DownRight
	Center
	PgUp
	PgDn
	Home
	End
	Insert
	Delete
	Help
	Exit
	Clear
	Cancel
	Print
	Pause
	BackTab
	F1
	F2
	F3
	F4
	F5
	F6
	F7
	F8
	F9
	F10
	F11
	F12
)

This is the list of named keys. Rune is special however, in that it is a place holder key indicating that a printable character was sent. The actual value of the rune will be transported in the Rune of the associated KeyEvent.

View Source
const (
	CtrlSpace term.Key = iota
	CtrlA
	CtrlB
	CtrlC
	CtrlD
	CtrlE
	CtrlF
	CtrlG
	CtrlH
	CtrlI
	CtrlJ
	CtrlK
	CtrlL
	CtrlM
	CtrlN
	CtrlO
	CtrlP
	CtrlQ
	CtrlR
	CtrlS
	CtrlT
	CtrlU
	CtrlV
	CtrlW
	CtrlX
	CtrlY
	CtrlZ
	CtrlLeftSq // Escape
	CtrlBackslash
	CtrlRightSq
	CtrlCarat
	CtrlUnderscore
)

These are the control keys. Note that they overlap with other keys, perhaps. For example, CtrlH is the same as Backspace.

View Source
const (
	NUL term.Key = iota
	SOH
	STX
	ETX
	EOT
	ENQ
	ACK
	BEL
	BS
	TAB
	LF
	VT
	FF
	CR
	SO
	SI
	DLE
	DC1
	DC2
	DC3
	DC4
	NAK
	SYN
	ETB
	CAN
	EM
	SUB
	ESC
	FS
	GS
	RS
	US
	DEL term.Key = 0x7F
)

These are the defined ASCII values for key codes. They generally match with KeyCtrl values.

View Source
const (
	Backspace  = BS
	Tab        = TAB
	Esc        = ESC
	Escape     = ESC
	Enter      = CR
	Backspace2 = DEL
)

These keys are aliases for other names.

View Source
const (
	Debug = false
)

Variables

This section is empty.

Functions

func NewEvent

func NewEvent(k term.Key, ch rune, mod term.ModMask) term.KeyEvent

NewEvent attempts to create a suitable event. It parses the various ASCII control sequences if Rune is passed for Key, but if the caller has more precise information it should set that specifically. Callers that aren't sure about modifier state (most) should just pass ModNone.

func NewEventDispatcher

func NewEventDispatcher(opts ...Option) (term.KeyDispatcher, error)

Types

type Code

type Code struct {
	Key term.Key
	Mod term.ModMask
}

Code represents a combination of a key code and modifiers.

type Finalizer

type Finalizer func()

Finalizer

type Option

type Option func(core *eventDispatcher)

Option

func WithFinalizer

func WithFinalizer(c Finalizer) Option

WithFinalizer provides a way of calling a function upon dispatcher death

func WithKeyTimerInterval

func WithKeyTimerInterval(duration time.Duration) Option

WithKeyTimerInterval is a functional option to set the interval between key reads, for those of you brave enough to go slower or faster. Default is 50 milliseconds.

func WithTerminalInfo

func WithTerminalInfo(ti *info.Term) Option

WithTerminalInfo is mandatory for the composition, provided by core

Jump to

Keyboard shortcuts

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