Show More
@@ -16,14 +16,12 b' from IPython.utils.process import abbrev_cwd' | |||
|
16 | 16 | from traitlets import Bool, CBool, Unicode, Dict, Integer |
|
17 | 17 | |
|
18 | 18 | from prompt_toolkit.completion import Completer, Completion |
|
19 | from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER | |
|
20 | from prompt_toolkit.filters import HasFocus, HasSelection, Condition | |
|
19 | from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode | |
|
20 | from prompt_toolkit.filters import HasFocus, HasSelection, Condition, ViInsertMode, EmacsInsertMode | |
|
21 | 21 | from prompt_toolkit.history import InMemoryHistory |
|
22 | 22 | from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_prompt_layout |
|
23 | 23 | from prompt_toolkit.interface import CommandLineInterface |
|
24 | 24 | from prompt_toolkit.key_binding.manager import KeyBindingManager |
|
25 | from prompt_toolkit.key_binding.vi_state import InputMode | |
|
26 | from prompt_toolkit.key_binding.bindings.vi import ViStateFilter | |
|
27 | 25 | from prompt_toolkit.keys import Keys |
|
28 | 26 | from prompt_toolkit.layout.lexers import Lexer |
|
29 | 27 | from prompt_toolkit.layout.lexers import PygmentsLexer |
@@ -168,8 +166,8 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
168 | 166 | self.prompt_for_code = prompt |
|
169 | 167 | return |
|
170 | 168 | |
|
171 |
kbmanager = KeyBindingManager.for_prompt( |
|
|
172 | insert_mode = ViStateFilter(kbmanager.get_vi_state, InputMode.INSERT) | |
|
169 | kbmanager = KeyBindingManager.for_prompt() | |
|
170 | insert_mode = ViInsertMode() | EmacsInsertMode() | |
|
173 | 171 | # Ctrl+J == Enter, seemingly |
|
174 | 172 | @kbmanager.registry.add_binding(Keys.ControlJ, |
|
175 | 173 | filter=(HasFocus(DEFAULT_BUFFER) |
@@ -236,7 +234,10 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
236 | 234 | self._style = self._make_style_from_name(self.highlighting_style) |
|
237 | 235 | style = DynamicStyle(lambda: self._style) |
|
238 | 236 | |
|
237 | editing_mode = EditingMode.VI if self.vi_mode else EditingMode.EMACS | |
|
238 | ||
|
239 | 239 | self._app = create_prompt_application( |
|
240 | editing_mode=editing_mode, | |
|
240 | 241 | key_bindings_registry=kbmanager.registry, |
|
241 | 242 | history=history, |
|
242 | 243 | completer=IPythonPTCompleter(self.Completer), |
@@ -299,7 +300,8 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
299 | 300 | self._app.layout = create_prompt_layout(**self._layout_options()) |
|
300 | 301 | |
|
301 | 302 | def prompt_for_code(self): |
|
302 |
document = self.pt_cli.run( |
|
|
303 | document = self.pt_cli.run( | |
|
304 | pre_run=self.pre_prompt, reset_current_buffer=True) | |
|
303 | 305 | return document.text |
|
304 | 306 | |
|
305 | 307 | def init_io(self): |
General Comments 0
You need to be logged in to leave comments.
Login now