可用于在仓颉环境中实现终端文本样式控制与输出处理。提供 ANSI 样式定义、转义序列解析、终端能力检测、颜色转换等功能,支持超链接、进度条及 SVG/HTML 渲染。【此简介由AI生成】
| Files | Last commit | Last update |
|---|---|---|
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 7 months ago |
cjterm
仓颉 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 build
测试
cjpm test
许可证
MIT
Introduction
可用于在仓颉环境中实现终端文本样式控制与输出处理。提供 ANSI 样式定义、转义序列解析、终端能力检测、颜色转换等功能,支持超链接、进度条及 SVG/HTML 渲染。【此简介由AI生成】
Customize your domain