@@ -246,7 +246,8 @@ def __init__(self,
246
246
interactive = True ,
247
247
orig_tcattrs = None ,
248
248
on_suspend = lambda * args : None ,
249
- after_suspend = lambda * args : None ):
249
+ after_suspend = lambda * args : None ,
250
+ get_top_usable_line = lambda : 0 ):
250
251
"""
251
252
locals_ is a mapping of locals to pass into the interpreter
252
253
config is a bpython config.Struct with config attributes
@@ -266,6 +267,7 @@ def __init__(self,
266
267
original terminal state, useful for shelling out with normal terminal
267
268
on_suspend will be called on sigtstp
268
269
after_suspend will be called when process foregrounded after suspend
270
+ get_top_usable_line returns the top line of the terminal owned
269
271
"""
270
272
271
273
logger .debug ("starting init" )
@@ -361,6 +363,7 @@ def smarter_request_reload(files_modified=()):
361
363
self .orig_tcattrs = orig_tcattrs
362
364
self .on_suspend = on_suspend
363
365
self .after_suspend = after_suspend
366
+ self .get_top_usable_line = get_top_usable_line
364
367
365
368
self .coderunner = CodeRunner (self .interp , self .request_refresh )
366
369
self .stdout = FakeOutput (self .coderunner , self .send_to_stdout )
@@ -370,6 +373,8 @@ def smarter_request_reload(files_modified=()):
370
373
# next paint should clear screen
371
374
self .request_paint_to_clear_screen = False
372
375
376
+ self .request_paint_to_pad_bottom = 0
377
+
373
378
# offscreen command yields results different from scrollback bufffer
374
379
self .inconsistent_history = False
375
380
@@ -1125,6 +1130,10 @@ def paint(self, about_to_exit=False, user_quit=False):
1125
1130
if self .request_paint_to_clear_screen : # or show_status_bar and about_to_exit ?
1126
1131
self .request_paint_to_clear_screen = False
1127
1132
arr = FSArray (min_height + current_line_start_row , width )
1133
+ elif self .request_paint_to_pad_bottom :
1134
+ # min_height - 1 for startup banner with python version
1135
+ arr = FSArray (min (self .request_paint_to_pad_bottom , min_height - 1 ), width )
1136
+ self .request_paint_to_pad_bottom = 0
1128
1137
else :
1129
1138
arr = FSArray (0 , width )
1130
1139
#TODO test case of current line filling up the whole screen (there aren't enough rows to show it)
@@ -1209,7 +1218,8 @@ def move_screen_up(current_line_start_row):
1209
1218
if self .list_win_visible and not self .coderunner .running :
1210
1219
logger .debug ('infobox display code running' )
1211
1220
visible_space_above = history .height
1212
- visible_space_below = min_height - current_line_end_row - 1
1221
+ potential_space_below = min_height - current_line_end_row - 1
1222
+ visible_space_below = potential_space_below - self .get_top_usable_line ()
1213
1223
1214
1224
info_max_rows = max (visible_space_above , visible_space_below )
1215
1225
infobox = paint .paint_infobox (info_max_rows ,
@@ -1219,12 +1229,16 @@ def move_screen_up(current_line_start_row):
1219
1229
self .current_match ,
1220
1230
self .docstring ,
1221
1231
self .config ,
1222
- self .matches_iter .completer .format if self .matches_iter .completer else None )
1232
+ self .matches_iter .completer .format
1233
+ if self .matches_iter .completer
1234
+ else None )
1223
1235
1224
- if visible_space_above >= infobox .height and self .config .curtsies_list_above :
1225
- arr [ current_line_start_row - infobox .height :current_line_start_row , 0 : infobox . width ] = infobox
1226
- else :
1236
+ if visible_space_below >= infobox .height or not self .config .curtsies_list_above :
1237
+ if visible_space_below < infobox .height :
1238
+ raise ValueError ( 'whoops %r %r' % ( visible_space_below , infobox . height ))
1227
1239
arr [current_line_end_row + 1 :current_line_end_row + 1 + infobox .height , 0 :infobox .width ] = infobox
1240
+ else :
1241
+ arr [current_line_start_row - infobox .height :current_line_start_row , 0 :infobox .width ] = infobox
1228
1242
logger .debug ('slamming infobox of shape %r into arr of shape %r' , infobox .shape , arr .shape )
1229
1243
1230
1244
logger .debug ('about to exit: %r' , about_to_exit )
0 commit comments