(s: string)
| 37 | |
| 38 | /** Visible width of a string: length with ANSI SGR (colour/dim) escapes removed. Pure → testable. */ |
| 39 | export 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 |
no outgoing calls
no test coverage detected