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 |
@@ -164,8 +162,8 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
164 | 162 | self.prompt_for_code = prompt |
|
165 | 163 | return |
|
166 | 164 | |
|
167 |
kbmanager = KeyBindingManager.for_prompt( |
|
|
168 | insert_mode = ViStateFilter(kbmanager.get_vi_state, InputMode.INSERT) | |
|
165 | kbmanager = KeyBindingManager.for_prompt() | |
|
166 | insert_mode = ViInsertMode() | EmacsInsertMode() | |
|
169 | 167 | # Ctrl+J == Enter, seemingly |
|
170 | 168 | @kbmanager.registry.add_binding(Keys.ControlJ, |
|
171 | 169 | filter=(HasFocus(DEFAULT_BUFFER) |
@@ -232,7 +230,10 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
232 | 230 | self._style = self._make_style_from_name(self.highlighting_style) |
|
233 | 231 | style = DynamicStyle(lambda: self._style) |
|
234 | 232 | |
|
233 | editing_mode = EditingMode.VI if self.vi_mode else EditingMode.EMACS | |
|
234 | ||
|
235 | 235 | self._app = create_prompt_application( |
|
236 | editing_mode=editing_mode, | |
|
236 | 237 | key_bindings_registry=kbmanager.registry, |
|
237 | 238 | history=history, |
|
238 | 239 | completer=IPythonPTCompleter(self.Completer), |
@@ -295,7 +296,8 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
295 | 296 | self._app.layout = create_prompt_layout(**self._layout_options()) |
|
296 | 297 | |
|
297 | 298 | def prompt_for_code(self): |
|
298 |
document = self.pt_cli.run( |
|
|
299 | document = self.pt_cli.run( | |
|
300 | pre_run=self.pre_prompt, reset_current_buffer=True) | |
|
299 | 301 | return document.text |
|
300 | 302 | |
|
301 | 303 | def init_io(self): |
General Comments 0
You need to be logged in to leave comments.
Login now