|
34 | 34 |
|
35 | 35 | #TODO implement paste mode and figure out what the deal with config.paste_time is |
36 | 36 | #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) |
39 | 39 | #TODO figure out what config.flush_output is |
40 | 40 | #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 |
43 | 41 | #TODO use events instead of length-one queues for interthread communication |
44 | 42 |
|
45 | | -#TODO check py3 compatibility |
46 | | - |
47 | 43 |
|
48 | 44 | from bpython.keys import cli_key_dispatch as key_dispatch |
49 | 45 |
|
@@ -252,6 +248,8 @@ def clean_up_current_line_for_exit(self): |
252 | 248 | ## Event handling |
253 | 249 | def process_event(self, e): |
254 | 250 | """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 |
255 | 253 |
|
256 | 254 | if not isinstance(e, events.Event): |
257 | 255 | self.last_events.append(e) |
@@ -281,12 +279,12 @@ def process_event(self, e): |
281 | 279 | self.update_completion() |
282 | 280 |
|
283 | 281 | # 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]: |
285 | 283 | self.rl_history.enter(self._current_line) |
286 | 284 | self._current_line = self.rl_history.back(False) |
287 | 285 | self.cursor_offset_in_line = len(self._current_line) |
288 | 286 | 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]: |
290 | 288 | self.rl_history.enter(self._current_line) |
291 | 289 | self._current_line = self.rl_history.forward(False) |
292 | 290 | self.cursor_offset_in_line = len(self._current_line) |
@@ -320,18 +318,18 @@ def process_event(self, e): |
320 | 318 | #TODO use a whitelist instead of a blacklist! |
321 | 319 | elif e == '\t': # tab |
322 | 320 | self.on_tab() |
323 | | - elif e in ('[Z', "KEY_BTAB"): # shift-tab |
| 321 | + elif e in ("KEY_BTAB",): # shift-tab |
324 | 322 | 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 |
326 | 324 | 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 |
328 | 326 | t = threading.Thread(target=self.write2file) |
329 | 327 | t.daemon = True |
330 | 328 | logging.debug('starting write2file thread') |
331 | 329 | t.start() |
332 | 330 | self.interact.wait_for_request_or_notify() |
333 | 331 | # 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]: |
335 | 333 | t = threading.Thread(target=self.pastebin) |
336 | 334 | t.daemon = True |
337 | 335 | logging.debug('starting pastebin thread') |
@@ -853,8 +851,9 @@ def reevaluate(self, insert_into_history=False): |
853 | 851 |
|
854 | 852 | def getstdout(self): |
855 | 853 | 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] |
858 | 857 | ) if lines else '' |
859 | 858 | return s |
860 | 859 | def send_to_external_editor(self, filename=None): |
|
0 commit comments