From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18936 invoked from network); 13 Dec 2000 05:04:01 -0000 Received: from sunsite.dk (HELO sunsite.auc.dk) (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Dec 2000 05:04:01 -0000 Received: (qmail 23939 invoked by alias); 13 Dec 2000 05:03:50 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3563 Received: (qmail 23932 invoked from network); 13 Dec 2000 05:03:46 -0000 From: "Bart Schaefer" Message-Id: <1001213050341.ZM11148@candle.brasslantern.com> Date: Wed, 13 Dec 2000 05:03:41 +0000 In-Reply-To: Comments: In reply to mason@primenet.com.au (Geoff Wing) "Re: Bindkey + PageUp/PageDown keys" (Dec 12, 1:38am) References: X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.auc.dk Subject: Re: Bindkey + PageUp/PageDown keys MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Dec 12, 1:38am, Geoff Wing wrote: } Subject: Re: Bindkey + PageUp/PageDown keys } } Oliver Grimm typed: } :In xterm, they are called 'Prior', 'Next', etc. but how do I use } :this with bindkey ? } } Your terminal emulator (xterm) will translate the Prior (PageUp) } and Next (PageDown) keys into a character sequence - usually an } escape sequence (i.e. the first character in the sequence is an } escape character). Here's a little something I cobbled together. I've called it "zkbd". It works better as a shell script than as a function, so I suppose if it goes into the distribution it should go under the top-level Misc/ directory rather than in Functions/Misc/. Run "zkbd" and it'll ask you to press a bunch of function and movement keys. It records those sequences in ~/.zkbd/$TERM in the associative array $key (so this requires 3.1.9). I realize that naming the file after $TERM is not quite accurate because e.g. one can use an xterm with with just about any kind of keyboard. On the other hand, the same keyboard can generate different sequences in different terminal emulators. If someone has a better idea for the file naming convention, I'd be happy to hear it. Further, if somebody has one of those Sun keyboards with the 24 extra function keys in left and right banks, and wants to fix this up to work with that as well -- e.g., check that $DISPLAY or $TTY refers to the console, that the hardware is Sun, et cetera, and prompt for the extra keys when so -- that'd be cool too. ---- 8< ---- cut here ---- 8< ---- #! /bin/zsh -f emulate -RL zsh local zkbd term key seq zkbd=${ZDOTDIR:-$HOME}/.zkbd [[ -d $zkbd ]] || mkdir $zkbd || return 1 print 'typeset -A key\n' > $zkbd/$TERM.tmp || return 1 trap "command rm -f $zkbd/$TERM.tmp" 0 1 2 read term"?Enter current terminal type: [$TERM] " [[ -n $term ]] && TERM=$term cat <0; --i)) do read -t -k 1 k && break sleep 1 done [[ -n $k ]] || return 1 [[ $k = $'\012' || $k = $'\015' || $k = ' ' ]] && return 0 seq=$k while read -t -k 1 k do seq=$seq$k done print -R ${(V)seq} } exec 3>/dev/tty for key in F{1..12} Insert Delete Home End PageUp PageDown Up Left Down Right do print -u3 -Rn "Press $key: " seq="$(getseq)" || return 1 print "key{$key}=${(q)seq}" print -u3 done >> $zkbd/$TERM.tmp command mv $zkbd/$TERM.tmp $zkbd/$TERM cat <