parsing

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package parsing converts a terminal byte stream into ANSI/DEC parser events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Prefix       byte
	Intermediate byte
	Final        byte
}

Command identifies an ANSI escape command.

type Handler

type Handler struct {
	Print   func(rune)
	Execute func(byte)
	CSI     func(Command, []Parameter)
	Escape  func(Command)
	// OSC receives an operating system command. Command is its leading
	// numeric identifier, or -1 when it has none; data follows the separating
	// semicolon.
	OSC func(command int, data []byte)
	// DCS receives a device control string's command, parameters, and data.
	DCS func(Command, []Parameter, []byte)
	// ControlString reports a PM, APC, or SOS string; kind is "PM", "APC",
	// or "SOS". Their content is not delivered.
	ControlString func(kind string)
}

Handler receives parser events synchronously during Parser.Write. Control string data is valid only for the duration of the call.

type Parameter

type Parameter struct {
	Value   int
	Present bool
	More    bool
}

Parameter is one CSI parameter. Present distinguishes an omitted parameter from an explicit zero. More reports that a subparameter follows.

type Parser

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

Parser is an incremental ANSI/DEC-compatible byte-stream parser.

func New

func New(handler Handler) *Parser

New creates a parser that dispatches events to handler.

func (*Parser) Write

func (p *Parser) Write(data []byte) (int, error)

Write incrementally parses data. Incomplete sequences remain buffered until a later call supplies the remaining bytes.

Jump to

Keyboard shortcuts

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