@@ -342,8 +342,9 @@ def clear_current_line(self):
342342 def clear_wrapped_lines (self ):
343343 """Clear the wrapped lines of the current input."""
344344 # curses does not handle this on its own. Sad.
345- width = self .scr .getmaxyx ()[1 ]
346- for y in xrange (self .iy + 1 , self .iy + len (self .s ) // width + 1 ):
345+ height , width = self .scr .getmaxyx ()
346+ max_y = min (self .iy + (self .ix + len (self .s )) // width + 1 , height )
347+ for y in xrange (self .iy + 1 , max_y ):
347348 self .scr .move (y , 0 )
348349 self .scr .clrtoeol ()
349350
@@ -461,6 +462,13 @@ def echo(self, s, redraw=True):
461462 # Replace NUL bytes, as addstr raises an exception otherwise
462463 s = s .replace ('\x00 ' , '' )
463464
465+ screen_height , screen_width = self .scr .getmaxyx ()
466+ if self .iy >= (screen_height - 1 ):
467+ lines = (self .ix + len (s )) // screen_width
468+ if lines > 0 :
469+ self .scr .scroll (lines )
470+ self .iy -= lines
471+ self .scr .move (self .iy , self .ix )
464472 self .scr .addstr (s , a )
465473
466474 if redraw and not self .evaluating :
@@ -481,12 +489,7 @@ def fwd(self):
481489 """Same as back() but, well, forward"""
482490
483491 self .cpos = 0
484-
485- width = self .scr .getmaxyx ()[1 ]
486- for y in xrange (self .iy + 1 , self .iy + len (self .s ) // width + 1 ):
487- self .scr .move (y , 0 )
488- self .scr .clrtoeol ()
489-
492+ self .clear_wrapped_lines ()
490493 self .rl_history .enter (self .s )
491494 self .s = self .rl_history .forward ()
492495 self .print_line (self .s , clr = True )
@@ -1397,7 +1400,7 @@ def init_wins(scr, colors, config):
13971400# This should show to be configured keys from ~/.bpython/config
13981401#
13991402 statusbar = Statusbar (scr , main_win , background , config ,
1400- " <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
1403+ " <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
14011404 (config .undo_key , config .save_key ,
14021405 config .pastebin_key , config .last_output_key ,
14031406 config .show_source_key ),
0 commit comments