1 ; Like all the other files in this dir, this one needs to be redone
2 ; for the new way of handling function keys.
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
10 ; at least some of these should be transferred to keypad.el
11 (keypad-default "A" '(lambda () (interactive)
12 ; actually insert an empty line
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
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
31 (keypad-default "\^i" 'delete-other-windows
) ; F9
32 (keypad-default "\^j" 'other-window
) ; F10
33 (keypad-default "\^k" 'split-window-vertically
) ; F11
35 (keypad-default "\^m" 'help-for-help
) ; F13
36 (keypad-default "\^n" 'toggle-screen-width
) ; F14
37 (keypad-default "\^o" 'set-function-key
) ; F15
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
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
56 ; Print -- put in some extra security
57 (global-set-key "\eP" '(lambda () (interactive)
59 (concat "Print buffer "
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"))))
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, C-a C-a
86 LFD Funct Return, some modes override down-arrow via LFD
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."
95 (define-key global-map
"\^a" (define-prefix-command 'Funct-prefix
))
98 (setup-terminal-keymap global-map
99 '(("\C-a\C-a" . beginning-of-line
) ; for auld lang syne
100 ("\^a\^m\^m" . newline-and-indent
)
102 ("\^k" . ?u
) ; up-arrow
103 ("\^j" . ?d
) ; down-arrow
104 ("\^l" . ?r
) ; right-arrow
105 ("\^h" . ?l
) ; left-arrow
107 ; Terminal needs both Ins and Repl but Emacs knows how to toggle
108 ; with just one key. No need to override Ins which is "\eq".
111 ("\^a\^i\^m" . ?t
) ; Funct Tab
113 ; Function keys F1 thru F16 (we don't define shifted function keys,
114 ; they send the same code with the middle character in lowercase.
115 ; eg. "Shift F2" is the same as "Funct a" which is more mnemonic but
116 ; keypad.el doesn't provide enough codes to accomodate all these)
117 ("\^a@\^m" .
1) ("\^aH\^m" .
9)
118 ("\^aA\^m" .
2) ("\^aI\^m" .
10)
119 ("\^aB\^m" .
3) ("\^aJ\^m" .
11)
120 ("\^aC\^m" .
4) ("\^aK\^m" .
12)
121 ("\^aD\^m" .
5) ("\^aL\^m" .
13)
122 ("\^aE\^m" .
6) ("\^aM\^m" .
14)
123 ("\^aF\^m" .
7) ("\^aN\^m" .
15)
124 ("\^aG\^m" .
8) ("\^aO\^m" .
16)
127 ("\^a\^k\^m" .
(lambda (n) (interactive "p")
128 (move-to-window-line (1- n
))))
129 ("\^a\^j\^m" .
(lambda (n) (interactive "p")
130 (move-to-window-line (- n
))))
131 ("\^a\^h\^m" . beginning-of-line
)
132 ("\^a\^l\^m" . end-of-line
)))
134 ; forget self to put memory to some serious use
135 (fmakunbound 'enable-arrow-keys
))
138 (defun toggle-screen-width ()
139 "Alternate between 80 and 132 columns."
141 (if (<= (screen-width) 80)
143 (send-string-to-terminal "\e`;")
144 (set-screen-width 131))
145 (send-string-to-terminal "\e`:")
146 (set-screen-width 79)))
148 ;-----------------------------------------------------------------------------
149 ; this function is completely independent of wyse, it should be auto-loadable
150 ; (presumably from keypad.el) for use in ~/emacs. It should be the only thing
151 ; users need to know about all this unintelligible "forwarding" gibberish.
152 ; This paves the way for a save-function-keys (some day or sleepless night)
153 ; that will edit calls like (set-function-key ?x 'do-whatever) in ~/.emacs.
154 (defun set-function-key (key &optional def
)
155 "Prompt for a function or other special key and assign it a meaning.
156 The key must have been \"forwarded\" to a character by term/*.el.
158 As a function takes two args CHAR and DEF, with DEF as in define-key.
159 If your terminals term/*.el forwards a physical key to CHAR (before or after
160 calling this function), then that key will mean DEF, else it is ignored.
161 CHAR is one of the following:
162 For numbered function keys
163 0, 1, ..., 24 (or ?\\^@, ?\\^a, ..., ?\\^x which is the same)
164 For keypad keys in application mode
165 ?0, ?1, ..., ?9 -- keypad key labelled with that digit,
166 but only if that key is not an arrow key (see ?u, ?d, ?r, ?l).
167 ?- -- keypad key labelled `-'.
168 ?. -- keypad key labelled `.'.
169 ?, -- keypad key labelled `,'.
170 ?e -- key labelled enter.
171 For keys labelled with some words or a symbol
172 ?a -- clear all tabs key.
173 ?A -- insert line key.
174 ?C -- clear screen key.
176 ?D -- delete character key.
178 ?E -- clear to end of line key.
179 ?e -- key labelled enter.
180 ?f -- find key or search key.
181 ?F -- scroll forward key.
183 ?h -- home-position key.
184 ?I -- insert character key
185 If there is just an \"insert\" key, it should be this.
186 ?k -- delete key or remove key.
187 ?L -- delete line key.
189 ?M -- exit insert mode key.
192 ?P -- previous page key.
193 ?q -- landscape mode.
195 ?R -- scroll reverse key.
196 ?S -- clear to end of screen key.
198 ?t -- clear tab this column key.
199 ?T -- set tab this column key.
203 (interactive "kHit key to redefine")
204 (let ((map function-keymap
))
207 ; reinvent lookup-key to get (map . char) instead of def of char in map
208 (setq map
(or (lookup-key global-map
209 (substring key
0 (1- (length key
))))
211 key
(string-to-char (substring key
(1- (length key
)))))
213 (setq map
(symbol-function map
)))
214 (setq map
(if (listp map
)
215 (cdr (assq key
(cdr map
)))
218 (integerp (cdr map
)))
220 map
(car map
)) ; function-keymap usually
221 (error "Key is not a \"forwarded\" definition.")))
224 (setq def
(read-command "command (default last keyboard macro): "))
225 (if (string-equal (symbol-name def
) "")
226 (setq def last-kbd-macro
))
227 (setq command-history
; nonsense really, since you don't see
228 (cons ; key as in a function call (?char)
229 (list 'set-function-key key
230 (if (stringp def
) def
(list 'quote def
)))
232 ; all we do when called as a function
233 (define-key map
(char-to-string key
) def
)))