##// END OF EJS Templates
Support prompt_toolkit 3.0 as well.
Jonathan Slenders -
Show More
@@ -25,6 +25,7 b' from prompt_toolkit.patch_stdout import patch_stdout'
25 from prompt_toolkit.shortcuts import PromptSession, CompleteStyle, print_formatted_text
25 from prompt_toolkit.shortcuts import PromptSession, CompleteStyle, print_formatted_text
26 from prompt_toolkit.styles import DynamicStyle, merge_styles
26 from prompt_toolkit.styles import DynamicStyle, merge_styles
27 from prompt_toolkit.styles.pygments import style_from_pygments_cls, style_from_pygments_dict
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 from pygments.styles import get_style_by_name
30 from pygments.styles import get_style_by_name
30 from pygments.style import Style
31 from pygments.style import Style
@@ -38,6 +39,7 b' from .ptutils import IPythonPTCompleter, IPythonPTLexer'
38 from .shortcuts import create_ipython_shortcuts
39 from .shortcuts import create_ipython_shortcuts
39
40
40 DISPLAY_BANNER_DEPRECATED = object()
41 DISPLAY_BANNER_DEPRECATED = object()
42 PTK3 = ptk_version.startswith('3.')
41
43
42
44
43 class _NoStyle(Style): pass
45 class _NoStyle(Style): pass
@@ -415,7 +417,7 b' class TerminalInteractiveShell(InteractiveShell):'
415 # work around this.
417 # work around this.
416 get_message = get_message()
418 get_message = get_message()
417
419
418 return {
420 options = {
419 'complete_in_thread': False,
421 'complete_in_thread': False,
420 'lexer':IPythonPTLexer(),
422 'lexer':IPythonPTLexer(),
421 'reserve_space_for_menu':self.space_for_menu,
423 'reserve_space_for_menu':self.space_for_menu,
@@ -432,8 +434,11 b' class TerminalInteractiveShell(InteractiveShell):'
432 processor=HighlightMatchingBracketProcessor(chars='[](){}'),
434 processor=HighlightMatchingBracketProcessor(chars='[](){}'),
433 filter=HasFocus(DEFAULT_BUFFER) & ~IsDone() &
435 filter=HasFocus(DEFAULT_BUFFER) & ~IsDone() &
434 Condition(lambda: self.highlight_matching_brackets))],
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 def prompt_for_code(self):
443 def prompt_for_code(self):
439 if self.rl_next_input:
444 if self.rl_next_input:
@@ -559,6 +564,16 b' class TerminalInteractiveShell(InteractiveShell):'
559 else:
564 else:
560 self.active_eventloop = self._inputhook = None
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 # Run !system commands directly, not through pipes, so terminal programs
577 # Run !system commands directly, not through pipes, so terminal programs
563 # work correctly.
578 # work correctly.
564 system = InteractiveShell.system_raw
579 system = InteractiveShell.system_raw
@@ -190,7 +190,7 b' install_requires = ['
190 'decorator',
190 'decorator',
191 'pickleshare',
191 'pickleshare',
192 'traitlets>=4.2',
192 'traitlets>=4.2',
193 'prompt_toolkit>=2.0.0,<2.1.0',
193 'prompt_toolkit>=2.0.0,<3.1.0',
194 'pygments',
194 'pygments',
195 'backcall',
195 'backcall',
196 ]
196 ]
General Comments 0
You need to be logged in to leave comments. Login now