File: parse_ansi.rs

package info (click to toggle)
rust-ansitok 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 224 kB
  • sloc: makefile: 4
file content (21 lines) | stat: -rw-r--r-- 531 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use ansitok::{parse_ansi, ElementKind};

fn main() {
    let text = "\x1b[31;1;4mHello World\x1b[0m";

    for e in parse_ansi(text) {
        match e.kind() {
            ElementKind::Text => {
                println!("Got a text: {:?}", &text[e.range()],);
            }
            _ => {
                println!(
                    "Got an escape sequence: {:?} from {:#?} to {:#?}",
                    e.kind(),
                    e.start(),
                    e.end()
                );
            }
        }
    }
}