Show More
@@ -11,7 +11,7 b' from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC' | |||
|
11 | 11 | from IPython.utils.py3compat import PY3, cast_unicode_py2, input |
|
12 | 12 | from IPython.utils.terminal import toggle_set_term_title, set_term_title |
|
13 | 13 | from IPython.utils.process import abbrev_cwd |
|
14 | from traitlets import Bool, Unicode, Dict, Integer, observe, Instance, Type, default | |
|
14 | from traitlets import Bool, Unicode, Dict, Integer, observe, Instance, Type, default, Enum | |
|
15 | 15 | |
|
16 | 16 | from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode |
|
17 | 17 | from prompt_toolkit.filters import (HasFocus, HasSelection, Condition, |
@@ -24,6 +24,7 b' from prompt_toolkit.key_binding.manager import KeyBindingManager' | |||
|
24 | 24 | from prompt_toolkit.keys import Keys |
|
25 | 25 | from prompt_toolkit.layout.processors import ConditionalProcessor, HighlightMatchingBracketProcessor |
|
26 | 26 | from prompt_toolkit.styles import PygmentsStyle, DynamicStyle |
|
27 | from prompt_toolkit.key_binding.bindings.completion import display_completions_like_readline | |
|
27 | 28 | |
|
28 | 29 | from pygments.styles import get_style_by_name, get_all_styles |
|
29 | 30 | from pygments.token import Token |
@@ -147,10 +148,17 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
147 | 148 | help="Automatically set the terminal title" |
|
148 | 149 | ).tag(config=True) |
|
149 | 150 | |
|
150 |
display_completions_in_columns = Bool( |
|
|
151 | help="Display a multi column completion menu.", | |
|
151 | display_completions_in_columns = Bool(None, | |
|
152 | help="Display a multi column completion menu.", allow_none=True | |
|
152 | 153 | ).tag(config=True) |
|
153 | 154 | |
|
155 | @observe('display_completions_in_columns') | |
|
156 | def _display_completions_in_columns_changed(self, new): | |
|
157 | raise DeprecationWarning("The `display_completions_in_columns` Boolean has been replaced by the enum `display_completions`" | |
|
158 | "with the following acceptable value: 'column', 'multicolumn','readlinelike'. ") | |
|
159 | ||
|
160 | display_completions = Enum(('column', 'multicolumn','readlinelike'), default_value='multicolumn').tag(config=True) | |
|
161 | ||
|
154 | 162 | highlight_matching_brackets = Bool(True, |
|
155 | 163 | help="Highlight matching brackets .", |
|
156 | 164 | ).tag(config=True) |
@@ -273,6 +281,18 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
273 | 281 | def _indent_buffer(event): |
|
274 | 282 | event.current_buffer.insert_text(' ' * 4) |
|
275 | 283 | |
|
284 | ||
|
285 | if self.display_completions == 'readlinelike': | |
|
286 | @kbmanager.registry.add_binding(Keys.ControlI, | |
|
287 | filter=(HasFocus(DEFAULT_BUFFER) | |
|
288 | & ~HasSelection() | |
|
289 | & insert_mode | |
|
290 | & ~cursor_in_leading_ws | |
|
291 | )) | |
|
292 | def _disaply_compl(ev): | |
|
293 | display_completions_like_readline(ev) | |
|
294 | ||
|
295 | ||
|
276 | 296 | if sys.platform == 'win32': |
|
277 | 297 | from IPython.lib.clipboard import (ClipboardEmpty, |
|
278 | 298 | win32_clipboard_get, tkinter_clipboard_get) |
@@ -360,7 +380,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
360 | 380 | 'get_prompt_tokens':self.prompts.in_prompt_tokens, |
|
361 | 381 | 'get_continuation_tokens':self.prompts.continuation_prompt_tokens, |
|
362 | 382 | 'multiline':True, |
|
363 |
'display_completions_in_columns': self.display_completions |
|
|
383 | 'display_completions_in_columns': (self.display_completions == 'multicolumn'), | |
|
364 | 384 | |
|
365 | 385 | # Highlight matching brackets, but only when this setting is |
|
366 | 386 | # enabled, and only when the DEFAULT_BUFFER has the focus. |
General Comments 0
You need to be logged in to leave comments.
Login now