@@ -303,7 +303,8 @@ def __init__(self,
303303 interactive = True ,
304304 orig_tcattrs = None ,
305305 on_suspend = lambda * args : None ,
306- after_suspend = lambda * args : None ):
306+ after_suspend = lambda * args : None ,
307+ get_top_usable_line = lambda : 0 ):
307308 """
308309 locals_ is a mapping of locals to pass into the interpreter
309310 config is a bpython config.Struct with config attributes
@@ -323,6 +324,7 @@ def __init__(self,
323324 original terminal state, useful for shelling out with normal terminal
324325 on_suspend will be called on sigtstp
325326 after_suspend will be called when process foregrounded after suspend
327+ get_top_usable_line returns the top line of the terminal owned
326328 """
327329
328330 logger .debug ("starting init" )
@@ -417,6 +419,7 @@ def smarter_request_reload(files_modified=()):
417419 self .orig_tcattrs = orig_tcattrs
418420 self .on_suspend = on_suspend
419421 self .after_suspend = after_suspend
422+ self .get_top_usable_line = get_top_usable_line
420423
421424 self .coderunner = CodeRunner (self .interp , self .request_refresh )
422425 self .stdout = FakeOutput (self .coderunner , self .send_to_stdout )
@@ -426,6 +429,8 @@ def smarter_request_reload(files_modified=()):
426429 # next paint should clear screen
427430 self .request_paint_to_clear_screen = False
428431
432+ self .request_paint_to_pad_bottom = 0
433+
429434 # offscreen command yields results different from scrollback bufffer
430435 self .inconsistent_history = False
431436
@@ -1169,6 +1174,10 @@ def paint(self, about_to_exit=False, user_quit=False):
11691174 if self .request_paint_to_clear_screen : # or show_status_bar and about_to_exit ?
11701175 self .request_paint_to_clear_screen = False
11711176 arr = FSArray (min_height + current_line_start_row , width )
1177+ elif self .request_paint_to_pad_bottom :
1178+ # min_height - 1 for startup banner with python version
1179+ arr = FSArray (min (self .request_paint_to_pad_bottom , min_height - 1 ), width )
1180+ self .request_paint_to_pad_bottom = 0
11721181 else :
11731182 arr = FSArray (0 , width )
11741183 # TODO test case of current line filling up the whole screen (there
@@ -1265,7 +1274,8 @@ def move_screen_up(current_line_start_row):
12651274 if self .list_win_visible and not self .coderunner .running :
12661275 logger .debug ('infobox display code running' )
12671276 visible_space_above = history .height
1268- visible_space_below = min_height - current_line_end_row - 1
1277+ potential_space_below = min_height - current_line_end_row - 1
1278+ visible_space_below = potential_space_below - self .get_top_usable_line ()
12691279
12701280 info_max_rows = max (visible_space_above , visible_space_below )
12711281 infobox = paint .paint_infobox (info_max_rows ,
@@ -1276,12 +1286,16 @@ def move_screen_up(current_line_start_row):
12761286 self .current_match ,
12771287 self .docstring ,
12781288 self .config ,
1279- self .matches_iter .completer .format if self .matches_iter .completer else None )
1289+ self .matches_iter .completer .format
1290+ if self .matches_iter .completer
1291+ else None )
12801292
1281- if visible_space_above >= infobox .height and self .config .curtsies_list_above :
1282- arr [ current_line_start_row - infobox .height :current_line_start_row , 0 : infobox . width ] = infobox
1283- else :
1293+ if visible_space_below >= infobox .height or not self .config .curtsies_list_above :
1294+ if visible_space_below < infobox .height :
1295+ raise ValueError ( 'whoops %r %r' % ( visible_space_below , infobox . height ))
12841296 arr [current_line_end_row + 1 :current_line_end_row + 1 + infobox .height , 0 :infobox .width ] = infobox
1297+ else :
1298+ arr [current_line_start_row - infobox .height :current_line_start_row , 0 :infobox .width ] = infobox
12851299 logger .debug ('slamming infobox of shape %r into arr of shape %r' , infobox .shape , arr .shape )
12861300
12871301 logger .debug ('about to exit: %r' , about_to_exit )
0 commit comments