csi_parser

Crates.iocsi_parser
lib.rscsi_parser
version0.1.3
sourcesrc
created_at2023-05-27 11:48:05.945125
updated_at2023-06-24 07:44:46.857816
descriptionCSI escape code parser.
homepagehttps://github.com/GengYage/csi_parser
repositoryhttps://github.com/GengYage/csi_parser
max_upload_size
id875910
size24,732
Geng (GengYage)

documentation

README

CSI parser

This is a simple CSI parser that only provides parsing for a subset of common CSI.

This repository was inspired by cansi

If you have additional requirements, feel free to submit a PR (Pull Request)

Please refer to the definition of CSI.

See the rs docs.

Look at progress and contribute on github.

Example

use csi_parser::iter::{CsiParser, Output};

fn main() {
    let text = "👋, \x1b[31;4m🌍\x1b[0m!";

    let result: Vec<Output> = text.csi_parser().skip(1).collect();

    for out in result {
        match out {
            Output::Text(txt) => {
                println!("{}", txt);
            }
            Output::Escape(csi_seq) => {
                println!("{}", csi_seq);
            }
        }
    }
}

and you will be got the result:

[Some(31);None;Some(4)m
🌍
[Some(0);None;Nonem

Features

To support the no_std feature, you simply need to run cargo add --no-default-features -F no_std to your project.

Commit count: 8

cargo fmt