vte

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 4 Imported by: 1

README

go-vte

Go Report Card License MIT Go Doc

A GO version of https://github.com/alacritty/vte.

The pkg vtparse implements a state machine that mirrors the behaviour of DEC (Digital Equipment Corporation) VT hardware terminals. The state machine was originally described by Paul Williams; more information can be found here: http://www.vt100.net/emu/dec_ansi_parser.

Install

go get -u github.com/danielgatis/go-vte

And then import the package in your code:

import "github.com/danielgatis/go-vte"
Example

Please look at: examples/parserlog/main.go

❯ echo -ne "Hello\nWorld" | go run ./examples/parserlog/main.go
[Print] H
[Print] e
[Print] l
[Print] l
[Print] o
[Execute] 0a
[Print] W
[Print] o
[Print] r
[Print] l
[Print] d

License

Copyright (c) 2020-present Daniel Gatis

Licensed under MIT License

Documentation

Index

Constants

View Source
const (
	AnywhereState           State = 0
	CsiEntryState           State = 1
	CsiIgnoreState          State = 2
	CsiIntermediateState    State = 3
	CsiParamState           State = 4
	DcsEntryState           State = 5
	DcsIgnoreState          State = 6
	DcsIntermediateState    State = 7
	DcsParamState           State = 8
	DcsPassthroughState     State = 9
	EscapeState             State = 10
	EscapeIntermediateState State = 11
	GroundState             State = 12
	OscStringState          State = 13
	SosPmApcStringState     State = 14
	Utf8State               State = 15

	NoneAction        Action = 0
	ClearAction       Action = 1
	CollectAction     Action = 2
	CsiDispatchAction Action = 3
	EscDispatchAction Action = 4
	ExecuteAction     Action = 5
	HookAction        Action = 6
	IgnoreAction      Action = 7
	OscEndAction      Action = 8
	OscPutAction      Action = 9
	OscStartAction    Action = 10
	ParamAction       Action = 11
	PrintAction       Action = 12
	PutAction         Action = 13
	UnhookAction      Action = 14
	BeginUtf8Action   Action = 15
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action = byte

Action represents a action type

type Parser

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

Parser represents a state machine.

func NewParser

func NewParser(
	performer Performer,
) *Parser

NewParser returns a new parser.

func (*Parser) Advance

func (p *Parser) Advance(b byte)

Advance advances the state machine.

func (*Parser) Intermediates

func (p *Parser) Intermediates() []byte

Intermediates returns the intermediates

func (*Parser) OscParams

func (p *Parser) OscParams() [][]byte

OscParams returns the osc params

func (*Parser) Params

func (p *Parser) Params() [][]uint16

Params returns the params

func (*Parser) State

func (p *Parser) State() State

State returns the current state

func (*Parser) StateName

func (p *Parser) StateName() string

StateName returns the current state name

type Performer

type Performer interface {
	// Print is called when a print action is performed.
	Print(r rune)

	// Execute is called when an execute action is performed.
	Execute(b byte)

	// Put is called when a put action is performed.
	Put(b byte)

	// Unhook is called when an unhook action is performed.
	Unhook()

	// Hook is called when a hook action is performed.
	Hook(params [][]uint16, intermediates []byte, ignore bool, r rune)

	// OscDispatch is called when an osc dispatch action is performed.
	OscDispatch(params [][]byte, bellTerminated bool)

	// CsiDispatch is called when a csi dispatch action is performed.
	CsiDispatch(params [][]uint16, intermediates []byte, ignore bool, r rune)

	// EscDispatch is called when an esc dispatch action is performed.
	EscDispatch(intermediates []byte, ignore bool, b byte)
}

Performer is an interface for parsing.

type State

type State = byte

State represents a state type

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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