MCPcopy Create free account
hub / github.com/bpython/bpython / display_linize

Function display_linize

bpython/curtsiesfrontend/replpainter.py:17–35  ·  view source on GitHub ↗

Returns lines obtained by splitting msg over multiple lines. Warning: if msg is empty, returns an empty list of lines

(msg, columns, blank_line=False)

Source from the content-addressed store, hash-verified

15
16
17def display_linize(msg, columns, blank_line=False):
18 """Returns lines obtained by splitting msg over multiple lines.
19
20 Warning: if msg is empty, returns an empty list of lines"""
21 if not msg:
22 return [""] if blank_line else []
23 msg = fmtstr(msg)
24 try:
25 display_lines = list(msg.width_aware_splitlines(columns))
26 # use old method if wcwidth can't determine width of msg
27 except ValueError:
28 display_lines = [
29 msg[start:end]
30 for start, end in zip(
31 range(0, len(msg), columns),
32 range(columns, len(msg) + columns, columns),
33 )
34 ]
35 return display_lines
36
37
38def paint_history(rows, columns, display_lines):

Callers 2

paint_current_lineFunction · 0.85
formatted_docstringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected