Skip to content

Cut a string while preserving colors and other ansi option in front of cut.

License

Notifications You must be signed in to change notification settings

sholderbach/ansi-cut

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ansi-cut Build Status codecov Crate docs.rs license

A library for cutting a string while preserving colors.

Cut

use ansi_cut::AnsiCut;
use owo_colors::{colors::*, OwoColorize};

pub fn main() {
    let colored_text = "When the night has come"
        .fg::<Black>()
        .bg::<White>()
        .to_string();
    let cutted_text = colored_text.cut(5..);

    println!("{}", cutted_text);
}

Chunks

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

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

    let chunks = ansi_cut::chunks(colored_text, 5);
}

Question

Are any other usefull ansi sequense that would be usefull to keep in mind?

About

Cut a string while preserving colors and other ansi option in front of cut.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%