X Tutup
Skip to content

Commit d32440d

Browse files
Rely on fmtstr for width in replpainter
--HG-- branch : scroll-frontend
1 parent 439faba commit d32440d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

bpython/scrollfrontend/replpainter.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ def display_linize(msg, columns):
2828
def paint_history(rows, columns, display_lines):
2929
lines = []
3030
for r, line in zip(range(rows), display_lines[-rows:]):
31-
lines.append((fmtstr(line)+' '*1000)[:columns])
32-
r = fsarray(lines)
31+
lines.append(fmtstr(line))
32+
r = fsarray(lines, width=columns)
3333
assert r.shape[0] <= rows, repr(r.shape)+' '+repr(rows)
3434
assert r.shape[1] <= columns, repr(r.shape)+' '+repr(columns)
3535
return r
3636

3737
def paint_current_line(rows, columns, current_display_line):
3838
lines = display_linize(current_display_line, columns)
39-
return fsarray([(line+' '*columns)[:columns] for line in lines])
39+
return fsarray(lines, width=columns)
4040

4141
def matches_lines(rows, columns, matches, current, config):
4242
highlight_color = func_for_letter(config.color_scheme['operator'].lower())
@@ -48,14 +48,15 @@ def matches_lines(rows, columns, matches, current, config):
4848
words_wide = max(1, (columns - 1) // (max_match_width + 1))
4949
matches_lines = [fmtstr(' ').join(color(m.ljust(max_match_width))
5050
if m != current
51-
else highlight_color(m) + ' '*(max_match_width - len(m))
51+
else highlight_color(m.ljust(max_match_width))
5252
for m in matches[i:i+words_wide])
5353
for i in range(0, len(matches), words_wide)]
5454
logging.debug('match: %r' % current)
5555
logging.debug('matches_lines: %r' % matches_lines)
5656
return matches_lines
5757

5858
def formatted_argspec(argspec, columns, config):
59+
# Pretty directly taken from bpython.cli
5960
is_bound_method = argspec[2]
6061
func = argspec[0]
6162
args = argspec[1][0]
@@ -153,9 +154,7 @@ def paint_infobox(rows, columns, matches, argspec, match, docstring, config):
153154
output_lines.append(border_color(u'│ ')+((line+' '*(width - len(line)))[:width])+border_color(u' │'))
154155
output_lines.append(border_color(u'└─'+u'─'*width+u'─┘'))
155156
r = fsarray(output_lines[:min(rows-1, len(output_lines)-1)] + output_lines[-1:])
156-
assert len(r.shape) == 2
157-
#return r
158-
return fsarray(r[:rows, :])
157+
return r
159158

160159
def paint_last_events(rows, columns, names):
161160
width = min(max(len(name) for name in names), columns-2)
@@ -164,8 +163,7 @@ def paint_last_events(rows, columns, names):
164163
for name in names[-(rows-2):]:
165164
output_lines.append(u'│'+name[:width].center(width)+u'│')
166165
output_lines.append(u'└'+u'─'*width+u'┘')
167-
r = fsarray(output_lines)
168-
return r
166+
return fsarray(output_lines)
169167

170168
def paint_statusbar(rows, columns, msg, config):
171169
return fsarray([func_for_letter(config.color_scheme['main'])(msg.ljust(columns))[:columns]])

0 commit comments

Comments
 (0)
X Tutup