joe@fluke.UUCP (Joe Kelsey) (06/07/85)
I am posting the terminal initialization files I use for VT100 and VT200 series terminals. They define two new keymaps: CSI-map and SS3-map. CSI-map maps the <esc>[ control sequences and SS3-map maps the <esc>O sequences (keypad). Also included is doc strings for the auxiliary keypad with my definitions included. Of course, you can and should change these! Also, in order for them to work correctly, you either need send-string-to-terminal or else install the attached patches to TrmVT100 and TrmTERM. In emacs 15.34, TrmVT100 will automatically set the terminal into auxiliary keypad mode. The attached mod merely make it reset aux. keypad mode when we exit. The mod to TrmTERM will use the ks and ke strings to set up and reset the keypad on entry and exit. Be careful about your ks and ke strings. Some that we WERE using set both auxiliary keypad and application cursor keys - the terminal init files assume application keypad, but NORMAL arrows! For VT series terminals the correct entries are: :ks=\E=:ke=\E>: The attached files are term-vt100.el, term-vt200.el, and the diffs for TrmVT100.c and TrmTERM.c. I believe that the changes to the Trm* files are in the current working version of GNU Emacs, so they will appear in version 16. The way to use these files is to set up other term-vtXXX.el files which look like: ;; VT220 initialize entry. Load term-vt200.el (load "term-vt200" t t) (Of course, the term-vt1xx.el files would load term-vt100). Alternatley, you could place real or symbolic links from the appropriate file names to the vt100 or vt200 file, but I find that to be too confusing for multiple machine maintenance. So, now you have a bunch of files like: term-vt220.el,term-vt240.el, term-vt102.el, term-vt132.el, elc. When Emacs starts, it will automatically load these files if your TERM variable matches. Now, in your .emacs file, place the following commands: (if (string-equal (substring (getenv "TERM") 0 3) "vt2") (vt200-init)) (if (string-equal (substring (getenv "TERM") 0 3) "vt1") (vt100-init)) This will call the appropriate init function to set up your keypad commands. /Joe ------------------------------ #!/bin/sh # This is a shar file containing term-vt100.el, term-vt200.el, # TrmTERM.c.diff, and TrmVT100.c.diff. : Run this shell script with "sh" not "csh" PATH=:/bin:/usr/bin:/usr/ucb export PATH all=FALSE if [ $1x = -ax ] then all=TRUE fi echo 'x term-vt100.el' sed 's/^X//' <<'//GO.SYSIN DD *' >term-vt100.el ;; vt100 series terminal stuff. ;; April 1985, Joe Kelsey (defvar CSI-map nil "The CSI-map maps the arrow keys on the VT100 to the obvious definitions: previous-line, next-line, backward-char, forward-char.") (defvar SS3-map nil "SS3-map maps the SS3 function keys on the VT201 keyboard. The SS3 keys are the numeric keypad keys in keypad application mode (DECKPAM). SS3 is the ASCII-8bit character for the 7-bit escape sequence <ESC>O. The functions provided are: ----------------------------------------------------------------- |PF1 |PF2 |PF3 |PF4 | |beginning-of- | | | | |line |end-of-line |isearch-forward|kill-line | |---------------+---------------+---------------+---------------| |7 |8 |9 |- | |forward- |backward- | | | |paragraph |paragraph |kill-region |kill-word | |---------------+---------------+---------------+---------------| |4 |5 |6 |, | | |beginning-of- | | | |end-of-buffer |buffer |yank |delete-char | |---------------+---------------+---------------+---------------| |1 |2 |3 |Enter | | | | | | |forward-word |backward-word |quoted-insert | | |---------------+---------------+---------------| | |0 |. | | | |beginning-of- | | |beginning-of-next-line |previous-line |open-line | -----------------------------------------------------------------") (if (not CSI-map) (progn (setq CSI-map (make-keymap)) ;; <ESC>[ commands (define-key CSI-map "A" 'previous-line) ;; up arrow (define-key CSI-map "B" 'next-line) ;; down-arrow (define-key CSI-map "C" 'forward-char) ;; right-arrow (define-key CSI-map "D" 'backward-char) ;; left-arrow (setq SS3-map (make-keymap)) ;; <ESC>O commands (define-key SS3-map "M" 'open-line) ;; Enter (define-key SS3-map "P" 'beginning-of-line) ;; PF1 (define-key SS3-map "Q" 'end-of-line) ;; PF2 (define-key SS3-map "R" 'isearch-forward) ;; PF3 (define-key SS3-map "S" 'kill-line) ;; PF4 (define-key SS3-map "l" 'delete-char) ;; , (define-key SS3-map "m" 'kill-word) ;; - (define-key SS3-map "n" 'beginning-of-previous-line) ;; . (define-key SS3-map "p" 'beginning-of-next-line) ;; 0 (define-key SS3-map "q" 'forward-word) ;; 1 (define-key SS3-map "r" 'backward-word) ;; 2 (define-key SS3-map "s" 'quoted-insert) ;; 3 (define-key SS3-map "t" 'end-of-buffer) ;; 4 (define-key SS3-map "u" 'beginning-of-buffer) ;; 5 (define-key SS3-map "v" 'yank) ;; 6 (define-key SS3-map "w" 'forward-paragraph) ;; 7 (define-key SS3-map "x" 'backward-paragraph) ;; 8 (define-key SS3-map "y" 'kill-region) ;; 9 )) (defun vt100-init () "Initialize vt100 series terminals to use alternate keymaps." (interactive) (define-key global-map "\eO" SS3-map) (define-key global-map "\e[" CSI-map)) //GO.SYSIN DD * made=TRUE if [ $made = TRUE ] then /bin/chmod 644 term-vt100.el echo -n ' '; /bin/ls -ld term-vt100.el fi echo 'x term-vt200.el' sed 's/^X//' <<'//GO.SYSIN DD *' >term-vt200.el ;; vt200 series terminal stuff. ;; April 1985, Joe Kelsey (defvar CSI-map nil "The CSI-map maps the CSI function keys on the VT201 keyboard. The CSI keys are the dark function keys, and are only active in VT200-mode, except for the arrow keys. The functions provided are: Arrows: The obvious definitions: backward-char, next-line, forward-char, previous-line. Editing Keys: Find re-search-forward Insert Here open-line Remove kill-region Select set-mark-command Prev Screen scroll-up Next Screen scroll-down Top row keys: F11 ESC-prefix Help help-command Do eval-expression You can bind other function keys by doing: (define-key CSI-map \"<key>\" '<function>) where <key> is the function key with the CSI (<ESC>[) stripped off and <function> is the name of the function to map the key to.") (defvar SS3-map nil "SS3-map maps the SS3 function keys on the VT201 keyboard. The SS3 keys are the numeric keypad keys in keypad application mode (DECKPAM). SS3 is the ASCII-8bit character for the 7-bit escape sequence <ESC>O. The functions provided are: ----------------------------------------------------------------- |PF1 |PF2 |PF3 |PF4 | |beginning-of- | | | | |line |end-of-line |isearch-forward|kill-line | |---------------+---------------+---------------+---------------| |7 |8 |9 |- | |forward- |backward- | | | |paragraph |paragraph |kill-region |kill-word | |---------------+---------------+---------------+---------------| |4 |5 |6 |, | | |beginning-of- | | | |end-of-buffer |buffer |yank |delete-char | |---------------+---------------+---------------+---------------| |1 |2 |3 |Enter | | | | | | |forward-word |backward-word |quoted-insert | | |---------------+---------------+---------------| | |0 |. | | | |beginning-of- | | |beginning-of-next-line |previous-line |open-line | -----------------------------------------------------------------") (if (not CSI-map) (progn (setq CSI-map (make-keymap)) ;; <ESC>[ commands (define-key CSI-map "A" 'previous-line) ;; up arrow (define-key CSI-map "B" 'next-line) ;; down-arrow (define-key CSI-map "C" 'forward-char) ;; right-arrow (define-key CSI-map "D" 'backward-char) ;; left-arrow (define-key CSI-map "1~" 're-search-forward) ;; Find (define-key CSI-map "2~" 'open-line) ;; Insert Here (define-key CSI-map "3~" 'kill-region) ;; Re-move (define-key CSI-map "4~" 'set-mark-command) ;; Select (define-key CSI-map "5~" 'scroll-down) ;; Prev Screen (define-key CSI-map "6~" 'scroll-up) ;; Next Screen (define-key CSI-map "23~" 'ESC-prefix) ;; F11 (ESC) (define-key CSI-map "28~" 'help-command) ;; Help (define-key CSI-map "29~" 'eval-expression) ;; Do (setq SS3-map (make-keymap)) ;; <ESC>O commands (define-key SS3-map "M" 'open-line) ;; Enter (define-key SS3-map "P" 'beginning-of-line) ;; PF1 (define-key SS3-map "Q" 'end-of-line) ;; PF2 (define-key SS3-map "R" 'isearch-forward) ;; PF3 (define-key SS3-map "S" 'kill-line) ;; PF4 (define-key SS3-map "l" 'delete-char) ;; , (define-key SS3-map "m" 'kill-word) ;; - (define-key SS3-map "n" 'beginning-of-previous-line) ;; . (define-key SS3-map "p" 'beginning-of-next-line) ;; 0 (define-key SS3-map "q" 'forward-word) ;; 1 (define-key SS3-map "r" 'backward-word) ;; 2 (define-key SS3-map "s" 'quoted-insert) ;; 3 (define-key SS3-map "t" 'end-of-buffer) ;; 4 (define-key SS3-map "u" 'beginning-of-buffer) ;; 5 (define-key SS3-map "v" 'yank) ;; 6 (define-key SS3-map "w" 'forward-paragraph) ;; 7 (define-key SS3-map "x" 'backward-paragraph) ;; 8 (define-key SS3-map "y" 'kill-region) ;; 9 )) (defun vt200-init () "Initialize vt200 series terminals to use alternate keymaps." (interactive) (define-key global-map "\eO" SS3-map) (define-key global-map "\e[" CSI-map)) //GO.SYSIN DD * made=TRUE if [ $made = TRUE ] then /bin/chmod 644 term-vt200.el echo -n ' '; /bin/ls -ld term-vt200.el fi echo 'x TrmTERM.c.diff' sed 's/^X//' <<'//GO.SYSIN DD *' >TrmTERM.c.diff *** /tmp/,RCSt1017551 Thu Jun 6 13:30:38 1985 --- TrmTERM.c Wed May 15 20:09:17 1985 *************** *** 59,64 *ICstr, /* insert character */ *IMstr, /* begin insert mode */ *IPstr, /* insert character pad */ *SEstr, /* end standout mode */ *SOstr, /* begin standout mode */ *TEstr, /* end cursor motion (editor) mode */ --- 59,66 ----- *ICstr, /* insert character */ *IMstr, /* begin insert mode */ *IPstr, /* insert character pad */ + *KEstr, /* end keypad mode */ + *KSstr, /* begin keypad mode */ *SEstr, /* end standout mode */ *SOstr, /* begin standout mode */ *TEstr, /* end cursor motion (editor) mode */ *************** *** 415,420 tputs (TIstr, 1, cmputc); if (VSstr) tputs (VSstr, 1, cmputc); losecursor (); wipescreen (); } --- 417,424 ----- tputs (TIstr, 1, cmputc); if (VSstr) tputs (VSstr, 1, cmputc); + if (KSstr) + tputs (KSstr, 1, cmputc); losecursor (); wipescreen (); } *************** *** 424,429 { setHL (1); setIM (1); if (VEstr) tputs (VEstr, 1, cmputc); if (TEstr) --- 428,435 ----- { setHL (1); setIM (1); + if (KEstr) + tputs (KEstr, 1, cmputc); if (VEstr) tputs (VEstr, 1, cmputc); if (TEstr) *************** *** 540,545 "ic", &ICstr, "im", &IMstr, "ip", &IPstr, "le", &LEstr, "ll", &LastLine, "nd", &Right, --- 546,553 ----- "ic", &ICstr, "im", &IMstr, "ip", &IPstr, + "ke", &KEstr, + "ks", &KSstr, "le", &LEstr, "ll", &LastLine, "nd", &Right, //GO.SYSIN DD * made=TRUE if [ $made = TRUE ] then /bin/chmod 644 TrmTERM.c.diff echo -n ' '; /bin/ls -ld TrmTERM.c.diff fi echo 'x TrmVT100.c.diff' sed 's/^X//' <<'//GO.SYSIN DD *' >TrmVT100.c.diff *** /tmp/,RCSt1017556 Thu Jun 6 13:31:11 1985 --- TrmVT100.c Wed May 15 20:09:36 1985 *************** *** 165,170 static cleanup () { HLmode (0); } --- 165,172 ----- static cleanup () { + /* num kpd */ + printf ("\033>"); HLmode (0); } //GO.SYSIN DD * made=TRUE if [ $made = TRUE ] then /bin/chmod 644 TrmVT100.c.diff echo -n ' '; /bin/ls -ld TrmVT100.c.diff fi