@@ -339,8 +339,9 @@ def clear_current_line(self):
339339 def clear_wrapped_lines (self ):
340340 """Clear the wrapped lines of the current input."""
341341 # curses does not handle this on its own. Sad.
342- width = self .scr .getmaxyx ()[1 ]
343- for y in xrange (self .iy + 1 , self .iy + len (self .s ) // width + 1 ):
342+ height , width = self .scr .getmaxyx ()
343+ max_y = min (self .iy + (self .ix + len (self .s )) // width + 1 , height )
344+ for y in xrange (self .iy + 1 , max_y ):
344345 self .scr .move (y , 0 )
345346 self .scr .clrtoeol ()
346347
@@ -478,12 +479,7 @@ def fwd(self):
478479 """Same as back() but, well, forward"""
479480
480481 self .cpos = 0
481-
482- width = self .scr .getmaxyx ()[1 ]
483- for y in xrange (self .iy + 1 , self .iy + len (self .s ) // width + 1 ):
484- self .scr .move (y , 0 )
485- self .scr .clrtoeol ()
486-
482+ self .clear_wrapped_lines ()
487483 self .rl_history .enter (self .s )
488484 self .s = self .rl_history .forward ()
489485 self .print_line (self .s , clr = True )
@@ -1215,8 +1211,8 @@ def undo(self, n=1):
12151211
12161212 def writetb (self , lines ):
12171213 for line in lines :
1218- self .echo ('\x01 %s\x03 %s' % (self .config .color_scheme ['error' ],
1219- line ))
1214+ self .write ('\x01 %s\x03 %s' % (self .config .color_scheme ['error' ],
1215+ line ))
12201216
12211217 def yank_from_buffer (self ):
12221218 """Paste the text from the cut buffer at the current cursor location"""
@@ -1394,7 +1390,7 @@ def init_wins(scr, colors, config):
13941390# This should show to be configured keys from ~/.bpython/config
13951391#
13961392 statusbar = Statusbar (scr , main_win , background , config ,
1397- " <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
1393+ " <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
13981394 (config .undo_key , config .save_key ,
13991395 config .pastebin_key , config .last_output_key ,
14001396 config .show_source_key ),
0 commit comments