input

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallASCIICodeParse

func InstallASCIICodeParse(codes ...*ASCIICode)

InstallASCIICodeParse install ascii code parse. NOTE: it must call in init func

Types

type ASCIICode

type ASCIICode struct {
	Key       Key
	ASCIICode []byte
}

ASCIICode is the type contains Key and it's ascii byte array.

type ConsoleParser

type ConsoleParser interface {
	// Setup should be called before starting input
	Setup() error
	// TearDown should be called after stopping input
	TearDown() error
	// GetWinSize returns WinSize object to represent width and height of terminal.
	GetWinSize() *WinSize
	// Read returns byte array.
	Read() ([]byte, error)
}

ConsoleParser is an interface to abstract input layer.

type Key

type Key uint64

Key is the type express the key inserted from user.

const (
	Escape Key = iota

	ControlA
	ControlB
	ControlC
	ControlD
	ControlE
	ControlF
	ControlG
	ControlH

	ControlK
	ControlL

	ControlN
	ControlO
	ControlP
	ControlQ
	ControlR
	ControlS
	ControlT
	ControlU
	ControlV
	ControlW
	ControlX
	ControlY
	ControlZ

	// Meta[Alt] + [a-f]
	MetaA
	MetaB
	MetaC
	MetaD
	MetaE
	MetaF
	MetaG
	MetaH
	MetaI
	MetaJ
	MetaK
	MetaL
	MetaM
	MetaN
	MetaO
	MetaP
	MetaQ
	MetaR
	MetaS
	MetaT
	MetaU
	MetaV
	MetaW
	MetaX
	MetaY
	MetaZ

	// Meta[Alt] + Shift [a-z]
	// Meta[Alt] + [A-Z]
	MetaShiftA
	MetaShiftB
	MetaShiftC
	MetaShiftD
	MetaShiftE
	MetaShiftF
	MetaShiftG
	MetaShiftH
	MetaShiftI
	MetaShiftJ
	MetaShiftK
	MetaShiftL
	MetaShiftM
	MetaShiftN
	MetaShiftO
	MetaShiftP
	MetaShiftQ
	MetaShiftR
	MetaShiftS
	MetaShiftT
	MetaShiftU
	MetaShiftV
	MetaShiftW
	MetaShiftX
	MetaShiftY
	MetaShiftZ

	ControlSpace
	ControlBackslash
	ControlSquareClose
	ControlCircumflex
	ControlUnderscore
	ControlLeft
	ControlRight
	ControlUp
	ControlDown

	Up
	Down
	Right
	Left

	ShiftLeft
	ShiftUp
	ShiftDown
	ShiftRight

	Home
	End
	Delete
	ShiftDelete
	ControlDelete
	PageUp
	PageDown
	BackTab
	Insert
	Backspace

	// Aliases.
	Tab
	Enter

	F1
	F2
	F3
	F4
	F5
	F6
	F7
	F8
	F9
	F10
	F11
	F12
	F13
	F14
	F15
	F16
	F17
	F18
	F19
	F20
	F21
	F22
	F23
	F24

	// Matches any key.
	Any

	// Special
	CPRResponse
	Vt100MouseEvent
	WindowsMouseEvent
	BracketedPaste

	// Key which is ignored. (The key binding for this key should not do anything.)
	Ignore

	// Key is not defined
	NotDefined
)
var UnkownKey Key = math.MaxUint64

UnkownKey use to set block manager cancel/finish key

func GetKey

func GetKey(b []byte) Key

GetKey returns Key correspond to input byte codes.

func (Key) String

func (i Key) String() string

type PosixParser

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

PosixParser is a ConsoleParser implementation for POSIX environment.

func NewStandardInputParser

func NewStandardInputParser() *PosixParser

NewStandardInputParser returns ConsoleParser object to read from stdin.

func (*PosixParser) GetWinSize

func (t *PosixParser) GetWinSize() *WinSize

GetWinSize returns WinSize object to represent width and height of terminal.

func (*PosixParser) Read

func (t *PosixParser) Read() ([]byte, error)

Read returns byte array.

func (*PosixParser) Setup

func (t *PosixParser) Setup() error

Setup should be called before starting input

func (*PosixParser) TearDown

func (t *PosixParser) TearDown() error

TearDown should be called after stopping input

type WinSize

type WinSize struct {
	Row int
	Col int
}

WinSize represents the width and height of terminal.

Jump to

Keyboard shortcuts

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