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