MCPcopy Index your code
hub / github.com/RustPython/RustPython / wlen

Function wlen

Lib/_pyrepl/utils.py:18–25  ·  view source on GitHub ↗
(s: str)

Source from the content-addressed store, hash-verified

16
17
18def wlen(s: str) -> int:
19 if len(s) == 1 and s != '\x1a':
20 return str_width(s)
21 length = sum(str_width(i) for i in s)
22 # remove lengths of any escape sequences
23 sequence = ANSI_ESCAPE_SEQUENCE.findall(s)
24 ctrl_z_cnt = s.count('\x1a')
25 return length - sum(len(i) for i in sequence) + ctrl_z_cnt

Callers 4

calc_screenMethod · 0.85
process_promptMethod · 0.85
__write_changed_lineMethod · 0.85
__write_changed_lineMethod · 0.85

Calls 5

lenFunction · 0.85
str_widthFunction · 0.85
sumFunction · 0.50
findallMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected