1 个不稳定版本
| 新增 0.2.0 | 2024年8月23日 | 
|---|
#34 在 #转义
58KB
 1K  SLoC
ANSI 转义码标记化
这是一个解析 ANSI 转义序列的库。
覆盖的序列列表。
- 光标位置
- 光标 {上,下,前,后}
- 光标 {保存,恢复}
- 清除显示
- 清除行
- 设置图形模式
- 设置/重置文本模式
用法
use ansitok::{parse_ansi, Output};
fn main() {
    let text = "\x1b[31;1;4mHello World\x1b[0m";
    for output in parse_ansi(text) {
        match output {
            Output::Text(text) => println!("Got a text: {:?}", text),
            Output::Escape(esc) => println!("Got an escape sequence: {:?}", esc),
        }
    }
}
no_std 支持
no_std 通过在你的 Cargo.toml 中禁用 std 功能来支持。
注意
该项目受到了 https://gitlab.com/davidbittner/ansi-parser 的启发。
依赖关系
~1MB
~23K SLoC