net.digger:vt-parser

ANSI and DEC VT escape sequence parser.

License

License

Categories

Categories

Net
GroupId

GroupId

net.digger
ArtifactId

ArtifactId

vt-parser
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

net.digger:vt-parser
ANSI and DEC VT escape sequence parser.
Project URL

Project URL

https://github.com/diggernet/VTParser
Source Code Management

Source Code Management

https://github.com/diggernet/VTParser/tree/develop

Download vt-parser

How to add to project

<!-- https://jarcasting.com/artifacts/net.digger/vt-parser/ -->
<dependency>
    <groupId>net.digger</groupId>
    <artifactId>vt-parser</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.digger/vt-parser/
implementation 'net.digger:vt-parser:1.0.0'
// https://jarcasting.com/artifacts/net.digger/vt-parser/
implementation ("net.digger:vt-parser:1.0.0")
'net.digger:vt-parser:jar:1.0.0'
<dependency org="net.digger" name="vt-parser" rev="1.0.0">
  <artifact name="vt-parser" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.digger', module='vt-parser', version='1.0.0')
)
libraryDependencies += "net.digger" % "vt-parser" % "1.0.0"
[net.digger/vt-parser "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
net.digger : state-machine jar 1.0.0

Project Modules

There are no modules declared in this project.

VTParser

VTParser is an ANSI and DEC VT escape sequence parser. It enables implementing an ANSI or VT-xxx emulator (or a subset), without needing to do the hard part of parsing the text for escape sequences and correctly handling the subtle complications found there.

It implements Paul Flo Williams' state machine, and is loosely based on Joshua Haberman's vtparse.

Maven configuration

	<dependency>
		<groupId>net.digger</groupId>
		<artifactId>vt-parser</artifactId>
		<version>1.0.0</version>
	</dependency>

Usage

  1. Implement the VTEmulator interface, which contains handlers for all the possible ANSI/VT actions. Implement only those actions you care about, and ignore the rest.
  2. Pass an instance of your VTEmulator implementation to the VTParser constructor.
  3. Send your text to VTParser.parse().

For example, if all you care about is printing text with color (using the SGR command), you can implement these handlers in VTEmulator:

  • actionPrint(): ch is a printable character, to be printed in the current text color.
  • actionExecute(): ch is a control character (or printable in some character sets).
  • actionCSIDispatch(): If ch equals 'm' and intermediateChars is empty, this is an SGR command, and params contains the list of codes for setting text color.

JScreen contains a VTEmulator implementation in ANSI.java.

Dependencies

License

VTParser is provided under the terms of the GNU LGPLv3.

Versions

Version
1.0.0