Show More
@@ -25,6 +25,7 b' from prompt_toolkit.patch_stdout import patch_stdout' | |||
|
25 | 25 | from prompt_toolkit.shortcuts import PromptSession, CompleteStyle, print_formatted_text |
|
26 | 26 | from prompt_toolkit.styles import DynamicStyle, merge_styles |
|
27 | 27 | from prompt_toolkit.styles.pygments import style_from_pygments_cls, style_from_pygments_dict |
|
28 | from prompt_toolkit import __version__ as ptk_version | |
|
28 | 29 | |
|
29 | 30 | from pygments.styles import get_style_by_name |
|
30 | 31 | from pygments.style import Style |
@@ -38,6 +39,7 b' from .ptutils import IPythonPTCompleter, IPythonPTLexer' | |||
|
38 | 39 | from .shortcuts import create_ipython_shortcuts |
|
39 | 40 | |
|
40 | 41 | DISPLAY_BANNER_DEPRECATED = object() |
|
42 | PTK3 = ptk_version.startswith('3.') | |
|
41 | 43 | |
|
42 | 44 | |
|
43 | 45 | class _NoStyle(Style): pass |
@@ -415,7 +417,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
415 | 417 | # work around this. |
|
416 | 418 | get_message = get_message() |
|
417 | 419 | |
|
418 |
|
|
|
420 | options = { | |
|
419 | 421 | 'complete_in_thread': False, |
|
420 | 422 | 'lexer':IPythonPTLexer(), |
|
421 | 423 | 'reserve_space_for_menu':self.space_for_menu, |
@@ -432,8 +434,11 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
432 | 434 | processor=HighlightMatchingBracketProcessor(chars='[](){}'), |
|
433 | 435 | filter=HasFocus(DEFAULT_BUFFER) & ~IsDone() & |
|
434 | 436 | Condition(lambda: self.highlight_matching_brackets))], |
|
435 | 'inputhook': self.inputhook, | |
|
436 | 437 | } |
|
438 | if not PTK3: | |
|
439 | options['inputhook'] = self.inputhook | |
|
440 | ||
|
441 | return options | |
|
437 | 442 | |
|
438 | 443 | def prompt_for_code(self): |
|
439 | 444 | if self.rl_next_input: |
@@ -559,6 +564,16 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
559 | 564 | else: |
|
560 | 565 | self.active_eventloop = self._inputhook = None |
|
561 | 566 | |
|
567 | # For prompt_toolkit 3.0. We have to create an asyncio event loop with | |
|
568 | # this inputhook. | |
|
569 | if PTK3: | |
|
570 | if self._inputhook: | |
|
571 | from prompt_toolkit.eventloop import set_eventloop_with_inputhook | |
|
572 | set_eventloop_with_inputhook(self._inputhook) | |
|
573 | else: | |
|
574 | import asyncio | |
|
575 | asyncio.set_event_loop(asyncio.new_event_loop()) | |
|
576 | ||
|
562 | 577 | # Run !system commands directly, not through pipes, so terminal programs |
|
563 | 578 | # work correctly. |
|
564 | 579 | system = InteractiveShell.system_raw |
General Comments 0
You need to be logged in to leave comments.
Login now