166
|
1 ; Terminal mode for Wyse 50
|
|
2 ; should work well for Televideo Tvi 925 though it's an overkill
|
|
3 ; Author Daniel Pfeiffer <pfeiffer@cix.cict.fr> january 1991
|
|
4
|
|
5 (require 'keypad)
|
|
6
|
|
7 ; at least some of these should be transferred to keypad.el
|
|
8 (keypad-default "A" '(lambda () (interactive)
|
|
9 ; actually insert an empty line
|
|
10 (beginning-of-line)
|
|
11 (open-line 1)))
|
|
12 (keypad-default "E" 'kill-line)
|
|
13 ; (keypad-default "h" 'execute-extended-command)
|
|
14 (define-key function-keymap "h" 'execute-extended-command) ; bad, bad !!
|
|
15 (keypad-default "H" 'shell-command)
|
|
16 (keypad-default "I" '(lambda () (interactive)
|
|
17 (insert ? ))) ; works even in overwrite-mode
|
|
18 (keypad-default "L" '(lambda () (interactive)
|
|
19 ; delete the whole line
|
|
20 (beginning-of-line)
|
|
21 (kill-line 1)))
|
|
22 (keypad-default "M" 'overwrite-mode)
|
|
23 (keypad-default "\^e" 'shell) ; F5
|
|
24 (keypad-default "\^f" 'dired) ; F6
|
|
25 (keypad-default "\^g" 'rnews) ; F7
|
|
26 (keypad-default "\^h" 'rmail) ; F8
|
|
27
|
|
28 (keypad-default "\^i" 'delete-other-windows) ; F9
|
|
29 (keypad-default "\^j" 'other-window) ; F10
|
|
30 (keypad-default "\^k" 'split-window-vertically) ; F11
|
|
31
|
|
32 (keypad-default "\^m" 'help-for-help) ; F13
|
|
33 (keypad-default "\^n" 'toggle-screen-width) ; F14
|
|
34 (keypad-default "\^o" 'set-function-key) ; F15
|
|
35
|
|
36
|
|
37 ; Keys that don't conflict with Emacs defaults
|
|
38 ; I write \M-x and \C-x for what the user types, \ex and \^x for key sequences
|
|
39 (setup-terminal-keymap global-map
|
|
40 '(("\M-?" . ?\?) ; Esc ?
|
|
41 ("\eI" . ?T) ; Shift Tab
|
|
42 ("\eJ" . ?P) ; Shift Prev PAGE
|
|
43 ("\eK" . ?N) ; PAGE Next
|
|
44 ("\eY" . ?C) ; Shift Scrn CLR
|
|
45 ("\eT" . ?E) ; CLR Line
|
|
46 ("\^^" . ?h) ; Home
|
|
47 ("\M-\^^" . ?H) ; Esc Home
|
|
48 ("\eQ" . ?I) ; INS Char
|
|
49 ("\eE" . ?A) ; Shift Line INS
|
|
50 ("\eW" . ?D) ; DEL Char
|
|
51 ("\eR" . ?L))) ; Shift Line DEL
|
|
52
|
|
53 ; Print -- put in some extra security
|
|
54 (global-set-key "\eP" '(lambda () (interactive)
|
|
55 (if (y-or-n-p
|
|
56 (concat "Print buffer "
|
|
57 (buffer-name) "? "))
|
|
58 (print-buffer))))
|
|
59
|
|
60
|
|
61 ; this is an ugly hack for a nasty problem:
|
|
62 ; Wyse 50 takes one character cell to store video attributes (which seems to
|
|
63 ; explain width 79 rather than 80, column 1 is not used!!!).
|
|
64 ; On killing (C-x C-c) the end inverse code (on column 1 of line 24)
|
|
65 ; of the mode line is overwritten AFTER all the y-or-n questions.
|
|
66 ; This causes the attribute to remain in effect until the mode line has
|
|
67 ; scrolled of the screen. Suspending (C-z) does not cause this problem.
|
|
68 ; On such terminals, Emacs should sacrifice the first and last character of
|
|
69 ; each mode line, rather than a whole screen column!
|
|
70 (setq kill-emacs-hook '(lambda () (interactive)
|
|
71 (send-string-to-terminal
|
|
72 (concat "\ea23R" (1+ (screen-width)) "C\eG0"))))
|
|
73
|
|
74
|
|
75 ; This function does more than its name which was copied from term/vt100.el
|
|
76 ; Some more neutral name should be used thru-out term/*.el to simplify
|
|
77 ; programming term-setup-hook
|
|
78 (defun enable-arrow-keys ()
|
|
79 "To be called by term-setup-hook. Overrides 6 Emacs standard keys
|
|
80 whose functions are then typed as follows:
|
|
81 C-a Funct Left-arrow
|
|
82 C-h M-?
|
|
83 LFD Funct Return, some modes override down-arrow via LFD
|
|
84 C-k CLR Line
|
|
85 C-l Scrn CLR
|
|
86 M-r M-x move-to-window-line, Funct up-arrow or down-arrow are similar
|
|
87 All special keys except Send, Shift Ins, Shift Home and shifted functions keys
|
|
88 are assigned some hopefully useful meaning."
|
|
89 (interactive)
|
|
90
|
|
91 ; Function keys
|
|
92 (define-prefix-command 'Funct-prefix)
|
|
93 (define-key global-map "\^a" 'Funct-prefix)
|
|
94
|
|
95 ; Arrow keys
|
|
96 (setup-terminal-keymap global-map
|
|
97 '(("\C-a\C-a" . beginning-of-line) ; for auld lang syne
|
|
98 ("\^a\^m\^m" . newline-and-indent)
|
|
99
|
|
100 ("\^k" . ?u) ; up-arrow
|
|
101 ("\^j" . ?d) ; down-arrow
|
|
102 ("\^l" . ?r) ; right-arrow
|
|
103 ("\^h" . ?l) ; left-arrow
|
|
104
|
|
105 ; Terminal needs both Ins and Repl but Emacs knows how to toggle
|
|
106 ; with just one key. No need to override Ins which is "\eq".
|
|
107 ("\er" . ?M) ; Repl
|
|
108
|
|
109 ("\^a\^i\^m" . ?t) ; Funct Tab
|
|
110
|
|
111 ; Function keys F1 thru F16 (we don't define shifted function keys,
|
|
112 ; they send the same code with the middle character in lowercase.
|
|
113 ; eg. "Shift F2" is the same as "Funct a" which is more mnemonic but
|
|
114 ; keypad.el doesn't provide enough codes to accomodate all these)
|
|
115 ("\^a@\^m" . 1) ("\^aH\^m" . 9)
|
|
116 ("\^aA\^m" . 2) ("\^aI\^m" . 10)
|
|
117 ("\^aB\^m" . 3) ("\^aJ\^m" . 11)
|
|
118 ("\^aC\^m" . 4) ("\^aK\^m" . 12)
|
|
119 ("\^aD\^m" . 5) ("\^aL\^m" . 13)
|
|
120 ("\^aE\^m" . 6) ("\^aM\^m" . 14)
|
|
121 ("\^aF\^m" . 7) ("\^aN\^m" . 15)
|
|
122 ("\^aG\^m" . 8) ("\^aO\^m" . 16)
|
|
123
|
|
124 ; Funct Arrow keys
|
|
125 ("\^a\^k\^m" . (lambda (n) (interactive "p")
|
|
126 (move-to-window-line (1- n))))
|
|
127 ("\^a\^j\^m" . (lambda (n) (interactive "p")
|
|
128 (move-to-window-line (- n))))
|
|
129 ("\^a\^h\^m" . beginning-of-line)
|
|
130 ("\^a\^l\^m" . end-of-line)))
|
|
131
|
|
132 ; forget self to put memory to some serious use
|
|
133 (fset 'enable-arrow-keys nil))
|
|
134
|
|
135
|
|
136 (defun toggle-screen-width ()
|
|
137 "Alternate between 80 and 132 columns."
|
|
138 (interactive)
|
|
139 (if (<= (screen-width) 80)
|
|
140 (progn
|
|
141 (send-string-to-terminal "\e`;")
|
|
142 (set-screen-width 131))
|
|
143 (send-string-to-terminal "\e`:")
|
|
144 (set-screen-width 79)))
|
|
145
|
|
146 ;-----------------------------------------------------------------------------
|
|
147 ; this function is completely independent of wyse, it should be auto-loadable
|
|
148 ; (presumably from keypad.el) for use in ~/emacs. It should be the only thing
|
|
149 ; users need to know about all this unintelligible "forwarding" gibberish.
|
|
150 ; This paves the way for a save-function-keys (some day or sleepless night)
|
|
151 ; that will edit calls like (set-function-key ?x 'do-whatever) in ~/.emacs.
|
|
152 (defun set-function-key (key &optional def)
|
|
153 "Prompt for a function or other special key and assign it a meaning.
|
|
154 The key must have been \"forwarded\" to a character in term/*.el.
|
|
155
|
|
156 As a function takes two args CHAR and DEF, with DEF as in define-key.
|
|
157 If your terminals term/*.el forwards a physical key to CHAR (before or after
|
|
158 calling this function), then that key will mean DEF, else it is ignored.
|
|
159 CHAR is one of the following:
|
|
160 For numbered function keys
|
|
161 0, 1, ..., 24 (or ?\\^@, ?\\^a, ..., ?\\^x which is the same)
|
|
162 For keypad keys in application mode
|
|
163 ?0, ?1, ..., ?9 -- keypad key labelled with that digit,
|
|
164 but only if that key is not an arrow key (see ?u, ?d, ?r, ?l).
|
|
165 ?- -- keypad key labelled `-'.
|
|
166 ?. -- keypad key labelled `.'.
|
|
167 ?, -- keypad key labelled `,'.
|
|
168 ?e -- key labelled enter.
|
|
169 For keys labelled with some words or a symbol
|
|
170 ?a -- clear all tabs key.
|
|
171 ?A -- insert line key.
|
|
172 ?C -- clear screen key.
|
|
173 ?c -- erase key.
|
|
174 ?D -- delete character key.
|
|
175 ?d -- down-arrow.
|
|
176 ?E -- clear to end of line key.
|
|
177 ?e -- key labelled enter.
|
|
178 ?f -- find key or search key.
|
|
179 ?F -- scroll forward key.
|
|
180 ?H -- home-down.
|
|
181 ?h -- home-position key.
|
|
182 ?I -- insert character key
|
|
183 If there is just an \"insert\" key, it should be this.
|
|
184 ?k -- delete key or remove key.
|
|
185 ?L -- delete line key.
|
|
186 ?l -- left-arrow.
|
|
187 ?M -- exit insert mode key.
|
|
188 ?N -- next page key.
|
|
189 ?p -- portrait mode.
|
|
190 ?P -- previous page key.
|
|
191 ?q -- landscape mode.
|
|
192 ?r -- right-arrow.
|
|
193 ?R -- scroll reverse key.
|
|
194 ?S -- clear to end of screen key.
|
|
195 ?s -- select key.
|
|
196 ?t -- clear tab this column key.
|
|
197 ?T -- set tab this column key.
|
|
198 ?u -- up-arrow.
|
|
199 ?x -- do key.
|
|
200 ?\\? -- help."
|
|
201 (interactive "kKey to redefine: ")
|
|
202 (let ((map function-keymap))
|
|
203 (if (integerp key)
|
|
204 ()
|
|
205 ; reinvent lookup-key to get (map . char) instead of def of char in map
|
|
206 (setq map (or (lookup-key global-map
|
|
207 (substring key 0 (1- (length key))))
|
|
208 global-map)
|
|
209 key (string-to-char (substring key (1- (length key)))))
|
|
210 (while (symbolp map)
|
|
211 (setq map (symbol-function map)))
|
|
212 (setq map (if (listp map)
|
|
213 (cdr (assq key (cdr map)))
|
|
214 (aref map key)))
|
|
215 (if (and (consp map)
|
|
216 (integerp (cdr map)))
|
|
217 (setq key (cdr map)
|
|
218 map (car map))
|
|
219 (error "Key is not a \"forwarded\" definition.")))
|
|
220 (if def
|
|
221 ()
|
|
222 (setq def (read-command "command (default last keyboard macro): "))
|
|
223 (if (string-equal (symbol-name def) "")
|
|
224 (setq def last-kbd-macro))
|
|
225 (setq command-history ; nonsense really, since you don't see
|
|
226 (cons ; key as in a function call (?char)
|
|
227 (list 'set-function-key key
|
|
228 (if (stringp def) def (list 'quote def)))
|
|
229 command-history)))
|
|
230 ; all we do when called as a function
|
|
231 (define-key map (char-to-string key) def)))
|
|
232
|
|
233
|