parser

package
v0.0.0-...-80c3d28 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2021 License: BSD-3-Clause Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	NUL = 0x0
	DEL = 0x7f
	CAN = 0x18
	SUB = 0x1a
	ESC = 0x1b
	BEL = 0x7
	C0  = 0x20
)

Variables

View Source
var CSICodes = map[CSICommand]CSICode{
	0x3c:                 {"MOUSE", "XTerm Mouse Event"},
	0x40:                 {"ICH", "ECMA-48 8.3.64"},
	0x41:                 {"CUU", "ECMA-48 8.3.22"},
	0x42:                 {"CUD", "ECMA-48 8.3.19"},
	0x43:                 {"CUF", "ECMA-48 8.3.20"},
	0x44:                 {"CUB", "ECMA-48 8.3.18"},
	0x45:                 {"CNL", "ECMA-48 8.3.12"},
	0x46:                 {"CPL", "ECMA-48 8.3.13"},
	0x47:                 {"CHA", "ECMA-48 8.3.9"},
	0x48:                 {"CUP", "ECMA-48 8.3.21"},
	0x49:                 {"CHT", "ECMA-48 8.3.10"},
	0x4a:                 {"ED", "ECMA-48 8.3.39"},
	LEADER('?', 0x4a):    {"DECSED", "Selective Erase in Display"},
	0x4b:                 {"EL", "ECMA-48 8.3.41"},
	LEADER('?', 0x4b):    {"DECSEL", "Selective Erase in Line"},
	0x4c:                 {"IL", "ECMA-48 8.3.67"},
	0x4d:                 {"DL", "ECMA-48 8.3.32"},
	0x50:                 {"DCH", "ECMA-48 8.3.26"},
	0x53:                 {"SU", "ECMA-48 8.3.147"},
	0x54:                 {"SD", "ECMA-48 8.3.113"},
	0x58:                 {"ECH", "ECMA-48 8.3.38"},
	0x5a:                 {"CBT", "ECMA-48 8.3.7"},
	0x60:                 {"HPA", "ECMA-48 8.3.57"},
	0x61:                 {"HPR", "ECMA-48 8.3.59"},
	0x62:                 {"REP", "ECMA-48 8.3.103"},
	0x63:                 {"DA", "ECMA-48 8.3.24"},
	LEADER('>', 0x63):    {"DA-LT", "DEC secondary Device Attributes"},
	0x64:                 {"VPA", "ECMA-48 8.3.158"},
	0x65:                 {"VPR", "ECMA-48 8.3.160"},
	0x66:                 {"HVP", "ECMA-48 8.3.63"},
	0x67:                 {"TBC", "ECMA-48 8.3.154"},
	0x68:                 {"SM", "ECMA-48 8.3.125"},
	LEADER('?', 0x68):    {"SM-Q", "DEC private mode set"},
	0x6a:                 {"HPB", "ECMA-48 8.3.58"},
	0x6b:                 {"VPB", "ECMA-48 8.3.159"},
	0x6c:                 {"RM", "ECMA-48 8.3.106"},
	LEADER('?', 0x6c):    {"RM-Q", "DEC private mode reset"},
	0x6d:                 {"SGR", "ECMA-48 8.3.117"},
	0x6e:                 {"DSR", "ECMA-48 8.3.35"},
	LEADER('?', 0x6e):    {"DSR-Q", "DECDSR"},
	LEADER('!', 0x70):    {"DECSTR", "DEC soft terminal reset"},
	INTERMED(' ', 0x71):  {"DECSCUSR", "DEC set cursor shape"},
	INTERMED('"', 0x71):  {"DECSCA", "DEC select character protection attribute"},
	0x72:                 {"DECSTBM", "DEC custom"},
	0x73:                 {"DECSLRM", "DEC custom"},
	INTERMED('\'', 0x7D): {"DECIC", "DEC Scroll Screen Up"},
	INTERMED('\'', 0x7E): {"DECDC", "DEC Scroll Screen Down"},
}
View Source
var EscapeMatcher = map[EscapeCommand][]byte{
	S7C1T:         []byte{' ', 'F'},
	S8C1T:         []byte{' ', 'G'},
	DECDHL_TOP:    []byte{'#', '3'},
	DECDHL_BOTTOM: []byte{'#', '4'},
	DECSWL:        []byte{'#', '5'},
	DECDWL:        []byte{'#', '6'},
	DECALN:        []byte{'#', '8'},
	SCS1:          []byte{'('},
	SCS2:          []byte{')'},
	SCS3:          []byte{'*'},
	SCS4:          []byte{'+'},
	DECSC:         []byte{'7'},
	DECRC:         []byte{'8'},
	VT100UP:       []byte{'<'},
	DECKPAM:       []byte{'='},
	DECKPNM:       []byte{'>'},
	RIS:           []byte{'c'},
	LS2:           []byte{'n'},
	LS3:           []byte{'o'},
	LS1R:          []byte{'~'},
	LS2R:          []byte{'}'},
	LS3R:          []byte{'|'},
}
View Source
var L = hclog.L()

