Subject: Re: CVS commit: basesrc/bin/ksh
To: NetBSD Userlevel Technical Discussion List <firstname.lastname@example.org>
From: Matthias Buelow <email@example.com>
Date: 09/28/2002 22:15:56
Greg A. Woods writes:
>I don't have the full X3.64 spec., but I do know that the cursor keys in
>ANSI mode are expected to generate <ESC>[A and so on. The <HOME> key is
>well defined too as <ESC>[H, but indeed I'm unsure of the <END> key.
Well, we have termcap/info of course.
If one really wanted to get the strings returned by those special keys,
he could use tput(1), like: foo=`tput k1` will set the variable foo to
the string that the key labelled "F1" or "PF1" sends to the system.
Add additional logic for the case that the capabilities don't have the
special key you want (not all terminals have arrow keys, for example),
perhaps defaulting to the ANSI sequences just as a fallback in that
Having never used pdksh's keybinding facilities, I don't know if it's
easy enough to bind functions to the string stored in a variable but
I guess it's not hard.
One disadvantage is that tput(1) is a fairly recent addition and might
not be available in older systems (4.3BSD etc.).
But in that case you can also fallback to some predefined values, or
just use the keys that will work on about all terminals: Ctrl+<key>
for emacs-mode, hjkl and friends for vi-mode. IMHO it doesn't really
pay off to bother about binding functions to special keys anyways.