Skip to content

Commit 3fce108

Browse files
fix infobox display bug
--HG-- branch : scroll-frontend
1 parent 5620fd2 commit 3fce108

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

bpython/scrollfrontend/repl.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def process_event(self, e):
298298
t.start()
299299
self.interact.wait_for_request_or_notify()
300300
elif e in key_dispatch[EDITOR_KEY]:
301-
self.external_editor()
301+
self.send_to_external_editor()
302302
#TODO add PAD keys hack as in bpython.cli
303303
else:
304304
self.add_normal_character(e if len(e) == 1 else e[-1]) #strip control seq
@@ -601,19 +601,21 @@ def paint(self, about_to_exit=False):
601601
cursor_column = (self.cursor_offset_in_line + len(self.display_line_with_prompt) - len(self._current_line)) % width
602602

603603
if self.list_win_visible:
604-
#TODO infobox not properly expanding window! try reduce( docs about halfway down a 80x24 terminal
604+
#infobox not properly expanding window! try reduce( docs about halfway down a 80x24 terminal
605+
#TODO what's the desired behavior here? Currently uses only the space already on screen,
606+
# scrolling down only if there would have been more space above the current line, but being forced to put below
605607
logging.debug('infobox display code running')
606608
visible_space_above = history.height
607-
visible_space_below = min_height - cursor_row
608-
info_max_rows = max(visible_space_above, visible_space_below)
609+
visible_space_below = min_height - cursor_row - 1
609610

611+
info_max_rows = max(visible_space_above, visible_space_below)
610612
infobox = paint.paint_infobox(info_max_rows, int(width * self.config.cli_suggestion_width), self.matches, self.argspec, self.current_word, self.docstring, self.config)
611613

612614
if visible_space_above >= infobox.height and not INFOBOX_ONLY_BELOW:
613615
arr[current_line_start_row - infobox.height:current_line_start_row, 0:infobox.width] = infobox
614616
else:
615617
arr[cursor_row + 1:cursor_row + 1 + infobox.height, 0:infobox.width] = infobox
616-
#logging.debug('slamming infobox of shape %r into arr', infobox.shape)
618+
logging.debug('slamming infobox of shape %r into arr of shape %r', infobox.shape, arr.shape)
617619

618620
logging.debug('about to exit: %r', about_to_exit)
619621
if show_status_bar:
@@ -732,7 +734,7 @@ def getstdout(self):
732734
s = '\n'.join([x.s if isinstance(x, FmtStr) else x
733735
for x in lines]) if lines else ''
734736
return s
735-
def external_editor(self):
737+
def send_to_external_editor(self, filename=None):
736738
editor = os.environ.get('VISUAL', os.environ.get('EDITOR', 'vim'))
737739
text = self.getstdout()
738740
with tempfile.NamedTemporaryFile(suffix='.py') as temp:

bpython/scrollfrontend/replpainter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ def paint_infobox(rows, columns, matches, argspec, match, docstring, config):
7171
for line in lines:
7272
output_lines.append(u'│'+((line+' '*(width - len(line)))[:width])+u'│')
7373
output_lines.append(u'└'+u'─'*width+u'┘')
74-
r = fsarray(output_lines[:rows])
74+
r = fsarray(output_lines[:min(rows-1, len(output_lines)-1)] + output_lines[-1:])
7575
assert len(r.shape) == 2
7676
#return r
77-
return fsarray(r[:rows-1, :])
77+
return fsarray(r[:rows, :])
7878

7979
def paint_last_events(rows, columns, names):
8080
width = min(max(len(name) for name in names), columns-2)

0 commit comments

Comments
 (0)