package parser
Import Path
github.com/charmbracelet/x/ansi/parser (on go.dev)
Dependency Relation
imports one package, and imported by 2 packages
Involved Source Files
Package parser provides ANSI escape sequence parsing functionality.
seq.go
transition_table.go
Package-Level Type Names (total 3, all are exported)
Action is a DEC ANSI parser action.
State is a DEC ANSI parser state.
TransitionTable is a DEC ANSI transition table.
https://vt100.net/emu/dec_ansi_parser
AddMany adds many transitions.
AddOne adds a transition.
AddRange adds a range of transitions.
SetDefault sets default transition.
Transition returns the next state and action for the given state and byte.
func GenerateTransitionTable() TransitionTable
func NewTransitionTable(size int) TransitionTable
var Table
Package-Level Functions (total 11, in which 10 are exported)
Command returns the command byte of the CSI sequence.
GenerateTransitionTable generates a DEC ANSI transition table compatible
with the VT500-series of terminals. This implementation includes a few
modifications that include:
- A new Utf8State is introduced to handle UTF8 sequences.
- Osc and Dcs data accept UTF8 sequences by extending the printable range
to 0xFF and 0xFE respectively.
- We don't ignore 0x3A (':') when building Csi and Dcs parameters and
instead use it to denote sub-parameters.
- Support dispatching SosPmApc sequences.
- The DEL (0x7F) character is executed in the Ground state.
- The DEL (0x7F) character is collected in the DcsPassthrough string state.
- The ST C1 control character (0x9C) is executed and not ignored.
HasMore returns true if the parameter has more sub-parameters.
Intermediate returns the intermediate byte of the sequence.
An intermediate byte is in the range of 0x20-0x2F. This includes these
characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+',
',', '-', '.', '/'.
Zero is returned if the sequence does not have an intermediate byte.
Len returns the number of parameters in the sequence.
This will return the number of parameters in the sequence, excluding any
sub-parameters.
NewTransitionTable returns a new DEC ANSI transition table.
Param returns the parameter at the given index.
It returns -1 if the parameter does not exist.
Prefix returns the prefix byte of the sequence.
This is always gonna be one of the following '<' '=' '>' '?' and in the
range of 0x3C-0x3F.
Zero is returned if the sequence does not have a prefix.
Range iterates over the parameters of the sequence and calls the given
function for each parameter.
The function should return false to stop the iteration.
Subparams returns the sub-parameters of the given parameter.
It returns nil if the parameter does not exist.
Package-Level Variables (total 3, all are exported)
ActionNames provides string names for parser actions.
StateNames provides string names for parser states.
Table is a DEC ANSI transition table.
Package-Level Constants (total 40, all are exported)
These are the states that the parser can be in.
These are the actions that the parser can take.
These are the actions that the parser can take.
These are the states that the parser can be in.
These are the states that the parser can be in.
These are the states that the parser can be in.
These are the states that the parser can be in.
These are the states that the parser can be in.
These are the states that the parser can be in.
These are the states that the parser can be in.
DefaultParamValue is the default value used for missing parameters.
DefaultTableSize is the default size of the transition table.
These are the actions that the parser can take.
These are the states that the parser can be in.
These are the states that the parser can be in.
These are the actions that the parser can take.
Shift and masks for sequence parameters and intermediates.
These are the states that the parser can be in.
Shift and masks for sequence parameters and intermediates.
These are the actions that the parser can take.
Table values are generated like this:
index: currentState << IndexStateShift | charCode
value: action << TransitionActionShift | nextState
Shift and masks for sequence parameters and intermediates.
Shift and masks for sequence parameters and intermediates.
MaxParamsSize is the maximum number of parameters a sequence can have.
Shift and masks for sequence parameters and intermediates.
Shift and masks for sequence parameters and intermediates.
These are the actions that the parser can take.
These are the states that the parser can be in.
These are the actions that the parser can take.
Shift and masks for sequence parameters and intermediates.
These are the states that the parser can be in.
These are the actions that the parser can take.
Shift and masks for sequence parameters and intermediates.
These are the actions that the parser can take.
These are the actions that the parser can take.
These are the states that the parser can be in.
These are the actions that the parser can take.
Table values are generated like this:
index: currentState << IndexStateShift | charCode
value: action << TransitionActionShift | nextState
Table values are generated like this:
index: currentState << IndexStateShift | charCode
value: action << TransitionActionShift | nextState
Utf8State is not part of the DEC ANSI standard. It is used to handle
UTF-8 sequences.
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64)