[gnu.emacs] 'keypad' interfaces for AT&T 630, AT386, xterm

jbm@attunix.att.com (02/03/89)

I enclose some '.el' files to do the 'keypad'-mechanism virtual
bindings for some AT&T terminal-types: the 630MTG, the 'AT386' 386
console, and the 'xterm' X11 terminal emulator...  these obviously go
in the <emacs-home>/lisp/term directory.

		-Jeff Moore
		 (jbm@attunix.sf.att.com)
		 [and, of course, nobody is responsible for anything, etc.]
---------------------------------------------------------------------
#!/bin/sh
# To unbundle, sh this file
echo 630.el 1>&2
sed 's/.//' >630.el <<'Shar_Eof_630.el'
X;; 'keypad' interface for AT&T 630MTG terminal
X;; Jeff Moore (jbm@attunix.sf.att.com)
X;; 13 Jan 89
X;;
X;; Tested on: GNU Emacs 18.51.50 of Fri Aug 26 1988 on gronk (usg-unix-v)
X;; 
X;; Can be installed linked to names '630.el', '630-24.el'
X;;
X
X(require 'keypad)
X
X(defvar att630-map-1 nil
X  "630MTG keys generating <ESC>[ prefix (most keypad keys)")
X(defvar att630-map-2 nil
X  "630MTG keys generating <ESC>N prefix (some function keys)")
X
X(defun enable-att630-keys ()
X  "Enable the use of the AT&T 630MTG function keys.  Because of the
Xnature of the 630 keyboard, this unavoidably breaks several standard Emacs
Xbindings; therefore, it is not done by default, but only if you give
Xthis command."
X  (interactive)
X  (global-set-key "\e[" att630-map-1)
X  (global-set-key "\eN" att630-map-2))
X
X(if att630-map-1
X    nil
X  (setq att630-map-1 (make-keymap))   ; "<ESC>[" commands
X  (setup-terminal-keymap att630-map-1
X			 '(("A" . ?u)	; Up Arrow (previous-line)
X			   ("B" . ?d)	; Down Arrow (next-line)
X			   ("C" . ?r)	; Right Arrow (forward-char)
X			   ("D" . ?l)	; Left Arrow (backward-char)
X			   ("H" . ?h)	; Home (opinions vary...)
X			   )))
X
X(if att630-map-2
X    nil
X  (setq att630-map-2 (make-keymap))   ; "<ESC>N" commands
X  (setup-terminal-keymap att630-map-2
X			 '(		; F1 - F8 are "soft"
X			   ("o" . ?\C-i) ; F9
X			   ("p" . ?\C-j) ; F10
X			   ("q" . ?\C-k) ; F11
X			   ("r" . ?\C-l) ; F12 (out of range?)
X			   ("s" . ?\C-m) ; F13 (out of range?)
X			   ("t" . ?\C-n)))) ; F14 (out of range?)
Shar_Eof_630.el
echo at386.el 1>&2
sed 's/.//' >at386.el <<'Shar_Eof_at386.el'
X;; 'keypad' interface for the AT&T 386 console (sV/386r3.2)
X;; Jeff Moore (jbm@attunix.sf.att.com)
X;; 13 Jan 89
X;;
X;; Tested on: GNU Emacs 18.51.50 of Fri Aug 26 1988 on gronk (usg-unix-v)
X;;
X;; Can be installed linked to names at386.el, at386-m.el, AT386.el, AT386-M.el
X;; (unless there's a better mechanism for such aliasing)
X;;
X;; Additional 'AT386' family note: they insist on setting the terminfo 'xt'
X;; cap, and emacs takes that to mean the terminal's a Teleray.  Unset 'xt'.
X;;
X;; Also works for some flavors of AT&T xterm;  if true for you (check esp.
X;; arrow keys), link to xterm.el and xterms.el, as well.
X
X(require 'keypad)
X
X(defvar at386-map-1 nil
X  "AT386 keys generating <ESC>[ prefix (most keypad keys)")
X(defvar at386-map-2 nil
X  "AT386 keys generating <ESC>O prefix (function keys)")
X
X(defun enable-at386-keys ()
X  "Enable the use of the AT&T AT386 function keys.  Because of the
Xnature of the AT386 keyboard, this unavoidably breaks several standard Emacs
Xbindings; therefore, it is not done by default, but only if you give
Xthis command."
X  (interactive)
X  (global-set-key "\e[" at386-map-1)
X  (global-set-key "\eO" at386-map-2)
X  ;; Alt-key on 386 becomes Meta (Yah!  Emacs the way God and RMS meant it!)
X  (fset 'esc-prefix esc-map)
X  (define-key esc-map "N" 'esc-prefix))
X
X;;; Set some new/different keypad defaults
X(keypad-default "I" 'overwrite-mode)	; Insert -> toggle insert mode
X(keypad-default "h" 'beginning-of-buffer) ; Home -> home to top
X;for some reason, the 'keypad.el' "h" redefinition won't take without
X;dynamite.  Load order?  Anyway, we'd be exceeding our charter here if we
X;chanced overwriting the user's own definition by directly calling define-key;
X;let's hope s/he's sensible enough to bind "h" to beginning-of-buffer...
X(keypad-default "H" 'end-of-buffer)	; End -> home to bottom
X
X(if at386-map-1
X    nil
X  (setq at386-map-1 (make-keymap))   ; "<ESC>[" commands
X  (setup-terminal-keymap at386-map-1
X			 '(("A" . ?u)	; Up Arrow (previous-line)
X			   ("B" . ?d)	; Down Arrow (next-line)
X			   ("C" . ?r)	; Right Arrow (forward-char)
X			   ("D" . ?l)	; Left Arrow (backward-char)
X			   ("@" . ?I)	; Insert
X			   ("H" . ?h)	; Home (beginning-of-buffer)
X			   ("Y" . ?H)	; End (end-of-buffer)
X			   ("U" . ?N)	; Page Down (scroll-up)
X			   ("V" . ?P)   ; Page Up (scroll-down)
X			   )))
X
X(if at386-map-2
X    nil
X  (setq at386-map-2 (make-keymap))   ; "<ESC>O" commands
X  (setup-terminal-keymap at386-map-2
X			 '(("P" . ?\C-a) ; F1
X			   ("Q" . ?\C-b) ; F2
X			   ("R" . ?\C-c) ; F3
X			   ("S" . ?\C-d) ; F4
X			   ("T" . ?\C-e) ; F5
X			   ("U" . ?\C-f) ; F6
X			   ("V" . ?\C-g) ; F7
X			   ("W" . ?\C-h) ; F8
X			   ("X" . ?\C-i) ; F9
X			   ("Y" . ?\C-j) ; F10
X			   ("Z" . ?\C-k) ; F11
X			   ("A" . ?\C-l)))) ; F12 (out of range?)
Shar_Eof_at386.el
echo xterm.el 1>&2
sed 's/.//' >xterm.el <<'Shar_Eof_xterm.el'
X;; 'keypad' interface for AT&T version of 'xterm' (X11 terminal emulator)
X;; Jeff Moore (jbm@attunix.sf.att.com)
X;; 13 Jan 89
X;;
X;; Tested on: GNU Emacs 18.51.50 of Fri Aug 26 1988 on gronk (usg-unix-v)
X;; 
X;; Can be installed linked to names 'xterm.el', 'xterms.el'
X;; 
X;; Some 'xterm' flavors generate different arrow-key sequences;  'at386.el'
X;; should work for them.
X
X(require 'keypad)
X
X(defvar xterm-map-1 nil
X  "xterm keys generating <ESC>[ prefix (some keypad keys)")
X(defvar xterm-map-2 nil
X  "xterm keys generating <ESC>O prefix (some keypad keys, function keys)")
X
X(defun enable-xterm-keys ()
X  "Enable the use of the AT&T xterm/386 function keys.  Because of the
Xnature of the 386 console, this unavoidably breaks several standard Emacs
Xbindings; therefore, it is not done by default, but only if you give
Xthis command."
X  (interactive)
X  (global-set-key "\e[" xterm-map-1)
X  (global-set-key "\eO" xterm-map-2)
X  ;; Alt-key on 386 becomes Meta (Yah!  Emacs the way God and RMS meant it!)
X  (global-set-key "\eN" esc-map))
X
X;;; Set some new/different keypad defaults
X(keypad-default "I" 'overwrite-mode)	; Insert -> toggle insert mode
X(keypad-default "h" 'beginning-of-buffer) ; Home -> home to top
X;for some reason, the 'keypad.el' "h" redefinition won't take without
X;dynamite.  Load order?  Anyway, we'd be exceeding our charter here if we
X;chanced overwriting the user's own definition by directly calling define-key;
X;let's hope s/he's sensible enough to bind "h" to beginning-of-buffer...
X(keypad-default "H" 'end-of-buffer)	; End -> home to bottom
X
X(if xterm-map-1
X    nil
X  (setq xterm-map-1 (make-keymap))   ; "<ESC>[" commands
X  (setup-terminal-keymap xterm-map-1
X			 '(("H" . ?h)	; Home (beginning-of-buffer)
X			   ("Y" . ?H)	; End (end-of-buffer)
X			   ("U" . ?N)	; Page Down (scroll-up)
X			   ("V" . ?P)   ; Page Up (scroll-down)
X			   ("2~" . ?I)	; Insert
X			   )))
X
X(if xterm-map-2
X    nil
X  (setq xterm-map-2 (make-keymap))   ; "<ESC>O" commands
X  (setup-terminal-keymap xterm-map-2
X			 '(("A" . ?u)	; Up Arrow (previous-line)
X			   ("B" . ?d)	; Down Arrow (next-line)
X			   ("C" . ?r)	; Right Arrow (forward-char)
X			   ("D" . ?l)	; Left Arrow (backward-char)
X			   ("P" . ?\C-a) ; F1
X			   ("Q" . ?\C-b) ; F2
X			   ("R" . ?\C-c) ; F3
X			   ("S" . ?\C-d) ; F4
X			   ("T" . ?\C-e) ; F5
X			   ("U" . ?\C-f) ; F6
X			   ("V" . ?\C-g) ; F7
X			   ("W" . ?\C-h) ; F8
X			   ("X" . ?\C-i) ; F9
X			   ("Y" . ?\C-j) ; F10
X			   ("Z" . ?\C-k) ; F11
X;collides w/Up Arrow(!)    ("A" . ?\C-l) ; F12 (out of range?)
X			   )))
Shar_Eof_xterm.el