💡 Expose display-width helpers (stringWidth / charWidth)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- c, typescript, wasm
- 领域
- api, cli, computer-graphics
调研方向
从 mod.ts 和 test/string-width.test.ts 开始,然后检查 src/wcwidth.h 中现有的表以及 Makefile:12 处的 wasm 导出设置。使用链接的 string-width 测试和 diff 来理解预期行为,包括 ANSI 序列和 codepoint;当 width helpers 被公开提供且测试通过时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem?
The C layer already measures the display width of a character and of a whole string—it's how text gets laid out—but that isn't surfaced to consumers. There are real use cases for measuring text JS-side (truncating to a column budget, padding or aligning labels) with no way to do it today short of a throwaway render.
Describe the solution you'd like
Expose two pure helpers (exact names TBD), backed by the internal wcwidth table:
charWidth(0x4f60); // 2 (CJK)
stringWidth("你好"); // 4
charWidth returns 0/1/2; stringWidth sums codepoints with proper handling for ANSI escape sequences.
Describe alternatives you've considered
Add a JS-side width dependency (duplicates the table we already ship and can drift to a different Unicode version than layout uses), or render into a fit element and read back info.get(id).bounds.width (slow, and gets VS16 emoji clusters wrong).
Additional context
Failing test case on nm/repro/string-width (test · diff). The table is already in C (src/wcwidth.h:8) and exported from the wasm (Makefile:12, --export-all); this is mostly surfacing it from mod.ts.
- 主要语言
- TypeScript
- 星标
- 42
- 派生
- 2
- 平均合并
- 21 小时 40 分钟
- 30 天内合并 PR
- 9
环境准备
这个项目没有提供开发容器、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 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
bombshell-dev/tty#129 ·
维护者通常 1 天内回复
-
question
难度 5/5 一周以上 新手友好度 38/100
bombshell-dev/tty#112 ·
维护者通常 1 天内回复
-
enhancement high priority
难度 3/5 1-2 天 新手友好度 68/100
bombshell-dev/tty#83 · 2 条评论 ·
维护者通常 1 天内回复
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
bombshell-dev/tty#82 ·
维护者通常 1 天内回复
查看 bombshell-dev/tty 的全部 Issue
相似的 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 88/100
inu-appcenter/memorIN-frontend#106 ·
维护者通常 1 天内回复
-
kind/bug
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 7 天内回复
-
[Bug] @deck.gl/arcgis dist import resolves to unpublished @deck.gl/core source path (9.3.11, 9.4.0)未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
CSCfi/sd-search-ui#145 ·
维护者通常 1 天内回复
-
check:passed streams:add
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复