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