[comp.emacs] vt100 cursor keys

Geoffm@AFSC-HQ.ARPA.UUCP (02/07/87)

Does GNU Emacs support vt100 cursor keys and if so how?

	geoff
-------

merlin@hqda-ai.UUCP (02/07/87)

In article <8702070041.AA09816@EDDIE.MIT.EDU>, Geoffm@AFSC-HQ.ARPA (Geoff Mulligan, USAFA) writes:
> Does GNU Emacs support vt100 cursor keys and if so how?
> 

     Terminal arrow keys are supported in v18.  On startup, GNU
consults the environment for the terminal type.  It then looks in
the lisp library directories for the file "term/vt100.el", or the
.elc compiled version.

     This file defines several keymaps, which are used to map the
key functions.  The vt100 key sequences all start with ESC-[,
which is a legitimate emacs command.  For this reason, although
the arrow keymaps are defined, they are not activated.  To turn
them on, give the command

     M-x enable-arrow-keys


-- 
	David S. Hayes, The Merlin of Avalon
	PhoneNet:	(202) 694-6900
	ARPA:		merlin%hqda-ai.uucp@smoke.brl.mil
	UUCP:		...!seismo!sundc!hqda-ai!merlin

earleh@dartvax.UUCP (02/08/87)

In article <265@hqda-ai.UUCP>, merlin@hqda-ai.UUCP (David S. Hayes) writes:

> key functions.  The vt100 key sequences all start with ESC-[,

     Sorry to be picky, but some of them start with ESC-O.  This seems to
depend on whether the terminal is in "ANSI" mode or "VT100" mode.  (That's
an "Oh", not a "zero".)  I am no expert on the subject, but I think the
sequence usually used by editors to "turn on" the keypad ("\E=") puts it
in ANSI mode, and then the sequences all start with ESC-O.

maddox@ernie.Berkeley.EDU.UUCP (02/10/87)

In article <5659@dartvax.UUCP> earleh@dartvax.UUCP (Earle R. Horton) writes:
>     Sorry to be picky, but some of them start with ESC-O.  This seems to
>depend on whether the terminal is in "ANSI" mode or "VT100" mode.  (That's
>an "Oh", not a "zero".)
Uh, the VT100 has two modes:  ANSI and VT52.  The ANSI mode is the one with
all the cute VT100 functions.  (I'm at the moment using a VT100 emulator I
wrote in FORTH that does just fine.)  The various codes are like \EOA, \EOB,
\EOC, \EOD for up, down, left, and right respectively (if memory serves me).
I am using gnumacs at the moment, but haven't the expertise to bind the M-O
keys do to things...
								Carl

/----------------------------------v------------------------------------------\
| Carl Greenberg, guest here       | "I have a very firm grasp on reality!  I |
| ARPA:  maddox@ernie.berkeley.edu | can reach out and strangle it any time I |
| UUCP: ...ucbvax!ucbernie!maddox  | want!"                         - Me      |
\----------------------------------^------------------------------------------/

gudeman@arizona.UUCP (02/10/87)

   From: earleh@dartvax.UUCP (Earle R. Horton)
   Date: 8 Feb 87 17:25:50 GMT

   In article <265@hqda-ai.UUCP>, merlin@hqda-ai.UUCP (David S. Hayes) writes:

   > key functions.  The vt100 key sequences all start with ESC-[,

	Sorry to be picky, but some of them start with ESC-O.  This seems to
   depend on whether the terminal is in "ANSI" mode or "VT100" mode.  (That's
   an "Oh", not a "zero".)  I am no expert on the subject, but I think the
   sequence usually used by editors to "turn on" the keypad ("\E=") puts it
   in ANSI mode, and then the sequences all start with ESC-O.

This is the case for wy75 terminals, which claim to be vt100
compatible, so it may work for vt100's.  Put "ks=\E[?1h\E=" in your
termcap.  The "ks" entry is for keypad start, "\E[?1h" makes the arrow
keys send "ESC O" sequences instead of "ESC [", and "\E=" makes the
keypad send "ESC O" sequences.

Also, every once in a while, the "ESC O" sequence gets changed to
"ESC G" somehow (every 100 times or so), so you should bind both to
the same keymap.  Here is part of my file "keypad.el", which is loaded
from my ".emacs".  To find out the code associated with a keypad key,
type "^Q" followed by the key.

(defvar ESC-O-keymap (make-keymap) "Keymap for arrow and keypad keys")
(global-set-key "\eO" ESC-O-keymap)
(global-set-key "\eG" ESC-O-keymap) ; sometimes sent as prefix for keypad
				     ; keys, probably a transmission error.

(define-key ESC-O-keymap "D" 'backward-char)		; <-
(define-key ESC-O-keymap "C" 'forward-char)		; ->
(define-key ESC-O-keymap "A" 'previous-line)		; up-arrow
(define-key ESC-O-keymap "B" 'next-line)		; dn-arrow
(define-key ESC-O-keymap "H" 'home)			; Home
(fset 'home "[0") ; home goes to the beginning of the current
			;  paragraph and puts that line at the top of
			;  the window.

(define-key ESC-O-keymap "l" 'scroll-down)		; KPD-,
(define-key ESC-O-keymap "M" 'scroll-up)		; Enter
(define-key ESC-O-keymap "n" 'move-to-window-line)	; KPD-.