diff options
author | Jonathan Slenders <jonathan@slenders.be> | 2016-10-21 17:31:27 +0200 |
---|---|---|
committer | Jonathan Slenders <jonathan@slenders.be> | 2016-10-21 17:35:26 +0200 |
commit | 8498692b31671fee7c5a426300a9df2ee290eae2 (patch) | |
tree | 47dc6bc88687d32e2aa8661255db6ea43de65754 /prompt_toolkit | |
parent | b2171606e60a5e1d60cc355b57e9611c18e86e8e (diff) |
Cleaned up some key bindings: auto_up/down handles selection properly.
Diffstat (limited to 'prompt_toolkit')
-rw-r--r-- | prompt_toolkit/key_binding/bindings/basic.py | 12 | ||||
-rw-r--r-- | prompt_toolkit/key_binding/bindings/emacs.py | 14 |
2 files changed, 4 insertions, 22 deletions
diff --git a/prompt_toolkit/key_binding/bindings/basic.py b/prompt_toolkit/key_binding/bindings/basic.py index 2d9de77c..8aa97f79 100644 --- a/prompt_toolkit/key_binding/bindings/basic.py +++ b/prompt_toolkit/key_binding/bindings/basic.py @@ -175,22 +175,14 @@ def load_basic_bindings(registry, filter=Always()): # Delete the word before the cursor. - @handle(Keys.Up, filter= ~has_selection) + @handle(Keys.Up) def _(event): event.current_buffer.auto_up(count=event.arg) - @handle(Keys.Up, filter=has_selection) - def _(event): - event.current_buffer.cursor_up(count=event.arg) - - @handle(Keys.Down, filter= ~has_selection) + @handle(Keys.Down) def _(event): event.current_buffer.auto_down(count=event.arg) - @handle(Keys.Down, filter=has_selection) - def _(event): - event.current_buffer.cursor_down(count=event.arg) - @handle(Keys.Delete, filter=has_selection) def _(event): data = event.current_buffer.cut_selection() diff --git a/prompt_toolkit/key_binding/bindings/emacs.py b/prompt_toolkit/key_binding/bindings/emacs.py index ba99cbac..48c093d9 100644 --- a/prompt_toolkit/key_binding/bindings/emacs.py +++ b/prompt_toolkit/key_binding/bindings/emacs.py @@ -71,31 +71,21 @@ def load_emacs_bindings(registry, filter=Always()): handle(Keys.Escape, '<', filter= ~has_selection)(get_by_name('beginning-of-history')) handle(Keys.Escape, '>', filter= ~has_selection)(get_by_name('end-of-history')) - @handle(Keys.ControlN, filter= ~has_selection) + @handle(Keys.ControlN) def _(event): " Next line. " event.current_buffer.auto_down() - @handle(Keys.ControlN, filter=has_selection) - def _(event): - " Next line (but don't cycle through history.) " - event.current_buffer.cursor_down() - @handle(Keys.ControlO, filter=insert_mode) def _(event): " Insert newline, but don't move the cursor. " event.current_buffer.insert_text('\n', move_cursor=False) - @handle(Keys.ControlP, filter= ~has_selection) + @handle(Keys.ControlP) def _(event): " Previous line. " event.current_buffer.auto_up(count=event.arg) - @handle(Keys.ControlP, filter=has_selection) - def _(event): - " Previous line. " - event.current_buffer.cursor_up(count=event.arg) - @handle(Keys.ControlQ, Keys.Any, filter= ~has_selection) def _(event): """ |