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