Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

💡 Expose display-width helpers (stringWidth / charWidth)

オープン
#72 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
c, typescript, wasm

調査の方向性

mod.ts と test/string-width.test.ts から始め、次に src/wcwidth.h にある既存のテーブルと Makefile:12 の wasm エクスポート設定を調べてください。リンクされた string-width のテストと diff を使って、ANSI シーケンスや codepoint を含む期待される動作を理解してください; width ヘルパーが公開され、テストがパスすれば完了です。

索引モデルが issue の本文から書いたものです。

説明

enhancement high priority

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
平均マージ
2日 5時間
マージ済み PR(30日)
12

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bombshell-dev/tty のほかの issue

bombshell-dev/tty の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。