Module tortoise::parser [−][src]
Expand description
This module implements a parser for ANSI escape codes. The parser is based on Paul Williams’ ANSI-compatible video terminal parser modified to support UTF-8 input. The implementation uses a static state transition table to minimize branches.
Usage
To read escape codes, create an ActionIter
from any std::io::Read
and consume the Action
s the iterator returns.
This crate comes with a “logger” example that will print a description of the actions produced by stdin.
To give it a try, run the following:
echo -n "\x1b[30mhello\x1b[0m" | cargo run --example logger
Below is the source for the logger example, which demonstrates how to read escape codes:
let stdin = std::io::stdin(); let stdin = stdin.lock(); let stdin = std::io::BufReader::new(stdin); let action_iter = tortoise::parser::ActionIter::new(stdin); for action in action_iter { println!("{:?}", action); }
Structs
ActionIter | An |
Enums
Action | An action, as described in Paul Williams’ ANSI-compatible video terminal parser.
To prevent heap allocation, intermediate and param bytes use arrays instead of Vecs.
Be sure to only read |
Error |