Skip to content

Commit

Permalink
Be smarter about setting terminal keypad mode
Browse files Browse the repository at this point in the history
Fixes issue #273.
  • Loading branch information
marlonrichert committed May 27, 2021
1 parent a19e847 commit e8563df
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions module/.autocomplete.key
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,28 @@ zmodload -Fa zsh/terminfo b:echoti p:terminfo
builtin autoload -Uz add-zle-hook-widget

.autocomplete.key.precmd() {
if [[ -v terminfo[rmkx] ]]; then
.autocomplete.key.normal-mode() {
echoti rmkx
return 0
}
add-zle-hook-widget line-init .autocomplete.key.normal-mode
fi
.autocomplete.key.set-keypad-mode() {
echoti ${${${key[Up]:#$terminfo[kcuu1]}:+rmkx}:-smkx} 2> /dev/null
return 0
}
add-zle-hook-widget line-init .autocomplete.key.set-keypad-mode
}

if [[ ${(t)key} != association ]]; then
unset key
typeset -gA key=()
fi

key+=(
Control-Space $'\0'
Tab $'\t'
Return $'\r'
Escape $'\e'
Up $'\e[A'
Down $'\e[B'
Right $'\e[C'
Left $'\e[D'
End $'\e[F'
Home $'\e[H'
Shift-Tab $'\e[Z'
PageUp $'\e[5~'
PageDown $'\e[6~'
)
: ${key[Control-Space]:=$'\0'}
: ${key[Tab]:=$'\t'}
: ${key[Return]:=$'\r'}
: ${key[Escape]:=$'\e'}
: ${key[Up]:=$'\e[A'}
: ${key[Down]:=$'\e[B'}
: ${key[Right]:=$'\e[C'}
: ${key[Left]:=$'\e[D'}
: ${key[End]:=$'\e[F'}
: ${key[Home]:=$'\e[H'}
: ${key[Shift-Tab]:=$'\e[Z'}
: ${key[PageUp]:=$'\e[5~'}
: ${key[PageDown]:=$'\e[6~'}

0 comments on commit e8563df

Please sign in to comment.