Functions

This section is empty.

Types

type CSICode

type CSICode struct {
	Name        string
	Description string
}

type CSICommand

type CSICommand int
var (
	MOUSE    CSICommand = 0x3c
	ICH      CSICommand = 0x40
	CUU      CSICommand = 0x41
	CUD      CSICommand = 0x42
	CUF      CSICommand = 0x43
	CUB      CSICommand = 0x44
	CNL      CSICommand = 0x45
	CPL      CSICommand = 0x46
	CHA      CSICommand = 0x47
	CUP      CSICommand = 0x48
	CHT      CSICommand = 0x49
	ED       CSICommand = 0x4a
	DECSED   CSICommand = LEADER('?', 0x4a)
	EL       CSICommand = 0x4b
	DECSEL   CSICommand = LEADER('?', 0x4b)
	IL       CSICommand = 0x4c
	DL       CSICommand = 0x4d
	DCH      CSICommand = 0x50
	SU       CSICommand = 0x53
	SD       CSICommand = 0x54
	ECH      CSICommand = 0x58
	CBT      CSICommand = 0x5a
	HPA      CSICommand = 0x60
	HPR      CSICommand = 0x61
	REP      CSICommand = 0x62
	DA       CSICommand = 0x63
	DA_LT    CSICommand = LEADER('>', 0x63)
	VPA      CSICommand = 0x64
	VPR      CSICommand = 0x65
	HVP      CSICommand = 0x66
	TBC      CSICommand = 0x67
	SM       CSICommand = 0x68
	SM_Q     CSICommand = LEADER('?', 0x68)
	HPB      CSICommand = 0x6a
	VPB      CSICommand = 0x6b
	RM       CSICommand = 0x6c
	RM_Q     CSICommand = LEADER('?', 0x6c)
	SGR      CSICommand = 0x6d
	DSR      CSICommand = 0x6e
	DSR_Q    CSICommand = LEADER('?', 0x6e)
	DECSTR   CSICommand = LEADER('!', 0x70)
	DECSCUSR CSICommand = INTERMED(' ', 0x71)
	DECSCA   CSICommand = INTERMED('"', 0x71)
	DECSTBM  CSICommand = 0x72
	DECSLRM  CSICommand = 0x73
	DECIC    CSICommand = INTERMED('\'', 0x7D)
	DECDC    CSICommand = INTERMED('\'', 0x7E)
)

func INTERMED

func INTERMED(i, b byte) CSICommand

func LEADER

func LEADER(l, b byte) CSICommand

func (CSICommand) String

func (c CSICommand) String() string

type CSIEvent

type CSIEvent struct {
	Command  byte
	Leader   []byte
	Args     []int
	Intermed []byte
}

func (*CSIEvent) CSICommand

func (c *CSIEvent) CSICommand() CSICommand

func (*CSIEvent) Recycle

func (c *CSIEvent) Recycle()

func (*CSIEvent) String

func (c *CSIEvent) String() string

type ControlCommand

type ControlCommand int
const (
	BELX ControlCommand = 0x7
	BS   ControlCommand = 0x8
	HT   ControlCommand = 0x9
	LF   ControlCommand = 0xa
	VT   ControlCommand = 0xb
	FF   ControlCommand = 0xc
	CR   ControlCommand = 0xd
	LSI  ControlCommand = 0xe
	LS0  ControlCommand = 0xf
)

type ControlEvent

type ControlEvent byte

func (ControlEvent) String

func (c ControlEvent) String() string

type DecModeCommand

