aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Blandy1991-12-20 08:24:06 +0000
committerJim Blandy1991-12-20 08:24:06 +0000
commite645a1ddd6a4552bf6d14dac038ecd9587c010ac (patch)
tree97856d4d75531943904f704161e8e63eb4446a13
parentcc0a8174baf4c25d69545fe5cd6cabddba6b1d2c (diff)
downloademacs-e645a1ddd6a4552bf6d14dac038ecd9587c010ac.tar.gz
emacs-e645a1ddd6a4552bf6d14dac038ecd9587c010ac.zip
Initial revision
-rw-r--r--lisp/term/sun.el273
-rw-r--r--lisp/term/vt100.el62
2 files changed, 335 insertions, 0 deletions
diff --git a/lisp/term/sun.el b/lisp/term/sun.el
new file mode 100644
index 00000000000..df4ddf80526
--- /dev/null
+++ b/lisp/term/sun.el
@@ -0,0 +1,273 @@
1;; keybinding for standard default sunterm keys
2;; Copyright (C) 1987 Free Software Foundation, Inc.
3
4;; This file is part of GNU Emacs.
5
6;; GNU Emacs is distributed in the hope that it will be useful,
7;; but WITHOUT ANY WARRANTY. No author or distributor
8;; accepts responsibility to anyone for the consequences of using it
9;; or for whether it serves any particular purpose or works at all,
10;; unless he says so in writing. Refer to the GNU Emacs General Public
11;; License for full details.
12
13;; Everyone is granted permission to copy, modify and redistribute
14;; GNU Emacs, but only under the conditions described in the
15;; GNU Emacs General Public License. A copy of this license is
16;; supposed to have been given to you along with GNU Emacs so you
17;; can know your rights and responsibilities. It should be in a
18;; file named COPYING. Among other things, the copyright notice
19;; and this notice must be preserved on all copies.
20
21;; Jeff Peck, Sun Microsystems Inc <peck@sun.com>
22
23;; The function key sequences for the console have been converted for
24;; use with function-key-map, but the *tool stuff hasn't been touched.
25
26
27(defun ignore-key ()
28 "interactive version of ignore"
29 (interactive)
30 (ignore))
31
32(defun scroll-down-in-place (n)
33 (interactive "p")
34 (previous-line n)
35 (scroll-down n))
36
37(defun scroll-up-in-place (n)
38 (interactive "p")
39 (next-line n)
40 (scroll-up n))
41
42(defun kill-region-and-unmark (beg end)
43 "Like kill-region, but pops the mark [which equals point, anyway.]"
44 (interactive "r")
45 (kill-region beg end)
46 (setq this-command 'kill-region-and-unmark)
47 (set-mark-command t))
48
49(defun select-previous-complex-command ()
50 "Select Previous-complex-command"
51 (interactive)
52 (if (zerop (minibuffer-depth))
53 (repeat-complex-command 1)
54 (previous-complex-command 1)))
55
56(defun rerun-prev-command ()
57 "Repeat Previous-complex-command."
58 (interactive)
59 (eval (nth 0 command-history)))
60
61(defvar grep-arg nil "Default arg for RE-search")
62(defun grep-arg ()
63 (if (memq last-command '(research-forward research-backward)) grep-arg
64 (let* ((command (car command-history))
65 (command-name (symbol-name (car command)))
66 (search-arg (car (cdr command)))
67 (search-command
68 (and command-name (string-match "search" command-name)))
69 )
70 (if (and search-command (stringp search-arg)) (setq grep-arg search-arg)
71 (setq search-command this-command
72 grep-arg (read-string "REsearch: " grep-arg)
73 this-command search-command)
74 grep-arg))))
75
76(defun research-forward ()
77 "Repeat RE search forward."
78 (interactive)
79 (re-search-forward (grep-arg)))
80
81(defun research-backward ()
82 "Repeat RE search backward."
83 (interactive)
84 (re-search-backward (grep-arg)))
85
86;;;
87;;; handle sun's extra function keys
88;;; this version for those who run with standard .ttyswrc and no emacstool
89;;;
90;;; sunview picks up expose and open on the way UP,
91;;; so we ignore them on the way down
92;;;
93
94(defvar sun-esc-bracket nil
95 "*If non-nil, rebind ESC [ as prefix for Sun function keys.")
96
97(define-prefix-command 'sun-raw-prefix 'sun-raw-map)
98(define-key function-key-map "\e[" 'sun-raw-prefix)
99
100(define-key sun-raw-map "210z" [r3])
101(define-key sun-raw-map "213z" [r6])
102(define-key sun-raw-map "214z" [r7])
103(define-key sun-raw-map "216z" [r9])
104(define-key sun-raw-map "218z" [r11])
105(define-key sun-raw-map "220z" [r13])
106(define-key sun-raw-map "222z" [r15])
107(define-key sun-raw-map "193z" [again])
108(define-key sun-raw-map "194z" [props])
109(define-key sun-raw-map "195z" [undo])
110; (define-key sun-raw-map "196z" 'ignore-key) ; Expose-down
111; (define-key sun-raw-map "197z" [put])
112; (define-key sun-raw-map "198z" 'ignore-key) ; Open-down
113; (define-key sun-raw-map "199z" [get])
114(define-key sun-raw-map "200z" [find])
115; (define-key sun-raw-map "201z" 'kill-region-and-unmark) ; Delete
116(define-key sun-raw-map "226z" [t3])
117(define-key sun-raw-map "227z" [t4])
118(define-key sun-raw-map "229z" [t6])
119(define-key sun-raw-map "230z" [t7])
120(define-key sun-raw-map "A" [up]) ; R8
121(define-key sun-raw-map "B" [down]) ; R14
122(define-key sun-raw-map "C" [right]) ; R12
123(define-key sun-raw-map "D" [left]) ; R10
124
125(global-set-key [r3] 'backward-page)
126(global-set-key [r6] 'forward-page)
127(global-set-key [r7] 'beginning-of-buffer)
128(global-set-key [r9] 'scroll-down)
129(global-set-key [r11] 'recenter)
130(global-set-key [r13] 'end-of-buffer)
131(global-set-key [r15] 'scroll-up)
132(global-set-key [again] 'redraw-display)
133(global-set-key [props] 'list-buffers)
134(global-set-key [undo] 'undo)
135(global-set-key [put] 'sun-select-region)
136(global-set-key [get] 'sun-yank-selection)
137(global-set-key [find] 'exchange-point-and-mark)
138(global-set-key [t3] 'scroll-down-in-place)
139(global-set-key [t4] 'scroll-up-in-place)
140(global-set-key [t6] 'shrink-window)
141(global-set-key [t7] 'enlarge-window)
142
143
144(if sun-esc-bracket (global-unset-key "\e["))
145
146;;; Since .emacs gets loaded before this file, a hook is supplied
147;;; for you to put your own bindings in.
148
149(defvar sun-raw-map-hooks nil
150 "List of forms to evaluate after setting sun-raw-map.")
151
152(let ((hooks sun-raw-map-hooks))
153 (while hooks
154 (eval (car hooks))
155 (setq hooks (cdr hooks))
156 ))
157
158
159;;; This section adds defintions for the emacstool users
160;;; emacstool event filter converts function keys to C-x*{c}{lrt}
161;;;
162;;; for example the Open key (L7) would be encoded as "\C-x*gl"
163;;; the control, meta, and shift keys modify the character {lrt}
164;;; note that (unshifted) C-l is ",", C-r is "2", and C-t is "4"
165;;;
166;;; {c} is [a-j] for LEFT, [a-i] for TOP, [a-o] for RIGHT.
167;;; A higher level insists on encoding {h,j,l,n}{r} (the arrow keys)
168;;; as ANSI escape sequences. Use the shell command
169;;; % setkeys noarrows
170;;; if you want these to come through for emacstool.
171;;;
172;;; If you are not using EmacsTool,
173;;; you can also use this by creating a .ttyswrc file to do the conversion.
174;;; but it won't include the CONTROL, META, or SHIFT keys!
175;;;
176;;; Important to define SHIFTed sequence before matching unshifted sequence.
177;;; (talk about bletcherous old uppercase terminal conventions!*$#@&%*&#$%)
178;;; this is worse than C-S/C-Q flow control anyday!
179;;; Do *YOU* run in capslock mode?
180;;;
181
182;;; Note: al, el and gl are trapped by EmacsTool, so they never make it here.
183
184(defvar meta-flag t)
185
186(defvar suntool-map (make-sparse-keymap)
187 "*Keymap for Emacstool bindings.")
188
189(define-key suntool-map "gr" 'beginning-of-buffer) ; r7
190(define-key suntool-map "iR" 'backward-page) ; R9
191(define-key suntool-map "ir" 'scroll-down) ; r9
192(define-key suntool-map "kr" 'recenter) ; r11
193(define-key suntool-map "mr" 'end-of-buffer) ; r13
194(define-key suntool-map "oR" 'forward-page) ; R15
195(define-key suntool-map "or" 'scroll-up) ; r15
196(define-key suntool-map "b\M-L" 'rerun-prev-command) ; M-AGAIN
197(define-key suntool-map "b\M-l" 'prev-complex-command) ; M-Again
198(define-key suntool-map "bl" 'redraw-display) ; Again
199(define-key suntool-map "cl" 'list-buffers) ; Props
200(define-key suntool-map "dl" 'undo) ; Undo
201(define-key suntool-map "el" 'ignore-key) ; Expose-Open
202(define-key suntool-map "fl" 'sun-select-region) ; Put
203(define-key suntool-map "f," 'copy-region-as-kill) ; C-Put
204(define-key suntool-map "gl" 'ignore-key) ; Open-Open
205(define-key suntool-map "hl" 'sun-yank-selection) ; Get
206(define-key suntool-map "h," 'yank) ; C-Get
207(define-key suntool-map "il" 'research-forward) ; Find
208(define-key suntool-map "i," 're-search-forward) ; C-Find
209(define-key suntool-map "i\M-l" 'research-backward) ; M-Find
210(define-key suntool-map "i\M-," 're-search-backward) ; C-M-Find
211
212(define-key suntool-map "jL" 'yank) ; DELETE
213(define-key suntool-map "jl" 'kill-region-and-unmark) ; Delete
214(define-key suntool-map "j\M-l" 'exchange-point-and-mark); M-Delete
215(define-key suntool-map "j,"
216 '(lambda () (interactive) (pop-mark 1))) ; C-Delete
217
218(define-key suntool-map "fT" 'shrink-window-horizontally) ; T6
219(define-key suntool-map "gT" 'enlarge-window-horizontally) ; T7
220(define-key suntool-map "ft" 'shrink-window) ; t6
221(define-key suntool-map "gt" 'enlarge-window) ; t7
222(define-key suntool-map "cT" '(lambda(n) (interactive "p") (scroll-down n)))
223(define-key suntool-map "dT" '(lambda(n) (interactive "p") (scroll-up n)))
224(define-key suntool-map "ct" 'scroll-down-in-place) ; t3
225(define-key suntool-map "dt" 'scroll-up-in-place) ; t4
226(define-key ctl-x-map "*" suntool-map)
227
228;;; Since .emacs gets loaded before this file, a hook is supplied
229;;; for you to put your own bindings in.
230
231(defvar suntool-map-hooks nil
232 "List of forms to evaluate after setting suntool-map.")
233
234(let ((hooks suntool-map-hooks))
235 (while hooks
236 (eval (car hooks))
237 (setq hooks (cdr hooks))
238 ))
239
240;;;
241;;; If running under emacstool, arrange to call suspend-emacstool
242;;; instead of suspend-emacs.
243;;;
244;;; First mouse blip is a clue that we are in emacstool.
245;;;
246;;; C-x C-@ is the mouse command prefix.
247
248(autoload 'sun-mouse-handler "sun-mouse"
249 "Sun Emacstool handler for mouse blips (not loaded)." t)
250
251(defun emacstool-init ()
252 "Set up Emacstool window, if you know you are in an emacstool."
253 ;; Make sure sun-mouse and sun-fns are loaded.
254 (require 'sun-fns)
255 (define-key ctl-x-map "\C-@" 'sun-mouse-handler)
256
257 (if (< (sun-window-init) 0)
258 (message "Not a Sun Window")
259 (progn
260 (substitute-key-definition 'suspend-emacs 'suspend-emacstool global-map)
261 (substitute-key-definition 'suspend-emacs 'suspend-emacstool esc-map)
262 (substitute-key-definition 'suspend-emacs 'suspend-emacstool ctl-x-map))
263 (send-string-to-terminal
264 (concat "\033]lEmacstool - GNU Emacs " emacs-version "\033\\"))
265 ))
266
267(defun sun-mouse-once ()
268 "Converts to emacstool and sun-mouse-handler on first mouse hit."
269 (interactive)
270 (emacstool-init)
271 (sun-mouse-handler) ; Now, execute this mouse blip.
272 )
273(define-key ctl-x-map "\C-@" 'sun-mouse-once)
diff --git a/lisp/term/vt100.el b/lisp/term/vt100.el
new file mode 100644
index 00000000000..c9d4e5db104
--- /dev/null
+++ b/lisp/term/vt100.el
@@ -0,0 +1,62 @@
1;;;; Define VT100 function key escape sequences in function-key-map.
2
3
4;;; CSI sequences - those that start with "\e[".
5(define-prefix-command 'vt100-CSI-prefix 'vt100-CSI-map)
6(define-key function-key-map "\e[" 'vt100-CSI-prefix)
7
8(define-key vt100-CSI-map "A" [up])
9(define-key vt100-CSI-map "B" [down])
10(define-key vt100-CSI-map "C" [right])
11(define-key vt100-CSI-map "D" [left])
12
13(defun enable-arrow-keys ()
14 "Enable the use of the VT100 arrow keys for cursor motion.
15Because of the nature of the VT100, this unavoidably breaks
16the standard Emacs command ESC [; therefore, it is not done by default,
17but only if you give this command."
18 (interactive)
19 (global-unset-key "\e["))
20
21
22
23;;; SS3 sequences - those that start with "\eO".
24(define-prefix-command 'vt100-SS3-prefix 'vt100-SS3-map)
25(define-key function-key-map "\eO" 'vt100-SS3-prefix)
26
27(define-key vt100-SS3-map "A" [up])
28(define-key vt100-SS3-map "B" [down]) ; down-arrow
29(define-key vt100-SS3-map "C" [right]) ; right-arrow
30(define-key vt100-SS3-map "D" [left]) ; left-arrow
31(define-key vt100-SS3-map "M" [kp-enter]) ; Enter
32(define-key vt100-SS3-map "P" [kp-f1]) ; PF1
33(define-key vt100-SS3-map "Q" [kp-f2]) ; PF2
34(define-key vt100-SS3-map "R" [kp-f3]) ; PF3
35(define-key vt100-SS3-map "S" [kp-f4]) ; PF4
36(define-key vt100-SS3-map "l" [kp-separator]) ; ,
37(define-key vt100-SS3-map "m" [kp-subtract]) ; -
38(define-key vt100-SS3-map "n" [kp-period]) ; .
39(define-key vt100-SS3-map "p" [kp-0]) ; 0
40(define-key vt100-SS3-map "q" [kp-1]) ; 1
41(define-key vt100-SS3-map "r" [kp-2]) ; 2
42(define-key vt100-SS3-map "s" [kp-3]) ; 3
43(define-key vt100-SS3-map "t" [kp-4]) ; 4
44(define-key vt100-SS3-map "u" [kp-5]) ; 5
45(define-key vt100-SS3-map "v" [kp-6]) ; 6
46(define-key vt100-SS3-map "w" [kp-7]) ; 7
47(define-key vt100-SS3-map "x" [kp-8]) ; 8
48(define-key vt100-SS3-map "y" [kp-9]) ; 9
49
50
51;;; Controlling the screen width.
52(defconst vt100-wide-mode (= (screen-width) 132)
53 "t if vt100 is in 132-column mode.")
54
55(defun vt100-wide-mode (&optional arg)
56 "Toggle 132/80 column mode for vt100s."
57 (interactive "P")
58 (setq vt100-wide-mode
59 (if (null arg) (not vt100-wide-mode)
60 (> (prefix-numeric-value arg) 0)))
61 (send-string-to-terminal (if vt100-wide-mode "\e[?3h" "\e[?3l"))
62 (set-screen-width (if vt100-wide-mode 132 80)))