3个不稳定版本
0.2.0 | 2022年1月22日 |
---|---|
0.1.1 | 2021年9月9日 |
0.1.0 | 2021年6月23日 |
在文本处理中排名第1426
每月下载量96次
29KB
690 代码行
ansi-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);
}
块
有一个方便的函数可以将字符串分割成一组块。它使用char
而不是字节,因此像emoji和象形文字这样的内容也会被处理而不会出现panic
。
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);
}
问题
还有哪些其他有用的ANSI序列需要记住?
依赖关系
~1.5MB
~35K SLoC