Skip to content

Commit 13cc842

Browse files
more closely match bpython docstring and arg display
--HG-- branch : scroll-frontend
1 parent 3d8327f commit 13cc842

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

bpython/scrollfrontend/replpainter.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# * return an array not larger than the height they were asked for
1414

1515
def display_linize(msg, columns):
16+
"""Returns lines obtained by splitting msg over multiple lines.
17+
18+
Warning: if msg is empty, returns an empty list of lines"""
1619
display_lines = ([msg[start:end]
1720
for start, end in zip(
1821
range(0, len(msg), columns),
@@ -50,26 +53,25 @@ def matches_lines(rows, columns, matches, current, config):
5053
return matches_lines
5154

5255
def formatted_argspec(argspec):
53-
return argspec[0] + '(' + ", ".join(argspec[1][0]) + ')'
56+
return argspec[0] + ': (' + ", ".join(argspec[1][0]) + ')'
5457

5558
def paint_infobox(rows, columns, matches, argspec, match, docstring, config):
5659
"""Returns painted completions, argspec, match, docstring etc."""
5760
if not (rows and columns):
5861
return fsarray(0, 0)
59-
width = columns - 2
62+
width = columns - 4
6063
color = func_for_letter(config.color_scheme['main'])
6164
lines = ((display_linize(blue(formatted_argspec(argspec)), width) if argspec else []) +
62-
([fmtstr('')] if docstring else []) +
63-
sum(([color(x) for x in display_linize(line, width)]
65+
sum(([color(x) for x in (display_linize(line, width) if line else fmtstr(''))]
6466
for line in docstring.split('\n')) if docstring else [], []) +
6567
(matches_lines(rows, columns, matches, match, config) if matches else [])
6668
)
6769

6870
output_lines = []
69-
output_lines.append(u'┌'+u'─'*width+u'┐')
71+
output_lines.append(u'┌'+u'─'*width+u'┐')
7072
for line in lines:
71-
output_lines.append(u'│'+((line+' '*(width - len(line)))[:width])+u'│')
72-
output_lines.append(u'└'+u'─'*width+u'┘')
73+
output_lines.append(u'│ '+((line+' '*(width - len(line)))[:width])+u' │')
74+
output_lines.append(u'└'+u'─'*width+u'┘')
7375
r = fsarray(output_lines[:min(rows-1, len(output_lines)-1)] + output_lines[-1:])
7476
assert len(r.shape) == 2
7577
#return r

0 commit comments

Comments
 (0)