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