ansi-cut 0.2.0

A library for cutting a string while preserving colors.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use owo_colors::{colors::*, OwoColorize};

pub fn main() {
    let colored_text = format!(
        "{hello} {world}",
        hello = "Hello".fg::<Black>().bg::<White>(),
        world = "World".fg::<Magenta>().bg::<Green>(),
    );

    println!("text={}", colored_text);

    println!("chunks");
    for chunk in ansi_cut::chunks(&colored_text, 4) {
        println!("{}", chunk);
    }
}