]> code.delx.au - gnu-emacs/blob - lisp/term/tvi970.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / term / tvi970.el
1 ;;; tvi970.el --- terminal support for the Televideo 970
2
3 ;; Copyright (C) 1992, 2001, 2002, 2003, 2004, 2005,
4 ;; 2006, 2007 Free Software Foundation, Inc.
5
6 ;; Author: Jim Blandy <jimb@occs.cs.oberlin.edu>, January 1992
7 ;; Keywords: terminals
8
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
13 ;; the Free Software Foundation; either version 3, or (at your option)
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
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.
25
26 ;;; Commentary:
27
28 ;; Uses the Emacs 19 terminal initialization features --- won't work with 18.
29
30 ;;; Code:
31
32 (defun terminal-init-tvi970 ()
33 "Terminal initialization function for tvi970."
34 (or (lookup-key local-function-key-map "\e[")
35 (define-key local-function-key-map "\e[" (make-keymap)))
36 ;; (or (lookup-key local-function-key-map "\eO")
37 ;; (define-key local-function-key-map "\eO" (make-keymap)))
38
39 ;; Miscellaneous keys
40 (mapcar (function (lambda (key-binding)
41 (define-key local-function-key-map
42 (car key-binding) (nth 1 key-binding))))
43 '(
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])
49
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
58
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])
64
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
85 ))
86
87 ;; The numeric keypad keys.
88 (let ((i 0))
89 (while (< i 10)
90 (define-key local-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 local-function-key-map
98 (format "\e?%c" (+ i ?a))
99 (vector (intern (format "f%d" (1+ i)))))
100 (define-key local-function-key-map
101 (format "\e?%c" (+ i ?A))
102 (vector (intern (format "S-f%d" (1+ i)))))
103 (setq i (1+ i))))
104
105 (tvi970-set-keypad-mode 1))
106
107 \f
108 ;;; Should keypad numbers send ordinary digits or distinct escape sequences?
109 (defvar tvi970-keypad-numeric nil
110 "The terminal should be in numeric keypad mode iff this variable is non-nil.
111 Do not set this variable! Call the function ``tvi970-set-keypad-mode''.")
112
113 (defun tvi970-set-keypad-mode (&optional arg)
114 "Set the current mode of the TVI 970 numeric keypad.
115 In ``numeric keypad mode'', the number keys on the keypad act as
116 ordinary digits. In ``alternate keypad mode'', the keys send distinct
117 escape sequences, meaning that they can have their own bindings,
118 independent of the normal number keys.
119 With no argument, toggle between the two possible modes.
120 With a positive argument, select alternate keypad mode.
121 With a negative argument, select numeric keypad mode."
122 (interactive "P")
123 (setq tvi970-keypad-numeric
124 (if (null arg)
125 (not tvi970-keypad-numeric)
126 (> (prefix-numeric-value arg) 0)))
127 (send-string-to-terminal (if tvi970-keypad-numeric "\e=" "\e>")))
128
129 ;;; arch-tag: c1334cf0-1462-41c3-a963-c077d175f8f0
130 ;;; tvi970.el ends here