]> code.delx.au - gnu-emacs/blob - lisp/term/tvi970.el
(font-lock-keywords): Add defvar.
[gnu-emacs] / lisp / term / tvi970.el
1 ;;; tvi970.el --- terminal support for the Televideo 970
2
3 ;; Author: Jim Blandy <jimb@occs.cs.oberlin.edu>, January 1992
4 ;; Keywords: terminals
5
6 ;; Copyright (C) 1992, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24
25 ;;; Commentary:
26
27 ;; Uses the Emacs 19 terminal initialization features --- won't work with 18.
28
29 ;;; Code:
30
31 (defun terminal-init-tvi970 ()
32 "Terminal initialization function for tvi970."
33 (or (lookup-key function-key-map "\e[")
34 (define-key function-key-map "\e[" (make-keymap)))
35 ;; (or (lookup-key function-key-map "\eO")
36 ;; (define-key function-key-map "\eO" (make-keymap)))
37
38 ;; Miscellaneous keys
39 (mapcar (function (lambda (key-binding)
40 (define-key function-key-map
41 (car key-binding) (nth 1 key-binding))))
42 '(
43 ;; These are set up by termcap or terminfo
44 ;; ("\eOP" [kp-f1])
45 ;; ("\eOQ" [kp-f2])
46 ;; ("\eOR" [kp-f3])
47 ;; ("\eOS" [kp-f4])
48
49 ;; These might br set by terminfo
50 ("\e[H" [home])
51 ("\e[Z" [backtab])
52 ("\e[i" [print])
53 ("\e[@" [insert])
54 ("\e[L" [insertline])
55 ("\e[M" [deleteline])
56 ("\e[U" [next]) ;; actually the `page' key
57
58 ;; These won't be set up by either
59 ("\eOm" [kp-subtract])
60 ("\eOl" [kp-separator])
61 ("\eOn" [kp-decimal])
62 ("\eOM" [kp-enter])
63
64 ;; These won't be set up by either either
65 ("\e[K" [key_eol]) ;; Not an X keysym
66 ("\e[J" [key_eos]) ;; Not an X keysym
67 ("\e[2J" [key_clear]) ;; Not an X keysym
68 ("\e[P" [key_dc]) ;; Not an X keysym
69 ("\e[g" [S-tab]) ;; Not an X keysym
70 ("\e[2N" [clearentry]) ;; Not an X keysym
71 ("\e[2K" [S-clearentry]) ;; Not an X keysym
72 ("\e[E" [?\C-j]) ;; Not an X keysym
73 ("\e[g" [S-backtab]) ;; Not an X keysym
74 ("\e[?1i" [key_sprint]) ;; Not an X keysym
75 ("\e[4h" [key_sic]) ;; Not an X keysym
76 ("\e[4l" [S-delete]) ;; Not an X keysym
77 ("\e[Q" [S-insertline]) ;; Not an X keysym
78 ("\e[1Q" [key_sdl]) ;; Not an X keysym
79 ("\e[19l" [key_seol]) ;; Not an X keysym
80 ("\e[19h" [S-erasepage]) ;; Not an X keysym
81 ("\e[V" [S-page]) ;; Not an X keysym
82 ("\eS" [send]) ;; Not an X keysym
83 ("\e5" [S-send]) ;; Not an X keysym
84 ))
85
86 ;; The numeric keypad keys.
87 (let ((i 0))
88 (while (< i 10)
89 (define-key function-key-map
90 (format "\eO%c" (+ i ?p))
91 (vector (intern (format "kp-%d" i))))
92 (setq i (1+ i))))
93 ;; The numbered function keys.
94 (let ((i 0))
95 (while (< i 16)
96 (define-key function-key-map
97 (format "\e?%c" (+ i ?a))
98 (vector (intern (format "f%d" (1+ i)))))
99 (define-key function-key-map
100 (format "\e?%c" (+ i ?A))
101 (vector (intern (format "S-f%d" (1+ i)))))
102 (setq i (1+ i))))
103
104 (tvi970-set-keypad-mode 1))
105 \f
106 ;;; Should keypad numbers send ordinary digits or distinct escape sequences?
107 (defvar tvi970-keypad-numeric nil
108 "The terminal should be in numeric keypad mode iff this variable is non-nil.
109 Do not set this variable! Call the function ``tvi970-set-keypad-mode''.")
110
111 (defun tvi970-set-keypad-mode (&optional arg)
112 "Set the current mode of the TVI 970 numeric keypad.
113 In ``numeric keypad mode'', the number keys on the keypad act as
114 ordinary digits. In ``alternate keypad mode'', the keys send distinct
115 escape sequences, meaning that they can have their own bindings,
116 independent of the normal number keys.
117 With no argument, toggle between the two possible modes.
118 With a positive argument, select alternate keypad mode.
119 With a negative argument, select numeric keypad mode."
120 (interactive "P")
121 (setq tvi970-keypad-numeric
122 (if (null arg)
123 (not tvi970-keypad-numeric)
124 (> (prefix-numeric-value arg) 0)))
125 (send-string-to-terminal (if tvi970-keypad-numeric "\e=" "\e>")))
126
127 ;;; arch-tag: c1334cf0-1462-41c3-a963-c077d175f8f0
128 ;;; tvi970.el ends here