diff options
author | Sebastian Gniazdowski <psprint@zdharma.org> | 2017-06-06 07:07:20 +0200 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2017-06-07 10:01:38 +0100 |
commit | d6d7ef2a0dbf3662eaa132040d2ddfdd7625a3ea (patch) | |
tree | 62f22c9b193a02ffceb1b045559c1931eec8172c | |
parent | 11d2dbda38c1b3cafdb3f91a02134b2807a15c27 (diff) | |
download | zsh-d6d7ef2a0dbf3662eaa132040d2ddfdd7625a3ea.tar.gz zsh-d6d7ef2a0dbf3662eaa132040d2ddfdd7625a3ea.tar.xz zsh-d6d7ef2a0dbf3662eaa132040d2ddfdd7625a3ea.zip |
41232: Use page up/down keys in zed keymap.
Find with terminfo where available.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Functions/Misc/zed | 23 |
2 files changed, 28 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index 634e75f1c..817b1ccbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-06-07 Peter Stephenson <p.stephenson@samsung.com> + + * Sebastian: 41232: Functions/Misc/zed: use terminfo to find + page up/down keys where available. + 2017-06-05 Barton E. Schaefer <schaefer@zsh.org> * 41225: Src/params.c: sethparam() should not attempt to change diff --git a/Functions/Misc/zed b/Functions/Misc/zed index 77d392bc3..33bd1025b 100644 --- a/Functions/Misc/zed +++ b/Functions/Misc/zed @@ -39,6 +39,24 @@ local curcontext=zed::: zstyle -m ":completion:zed:*" insert-tab '*' || zstyle ":completion:zed:*" insert-tab yes +zmodload zsh/terminfo 2>/dev/null + +__zed_pg_up() +{ + integer count=$(( LINES / 2 - 1 )) + while (( count -- )); do + zle up-line + done +} + +__zed_pg_down() +{ + integer count=$(( LINES / 2 - 1 )) + while (( count -- )); do + zle down-line + done +} + if (( bind )) || ! bindkey -M zed >&/dev/null; then # Make the zed keymap a copy of the current main. bindkey -N zed main @@ -54,6 +72,11 @@ if (( bind )) || ! bindkey -M zed >&/dev/null; then bindkey -M zed '^x^w' accept-line bindkey -M zed '^M' self-insert-unmeta + zle -N __zed_pg_up + zle -N __zed_pg_down + [[ ${+terminfo} = 1 && -n "$terminfo[kpp]" ]] && bindkey -M zed "$terminfo[kpp]" __zed_pg_up + [[ ${+terminfo} = 1 && -n "$terminfo[knp]" ]] && bindkey -M zed "$terminfo[knp]" __zed_pg_down + # Make zed-set-file-name available. # Assume it's in fpath; there's no error at this point if it isn't autoload -Uz zed-set-file-name |