ansitok-forked

Crates.ioansitok-forked
lib.rsansitok-forked
version0.2.0
sourcesrc
created_at2024-08-23 07:10:27.789513
updated_at2024-08-23 07:10:27.789513
descriptionA library for parsing ANSI Escape Codes
homepagehttps://gitlab.com/zhiburt/ansitok
repositoryhttps://gitlab.com/zhiburt/ansitok
max_upload_size
id1348763
size83,135
Junzhuo ZHOU (zao111222333)

documentation

README

ansi escape codes tokenization

gitlab crates.io docs.rs build status

This is a library 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, Output};

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

    for output in parse_ansi(text) {
        match output {
            Output::Text(text) => println!("Got a text: {:?}", text),
            Output::Escape(esc) => println!("Got an escape sequence: {:?}", esc),
        }
    }
}

no_std support

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

Notes

The project got an insiration from https://gitlab.com/davidbittner/ansi-parser.

Commit count: 18

cargo fmt