1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#![recursion_limit = "256"]
#![cfg_attr(not(any(feature = "std", test)), no_std)]
#![warn(missing_docs)]

//! This is a crate is made for parsing ANSI escape sequences.
//!
//! The list of covered sequences.
//!
//! * Cursor Position
//! * Cursor {Up, Down, Forward, Backward}
//! * Cursor {Save, Restore}
//! * Erase Display
//! * Erase Line
//! * Set Graphics mode
//! * Set/Reset Text Mode
//!
//! # Usage
//!
//! ```
//! use ansitok::parse_ansi;
//!
//! let text = "\x1b[31;1;4mHello World\x1b[0m";
//! for token in parse_ansi(text) {
//!     let kind = token.kind();
//!     let token_text = &text[token.start()..token.end()];
//!
//!     println!("text={:?} kind={:?}", token_text, kind);
//! }
//! ```
//!
//! Parse SGR.
//!
//! ```
//! use ansitok::{parse_ansi, parse_ansi_sgr, Output, ElementKind};
//!
//! let text = "\x1b[31;1;4mHello World\x1b[0m \x1b[38;2;255;255;0m!!!\x1b[0m";
//! for token in parse_ansi(text) {
//!     if token.kind() != ElementKind::Sgr {
//!         continue;
//!     }
//!
//!     let sgr = &text[token.start()..token.end()];
//!     for style in parse_ansi_sgr(sgr) {
//!         println!("style={:?}", style);
//!         let style = style.as_escape().unwrap();
//!         println!("style={:?}", style);
//!     }
//! }
//! ```

mod element;
mod parse;

pub use element::{Element, ElementKind};
pub use parse::{
    parse_ansi, parse_ansi_sgr, AnsiColor, AnsiIterator, EscapeCode, Output, VisualAttribute,
};