530
|
1 ;;; Terminal support for the Televideo 970.
|
|
2 ;;; Jim Blandy <jimb@occs.cs.oberlin.edu>, January 1992
|
|
3
|
|
4
|
|
5 ;;; Define the escape codes sent by the function keys.
|
|
6 (or (lookup-key function-key-map "\e[")
|
|
7 (define-key function-key-map "\e[" (make-keymap)))
|
|
8 (or (lookup-key function-key-map "\eO")
|
|
9 (define-key function-key-map "\eO" (make-keymap)))
|
|
10
|
|
11 ;; Miscellaneous keys
|
|
12 (mapcar (function (lambda (key-binding)
|
|
13 (define-key function-key-map
|
|
14 (car key-binding) (nth 1 key-binding))))
|
|
15 '(("\e[H" [home])
|
|
16 ("\e[Z" [backtab])
|
|
17 ("\e[i" [print])
|
|
18 ("\e[2J" [clear])
|
|
19 ("\e[@" [insert])
|
|
20 ("\e[P" [delete])
|
|
21 ("\e[L" [insertline])
|
|
22 ("\e[M" [deleteline])
|
|
23 ("\e[K" [eraseline])
|
|
24 ("\e[J" [erasepage])
|
|
25 ("\e[U" [page])
|
|
26 ("\e[g" [S-tab])
|
|
27 ("\e[2N" [clearentry])
|
|
28 ("\e[2K" [S-clearentry])
|
|
29 ("\e[E" [?\C-j])
|
|
30 ("\e[g" [S-backtab])
|
|
31 ("\e[?1i" [S-print])
|
|
32 ("\e[4h" [S-insert])
|
|
33 ("\e[4l" [S-delete])
|
|
34 ("\e[Q" [S-insertline])
|
|
35 ("\e[1Q" [S-deleteline])
|
|
36 ("\e[19l" [S-eraseline])
|
|
37 ("\e[19h" [S-erasepage])
|
|
38 ("\e[V" [S-page])
|
|
39 ("\eS" [send])
|
|
40 ("\e5" [S-send])
|
|
41 ("\eOm" [kp-subtract])
|
|
42 ("\eOl" [kp-separator])
|
|
43 ("\eOn" [kp-decimal])
|
|
44 ("\eOM" [enter])
|
|
45 ("\eOP" [kp-f1])
|
|
46 ("\eOQ" [kp-f2])
|
|
47 ("\eOR" [kp-f3])
|
|
48 ("\eOS" [kp-f4])))
|
|
49 ;; The numeric keypad keys.
|
|
50 (let ((i 0))
|
|
51 (while (< i 10)
|
|
52 (define-key function-key-map
|
|
53 (format "\eO%c" (+ i ?p))
|
|
54 (vector (intern (format "kp-%d" i))))
|
|
55 (setq i (1+ i))))
|
|
56 ;; The numbered function keys.
|
|
57 (let ((i 0))
|
|
58 (while (< i 16)
|
|
59 (define-key function-key-map
|
|
60 (format "\e?%c" (+ i ?a))
|
|
61 (vector (intern (format "f%d" (1+ i)))))
|
|
62 (define-key function-key-map
|
|
63 (format "\e?%c" (+ i ?A))
|
|
64 (vector (intern (format "S-f%d" (1+ i)))))
|
|
65 (setq i (1+ i))))
|
|
66
|
|
67
|
|
68 ;;; Should keypad numbers send ordinary digits or distinct escape sequences?
|
|
69 (defvar tvi970-keypad-numeric nil
|
|
70 "The terminal should be in numeric keypad mode iff this variable is non-nil.
|
|
71 Do not set this variable! Call the function ``tvi970-set-keypad-mode''.")
|
|
72
|
|
73 (defun tvi970-set-keypad-mode (&optional arg)
|
|
74 "Set the current mode of the TVI 970 numeric keypad.
|
|
75 In ``numeric keypad mode'', the number keys on the keypad act as
|
|
76 ordinary digits. In ``alternate keypad mode'', the keys send distinct
|
|
77 escape sequences, meaning that they can have their own bindings,
|
|
78 independent of the normal number keys.
|
|
79 With no argument, toggle between the two possible modes.
|
|
80 With a positive argument, select alternate keypad mode.
|
|
81 With a negative argument, select numeric keypad mode."
|
|
82 (interactive "P")
|
|
83 (setq tvi970-keypad-numeric
|
|
84 (if (null arg)
|
|
85 (not tvi970-keypad-numeric)
|
|
86 (> (prefix-numeric-value arg) 0)))
|
|
87 (send-string-to-terminal (if tvi970-keypad-numeric "\e=" "\e>")))
|
|
88
|
|
89 (tvi970-set-keypad-mode 1)
|