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