10 releases (6 breaking)
0.7.2 | Nov 29, 2022 |
---|---|
0.6.0 | Nov 28, 2022 |
0.3.0 | Jul 19, 2022 |
0.1.1 | Jan 31, 2022 |
#210 in Text processing
41,569 downloads per month
Used in 43 crates
(3 directly)
105KB
2K
SLoC
ansi-str

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).
Usage
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.
For more examples, you check out the examples
directory.
Note
The library has derivatived from zhiburt/ansi-cut
Dependencies
~1MB
~21K SLoC