Show More
@@ -11,7 +11,7 b' from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC' | |||||
11 | from IPython.utils.py3compat import PY3, cast_unicode_py2, input |
|
11 | from IPython.utils.py3compat import PY3, cast_unicode_py2, input | |
12 | from IPython.utils.terminal import toggle_set_term_title, set_term_title |
|
12 | from IPython.utils.terminal import toggle_set_term_title, set_term_title | |
13 | from IPython.utils.process import abbrev_cwd |
|
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 | from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode |
|
16 | from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode | |
17 | from prompt_toolkit.filters import (HasFocus, HasSelection, Condition, |
|
17 | from prompt_toolkit.filters import (HasFocus, HasSelection, Condition, | |
@@ -24,6 +24,7 b' from prompt_toolkit.key_binding.manager import KeyBindingManager' | |||||
24 | from prompt_toolkit.keys import Keys |
|
24 | from prompt_toolkit.keys import Keys | |
25 | from prompt_toolkit.layout.processors import ConditionalProcessor, HighlightMatchingBracketProcessor |
|
25 | from prompt_toolkit.layout.processors import ConditionalProcessor, HighlightMatchingBracketProcessor | |
26 | from prompt_toolkit.styles import PygmentsStyle, DynamicStyle |
|
26 | from prompt_toolkit.styles import PygmentsStyle, DynamicStyle | |
|
27 | from prompt_toolkit.key_binding.bindings.completion import display_completions_like_readline | |||
27 |
|
28 | |||
28 | from pygments.styles import get_style_by_name, get_all_styles |
|
29 | from pygments.styles import get_style_by_name, get_all_styles | |
29 | from pygments.token import Token |
|
30 | from pygments.token import Token | |
@@ -147,10 +148,17 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
147 | help="Automatically set the terminal title" |
|
148 | help="Automatically set the terminal title" | |
148 | ).tag(config=True) |
|
149 | ).tag(config=True) | |
149 |
|
150 | |||
150 |
display_completions_in_columns = Bool( |
|
151 | display_completions_in_columns = Bool(None, | |
151 | help="Display a multi column completion menu.", |
|
152 | help="Display a multi column completion menu.", allow_none=True | |
152 | ).tag(config=True) |
|
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 | highlight_matching_brackets = Bool(True, |
|
162 | highlight_matching_brackets = Bool(True, | |
155 | help="Highlight matching brackets .", |
|
163 | help="Highlight matching brackets .", | |
156 | ).tag(config=True) |
|
164 | ).tag(config=True) | |
@@ -273,6 +281,18 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
273 | def _indent_buffer(event): |
|
281 | def _indent_buffer(event): | |
274 | event.current_buffer.insert_text(' ' * 4) |
|
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 | if sys.platform == 'win32': |
|
296 | if sys.platform == 'win32': | |
277 | from IPython.lib.clipboard import (ClipboardEmpty, |
|
297 | from IPython.lib.clipboard import (ClipboardEmpty, | |
278 | win32_clipboard_get, tkinter_clipboard_get) |
|
298 | win32_clipboard_get, tkinter_clipboard_get) | |
@@ -360,7 +380,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
360 | 'get_prompt_tokens':self.prompts.in_prompt_tokens, |
|
380 | 'get_prompt_tokens':self.prompts.in_prompt_tokens, | |
361 | 'get_continuation_tokens':self.prompts.continuation_prompt_tokens, |
|
381 | 'get_continuation_tokens':self.prompts.continuation_prompt_tokens, | |
362 | 'multiline':True, |
|
382 | 'multiline':True, | |
363 |
'display_completions_in_columns': self.display_completions |
|
383 | 'display_completions_in_columns': (self.display_completions == 'multicolumn'), | |
364 |
|
384 | |||
365 | # Highlight matching brackets, but only when this setting is |
|
385 | # Highlight matching brackets, but only when this setting is | |
366 | # enabled, and only when the DEFAULT_BUFFER has the focus. |
|
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