[go: up one dir, main page]

ansi-str 0.1.1

A library which provides a set of methods to work with ANSI strings
Documentation

ansi-str Build Status codecov Crate docs.rs

This is a library for work with coloured and formatted strings on ANSI terminals.

Usage

use ansi_str::AnsiStr;
use owo_colors::{colors::*, OwoColorize};

pub fn main() {
    let colored_text = "When the night has come"
        .fg::<Red>()
        .bg::<Cyan>()
        .bold()
        .to_string();

    let s = colored_text.ansi_get(5..).unwrap();

    println!("{}", colored_text);
    println!("{}", s);
}

Running this code will result in the following output.

image

For more examples, you check the directory of the same name..
You can find a list of methods which are provided by the library on the documentation page.

Note

The library has derivatived from zhiburt/ansi-cut