Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

💡 Expose display-width helpers (stringWidth / charWidth)

Open
#72 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
c, typescript, wasm

Research direction

Start with mod.ts and test/string-width.test.ts, then inspect the existing table in src/wcwidth.h and the wasm export settings at Makefile:12. Use the linked string-width test and diff to understand expected behavior, including ANSI sequences and codepoints; done means the width helpers are publicly surfaced and the test passes.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
42
Forks
2
Avg merge
2d 5h
Merged PRs (30d)
12

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bombshell-dev/tty

All issues in bombshell-dev/tty

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.