Crates.io | ansi-str-forked |
lib.rs | ansi-str-forked |
version | 0.8.0 |
source | src |
created_at | 2024-08-23 07:14:17.062994 |
updated_at | 2024-08-23 07:14:17.062994 |
description | A library which provides a set of methods to work with ANSI strings |
homepage | https://github.com/zhiburt/ansi-str |
repository | https://github.com/zhiburt/ansi-str |
max_upload_size | |
id | 1348765 |
size | 114,593 |
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 (e.g. owo-colors, nu-ansi-term).
use ansi_str::AnsiStr;
use owo_colors::{colors::*, OwoColorize};
pub fn main() {
let text = "When the night has come"
.fg::<Red>()
.bg::<Cyan>()
.bold()
.to_string();
let cut = text.ansi_get(5..).expect("ansi_get mustn't fail");
println!("{}", text);
println!("{}", cut);
}
Running this code will result in the following output.
examples
directory.The library has derivatived from zhiburt/ansi-cut