Replace `iff' in doc-strings and comments.
[emacs.git] / lisp / term / tvi970.el
blob1c0bda519ac69118687c567693b0e5428dfe867f
1 ;;; tvi970.el --- terminal support for the Televideo 970
3 ;; Copyright (C) 1992, 2001, 2002, 2003, 2004, 2005,
4 ;; 2006, 2007 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, or (at your option)
14 ;; 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; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;; Uses the Emacs 19 terminal initialization features --- won't work with 18.
30 ;;; Code:
32 (defun terminal-init-tvi970 ()
33 "Terminal initialization function for tvi970."
34 (or (lookup-key function-key-map "\e[")
35 (define-key function-key-map "\e[" (make-keymap)))
36 ;; (or (lookup-key function-key-map "\eO")
37 ;; (define-key function-key-map "\eO" (make-keymap)))
39 ;; Miscellaneous keys
40 (mapcar (function (lambda (key-binding)
41 (define-key function-key-map
42 (car key-binding) (nth 1 key-binding))))
44 ;; These are set up by termcap or terminfo
45 ;; ("\eOP" [kp-f1])
46 ;; ("\eOQ" [kp-f2])
47 ;; ("\eOR" [kp-f3])
48 ;; ("\eOS" [kp-f4])
50 ;; These might br set by terminfo
51 ("\e[H" [home])
52 ("\e[Z" [backtab])
53 ("\e[i" [print])
54 ("\e[@" [insert])
55 ("\e[L" [insertline])
56 ("\e[M" [deleteline])
57 ("\e[U" [next]) ;; actually the `page' key
59 ;; These won't be set up by either
60 ("\eOm" [kp-subtract])
61 ("\eOl" [kp-separator])
62 ("\eOn" [kp-decimal])
63 ("\eOM" [kp-enter])
65 ;; These won't be set up by either either
66 ("\e[K" [key_eol]) ;; Not an X keysym
67 ("\e[J" [key_eos]) ;; Not an X keysym
68 ("\e[2J" [key_clear]) ;; Not an X keysym
69 ("\e[P" [key_dc]) ;; Not an X keysym
70 ("\e[g" [S-tab]) ;; Not an X keysym
71 ("\e[2N" [clearentry]) ;; Not an X keysym
72 ("\e[2K" [S-clearentry]) ;; Not an X keysym
73 ("\e[E" [?\C-j]) ;; Not an X keysym
74 ("\e[g" [S-backtab]) ;; Not an X keysym
75 ("\e[?1i" [key_sprint]) ;; Not an X keysym
76 ("\e[4h" [key_sic]) ;; Not an X keysym
77 ("\e[4l" [S-delete]) ;; Not an X keysym
78 ("\e[Q" [S-insertline]) ;; Not an X keysym
79 ("\e[1Q" [key_sdl]) ;; Not an X keysym
80 ("\e[19l" [key_seol]) ;; Not an X keysym
81 ("\e[19h" [S-erasepage]) ;; Not an X keysym
82 ("\e[V" [S-page]) ;; Not an X keysym
83 ("\eS" [send]) ;; Not an X keysym
84 ("\e5" [S-send]) ;; Not an X keysym
87 ;; The numeric keypad keys.
88 (let ((i 0))
89 (while (< i 10)
90 (define-key function-key-map
91 (format "\eO%c" (+ i ?p))
92 (vector (intern (format "kp-%d" i))))
93 (setq i (1+ i))))
94 ;; The numbered function keys.
95 (let ((i 0))
96 (while (< i 16)
97 (define-key function-key-map
98 (format "\e?%c" (+ i ?a))
99 (vector (intern (format "f%d" (1+ i)))))
100 (define-key function-key-map
101 (format "\e?%c" (+ i ?A))
102 (vector (intern (format "S-f%d" (1+ i)))))
103 (setq i (1+ i))))
105 (tvi970-set-keypad-mode 1))
107 ;;; Should keypad numbers send ordinary digits or distinct escape sequences?
108 (defvar tvi970-keypad-numeric nil
109 "Non-nil means the terminal should be in numeric keypad mode.
110 Do not set this variable! Call the function `tvi970-set-keypad-mode'.")
112 (defun tvi970-set-keypad-mode (&optional arg)
113 "Set the current mode of the TVI 970 numeric keypad.
114 In ``numeric keypad mode'', the number keys on the keypad act as
115 ordinary digits. In ``alternate keypad mode'', the keys send distinct
116 escape sequences, meaning that they can have their own bindings,
117 independent of the normal number keys.
118 With no argument, toggle between the two possible modes.
119 With a positive argument, select alternate keypad mode.
120 With a negative argument, select numeric keypad mode."
121 (interactive "P")
122 (setq tvi970-keypad-numeric
123 (if (null arg)
124 (not tvi970-keypad-numeric)
125 (> (prefix-numeric-value arg) 0)))
126 (send-string-to-terminal (if tvi970-keypad-numeric "\e=" "\e>")))
128 ;;; arch-tag: c1334cf0-1462-41c3-a963-c077d175f8f0
129 ;;; tvi970.el ends here