Component evidence

segmentGraphemes (utils/grapheme.ts)

takt · src/shared/utils/grapheme.ts · typescript · MIT
cli

Split text into grapheme clusters and measure terminal column widths for accurate text rendering.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/nrslib/takt | License: MIT | Copyright 2026 Masanobu Naruse
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Grapheme boundaries and terminal column widths, in one place.
 *
 * A user-perceived character can be several code points — a combining mark, a
 * variation selector, a ZWJ emoji sequence — and every part of a terminal
 * editor has to agree on where one ends: the caret must not stop inside one,
 * Backspace must remove all of it, and the renderer must draw it as the single
 * cell the terminal gives it. Splitting that logic across modules is what makes
 * a caret land half-way into an emoji.
 *
 * Widths come from `string-width`, the package Ink itself measures with, so the
 * wrapping computed here and the layout Ink performs ag

... (truncated -- full source via MCP)