zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Make zed understand page-up/down keys
@ 2017-06-06  5:07 Sebastian Gniazdowski
  0 siblings, 0 replies; only message in thread
From: Sebastian Gniazdowski @ 2017-06-06  5:07 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 483 bytes --]

Hello
Page up/down keys are currently bound to {beginning,end}-of-history. The keys are needed when editing multi-page functions. Currently, going few blocks up requires to hold up-cursor and wait. Pressing page up/down adds to the discomfort, in effect single history line is shown.

I've adapted number of lines jumped (LINES/2-1) so that user doesn't get lost (I think zle often centers view, jumping whole page doesn't feel OK).

--
Sebastian Gniazdowski
psprint /at/ zdharma.org

[-- Attachment #2: zed_pgud.diff --]
[-- Type: application/octet-stream, Size: 1229 bytes --]

diff --git a/Functions/Misc/zed b/Functions/Misc/zed
index 77d392b..33bd102 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-06  5:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-06  5:07 [PATCH] Make zed understand page-up/down keys Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).