diff options
author | Bart Schaefer <barts@users.sourceforge.net> | 2007-02-26 07:44:10 +0000 |
---|---|---|
committer | Bart Schaefer <barts@users.sourceforge.net> | 2007-02-26 07:44:10 +0000 |
commit | ac8ccbfc82472fd35143ea53fd099607de7e9c06 (patch) | |
tree | 3d92fb21ab5bb08f95b7ba7cf6eb9c79733566dd /Functions/Misc/zkbd | |
parent | 236d910fb396c76ec351889261c29277af918a2b (diff) | |
download | zsh-ac8ccbfc82472fd35143ea53fd099607de7e9c06.tar.gz zsh-ac8ccbfc82472fd35143ea53fd099607de7e9c06.tar.xz zsh-ac8ccbfc82472fd35143ea53fd099607de7e9c06.zip |
unposted: tweak for possible multibyte characters.
Diffstat (limited to 'Functions/Misc/zkbd')
-rw-r--r-- | Functions/Misc/zkbd | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Functions/Misc/zkbd b/Functions/Misc/zkbd index 30cb4a248..6b7959979 100644 --- a/Functions/Misc/zkbd +++ b/Functions/Misc/zkbd @@ -15,10 +15,10 @@ zkbd=${ZDOTDIR:-$HOME}/.zkbd [[ -d $zkbd ]] || mkdir $zkbd || return 1 print 'typeset -g -A key\n' > $zkbd/$TERM.tmp || return 1 -trap "unfunction getkey getseq; command rm -f $zkbd/$TERM.tmp" 0 +trap "unfunction getmbkey getseq; command rm -f $zkbd/$TERM.tmp" 0 trap "return 1" 1 2 15 -getkey () { +getmbkey () { local k='' i for ((i=10; i>0; --i)) do @@ -27,7 +27,13 @@ getkey () { done [[ -n $k ]] || return 1 [[ $k = $'\012' || $k = $'\015' || $k = ' ' ]] && return 0 - print -Rn $k + # We might not be done yet, thanks to multibyte characters + local mbk=$k + while read -t -k 1 k + do + mbk=$mbk$k + done + print -Rn $mbk } getseq () { @@ -65,7 +71,7 @@ EOF local ctrl alt meta print -n "Hold down Ctrl and press X: " -ctrl=$(getkey) || return 1 +ctrl=$(getmbkey) || return 1 print if [[ $ctrl != $'\030' ]] @@ -79,7 +85,7 @@ fi print "Your Meta key may have a Microsoft Windows logo on the cap." print -n "Hold down Meta and press X: " -meta=$(getkey) || return 1 +meta=$(getmbkey) || return 1 print if [[ $meta == x ]] @@ -95,7 +101,7 @@ fi print print -n "Hold down Alt and press X: " -alt=$(getkey) || return 1 +alt=$(getmbkey) || return 1 print if [[ $alt == x ]] |