type DecModeCommand int
const (
	DECCKM        DecModeCommand = 1  // Application Cursor Keys (DECCKM)
	DECANM        DecModeCommand = 2  // Designate USASCII for character sets G0-G3 (DECANM), and set VT100 mode.
	DECCOLM       DecModeCommand = 3  // 132 Column Mode (DECCOLM)
	DECSCLM       DecModeCommand = 4  // Smooth (Slow) Scroll (DECSCLM)
	DECSCNM       DecModeCommand = 5  // Reverse Video (DECSCNM)
	DECOM         DecModeCommand = 6  // Origin Mode (DECOM)
	DECAWM        DecModeCommand = 7  // Wraparound Mode (DECAWM)
	DECARM        DecModeCommand = 8  // Auto-repeat Keys (DECARM)
	DECSNDM       DecModeCommand = 9  // Send Mouse X & Y on button press. See the section Mouse Tracking.
	DECTOOL       DecModeCommand = 10 // Show toolbar (rxvt)
	DECBLINK      DecModeCommand = 12 // Start Blinking Cursor (att610)
	DECPFF        DecModeCommand = 18 // Print form feed (DECPFF)
	DECPEX        DecModeCommand = 19 // Set print extent to full screen (DECPEX)
	DECTCEM       DecModeCommand = 25 // Show Cursor (DECTCEM)
	DECSHOWSCROLL DecModeCommand = 30 // Show scrollbar (rxvt).
	DECFONTSHIFT  DecModeCommand = 35 // Enable font-shifting functions (rxvt).
	DECTEK        DecModeCommand = 38 // Enter Tektronix Mode (DECTEK)
	DEC132        DecModeCommand = 40 // Allow 80 → 132 Mode
	DECMORE       DecModeCommand = 41 // more(1) fix (see curses resource)
	DECNRCM       DecModeCommand = 42 // Enable Nation Replacement Character sets (DECNRCM)
	DECMBELL      DecModeCommand = 44 // Turn On Margin Bell
	DECRWRAP      DecModeCommand = 45 // Reverse-wraparound Mode
	DECLOG        DecModeCommand = 46 // Start Logging (normally disabled by a compile-time option)
	DECALT        DecModeCommand = 47 // Use Alternate Screen Buffer (unless disabled by the titeInhibit resource)
	DECNKM        DecModeCommand = 66 // Application keypad (DECNKM)
	DECBKM        DecModeCommand = 67 // Backarrow key sends backspace (DECBKM)
	DECVSSM       DecModeCommand = 69
	DECMCLICK     DecModeCommand = 1000 // Send Mouse X & Y on button press and release. See the section Mouse Tracking.
	DECMDRAG      DecModeCommand = 1002 // Use Cell Motion Mouse Tracking.
	DECMMOVE      DecModeCommand = 1003 // Use All Motion Mouse Tracking.
	DECRPTFOC     DecModeCommand = 1004
	DECMPROT1     DecModeCommand = 1005
	DECMPROT2     DecModeCommand = 1006
	DECMPROT3     DecModeCommand = 1015
	DECALTSCRN    DecModeCommand = 1047 // Use Alternate Screen Buffer (unless disabled by the titeInhibit resource)
	DECSAVECUR    DecModeCommand = 1048 // Save cursor as in DECSC (unless disabled by the titeInhibit resource)
	DECALTSCRN2   DecModeCommand = 1049 // Save cursor as in DECSC and use Alternate Screen Buffer, clearing it first (unless disabled by the titeInhibit resource). This combines the effects of the 1 0 4 7 and 1 0 4 8 modes. Use this with terminfo-based applications rather than the 4 7 mode.
	DECBRACKET    DecModeCommand = 2004 // Set bracketed paste mode.
)

func (DecModeCommand) String

func (i DecModeCommand) String() string

type EscapeCommand

type EscapeCommand int
const (
	S7C1T EscapeCommand = iota
	S8C1T
	DECDHL_TOP
	DECDHL_BOTTOM
	DECSWL
	DECDWL
	DECALN
	SCS1
	SCS2
	SCS3
	SCS4
	DECSC
	DECRC
	VT100UP
	DECKPAM
	DECKPNM
	RIS
	LS2
	LS3
	LS1R
	LS2R
	LS3R
)

type EscapeEvent

type EscapeEvent struct {
	Data []byte
}

type Event

type Event interface{}

type EventHandler

type EventHandler interface {
	HandleEvent(Event) error
}

type OSCEvent

type OSCEvent struct {
	Command int
	Data    string
}

type Parser

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

func NewParser

func NewParser(r io.Reader, h EventHandler) (*Parser, error)

func (*Parser) Drive

func (p *Parser) Drive(ctx context.Context) error

func (*Parser) Resize

func (p *Parser) Resize(ctx context.Context, rows, cols int) error

type ResizeEvent

type ResizeEvent struct {
	Rows, Cols int
	Confirm    chan error
}

type StringEvent

type StringEvent struct {
	Kind string
	Data []byte
}

type TextEvent

type TextEvent struct {
	Text []byte
}

func (*TextEvent) Recycle

func (ev *TextEvent) Recycle()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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