88
88
### To return to bpython without reevaluating make no changes to this file
89
89
### or save an empty file.
90
90
"""
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
94
95
95
96
# This is needed for is_nop and should be removed once is_nop is fixed.
96
97
if py3 :
@@ -152,7 +153,7 @@ def process_event(self, e):
152
153
self .has_focus = False
153
154
self .current_line = ''
154
155
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 ' )
156
157
else : # add normal character
157
158
self .add_input_character (e )
158
159
@@ -423,8 +424,8 @@ def __init__(self,
423
424
424
425
self .watcher = ModuleChangedEventHandler ([], self .request_reload )
425
426
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.
428
429
429
430
def get_cursor_vertical_diff (self ):
430
431
"""Return how the cursor moved due to a window size change"""
@@ -449,7 +450,7 @@ def _schedule_refresh(self, when='now'):
449
450
is only having an out of date UI until the user enters input, a
450
451
default NOP implementation is provided."""
451
452
452
- ### These methods must be overridden in subclasses
453
+ # The methods below must be overridden in subclasses.
453
454
454
455
def _request_refresh (self ):
455
456
"""Arrange for the bpython display to be refreshed soon.
@@ -467,7 +468,7 @@ def _request_reload(self, files_modified=('?',)):
467
468
raise NotImplementedError
468
469
469
470
def request_undo (self , n = 1 ):
470
- """ike request_refresh, but for undo request events."""
471
+ """Like request_refresh, but for undo request events."""
471
472
raise NotImplementedError
472
473
473
474
def on_suspend ():
@@ -483,17 +484,17 @@ def after_suspend():
483
484
if not in the middle of a process_event call when suspend happened."""
484
485
raise NotImplementedError
485
486
486
- ### End methods that should be overridden in subclass
487
+ # end methods that should be overridden in subclass
487
488
488
489
def request_refresh (self ):
489
- """Arrange for the bpython display to be refreshed soon."""
490
+ """Request that the bpython display to be refreshed soon."""
490
491
if self .reevaluating or self .paste_mode :
491
492
self .fake_refresh_requested = True
492
493
else :
493
494
self ._request_refresh ()
494
495
495
496
def request_reload (self , files_modified = ()):
496
- """Arrange for the """
497
+ """Request that a ReloadEvent be passed next into process_event """
497
498
if self .watching_files :
498
499
self ._request_reload (files_modified = files_modified )
499
500
@@ -611,7 +612,6 @@ def process_control_event(self, e):
611
612
else :
612
613
self .process_simple_keypress (ee )
613
614
614
-
615
615
elif isinstance (e , bpythonevents .RunStartupFileEvent ):
616
616
try :
617
617
self .startup ()
@@ -651,9 +651,9 @@ def process_key_event(self, e):
651
651
652
652
if (e in (key_dispatch [self .config .right_key ] +
653
653
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 )):
657
657
658
658
self .current_line += self .current_suggestion
659
659
self .cursor_offset = len (self .current_line )
@@ -669,8 +669,9 @@ def process_key_event(self, e):
669
669
self .incremental_search (reverse = True )
670
670
elif e in key_dispatch [self .config .incremental_search_key ]:
671
671
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 ):
674
675
self .add_to_incremental_search (self , backspace = True )
675
676
elif e in self .edit_keys .cut_buffer_edits :
676
677
self .readline_kill (e )
@@ -730,7 +731,7 @@ def get_last_word(self):
730
731
self ._set_current_line (line [:len (line ) - len (previous_word )] + word ,
731
732
reset_rl_history = False )
732
733
self ._set_cursor_offset (
733
- self .cursor_offset - len (previous_word ) + len (word ),
734
+ self .cursor_offset - len (previous_word ) + len (word ),
734
735
reset_rl_history = False )
735
736
736
737
def incremental_search (self , reverse = False , include_current = False ):
@@ -816,8 +817,8 @@ def only_whitespace_left_of_cursor():
816
817
self .list_win_visible = self .complete ()
817
818
818
819
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 ))
821
822
self ._cursor_offset , self ._current_line = self .matches_iter .cur_line ()
822
823
# using _current_line so we don't trigger a completion reset
823
824
self .list_win_visible = True
@@ -827,7 +828,7 @@ def on_control_d(self):
827
828
raise SystemExit ()
828
829
else :
829
830
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 ) :])
831
832
832
833
def cut_to_buffer (self ):
833
834
self .cut_buffer = self .current_line [self .cursor_offset :]
@@ -886,7 +887,7 @@ def send_session_to_external_editor(self, filename=None):
886
887
if line .startswith (self .ps1 ) else
887
888
line [len (self .ps2 ):]
888
889
if line .startswith (self .ps2 ) else
889
- '### ' + line
890
+ '### ' + line
890
891
for line in self .getstdout ().split ('\n ' ))
891
892
text = self .send_to_external_editor (for_editor )
892
893
if text == for_editor :
@@ -1056,7 +1057,7 @@ def run_code_and_maybe_finish(self, for_code=None):
1056
1057
self .display_lines .extend (paint .display_linize (self .current_stdouterr_line , self .width ))
1057
1058
self .current_stdouterr_line = ''
1058
1059
1059
- self ._set_current_line (' ' * indent , update_completion = True )
1060
+ self ._set_current_line (' ' * indent , update_completion = True )
1060
1061
self .cursor_offset = len (self .current_line )
1061
1062
1062
1063
def keyboard_interrupt (self ):
@@ -1226,7 +1227,7 @@ def paint(self, about_to_exit=False, user_quit=False):
1226
1227
"""
1227
1228
# The hairiest function in the curtsies - a cleanup would be great.
1228
1229
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!
1230
1231
1231
1232
width , min_height = self .width , self .height
1232
1233
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):
1239
1240
current_line_start_row = len (self .lines_for_display ) - max (0 , self .scroll_offset )
1240
1241
# TODO how is the situation of self.scroll_offset < 0 possible?
1241
1242
# 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 ?
1243
1244
self .request_paint_to_clear_screen = False
1244
1245
arr = FSArray (min_height + current_line_start_row , width )
1245
1246
elif self .request_paint_to_pad_bottom :
@@ -1275,9 +1276,11 @@ def move_screen_up(current_line_start_row):
1275
1276
self .history_already_messed_up = True
1276
1277
msg = INCONSISTENT_HISTORY_MSG
1277
1278
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
1281
1284
1282
1285
current_line_start_row = move_screen_up (current_line_start_row )
1283
1286
logger .debug ('current_line_start_row: %r' , current_line_start_row )
@@ -1313,7 +1316,7 @@ def move_screen_up(current_line_start_row):
1313
1316
1314
1317
self .inconsistent_history = False
1315
1318
1316
- if user_quit : # quit() or exit() in interp
1319
+ if user_quit : # quit() or exit() in interp
1317
1320
current_line_start_row = current_line_start_row - current_line .height
1318
1321
logger .debug ("---current line row slice %r, %r" , current_line_start_row ,
1319
1322
current_line_start_row + current_line .height )
@@ -1322,9 +1325,9 @@ def move_screen_up(current_line_start_row):
1322
1325
0 :current_line .width ] = current_line
1323
1326
1324
1327
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
1326
1329
1327
- lines = paint .display_linize (self .current_cursor_line + 'X' , width )
1330
+ lines = paint .display_linize (self .current_cursor_line + 'X' , width )
1328
1331
# extra character for space for the cursor
1329
1332
current_line_end_row = current_line_start_row + len (lines ) - 1
1330
1333
0 commit comments