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