仓颉 ANSI 终端样式库。
| 包 | 说明 |
|---|---|
| cjterm-style | ANSI 样式定义:颜色(4-bit、8-bit、24-bit RGB)、文本效果、可组合样式 |
| cjterm-parse | VT100 ANSI 转义序列解析器,完整状态机实现 |
| cjterm-stream | 自适应输出流,根据终端能力自动降级 ANSI 转义码 |
| cjterm-query | 终端能力检测(NO_COLOR、CLICOLOR、TERM、truecolor、CI、Windows ANSI) |
| cjterm-lossy | 有损颜色转换:RGB ↔ 256 色 ↔ 16 色 |
| cjterm-hyperlink | OSC 8 终端超链接,支持编辑器 URL scheme |
| cjterm-progress | OSC 9;4 终端进度条 |
| cjterm-git | Git 颜色配置语法解析 |
| cjterm-ls | LS_COLORS / SGR 代码解析 |
| cjterm-svg | 将 ANSI 终端输出渲染为 SVG 和 HTML |
在 cjpm.toml 中添加需要的包作为依赖:
[dependencies]
cjterm_style = { git = "https://github.com/ling-org/cjterm.git", path = "cjterm-style" }
cjterm_stream = { git = "https://github.com/ling-org/cjterm.git", path = "cjterm-stream" }import cjterm_style.*
import cjterm_stream.*
main() {
let style = Style.new()
.fgColor(Some(Color.Ansi(AnsiColor.Green)))
.bold()
let out = AutoStream.stdout()
style.writeTo(out)
out.write("Hello, styled world!".toArray())
let reset = Reset()
out.write(reset.toString().toArray())
out.flush()
}cjpm buildcjpm testMIT