David Bittner 9531dbe7a7 Merge branch 'fix_clippy' into 'master'
Fix cargo clippy && cargo fmt

See merge request davidbittner/ansi-parser!8
2022-05-16 14:14:49 +00:00
2022-01-31 19:12:01 +03:00
2020-11-27 22:43:28 +01:00
2019-04-26 22:27:37 -04:00
2021-04-25 14:15:14 -04:00
2019-04-27 19:41:31 +00:00
2020-10-05 11:56:07 +02:00

pipeline status docs deps license downloads

Ansi Escape Sequence Parser

For a complete list of implemented sequences, see the documentation.

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:

use ansi_parser::{Output, AnsiParser};
use ansi_parser::AnsiSequence;

fn main() {
    //Parse the first two blocks in the list
    //By parsing it this way, it allows you to iterate over the
    //elements returned.
    //
    //The parser only every holds a reference to the data,
    //so there is no allocation.
    let parsed: Vec<Output> = "This is \u{1b}[3Asome text!"
        .ansi_parse()
        .take(2)
        .collect();

    assert_eq!(
        vec![
            Output::TextBlock("This is "),
            Output::Escape(AnsiSequence::CursorUp(3))
        ],
        parsed
    );

    for block in parsed.into_iter() {
        match block {
            Output::TextBlock(text) => println!("{}", text),
            Output::Escape(seq)     => println!("{}", seq)
        }
    }
}

no_std support

no_std is supported via disabling the std feature in your Cargo.toml.

Description
No description provided
Readme 124 KiB
Languages
Rust 100%