]> code.delx.au - gnu-emacs/blob - lisp/term/wyse50.el
77c1655dfd1a526ed169e3aab9ffa119062b2cc3
[gnu-emacs] / lisp / term / wyse50.el
1 ;;; wyse50.el --- terminal support code for Wyse 50
2
3 ;; Copyright (C) 1989, 1993-1994, 2001-2014 Free Software Foundation, Inc.
4
5 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>,
6 ;; Jim Blandy <jimb@occs.cs.oberlin.edu>
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 of the License, or
14 ;; (at your option) 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. If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25
26 ;; Rewritten for Emacs 19 by jimb, January 1992
27 ;; Cleaned up for new terminal package conventions by esr, March 1993
28 ;; Should work well for Televideo TVI 925 although it's overkill.
29 ;;
30 ;; The Wyse50 is ergonomically wonderful, but its escape-sequence design sucks
31 ;; rocks. The left-arrow key emits a backspace (!) and the down-arrow a line
32 ;; feed (!!). Thus, you have to unbind some commonly-used Emacs keys to
33 ;; enable the arrows.
34
35 ;;; Code:
36
37 (defvar wyse50-terminal-map
38 (let ((map (make-sparse-keymap)))
39 (dolist (key-definition
40 '( ;; These might be set up by termcap and terminfo
41 ("\C-k" [up])
42 ("\C-j" [down])
43 ("\C-l" [right])
44 ("\C-h" [left])
45 ("\^a@\^m" [f1])
46 ("\^aA\^m" [f2])
47 ("\^aB\^m" [f3])
48 ("\^aC\^m" [f4])
49 ("\^aD\^m" [f5])
50 ("\^aE\^m" [f6])
51 ("\^aF\^m" [f7])
52 ("\^aG\^m" [f8])
53 ("\^aH\^m" [f9])
54
55 ;; These might be set up by terminfo
56 ("\eK" [next])
57 ("\eT" [clearline])
58 ("\^^" [home])
59 ("\e\^^" [end])
60 ("\eQ" [insert])
61 ("\eE" [insertline])
62 ("\eR" [deleteline])
63 ("\eP" [print])
64 ("\er" [replace])
65 ("\^aI\^m" [f10])
66 ("\^aJ\^m" [f11])
67 ("\^aK\^m" [f12])
68 ("\^aL\^m" [f13])
69 ("\^aM\^m" [f14])
70 ("\^aN\^m" [f15])
71 ("\^aO\^m" [f16])
72 ("\^a`\^m" [f17])
73 ("\^aa\^m" [f18])
74 ("\^ab\^m" [f19])
75 ("\^ac\^m" [f20])
76 ("\^ad\^m" [f21])
77 ("\^ae\^m" [f22])
78 ("\^af\^m" [f23])
79 ("\^ag\^m" [f24])
80 ("\^ah\^m" [f25])
81 ("\^ai\^m" [f26])
82 ("\^aj\^m" [f27])
83 ("\^ak\^m" [f28])
84 ("\^al\^m" [f29])
85 ("\^am\^m" [f30])
86 ("\^an\^m" [f31])
87 ("\^ao\^m" [f32])
88
89 ;; Terminfo may know about these, but X won't
90 ("\eI" [key-stab]) ;; Not an X keysym
91 ("\eJ" [key-snext]) ;; Not an X keysym
92 ("\eY" [key-clear]) ;; Not an X keysym
93
94 ;; These are totally strange :-)
95 ("\eW" [?\C-?]) ;; Not an X keysym
96 ("\^a\^k\^m" [funct-up]) ;; Not an X keysym
97 ("\^a\^j\^m" [funct-down]) ;; Not an X keysym
98 ("\^a\^l\^m" [funct-right]) ;; Not an X keysym
99 ("\^a\^h\^m" [funct-left]) ;; Not an X keysym
100 ("\^a\^m\^m" [funct-return]) ;; Not an X keysym
101 ("\^a\^i\^m" [funct-tab]) ;; Not an X keysym
102 ))
103 (define-key map
104 (car key-definition) (nth 1 key-definition)))
105 map))
106
107 (defun terminal-init-wyse50 ()
108 "Terminal initialization function for wyse50."
109 ;; Use inheritance to let the main keymap override these defaults.
110 ;; This way we don't override terminfo-derived settings or settings
111 ;; made in the init file.
112 (let ((m (copy-keymap wyse50-terminal-map)))
113 (set-keymap-parent m (keymap-parent input-decode-map))
114 (set-keymap-parent input-decode-map m))
115
116 ;; Miscellaneous hacks
117
118 ;; This is an ugly hack for a nasty problem:
119 ;; Wyse 50 takes one character cell to store video attributes (which seems to
120 ;; explain width 79 rather than 80, column 1 is not used!!!).
121 ;; On killing (C-x C-c) the end inverse code (on column 1 of line 24)
122 ;; of the mode line is overwritten AFTER all the y-or-n questions.
123 ;; This causes the attribute to remain in effect until the mode line has
124 ;; scrolled of the screen. Suspending (C-z) does not cause this problem.
125 ;; On such terminals, Emacs should sacrifice the first and last character of
126 ;; each mode line, rather than a whole screen column!
127 (add-hook 'kill-emacs-hook
128 (function (lambda () (interactive)
129 (send-string-to-terminal
130 (concat "\ea23R" (1+ (frame-width)) "C\eG0"))))))
131
132 (defun enable-arrow-keys ()
133 "To be called by `tty-setup-hook'. Overrides 6 Emacs standard keys
134 whose functions are then typed as follows:
135 C-a Funct Left-arrow
136 C-h M-?
137 LFD Funct Return, some modes override down-arrow via LFD
138 C-k CLR Line
139 C-l Scrn CLR
140 M-r M-x move-to-window-line, Funct up-arrow or down-arrow are similar"
141 (interactive)
142 ;; Not needed any more now that we use input-decode-map.
143 ;; (dolist (key-definition
144 ;; ;; By unsetting C-a and then binding it to a prefix, we
145 ;; ;; allow the rest of the function keys which start with C-a
146 ;; ;; to be recognized.
147 ;; '(("\C-a" nil)
148 ;; ("\C-k" nil)
149 ;; ("\C-j" nil)
150 ;; ("\C-l" nil)
151 ;; ("\C-h" nil)
152 ;; ("\er" nil)))
153 ;; (global-set-key (car key-definition)
154 ;; (nth 1 key-definition)))
155 (fset 'enable-arrow-keys nil))
156
157 ;;; wyse50.el ends here