summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2016-12-17 17:24:10 +0100
committerJonathan Slenders <jonathan@slenders.be>2016-12-17 17:25:02 +0100
commit28993b430ea57f13451b93142367709a458ae08a (patch)
tree4174e274b1bef5144f7e8a81a99e236f7247afad
parentb4d41f97b8b6d04d40e827133458ce517e399f48 (diff)
Added complete/menu-complete/menu-complete-backward named commands.
-rw-r--r--prompt_toolkit/key_binding/bindings/basic.py10
-rw-r--r--prompt_toolkit/key_binding/bindings/named_commands.py18
2 files changed, 19 insertions, 9 deletions
diff --git a/prompt_toolkit/key_binding/bindings/basic.py b/prompt_toolkit/key_binding/bindings/basic.py
index b1522e76..40561ca6 100644
--- a/prompt_toolkit/key_binding/bindings/basic.py
+++ b/prompt_toolkit/key_binding/bindings/basic.py
@@ -141,7 +141,8 @@ def load_basic_bindings():
get_by_name('self-insert'))
handle(Keys.ControlT, filter=insert_mode)(get_by_name('transpose-chars'))
handle(Keys.ControlW, filter=insert_mode)(get_by_name('unix-word-rubout'))
- handle(Keys.ControlI, filter=insert_mode)(get_by_name('complete'))
+ handle(Keys.ControlI, filter=insert_mode)(get_by_name('menu-complete'))
+ handle(Keys.BackTab, filter=insert_mode)(get_by_name('menu-complete-backward'))
handle(Keys.PageUp, filter= ~has_selection)(get_by_name('previous-history'))
handle(Keys.PageDown, filter= ~has_selection)(get_by_name('next-history'))
@@ -151,13 +152,6 @@ def load_basic_bindings():
text_before_cursor = Condition(lambda cli: cli.current_buffer.text)
handle(Keys.ControlD, filter=text_before_cursor & insert_mode)(get_by_name('delete-char'))
- @handle(Keys.BackTab, filter=insert_mode)
- def _(event):
- """
- Shift+Tab: go to previous completion.
- """
- event.current_buffer.complete_previous()
-
is_multiline = Condition(lambda cli: cli.current_buffer.is_multiline())
is_returnable = Condition(lambda cli: cli.current_buffer.accept_action.is_returnable)
diff --git a/prompt_toolkit/key_binding/bindings/named_commands.py b/prompt_toolkit/key_binding/bindings/named_commands.py
index f412f197..977da982 100644
--- a/prompt_toolkit/key_binding/bindings/named_commands.py
+++ b/prompt_toolkit/key_binding/bindings/named_commands.py
@@ -9,7 +9,7 @@ from prompt_toolkit.selection import PasteMode
from six.moves import range
import six
-from .completion import generate_completions
+from .completion import generate_completions, display_completions_like_readline
from prompt_toolkit.document import Document
from prompt_toolkit.enums import EditingMode
from prompt_toolkit.key_binding.input_processor import KeyPress
@@ -420,9 +420,25 @@ def yank_pop(event):
@register('complete')
def complete(event):
+ " Attempt to perform completion. "
+ display_completions_like_readline(event)
+
+
+@register('menu-complete')
+def menu_complete(event):
+ """
+ Generate completions, or go to the next completion. (This is the default
+ way of completing input in prompt_toolkit.)
+ """
generate_completions(event)
+@register('menu-complete-backward')
+def menu_complete_backward(event):
+ " Move backward through the list of possible completions. "
+ event.current_buffer.complete_previous()
+
+
#
# Miscellaneous Commands.
#