3434
3535#TODO implement paste mode and figure out what the deal with config.paste_time is
3636#TODO figure out how config.auto_display_list=False behaves and implement it
37- #TODO figure out how config.list_win_visible behaves and implement it
38- #TODO other autocomplete modes
37+ #TODO figure out how config.list_win_visible behaves and implement it, or toss
38+ #TODO other autocomplete modes (also fix in other bpython implementations)
3939#TODO figure out what config.flush_output is
4040#TODO figure out what options.quiet is
41- #TODO execute file if in args
42- #TODO proper raw_input (currently input isn't visible while typing, includes \r, and comes in as unicode in Python 2
4341#TODO use events instead of length-one queues for interthread communication
4442
45- #TODO check py3 compatibility
46-
4743
4844from bpython .keys import cli_key_dispatch as key_dispatch
4945
@@ -252,6 +248,8 @@ def clean_up_current_line_for_exit(self):
252248 ## Event handling
253249 def process_event (self , e ):
254250 """Returns True if shutting down, otherwise mutates state of Repl object"""
251+ # event names uses here are curses compatible, or the full names
252+ # for a full list of what should have pretty names, see fmtstr.events.CURSES_TABLE
255253
256254 if not isinstance (e , events .Event ):
257255 self .last_events .append (e )
@@ -281,12 +279,12 @@ def process_event(self, e):
281279 self .update_completion ()
282280
283281 # readline history commands
284- elif e in ("[A" , " KEY_UP" ) + key_dispatch [self .config .up_one_line_key ]:
282+ elif e in ("KEY_UP" , ) + key_dispatch [self .config .up_one_line_key ]:
285283 self .rl_history .enter (self ._current_line )
286284 self ._current_line = self .rl_history .back (False )
287285 self .cursor_offset_in_line = len (self ._current_line )
288286 self .update_completion ()
289- elif e in ("[B" , " KEY_DOWN" ) + key_dispatch [self .config .down_one_line_key ]:
287+ elif e in ("KEY_DOWN" , ) + key_dispatch [self .config .down_one_line_key ]:
290288 self .rl_history .enter (self ._current_line )
291289 self ._current_line = self .rl_history .forward (False )
292290 self .cursor_offset_in_line = len (self ._current_line )
@@ -320,18 +318,18 @@ def process_event(self, e):
320318 #TODO use a whitelist instead of a blacklist!
321319 elif e == '\t ' : # tab
322320 self .on_tab ()
323- elif e in ('[Z' , "KEY_BTAB" ): # shift-tab
321+ elif e in ("KEY_BTAB" , ): # shift-tab
324322 self .on_tab (back = True )
325- elif e in ( '' ,) + key_dispatch [self .config .undo_key ]:
323+ elif e in key_dispatch [self .config .undo_key ]: #ctrl-r for undo
326324 self .undo ()
327- elif e in ( ' \x13 ' ,) + key_dispatch [self .config .save_key ]: # ctrl-s for save
325+ elif e in key_dispatch [self .config .save_key ]: # ctrl-s for save
328326 t = threading .Thread (target = self .write2file )
329327 t .daemon = True
330328 logging .debug ('starting write2file thread' )
331329 t .start ()
332330 self .interact .wait_for_request_or_notify ()
333331 # F8 for pastebin
334- elif e in ( ' \x1b [19~' ,) + key_dispatch [self .config .pastebin_key ]:
332+ elif e in key_dispatch [self .config .pastebin_key ]:
335333 t = threading .Thread (target = self .pastebin )
336334 t .daemon = True
337335 logging .debug ('starting pastebin thread' )
@@ -853,8 +851,9 @@ def reevaluate(self, insert_into_history=False):
853851
854852 def getstdout (self ):
855853 lines = self .lines_for_display + [self .current_line_formatted ]
856- s = '\n ' .join (['%simport %s' % (self .ps1 , name ) for name in self .interp .locals .autoimported ] if self .config .scroll_auto_import else [] +
857- [x .s if isinstance (x , FmtStr ) else x for x in lines ]
854+ imports = (['%simport %s' % (self .ps1 , name ) for name in self .interp .locals .autoimported ]
855+ if hasattr (self .interp .locals , 'autoimported' ) else [])
856+ s = '\n ' .join (imports + [x .s if isinstance (x , FmtStr ) else x for x in lines ]
858857 ) if lines else ''
859858 return s
860859 def send_to_external_editor (self , filename = None ):
0 commit comments