##// END OF EJS Templates
Fix switching prompts in doctest mode
Thomas Kluyver -
Show More
@@ -98,6 +98,7 b' class TerminalInteractiveShell(InteractiveShell):'
98
98
99 pt_cli = None
99 pt_cli = None
100 debugger_history = None
100 debugger_history = None
101 _pt_app = None
101
102
102 simple_prompt = Bool(_use_simple_prompt,
103 simple_prompt = Bool(_use_simple_prompt,
103 help="""Use `raw_input` for the REPL, without completion, multiline input, and prompt colors.
104 help="""Use `raw_input` for the REPL, without completion, multiline input, and prompt colors.
@@ -203,7 +204,6 b' class TerminalInteractiveShell(InteractiveShell):'
203 self.display_formatter.active_types = ['text/plain']
204 self.display_formatter.active_types = ['text/plain']
204
205
205 def init_prompt_toolkit_cli(self):
206 def init_prompt_toolkit_cli(self):
206 self._app = None
207 if self.simple_prompt:
207 if self.simple_prompt:
208 # Fall back to plain non-interactive output for tests.
208 # Fall back to plain non-interactive output for tests.
209 # This is very limited, and only accepts a single line.
209 # This is very limited, and only accepts a single line.
@@ -350,7 +350,7 b' class TerminalInteractiveShell(InteractiveShell):'
350
350
351 editing_mode = getattr(EditingMode, self.editing_mode.upper())
351 editing_mode = getattr(EditingMode, self.editing_mode.upper())
352
352
353 self._app = create_prompt_application(
353 self._pt_app = create_prompt_application(
354 editing_mode=editing_mode,
354 editing_mode=editing_mode,
355 key_bindings_registry=kbmanager.registry,
355 key_bindings_registry=kbmanager.registry,
356 history=history,
356 history=history,
@@ -361,7 +361,7 b' class TerminalInteractiveShell(InteractiveShell):'
361 **self._layout_options()
361 **self._layout_options()
362 )
362 )
363 self._eventloop = create_eventloop(self.inputhook)
363 self._eventloop = create_eventloop(self.inputhook)
364 self.pt_cli = CommandLineInterface(self._app, eventloop=self._eventloop)
364 self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self._eventloop)
365
365
366 def _make_style_from_name(self, name):
366 def _make_style_from_name(self, name):
367 """
367 """
@@ -432,8 +432,8 b' class TerminalInteractiveShell(InteractiveShell):'
432 Ask for a re computation of the application layout, if for example ,
432 Ask for a re computation of the application layout, if for example ,
433 some configuration options have changed.
433 some configuration options have changed.
434 """
434 """
435 if getattr(self, '._app', None):
435 if self._pt_app:
436 self._app.layout = create_prompt_layout(**self._layout_options())
436 self._pt_app.layout = create_prompt_layout(**self._layout_options())
437
437
438 def prompt_for_code(self):
438 def prompt_for_code(self):
439 document = self.pt_cli.run(
439 document = self.pt_cli.run(
@@ -563,6 +563,7 b' class TerminalInteractiveShell(InteractiveShell):'
563 elif self._prompts_before:
563 elif self._prompts_before:
564 self.prompts = self._prompts_before
564 self.prompts = self._prompts_before
565 self._prompts_before = None
565 self._prompts_before = None
566 self._update_layout()
566
567
567
568
568 InteractiveShellABC.register(TerminalInteractiveShell)
569 InteractiveShellABC.register(TerminalInteractiveShell)
General Comments 0
You need to be logged in to leave comments. Login now