MCPcopy Create free account
hub / github.com/19PINE-AI/ikp / _visible_width

Function _visible_width

cli/progress.py:27–38  ·  view source on GitHub ↗

Number of terminal columns occupied by s, ignoring ANSI escapes.

(s: str)

Source from the content-addressed store, hash-verified

25
26
27def _visible_width(s: str) -> int:
28 """Number of terminal columns occupied by s, ignoring ANSI escapes."""
29 s = ANSI_RE.sub("", s)
30 w = 0
31 for ch in s:
32 if ch == "\n":
33 continue
34 if unicodedata.east_asian_width(ch) in ("W", "F"):
35 w += 2
36 else:
37 w += 1
38 return w
39
40
41def _wrapped_rows(s: str, term_w: int) -> int:

Callers 1

_wrapped_rowsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected