Show More
@@ -10,7 +10,10 b' from IPython.utils import io' | |||
|
10 | 10 | from IPython.utils.py3compat import cast_unicode_py2, input |
|
11 | 11 | from IPython.utils.terminal import toggle_set_term_title, set_term_title |
|
12 | 12 | from IPython.utils.process import abbrev_cwd |
|
13 | from traitlets import Bool, Unicode, Dict, Integer, observe, Instance, Type, default, Enum, Union | |
|
13 | from traitlets import ( | |
|
14 | Bool, Unicode, Dict, Integer, observe, Instance, Type, default, Enum, Union, | |
|
15 | Any, | |
|
16 | ) | |
|
14 | 17 | |
|
15 | 18 | from prompt_toolkit.document import Document |
|
16 | 19 | from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode |
@@ -192,6 +195,12 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
192 | 195 | "This is in addition to the F2 binding, which is always enabled." |
|
193 | 196 | ).tag(config=True) |
|
194 | 197 | |
|
198 | handle_return = Any(None, | |
|
199 | help="Provide an alternative handler to be called when the user presses " | |
|
200 | "Return. This is an advanced option intended for debugging, which " | |
|
201 | "may be changed or removed in later releases." | |
|
202 | ).tag(config=True) | |
|
203 | ||
|
195 | 204 | @observe('term_title') |
|
196 | 205 | def init_term_title(self, change=None): |
|
197 | 206 | # Enable or disable the terminal title. |
@@ -31,12 +31,17 b' def register_ipython_shortcuts(registry, shell):' | |||
|
31 | 31 | """Set up the prompt_toolkit keyboard shortcuts for IPython""" |
|
32 | 32 | insert_mode = ViInsertMode() | EmacsInsertMode() |
|
33 | 33 | |
|
34 | if getattr(shell, 'handle_return', None): | |
|
35 | return_handler = shell.handle_return(shell) | |
|
36 | else: | |
|
37 | return_handler = newline_or_execute_outer(shell) | |
|
38 | ||
|
34 | 39 | # Ctrl+J == Enter, seemingly |
|
35 | 40 | registry.add_binding(Keys.ControlJ, |
|
36 | 41 | filter=(HasFocus(DEFAULT_BUFFER) |
|
37 | 42 | & ~HasSelection() |
|
38 | 43 | & insert_mode |
|
39 |
))( |
|
|
44 | ))(return_handler) | |
|
40 | 45 | |
|
41 | 46 | registry.add_binding(Keys.ControlBackslash)(force_exit) |
|
42 | 47 |
General Comments 0
You need to be logged in to leave comments.
Login now