[comp.unix.wizards] Ksh cursor keys

jv@mhres.mh.nl (Johan Vromans) (05/27/88)

Okay fellows, ksh is wonderfull. One of its most powerfull features is
command line editing. You can use your familiar editor-style to edit them.

But WHY does ksh not allow cursor (=arrow) keys to be used? Vi does. Emacs
does. Even VMS does it.

-- 
Johan Vromans                              | jv@mh.nl via European backbone
Multihouse N.V., Gouda, the Netherlands    | uucp: ..{uunet!}mcvax!mh.nl!jv
"It is better to light a candle than to curse the darkness"

lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) (05/29/88)

In article <1887@mhres.mh.nl>, jv@mhres.mh.nl (Johan Vromans) writes:
> But WHY does ksh not allow cursor (=arrow) keys to be used? Vi does. Emacs
> does. Even VMS does it.
> Johan Vromans                              | jv@mh.nl via European backbone

I think there are at least two reasons for this, one - ksh is a big
program and adding in the terminfo/termcap functions to implement the
arrow keys would make it too big for some machines (even with only
one of the command line editors compiled in), two - Korn wanted to
make ksh independent of terminfo/termcap to reduce portability and
debugging problems.

I know of one person that changed ksh to implement this capability,
so it is possible.  Why is this such a desirable feature?  Just curious.

-- 
Larry Cipriani, AT&T Network Systems and Ohio State University
Domain: lvc@tut.cis.ohio-state.edu
Path: ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!lvc (weird but right)

gwyn@brl-smoke.ARPA (Doug Gwyn ) (05/29/88)

In article <1887@mhres.mh.nl> jv@mhres.mh.nl (Johan Vromans) writes:
>But WHY does ksh not allow cursor (=arrow) keys to be used?

Different terminal transmit different sequences when an arrow key is
pressed.  Assuming that ksh allows user-specified editing key bindings,
as the BRL Bourne shell does, you CAN use arrow keys.

#	.shbind -- source to bind history/editing keypad keys
# following to support ANSI terminal keypads (e.g. VT100):

bind prefix-2 '^[O'
bind prefix-2 '^[['

bind up-history '^XA'
bind down-history '^XB'
bind forward-char '^XC'
bind backward-char '^XD'
bind beginning-of-line '^XH'

stan@sdba.UUCP (Stan Brown) (05/31/88)

> 
> Okay fellows, ksh is wonderfull. One of its most powerfull features is
> command line editing. You can use your familiar editor-style to edit them.
> 
> But WHY does ksh not allow cursor (=arrow) keys to be used? Vi does. Emacs
> does. Even VMS does it.
> 
> -- 
> Johan Vromans                              | jv@mh.nl via European backbone
> Multihouse N.V., Gouda, the Netherlands    | uucp: ..{uunet!}mcvax!mh.nl!jv
> "It is better to light a candle than to curse the darkness"

	vi does not always allow use of the arrow keys.  For example
	on Fortune termials they send [Escape]]]letter][Cr]  this
	causes  it to pitch fits .

	stan



-- 
Stan Brown	S. D. Brown & Associates	404-292-9497
(uunet gatech)!sdba!stan				"vi forever"

daveh@marob.MASA.COM (Dave Hammond) (06/01/88)

In article <1887@mhres.mh.nl> jv@mhres.mh.nl (Johan Vromans) writes:
>
>Okay fellows, ksh is wonderfull. One of its most powerfull features is
>command line editing. You can use your familiar editor-style to edit them.
>
>But WHY does ksh not allow cursor (=arrow) keys to be used? Vi does. Emacs
>does. Even VMS does it.

Ksh does not make use of any terminal-independent characteristics, such as
cursor-keys. External editors are emulated using only newlines, returns
and spaces to modify the edit line. Making use of cursor-keys also requires
parsing multiple character sequences which would add some overhead.


Dave Hammond
UUCP:   ...!marob!daveh
--------------------------------

jv@mhres.mh.nl (Johan Vromans) (06/02/88)

From article <284@marob.MASA.COM>, by daveh@marob.MASA.COM (Dave Hammond):
> In article <1887@mhres.mh.nl> jv@mhres.mh.nl (Johan Vromans) writes:
>>But WHY does ksh not allow cursor (=arrow) keys to be used?
> 
> Ksh does not make use of any terminal-independent characteristics, such as
> cursor-keys. External editors are emulated using only newlines, returns
> and spaces to modify the edit line. 

This is oversimplification. About 50 vi and emacs editing commands are 
emulated.

>                                     Making use of cursor-keys also requires
> parsing multiple character sequences which would add some overhead.

Sequences like ESC-d (delete-word), ESC-f (forward-word) etc. are
handled, as are ESC-* (filename generation) and ESC-= (file list).
Adding some overhead to break the misnotion that Unix is user-unfriendly
pays.
-- 
Johan Vromans                              | jv@mh.nl via European backbone
Multihouse N.V., Gouda, the Netherlands    | uucp: ..{uunet!}mcvax!mh.nl!jv
"It is better to light a candle than to curse the darkness"

rbj@icst-cmr.arpa (Root Boy Jim) (06/03/88)

   > Okay fellows, ksh is wonderfull. One of its most powerfull features is
   > command line editing. You can use your familiar editor-style to edit them.
   > 
   > But WHY does ksh not allow cursor (=arrow) keys to be used? Vi does. Emacs
   > does. Even VMS does it.
   > 
   > Johan Vromans                             | jv@mh.nl via European backbone
   > Multihouse N.V., Gouda, the Netherlands   | uucp: ..{uunet!}mcvax!mh.nl!jv
   > "It is better to light a candle than to curse the darkness"

Arrow and function keys are for wimps. Real programmers use control keys.

	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
	The opinions expressed are solely my own
	and do not reflect NBS policy or agreement
	My name is in /usr/dict/words. Is yours?

gwyn@brl-smoke.ARPA (Doug Gwyn ) (06/04/88)

In article <15850@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes:
-> But WHY does ksh not allow cursor (=arrow) keys to be used? Vi does. Emacs
-> does. Even VMS does it.
-Arrow and function keys are for wimps. Real programmers use control keys.

A lot of us use mice for this.

jgy@hropus.UUCP (John Young) (06/05/88)

For those of you discussing the use of arrow keys in ksh the
answer is you can use them.  Sometimes.

One of my terminals is an HP2626x, these arrow keys send escape-D, C,
A, and B for left, right, up and down respectivley.  Therefore in
ksh, if you use the emacs editing style (probably in vi to) you can
say the following:
	$ alias _D=^b
	$ alias _C=^f
	$ alias _A=^p
	$ alias _D=^n

Where ^ means the control key (with a \ in front).
People whose terminals don't send ESCAPE-X are in trouble, as are
those whose "X" characters happen to coincide with already used
emacs editing mode esacape sequences.

ksh documentaion calls these _ aliases soft-keys and they can be quite
usefull:  Try this one:

	$ alias _r='^] ^[ ^] ^X^X^W^Y^E^Y'

p.s.
If none of these work it's because you typed them incorrectly(or I did!)
or you are using a ksh version earler than 6/3/86.

John Young
AT&T-BL
Red Hill Rd.,
Middletown, NJ 07748
201-615-4412