HideIfDef mode bug fixes and enhancements. This is #2 of 3 patches based
[bpt/emacs.git] / lisp / term / tvi970.el
CommitLineData
a97beda4
ER
1;;; tvi970.el --- terminal support for the Televideo 970
2
ba318903 3;; Copyright (C) 1992, 2001-2014 Free Software Foundation, Inc.
f2e3589a 4
62507a6a 5;; Author: Jim Blandy <jimb@occs.cs.oberlin.edu>
a97beda4 6;; Keywords: terminals
62507a6a 7;; Created: January 1992
a97beda4 8
a97beda4
ER
9;; This file is part of GNU Emacs.
10
1fecc8fe 11;; GNU Emacs is free software: you can redistribute it and/or modify
a97beda4 12;; it under the terms of the GNU General Public License as published by
1fecc8fe
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
a97beda4
ER
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
1fecc8fe 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
a97beda4
ER
23
24;;; Commentary:
25
a97beda4 26;;; Code:
8f3e0167 27
14cbaa91
SM
28(defvar tvi970-terminal-map
29 (let ((map (make-sparse-keymap)))
30
31 ;; Miscellaneous keys
32 (dolist (key-binding
33 '(;; These are set up by termcap or terminfo
34 ;; ("\eOP" [kp-f1])
35 ;; ("\eOQ" [kp-f2])
36 ;; ("\eOR" [kp-f3])
37 ;; ("\eOS" [kp-f4])
38
39 ;; These might bre set by terminfo.
40 ("\e[H" [home])
41 ("\e[Z" [backtab])
42 ("\e[i" [print])
43 ("\e[@" [insert])
44 ("\e[L" [insertline])
45 ("\e[M" [deleteline])
46 ("\e[U" [next]) ;; actually the `page' key
47
48 ;; These won't be set up by either
49 ("\eOm" [kp-subtract])
50 ("\eOl" [kp-separator])
51 ("\eOn" [kp-decimal])
52 ("\eOM" [kp-enter])
53
54 ;; These won't be set up by either either
55 ("\e[K" [key_eol]) ;; Not an X keysym
56 ("\e[J" [key_eos]) ;; Not an X keysym
57 ("\e[2J" [key_clear]) ;; Not an X keysym
58 ("\e[P" [key_dc]) ;; Not an X keysym
59 ("\e[g" [S-tab]) ;; Not an X keysym
60 ("\e[2N" [clearentry]) ;; Not an X keysym
61 ("\e[2K" [S-clearentry]) ;; Not an X keysym
62 ("\e[E" [?\C-j]) ;; Not an X keysym
63 ("\e[g" [S-backtab]) ;; Not an X keysym
64 ("\e[?1i" [key_sprint]) ;; Not an X keysym
65 ("\e[4h" [key_sic]) ;; Not an X keysym
66 ("\e[4l" [S-delete]) ;; Not an X keysym
67 ("\e[Q" [S-insertline]) ;; Not an X keysym
68 ("\e[1Q" [key_sdl]) ;; Not an X keysym
69 ("\e[19l" [key_seol]) ;; Not an X keysym
70 ("\e[19h" [S-erasepage]) ;; Not an X keysym
71 ("\e[V" [S-page]) ;; Not an X keysym
72 ("\eS" [send]) ;; Not an X keysym
73 ("\e5" [S-send]) ;; Not an X keysym
74 ))
75 (define-key map (car key-binding) (nth 1 key-binding)))
76
77
78 ;; The numeric keypad keys.
79 (dotimes (i 10)
80 (define-key map (format "\eO%c" (+ i ?p))
81 (vector (intern (format "kp-%d" i)))))
82 ;; The numbered function keys.
83 (dotimes (i 16)
84 (define-key map (format "\e?%c" (+ i ?a))
85 (vector (intern (format "f%d" (1+ i)))))
86 (define-key map (format "\e?%c" (+ i ?A))
87 (vector (intern (format "S-f%d" (1+ i))))))
88 map))
89
4f0c9ba7
DN
90(defun terminal-init-tvi970 ()
91 "Terminal initialization function for tvi970."
14cbaa91
SM
92 ;; Use inheritance to let the main keymap override these defaults.
93 ;; This way we don't override terminfo-derived settings or settings
865fe16f 94 ;; made in the init file.
14cbaa91
SM
95 (let ((m (copy-keymap tvi970-terminal-map)))
96 (set-keymap-parent m (keymap-parent input-decode-map))
97 (set-keymap-parent input-decode-map m))
4f0c9ba7 98 (tvi970-set-keypad-mode 1))
8f3e0167
JB
99
100\f
14cbaa91 101;; Should keypad numbers send ordinary digits or distinct escape sequences?
80ac5d4d 102(define-minor-mode tvi970-set-keypad-mode
ac6c8639
CY
103 "Toggle alternate keypad mode on TVI 970 keypad.
104With a prefix argument ARG, enable the mode if ARG is positive,
105and disable it otherwise. If called from Lisp, enable the mode
106if ARG is omitted or nil.
107
108In ``alternate keypad mode'', the keys send distinct escape
109sequences, meaning that they can have their own bindings,
8f3e0167 110independent of the normal number keys.
ac6c8639
CY
111
112When disabled, the terminal enters ``numeric keypad mode'', in
113which the keypad's keys act as ordinary digits."
80ac5d4d
SM
114 :variable (terminal-parameter nil 'tvi970-keypad-numeric)
115 (send-string-to-terminal
116 (if (terminal-parameter nil 'tvi970-keypad-numeric) "\e=" "\e>")))
8f3e0167 117
e8af40ee 118;;; tvi970.el ends here