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