From d533eac192d53e6f874acf769c697d000d51fe78 Mon Sep 17 00:00:00 2001 From: David Bittner Date: Sat, 27 Apr 2019 15:08:04 -0400 Subject: [PATCH] updating readme --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fe45dd4..f5d5d1c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,43 @@ [![pipeline status](https://gitlab.com/davidbittner/ansi-parser/badges/master/pipeline.svg?style=flat-square)](https://gitlab.com/davidbittner/ansi-parser/commits/master) ![deps](https://img.shields.io/librariesio/release/cargo/ansi-parser.svg?style=flat-square) # Ansi Escape Sequence Parser + + +This is a library for parsing ANSI escape sequences. Currently all the basic escape sequences +are implemented: + + Cursor Position + + Cursor {Up, Down, Forward, Backward} + + Cursor {Save, Restore} + + Erase Display + + Erase Line + + Set Graphics mode + + Set and Reset Text Mode + + This is done through a pulldown type parser, where an iterator is exposed. This essentially + turns all of the ANSI sequences into enums and splits the string at every location that there + was an ANSI Sequence. + + Example: + + ```rust + +use ansi_parser::{Output, ParserIterator}; + +fn main() { + //Your input string here + let string = "..."; + let parsed: Vec = ParserIterator::new(&string) + //Because it implements Iterator, you can use whatever + //your favorite iterator functions are. + .take(4) + .collect(); + + for block in parsed.into_iter() { + match block { + TextBlock(text) => println!("{}", text), + AnsiSequence(seq) => println!("{}", seq) + } + } +} + + ``` diff --git a/src/lib.rs b/src/lib.rs index 55337d2..9620101 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ mod parsers; /// + Erase Display /// + Erase Line /// + Set Graphics mode -/// Set and Reset Text Mode +/// + Set and Reset Text Mode /// /// This is done through a pulldown type parser, where an iterator is exposed. This essentially /// turns all of the ANSI sequences into enums and splits the string at every location that there