8888### To return to bpython without reevaluating make no changes to this file
8989### or save an empty file.
9090"""
91- MAX_EVENTS_POSSIBLY_NOT_PASTE = 20 # more than this many events will be assumed to
92- # be a true paste event, i.e. control characters
93- # like '<Ctrl-a>' will be stripped
91+
92+ # more than this many events will be assumed to be a true paste event,
93+ # i.e. control characters like '<Ctrl-a>' will be stripped
94+ MAX_EVENTS_POSSIBLY_NOT_PASTE = 20
9495
9596# This is needed for is_nop and should be removed once is_nop is fixed.
9697if py3 :
@@ -152,7 +153,7 @@ def process_event(self, e):
152153 self .has_focus = False
153154 self .current_line = ''
154155 self .cursor_offset = 0
155- self .repl .run_code_and_maybe_finish (for_code = line + '\n ' )
156+ self .repl .run_code_and_maybe_finish (for_code = line + '\n ' )
156157 else : # add normal character
157158 self .add_input_character (e )
158159
@@ -423,8 +424,8 @@ def __init__(self,
423424
424425 self .watcher = ModuleChangedEventHandler ([], self .request_reload )
425426
426- ### These methods should be overridden, but the default implementations below
427- ### can be used as well.
427+ # The methods below should be overridden, but the default implementations
428+ # below can be used as well.
428429
429430 def get_cursor_vertical_diff (self ):
430431 """Return how the cursor moved due to a window size change"""
@@ -449,7 +450,7 @@ def _schedule_refresh(self, when='now'):
449450 is only having an out of date UI until the user enters input, a
450451 default NOP implementation is provided."""
451452
452- ### These methods must be overridden in subclasses
453+ # The methods below must be overridden in subclasses.
453454
454455 def _request_refresh (self ):
455456 """Arrange for the bpython display to be refreshed soon.
@@ -467,7 +468,7 @@ def _request_reload(self, files_modified=('?',)):
467468 raise NotImplementedError
468469
469470 def request_undo (self , n = 1 ):
470- """ike request_refresh, but for undo request events."""
471+ """Like request_refresh, but for undo request events."""
471472 raise NotImplementedError
472473
473474 def on_suspend ():
@@ -483,17 +484,17 @@ def after_suspend():
483484 if not in the middle of a process_event call when suspend happened."""
484485 raise NotImplementedError
485486
486- ### End methods that should be overridden in subclass
487+ # end methods that should be overridden in subclass
487488
488489 def request_refresh (self ):
489- """Arrange for the bpython display to be refreshed soon."""
490+ """Request that the bpython display to be refreshed soon."""
490491 if self .reevaluating or self .paste_mode :
491492 self .fake_refresh_requested = True
492493 else :
493494 self ._request_refresh ()
494495
495496 def request_reload (self , files_modified = ()):
496- """Arrange for the """
497+ """Request that a ReloadEvent be passed next into process_event """
497498 if self .watching_files :
498499 self ._request_reload (files_modified = files_modified )
499500
@@ -611,7 +612,6 @@ def process_control_event(self, e):
611612 else :
612613 self .process_simple_keypress (ee )
613614
614-
615615 elif isinstance (e , bpythonevents .RunStartupFileEvent ):
616616 try :
617617 self .startup ()
@@ -651,9 +651,9 @@ def process_key_event(self, e):
651651
652652 if (e in (key_dispatch [self .config .right_key ] +
653653 key_dispatch [self .config .end_of_line_key ] +
654- ("<RIGHT>" ,))
655- and self .config .curtsies_right_arrow_completion
656- and self .cursor_offset == len (self .current_line )):
654+ ("<RIGHT>" ,)) and
655+ self .config .curtsies_right_arrow_completion and
656+ self .cursor_offset == len (self .current_line )):
657657
658658 self .current_line += self .current_suggestion
659659 self .cursor_offset = len (self .current_line )
@@ -669,8 +669,9 @@ def process_key_event(self, e):
669669 self .incremental_search (reverse = True )
670670 elif e in key_dispatch [self .config .incremental_search_key ]:
671671 self .incremental_search ()
672- elif (e in ("<BACKSPACE>" ,) + key_dispatch [self .config .backspace_key ]
673- and self .incremental_search_mode ):
672+ elif (e in (("<BACKSPACE>" ,) +
673+ key_dispatch [self .config .backspace_key ]) and
674+ self .incremental_search_mode ):
674675 self .add_to_incremental_search (self , backspace = True )
675676 elif e in self .edit_keys .cut_buffer_edits :
676677 self .readline_kill (e )
@@ -730,7 +731,7 @@ def get_last_word(self):
730731 self ._set_current_line (line [:len (line ) - len (previous_word )] + word ,
731732 reset_rl_history = False )
732733 self ._set_cursor_offset (
733- self .cursor_offset - len (previous_word ) + len (word ),
734+ self .cursor_offset - len (previous_word ) + len (word ),
734735 reset_rl_history = False )
735736
736737 def incremental_search (self , reverse = False , include_current = False ):
@@ -816,8 +817,8 @@ def only_whitespace_left_of_cursor():
816817 self .list_win_visible = self .complete ()
817818
818819 elif self .matches_iter .matches :
819- self .current_match = (back and self .matches_iter .previous ()
820- or next (self .matches_iter ))
820+ self .current_match = (back and self .matches_iter .previous () or
821+ next (self .matches_iter ))
821822 self ._cursor_offset , self ._current_line = self .matches_iter .cur_line ()
822823 # using _current_line so we don't trigger a completion reset
823824 self .list_win_visible = True
@@ -827,7 +828,7 @@ def on_control_d(self):
827828 raise SystemExit ()
828829 else :
829830 self .current_line = (self .current_line [:self .cursor_offset ] +
830- self .current_line [self .cursor_offset + 1 :])
831+ self .current_line [( self .cursor_offset + 1 ) :])
831832
832833 def cut_to_buffer (self ):
833834 self .cut_buffer = self .current_line [self .cursor_offset :]
@@ -886,7 +887,7 @@ def send_session_to_external_editor(self, filename=None):
886887 if line .startswith (self .ps1 ) else
887888 line [len (self .ps2 ):]
888889 if line .startswith (self .ps2 ) else
889- '### ' + line
890+ '### ' + line
890891 for line in self .getstdout ().split ('\n ' ))
891892 text = self .send_to_external_editor (for_editor )
892893 if text == for_editor :
@@ -1056,7 +1057,7 @@ def run_code_and_maybe_finish(self, for_code=None):
10561057 self .display_lines .extend (paint .display_linize (self .current_stdouterr_line , self .width ))
10571058 self .current_stdouterr_line = ''
10581059
1059- self ._set_current_line (' ' * indent , update_completion = True )
1060+ self ._set_current_line (' ' * indent , update_completion = True )
10601061 self .cursor_offset = len (self .current_line )
10611062
10621063 def keyboard_interrupt (self ):
@@ -1226,7 +1227,7 @@ def paint(self, about_to_exit=False, user_quit=False):
12261227 """
12271228 # The hairiest function in the curtsies - a cleanup would be great.
12281229 if about_to_exit :
1229- self .clean_up_current_line_for_exit () # exception to not changing state!
1230+ self .clean_up_current_line_for_exit () # exception to not changing state!
12301231
12311232 width , min_height = self .width , self .height
12321233 show_status_bar = ((bool (self .status_bar .should_show_message ) or self .status_bar .has_focus )
@@ -1239,7 +1240,7 @@ def paint(self, about_to_exit=False, user_quit=False):
12391240 current_line_start_row = len (self .lines_for_display ) - max (0 , self .scroll_offset )
12401241 # TODO how is the situation of self.scroll_offset < 0 possible?
12411242 # current_line_start_row = len(self.lines_for_display) - self.scroll_offset
1242- if self .request_paint_to_clear_screen : # or show_status_bar and about_to_exit ?
1243+ if self .request_paint_to_clear_screen : # or show_status_bar and about_to_exit ?
12431244 self .request_paint_to_clear_screen = False
12441245 arr = FSArray (min_height + current_line_start_row , width )
12451246 elif self .request_paint_to_pad_bottom :
@@ -1275,9 +1276,11 @@ def move_screen_up(current_line_start_row):
12751276 self .history_already_messed_up = True
12761277 msg = INCONSISTENT_HISTORY_MSG
12771278 arr [0 , 0 :min (len (msg ), width )] = [msg [:width ]]
1278- current_line_start_row += 1 # for the message
1279- self .scroll_offset -= 1 # to make up for the scroll we're going to receive
1280- # after we render scrolls down a line
1279+ current_line_start_row += 1 # for the message
1280+
1281+ # to make up for the scroll that will be received after the
1282+ # scrolls are rendered down a line
1283+ self .scroll_offset -= 1
12811284
12821285 current_line_start_row = move_screen_up (current_line_start_row )
12831286 logger .debug ('current_line_start_row: %r' , current_line_start_row )
@@ -1313,7 +1316,7 @@ def move_screen_up(current_line_start_row):
13131316
13141317 self .inconsistent_history = False
13151318
1316- if user_quit : # quit() or exit() in interp
1319+ if user_quit : # quit() or exit() in interp
13171320 current_line_start_row = current_line_start_row - current_line .height
13181321 logger .debug ("---current line row slice %r, %r" , current_line_start_row ,
13191322 current_line_start_row + current_line .height )
@@ -1322,9 +1325,9 @@ def move_screen_up(current_line_start_row):
13221325 0 :current_line .width ] = current_line
13231326
13241327 if current_line .height > min_height :
1325- return arr , (0 , 0 ) # short circuit, no room for infobox
1328+ return arr , (0 , 0 ) # short circuit, no room for infobox
13261329
1327- lines = paint .display_linize (self .current_cursor_line + 'X' , width )
1330+ lines = paint .display_linize (self .current_cursor_line + 'X' , width )
13281331 # extra character for space for the cursor
13291332 current_line_end_row = current_line_start_row + len (lines ) - 1
13301333
0 commit comments