home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / terms / vt200.el < prev    next >
Encoding:
Text File  |  1990-07-22  |  5.3 KB  |  158 lines

  1. ;From ark1!uakari.primate.wisc.edu!samsung!cs.utexas.edu!uunet!aai!leo Mon May 14 23:31:52 EDT 1990
  2. ;Article 1627 of gnu.emacs:
  3. ;Path: ark1!uakari.primate.wisc.edu!samsung!cs.utexas.edu!uunet!aai!leo
  4. ;From: leo%aai@uunet.uu.net
  5. ;Newsgroups: gnu.emacs
  6. ;Subject: Re: emacs on vt220 terminal
  7. ;Message-ID: <1990May9.021728.4030%aai@uunet.uu.net>
  8. ;Date: 9 May 90 02:17:28 GMT
  9. ;References: <8125@cadillac.CAD.MCC.COM> <KIM.90May7220218@kannel.lut.fi>
  10. ;Organization: Amerinex Artificial Intelligence
  11. ;Lines: 145
  12. ;
  13. ;kim@kannel.lut.fi (Kimmo Suominen) writes:
  14. ;
  15. ;>>>>>> On 7 May 90 13:51:29 GMT, kwan@cadillac.cad.mcc.com said:
  16. ;
  17. ;>Johnny> All other control keys seem to work but I cannot figure out where
  18. ;>Johnny> the Meta key is or how to compose one.
  19. ;
  20. ;>The META key is usually ESC on all terminals.  However, VT200 and VT300
  21. ;>-series terminals don't have ESC (unless you run it in VT52 mode).
  22. ;
  23. ;The escape key is also F11 in vt100 mode, not just vt52 mode.  I use the
  24. ;following in my .emacs file to make the ` key into the escape, and the F11 key
  25. ;into the ` when in vt100 mode:
  26. ;
  27. ;; swap the escape and ` keys when on a vt100 or vt200, enable arrow keys
  28. ;(if (or (equal (getenv "TERM") "vt200")
  29. ;    (equal (getenv "TERM") "vt100"))
  30. ;    (progn
  31. ;       (setq vt200-swap-esc-and-tick t)
  32. ;       (setq term-setup-hook 'enable-arrow-keys)))
  33. ;
  34. ;and here's the vt200.el to go along with it:
  35.  
  36. ;; ...emacs/lisp/term/vt200.el
  37. ;; vt200 series terminal stuff.
  38. ;; April 1985, Joe Kelsey
  39. ;; January 1990, Skip Montanaro - swap ESC and `, add copyright hdr.
  40.  
  41. ;; Copyright (C) 1990 Free Software Foundation, Inc.
  42.  
  43. ;; This file is part of GNU Emacs.
  44.  
  45. ;; GNU Emacs is distributed in the hope that it will be useful,
  46. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  47. ;; accepts responsibility to anyone for the consequences of using it
  48. ;; or for whether it serves any particular purpose or works at all,
  49. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  50. ;; License for full details.
  51.  
  52. ;; Everyone is granted permission to copy, modify and redistribute
  53. ;; GNU Emacs, but only under the conditions described in the
  54. ;; GNU Emacs General Public License.   A copy of this license is
  55. ;; supposed to have been given to you along with GNU Emacs so you
  56. ;; can know your rights and responsibilities.  It should be in a
  57. ;; file named COPYING.  Among other things, the copyright notice
  58. ;; and this notice must be preserved on all copies.
  59.  
  60. (require 'keypad)
  61.  
  62. (defvar vt200-swap-esc-and-tick nil
  63.   "If non-nil, the keyboard translation of the ESC and ` keys are swapped.")
  64.  
  65. (defvar CSI-map nil
  66.   "The CSI-map maps the CSI function keys on the VT200 keyboard.
  67. The CSI keys are the dark function keys, and are only active in
  68. VT200-mode, except for the arrow keys.")
  69.  
  70. (defun enable-arrow-keys ()
  71.   "Enable the use of the VT200 arrow keys and dark function keys.
  72. Because of the nature of the VT200, this unavoidably breaks
  73. the standard Emacs command ESC [; therefore, it is not done by default,
  74. but only if you give this command."
  75.   (interactive)
  76.   (global-set-key "\e[" CSI-map))
  77.  
  78. ;; I suggest that someone establish standard mappings for all of
  79. ;; the VT200 CSI function keys into the function-keymap.
  80.  
  81. (if CSI-map
  82.     nil
  83.   (setq CSI-map (make-keymap))        ; <ESC>[ commands
  84.   (setup-terminal-keymap CSI-map
  85.         '(("A" . ?u)       ; up arrow
  86.           ("B" . ?d)       ; down-arrow
  87.           ("C" . ?r)       ; right-arrow
  88.           ("D" . ?l)       ; left-arrow
  89.           ("1~" . ?f)       ; Find
  90.           ("2~" . ?I)       ; Insert Here
  91.           ("3~" . ?k)       ; Re-move
  92.           ("4~" . ?s)       ; Select
  93.           ("5~" . ?P)       ; Prev Screen
  94.           ("6~" . ?N)       ; Next Screen
  95.           ("17~" . ?\C-f)       ; F6
  96.           ("18~" . ?\C-g)       ; F7
  97.           ("19~" . ?\C-h)       ; F8
  98.           ("20~" . ?\C-i)       ; F9
  99.           ("21~" . ?\C-j)       ; F10
  100.           ("23~" . ESC-prefix) ; F11 (ESC)
  101.           ("24~" . ?\C-l)       ; F12
  102.           ("25~" . ?\C-m)       ; F13
  103.           ("26~" . ?\C-n)       ; F14
  104.           ("31~" . ?\C-q)       ; F17
  105.           ("32~" . ?\C-r)       ; F18
  106.           ("33~" . ?\C-s)       ; F19
  107.           ("34~" . ?\C-t)       ; F20
  108.           ("28~" . ??)       ; Help
  109.           ("29~" . ?x))))       ; Do
  110.  
  111. (defvar SS3-map nil
  112.   "SS3-map maps the SS3 function keys on the VT200 keyboard.
  113. The SS3 keys are the numeric keypad keys in keypad application mode
  114. \(DECKPAM).  SS3 is DEC's name for the sequence <ESC>O which is
  115. the common prefix of what these keys transmit.")
  116.  
  117. (if SS3-map
  118.     nil
  119.   (setq SS3-map (make-keymap))        ; <ESC>O commands
  120.   (setup-terminal-keymap SS3-map
  121.         '(("A" . ?u)       ; up arrow
  122.           ("B" . ?d)       ; down-arrow
  123.           ("C" . ?r)       ; right-arrow
  124.           ("D" . ?l)       ; left-arrow
  125.           ("M" . ?e)       ; Enter
  126.           ("P" . ?\C-a)       ; PF1
  127.           ("Q" . ?\C-b)       ; PF2
  128.           ("R" . ?\C-c)       ; PF3
  129.           ("S" . ?\C-d)       ; PF4
  130.           ("l" . ?,)       ; ,
  131.           ("m" . ?-)       ; -
  132.           ("n" . ?.)       ; .
  133.           ("p" . ?0)       ; 0
  134.           ("q" . ?1)       ; 1
  135.           ("r" . ?2)       ; 2
  136.           ("s" . ?3)       ; 3
  137.           ("t" . ?4)       ; 4
  138.           ("u" . ?5)       ; 5
  139.           ("v" . ?6)       ; 6
  140.           ("w" . ?7)       ; 7
  141.           ("x" . ?8)       ; 8
  142.           ("y" . ?9)))       ; 9
  143.  
  144.      (define-key global-map "\eO" SS3-map))
  145.  
  146. (if vt200-swap-esc-and-tick
  147.   (let ((the-table (make-string 128 0)))
  148.     (let ((i 0))
  149.       (while (< i 128)
  150.     (aset the-table i i)
  151.     (setq i (1+ i))))
  152.     ;; Swap ESC and `
  153.     (aset the-table ?\e ?`)
  154.     (aset the-table ?` ?\e)
  155.     (setq keyboard-translate-table the-table)))
  156. ;-- 
  157. ;Leo    leo@aai.com   leo%aai@uunet.uu.net   ...uunet!aai!leo
  158.