public class VTParser extends Object implements net.digger.util.fsm.ActionHandler<Action,State,Character>
This class parses text for escape sequences, and runs the caller-provided callback with the details of each sequence. That callback will need to implement whichever sequences it chooses to support.
Implements Paul Flo Williams' state machine (https://vt100.net/emu/dec_ansi_parser). Loosely based on Joshua Haberman's vtparse (https://github.com/haberman/vtparse).
| Constructor and Description |
|---|
VTParser(VTEmulator emulator)
Create a new instance of VTParser, and provide a VTEmulator implementation.
|
VTParser(VTEmulator emulator,
boolean use7bits)
Create a new instance of VTParser using only 7-bit transitions, and provide a VTEmulator implementation.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
main(String[] args)
Test program, parses text from STDIN.
|
void |
onEntry(State state,
Action action) |
void |
onEvent(State state,
Character event,
Action action) |
void |
onExit(State state,
Action action) |
void |
parse(char ch)
Process a character.
|
void |
parse(String str)
Process a string.
|
static String |
stripString(String text,
boolean use7bits)
Returns the given text with all escape sequences stripped out of it.
|
public VTParser(VTEmulator emulator)
Event values 0xA0-0xFF are treated as 0x20-0x7F and values above 0xFF are treated as 0x7F.
emulator - VTEmulator implementation called when an escape sequence is parsed.public VTParser(VTEmulator emulator, boolean use7bits)
emulator - VTEmulator implementation called when an escape sequence is parsed.use7bits - Flag to process the text as 7-bit ASCII instead of 8-bit.public void parse(char ch)
ch - Character to process.public void parse(String str)
str - String to process.public static String stripString(String text, boolean use7bits)
text - Text to process.use7bits - Flag to process the text as 7-bit ASCII instead of 8-bit.public static void main(String[] args)
args - Command-line arguments for test program.Copyright © 2018. All rights reserved.