💡 Color-encoding modes (16-color / 256-color) derived from terminfo
还没有人认领这个 Issue。
- #106 来自 @natemoo-re —— 已关闭,未合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 68/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- c, typescript
- 领域
- cli
调研方向
从 src/clayterm.c:90 中的 emit_attr 和 input.ts:441-448 中现有的 terminfo 处理开始。运行 test/color-encoding-modes.test.ts,以确定 16 色、256 色、truecolor 和 override 的预期行为。当从 terminfo 派生的模式和显式模式都输出所请求的编码,同时默认行为保持逐字节一致时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem?
The renderer only generates 24-bit truecolor. emit_attr (src/clayterm.c:90) always emits \x1b[38;2;R;G;Bm / \x1b[48;2;R;G;Bm, with no way to ask for a narrower encoding. Applying the standard ANSI red emits \x1b[38;2;255;0;0m even when the destination is a 16-color terminal, a CI log, or a pipe that would render \x1b[31m better (or only understands the smaller palette).
Describe the solution you'd like
Derive the output color depth from the terminal's capabilities (terminfo), with an explicit colorMode override. We already accept a compiled terminfo binary on the input side (createInput({ terminfo }), input.ts:448); the renderer can read the same source's color capability (max_colors, plus the truecolor flag) to pick an encoding, and take an override for callers who want to force the color mode:
// derive from terminfo capabilities (default behavior stays truecolor—byte-identical to today)
const term = await createTerm({ width, height, terminfo });
// or force it explicitly
const term = await createTerm({ width, height, colorMode: "16" }); // standard red -> \x1b[31m (bg \x1b[41m)
const term = await createTerm({ width, height, colorMode: "256" }); // standard red -> \x1b[38;5;1m
Describe alternatives you've considered
Rewriting the byte stream in TS (parsing emitted SGR and downsampling 24-bit sequences) is fragile and wasteful—it re-parses what the renderer just produced. The reverse-mapping belongs in emit_attr, where the color is known.
Additional context
Failing test case on nm/repro/color-encoding-modes (test · diff).
The core change likely lives in emit_attr (src/clayterm.c:90). Existing terminfo precedent is input.ts:441-448.
- 主要语言
- TypeScript
- 星标
- 43
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bombshell-dev/tty 的其他 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 76/100
bombshell-dev/tty#61 · 1 个 reaction ·
-
Track terminfo capability follow-ups可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 25/100
bombshell-dev/tty#129 ·
-
question
难度 5/5 一周以上 新手友好度 38/100
bombshell-dev/tty#112 ·
-
enhancement high priority
难度 3/5 1-2 天 新手友好度 68/100
bombshell-dev/tty#83 · 2 条评论 ·
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
bombshell-dev/tty#82 ·
查看 bombshell-dev/tty 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug:new
难度 2/5 1-3 小时 新手友好度 76/100
callstackincubator/simlock#350 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
openwatersio/maritime-zones#33 ·
维护者通常 1 天内回复
-
Booking email verification fails for plus aliases with impersonation protection enabled可能已有人在做 @kankadev 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
calcom/cal.diy#30293 · 1 条评论 ·
维护者通常 5 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
AOSSIE-Org/DebateAI#611 ·
维护者通常 3 天内回复