Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

💡 Expose display-width helpers (stringWidth / charWidth)

Aperta
#72 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
c, typescript, wasm

Direzione di ricerca

Inizia con mod.ts e test/string-width.test.ts, poi esamina la tabella esistente in src/wcwidth.h e le impostazioni di esportazione wasm in Makefile:12. Usa il test e il diff collegati di string-width per comprendere il comportamento previsto, incluse le sequenze ANSI e i codepoint; il lavoro è completato quando gli helper di width sono esposti pubblicamente e il test passa.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
42
Fork
2
Merge medio
2g 5h
PR unite (30g)
12

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bombshell-dev/tty

Tutte le issue di bombshell-dev/tty

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.