MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / displayWidth

Function displayWidth

src/setup/prompt.ts:39–42  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

37
38/** Visible width of a string: length with ANSI SGR (colour/dim) escapes removed. Pure → testable. */
39export function displayWidth(s: string): number {
40 // eslint-disable-next-line no-control-regex
41 return s.replace(/\x1b\[[0-9;]*m/g, '').length;
42}
43
44/** How many PHYSICAL terminal rows a logical line occupies once the terminal wraps
45 * it at `cols`. A line wider than the terminal wraps to ⌈width/cols⌉ rows; empty

Callers 2

physicalRowsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected