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>
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/>.
27 ;; Uses the Emacs 19 terminal initialization features --- won't work with 18.
31 (eval-when-compile (require 'cl
))
33 (defvar tvi970-terminal-map
34 (let ((map (make-sparse-keymap)))
38 '(;; These are set up by termcap or terminfo
44 ;; These might bre set by terminfo.
51 ("\e[U" [next]) ;; actually the `page' key
53 ;; These won't be set up by either
54 ("\eOm" [kp-subtract])
55 ("\eOl" [kp-separator])
59 ;; These won't be set up by either either
60 ("\e[K" [key_eol]) ;; Not an X keysym
61 ("\e[J" [key_eos]) ;; Not an X keysym
62 ("\e[2J" [key_clear]) ;; Not an X keysym
63 ("\e[P" [key_dc]) ;; Not an X keysym
64 ("\e[g" [S-tab]) ;; Not an X keysym
65 ("\e[2N" [clearentry]) ;; Not an X keysym
66 ("\e[2K" [S-clearentry]) ;; Not an X keysym
67 ("\e[E" [?\C-j]) ;; Not an X keysym
68 ("\e[g" [S-backtab]) ;; Not an X keysym
69 ("\e[?1i" [key_sprint]) ;; Not an X keysym
70 ("\e[4h" [key_sic]) ;; Not an X keysym
71 ("\e[4l" [S-delete]) ;; Not an X keysym
72 ("\e[Q" [S-insertline]) ;; Not an X keysym
73 ("\e[1Q" [key_sdl]) ;; Not an X keysym
74 ("\e[19l" [key_seol]) ;; Not an X keysym
75 ("\e[19h" [S-erasepage]) ;; Not an X keysym
76 ("\e[V" [S-page]) ;; Not an X keysym
77 ("\eS" [send]) ;; Not an X keysym
78 ("\e5" [S-send]) ;; Not an X keysym
80 (define-key map (car key-binding) (nth 1 key-binding)))
83 ;; The numeric keypad keys.
85 (define-key map (format "\eO%c" (+ i ?p))
86 (vector (intern (format "kp-%d" i)))))
87 ;; The numbered function keys.
89 (define-key map (format "\e?%c" (+ i ?a))
90 (vector (intern (format "f%d" (1+ i)))))
91 (define-key map (format "\e?%c" (+ i ?A))
92 (vector (intern (format "S-f%d" (1+ i))))))
95 (defun terminal-init-tvi970 ()
96 "Terminal initialization function for tvi970."
97 ;; Use inheritance to let the main keymap override these defaults.
98 ;; This way we don't override terminfo-derived settings or settings
99 ;; made in the .emacs file.
100 (let ((m (copy-keymap tvi970-terminal-map)))
101 (set-keymap-parent m (keymap-parent input-decode-map))
102 (set-keymap-parent input-decode-map m))
103 (tvi970-set-keypad-mode 1))
106 ;; Should keypad numbers send ordinary digits or distinct escape sequences?
107 (define-minor-mode tvi970-set-keypad-mode
108 "Set the current mode of the TVI 970 numeric keypad.
109 In ``numeric keypad mode'', the number keys on the keypad act as
110 ordinary digits. In ``alternate keypad mode'', the keys send distinct
111 escape sequences, meaning that they can have their own bindings,
112 independent of the normal number keys.
113 With no argument, toggle between the two possible modes.
114 With a positive argument, select alternate keypad mode.
115 With a negative argument, select numeric keypad mode."
116 :variable (terminal-parameter nil 'tvi970-keypad-numeric)
117 (send-string-to-terminal
118 (if (terminal-parameter nil 'tvi970-keypad-numeric) "\e=" "\e>")))
120 ;; arch-tag: c1334cf0-1462-41c3-a963-c077d175f8f0
121 ;;; tvi970.el ends here