ansi-str

Crates.ioansi-str
lib.rsansi-str
version0.9.0
created_at2022-01-31 09:57:51.044917+00
updated_at2025-01-30 21:29:28.917372+00
descriptionA library which provides a set of methods to work with ANSI strings
homepagehttps://github.com/zhiburt/ansi-str
repositoryhttps://github.com/zhiburt/ansi-str
max_upload_size
id524485
size110,460
Maxim Zhiburt (zhiburt)

documentation

https://docs.rs/ansi-str

README

ansi-str Build Status codecov Crate docs.rs

This is a library provides a set of methods to work with strings escaped with ansi code sequences.

It's an agnostic library in regard to different color libraries. Therefore it can be used with any library.

Usage

use ansi_str::AnsiStr;

pub fn main() {
    let text = "\u{1b}[1m\u{1b}[31;46mWhen the night has come\u{1b}[0m\u{1b}[0m";

    let cut = text.ansi_get(5..).expect("ok");

    println!("{}", text);
    println!("{}", cut);
}

Running this code will result in the following output.

image

For more examples, you check out the examples directory.

Note

The library has derivatived from zhiburt/ansi-cut

Commit count: 56

cargo fmt