annotate lisp/packages/terminal.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 0293115a14e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; terminal.el --- terminal emulator for GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Keywords: comm, terminals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1986, 1987, 1988, 1989, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Written by Richard Mlynarik, November 1986.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Face and attribute support added by Richard Mlynarik, April 1996.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: Not synched with FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;#### TODO
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;#### terminfo?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;#### One probably wants to do setenv MORE -c when running with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;#### more-processing enabled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (provide 'terminal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'ehelp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar terminal-escape-char ?\C-^
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 "*All characters except for this are passed verbatim through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 terminal-emulator. This character acts as a prefix for commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 to the emulator program itself. Type this character twice to send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 it through the emulator. Type ? after typing it for a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 possible commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 This variable is local to each terminal-emulator buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvar terminal-scrolling t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "*If non-nil, the terminal-emulator will `scroll' when output occurs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 past the bottom of the screen. If nil, output will `wrap' to the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 of the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 This variable is local to each terminal-emulator buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defvar terminal-more-processing t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "*If non-nil, do more-processing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 This variable is local to each terminal-emulator buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; If you are the sort of loser who uses scrolling without more breaks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; and expects to actually see anything, you should probably set this to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; around 400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defvar terminal-redisplay-interval 5000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 "*Maximum number of characters which will be processed by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 terminal-emulator before a screen redisplay is forced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 Set this to a large value for greater throughput,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 set it smaller for more frequent updates but overall slower
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 performance.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defvar terminal-more-break-insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "*** More break -- Press space to continue ***")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defvar terminal-escape-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defvar terminal-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defvar terminal-more-break-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (if terminal-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (let ((map (make-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (set-keymap-name map 'terminal-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (let ((meta-prefix-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (s (make-string 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (while (< i 256)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (aset s 0 i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (define-key map s 'te-pass-through)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;(define-key map "\C-l"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ; '(lambda () (interactive) (te-pass-through) (redraw-display)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (setq terminal-map map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (if terminal-escape-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (let ((map (make-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (set-keymap-name map 'terminal-escape-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (let ((s (make-string 1 ?0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (while (<= (aref s 0) ?9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (define-key map s 'digit-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (aset s 0 (1+ (aref s 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (define-key map "b" 'switch-to-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (define-key map "o" 'other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (define-key map "e" 'te-set-escape-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (define-key map "\C-l" 'redraw-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (define-key map "\C-o" 'te-flush-pending-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (define-key map "m" 'te-toggle-more-processing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (define-key map "x" 'te-escape-extended-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (define-key map "?" 'te-escape-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (define-key map (char-to-string help-char) 'te-escape-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (setq terminal-escape-map map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defvar te-escape-command-alist '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if te-escape-command-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (setq te-escape-command-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 '(("Set Escape Character" . te-set-escape-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ("Refresh" . redraw-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ("Record Output" . te-set-output-log)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ("Photo" . te-set-output-log)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ("Tofu" . te-tofu) ;; confuse the uninitiated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ("Stuff Input" . te-stuff-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ("Flush Pending Output" . te-flush-pending-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ("Enable More Processing" . te-enable-more-processing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ("Disable More Processing" . te-disable-more-processing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ("Scroll at end of page" . te-do-scrolling)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ("Wrap at end of page" . te-do-wrapping)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ("Switch To Buffer" . switch-to-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ("Other Window" . other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ("Kill Buffer" . kill-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ("Help" . te-escape-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ("Set Redisplay Interval" . te-set-redisplay-interval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;(setq terminal-more-break-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (if terminal-more-break-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (let ((map (make-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (set-keymap-name map 'terminal-more-break-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (let ((meta-prefix-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (s (make-string 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (while (< i 256)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (aset s 0 i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (define-key map s 'te-more-break-unwind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (define-key map (char-to-string help-char) 'te-more-break-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (define-key map " " 'te-more-break-resume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (define-key map "\C-l" 'redraw-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (define-key map "\C-o" 'te-more-break-flush-pending-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;#### this isn't right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;(define-key map "\^?" 'te-more-break-flush-pending-output) ;DEL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (define-key map "\r" 'te-more-break-advance-one-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (setq terminal-more-break-map map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defvar te-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defvar te-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defvar te-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defvar te-pending-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defvar te-saved-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defvar te-pending-output-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (defvar te-log-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (defvar te-more-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defvar te-redisplay-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defvar te-current-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (defvar te-current-attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (make-face 'terminal-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (make-face 'terminal-standout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (if (not (face-differs-from-default-p 'terminal-standout))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (copy-face 'bold 'terminal-standout))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (make-face 'terminal-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (cond ((face-differs-from-default-p 'terminal-underline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ((find-face 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (copy-face 'underline 'terminal-underline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (set-face-underline-p 'terminal-underline t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (make-face 'terminal-standout-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (cond ((face-differs-from-default-p 'terminal-standout-underline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (copy-face 'terminal-standout 'terminal-standout-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (set-face-underline-p 'terminal-standout-underline t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (defun te-insert-blank (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (let ((p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (insert-char ?\ count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (put-text-property p (point) 'face 'terminal-default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;;; escape map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (defun te-escape-p (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (cond ((eventp terminal-escape-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (cond ((key-press-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (and (key-press-event-p terminal-escape-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (= (event-modifier-bits event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (event-modifier-bits terminal-escape-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (eq (event-key event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (event-key terminal-escape-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ((button-press-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (and (button-press-event-p terminal-escape-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (= (event-modifier-bits event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (event-modifier-bits terminal-escape-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (eq (event-button event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (event-button terminal-escape-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ((numberp terminal-escape-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (let ((c (event-to-character event nil t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (and c (= c terminal-escape-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defun te-escape ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (let ((c (let ((cursor-in-echo-area t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (prompt (if prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (format "Emacs Terminal escape> %d "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (prefix-numeric-value prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Emacs Terminal escape> ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (message "%s" prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (let ((e (next-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (while (button-release-event-p e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (setq e (next-command-event e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (if (te-escape-p e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (setq unread-command-event e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (lookup-key terminal-escape-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (read-key-sequence prompt))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (cond ((eventp c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (message nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (copy-event c last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (let ((terminal-escape-char -259))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (te-pass-through)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (call-interactively c)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (defun te-escape-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 "Provide help on commands available after terminal-escape-char is typed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (message "Terminal emulator escape help...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (let ((char (single-key-description terminal-escape-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (with-electric-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (princ (format "Terminal-emulator escape, invoked by \"%s\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 Type \"%s\" twice to send a single \"%s\" through.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 Other chars following \"%s\" are interpreted as follows:\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 char char char char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (princ (substitute-command-keys "\\{terminal-escape-map}\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (princ (format "\nSubcommands of \"%s\" (%s)\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (where-is-internal 'te-escape-extended-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 terminal-escape-map t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 'te-escape-extended-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (let ((l (if (fboundp 'sortcar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (sortcar (copy-sequence te-escape-command-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 'string<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (sort (copy-sequence te-escape-command-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (function (lambda (a b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (string< (car a) (car b))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (while l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (let ((doc (or (documentation (cdr (car l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 "Not documented")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (if (string-match "\n" doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; just use first line of documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (setq doc (substring doc 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (princ " \"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (princ (car (car l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (princ "\":\n ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (princ doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (write-char ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (setq l (cdr l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (defun te-escape-extended-command ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (let ((c (let ((completion-ignore-case t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (completing-read "terminal command: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 te-escape-command-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (if c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (catch 'foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setq c (downcase c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (let ((l te-escape-command-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (while l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if (string= c (downcase (car (car l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (throw 'foo (call-interactively (cdr (car l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (setq l (cdr l)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; not used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defun te-escape-extended-command-unread ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq unread-command-event last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (te-escape-extended-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (defun te-set-escape-char (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 "Change the terminal-emulator escape character."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (interactive (list (let ((cursor-in-echo-area t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (message "Set escape character to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (let ((e (next-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (while (button-release-event-p e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (setq e (next-command-event e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 e))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (cond ((te-escape-p c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (message "\"%s\" is escape char"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ((and (eventp terminal-escape-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (event-to-character terminal-escape-char nil t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (message "\"%s\" is now escape; \"%s\" passes though"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (single-key-description c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (single-key-description terminal-escape-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (message "\"%s\" is now escape"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (single-key-description c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; Let mouse-events, for example, go back to looking at global map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (local-unset-key (vector terminal-escape-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (local-set-key (vector c) 'te-escape) ;ensure it's defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (setq terminal-escape-char c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defun te-stuff-string (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "Read a string to send to through the terminal emulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 as though that string had been typed on the keyboard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 Very poor man's file transfer protocol."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (interactive "sStuff string: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (process-send-string te-process string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defun te-set-output-log (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 "Record output from the terminal emulator in a buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (interactive (list (if te-log-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (read-buffer "Record output in buffer: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (format "%s output-log"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (buffer-name (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (if (or (null name) (equal name ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (progn (setq te-log-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (message "Output logging off."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (if (get-buffer name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (set-buffer (get-buffer-create name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (fundamental-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (setq te-log-buffer (get-buffer name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (message "Recording terminal emulator output into buffer \"%s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (buffer-name te-log-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defun te-tofu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 "Discontinue output log."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (te-set-output-log nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defun te-toggle (sym arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (set sym (cond ((not (numberp arg)) arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ((= arg 1) (not (symbol-value sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ((< arg 0) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (t t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (defun te-toggle-more-processing (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (message (if (te-toggle 'terminal-more-processing arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 "More processing on" "More processing off"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (if terminal-more-processing (setq te-more-count -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defun te-toggle-scrolling (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (message (if (te-toggle 'terminal-scrolling arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "Scroll at end of page" "Wrap at end of page")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defun te-enable-more-processing ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 "Enable ** MORE ** processing"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (te-toggle-more-processing t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun te-disable-more-processing ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "Disable ** MORE ** processing"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (te-toggle-more-processing nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (defun te-do-scrolling ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 "Scroll at end of page (yuck)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (te-toggle-scrolling t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defun te-do-wrapping ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "Wrap to top of window at end of page"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (te-toggle-scrolling nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (defun te-set-redisplay-interval (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 "Set the maximum interval (in output characters) between screen updates.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 Set this number to large value for greater throughput,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 set it smaller for more frequent updates (but overall slower performance."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (interactive "NMax number of output chars between redisplay updates: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (setq arg (max arg 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (setq terminal-redisplay-interval arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 te-redisplay-count 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;;;; more map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;; every command -must- call te-more-break-unwind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;; or grave lossage will result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (put 'te-more-break-unread 'suppress-keymap t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (defun te-more-break-unread ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (if (te-escape-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (call-interactively 'te-escape)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (message "Continuing from more break (\"%s\" typed, %d chars output pending...)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (single-key-description last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (te-pending-output-length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (setq te-more-count 259259)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (te-more-break-unwind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (let ((terminal-more-processing nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (te-pass-through))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (defun te-more-break-resume ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 "Proceed past the **MORE** break,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 allowing the next page of output to appear"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (message "Continuing from more break")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (te-more-break-unwind))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (defun te-more-break-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 "Provide help on commands available in a terminal-emulator **MORE** break"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (message "Terminal-emulator more break help...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (with-electric-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (princ "Terminal-emulator more break.\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (princ (format "Type \"%s\" (te-more-break-resume)\n%s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (where-is-internal 'te-more-break-resume
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 terminal-more-break-map t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (documentation 'te-more-break-resume)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (princ (substitute-command-keys "\\{terminal-more-break-map}\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (princ "Any other key is passed through to the program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 running under the terminal emulator and disables more processing until
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 all pending output has been dealt with.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun te-more-break-advance-one-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "Allow one more line of text to be output before doing another more break."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (setq te-more-count 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (te-more-break-unwind))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defun te-more-break-flush-pending-output ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 "Discard any output which has been received by the terminal emulator but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 not yet proceesed and then proceed from the more break."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (te-more-break-unwind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (te-flush-pending-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defun te-flush-pending-output ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 "Discard any as-yet-unprocessed output which has been received by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 the terminal emulator."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ;; this could conceivably be confusing in the presence of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; escape-sequences spanning process-output chunks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (if (null (cdr te-pending-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (message "(There is no output pending)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (let ((length (te-pending-output-length)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (message "Flushing %d chars of pending output" length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (setq te-pending-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (list 0 (format "\n*** %d chars of pending output flushed ***\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 length)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (te-update-pending-output-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (te-process-output nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (sit-for 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (defun te-pass-through ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 "Send the last character typed through the terminal-emulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 without any interpretation"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (if (te-escape-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (call-interactively 'te-escape)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (and terminal-more-processing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (null (cdr te-pending-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (te-set-more-count nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (let ((c (event-to-character last-command-event nil t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (if c (process-send-string te-process (make-string 1 c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (te-process-output t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (defun te-set-window-start ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (let* ((w (get-buffer-window (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (h (if w (window-height w))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (cond ((not w)) ; buffer not displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ((>= h (/ (- (point) (point-min)) (1+ te-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;; this is the normal case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (set-window-start w (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; this happens if some vandal shrinks our window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ((>= h (/ (- (point-max) (point)) (1+ te-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (set-window-start w (- (point-max) (* h (1+ te-width)) -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ;; I give up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (defun te-pending-output-length ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (let ((length (car te-pending-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (tem (cdr te-pending-output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (while tem
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (setq length (+ length (length (car tem))) tem (cdr tem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;;;; more break hair
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (defun te-more-break ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (te-set-more-count t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (make-local-variable 'te-more-old-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (setq te-more-old-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (make-local-variable 'te-more-old-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (setq te-more-old-local-map (current-local-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (use-local-map terminal-more-break-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (make-local-variable 'te-more-old-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (setq te-more-old-filter (process-filter te-process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (make-local-variable 'te-more-old-mode-line-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (setq te-more-old-mode-line-format mode-line-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 mode-line-format (list "-- **MORE** "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 mode-line-buffer-identification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 "%-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (set-process-filter te-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (function (lambda (process string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (set-buffer (process-buffer process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (setq te-pending-output (nconc te-pending-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (list string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (te-update-pending-output-display))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (te-update-pending-output-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (if (eq (window-buffer (selected-window)) (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (message "More break "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (or (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (null terminal-more-break-insertion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (delete-region (point) (+ (point) te-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (insert terminal-more-break-insertion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (run-hooks 'terminal-more-break-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (sit-for 0) ;get display to update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (throw 'te-process-output t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (defun te-more-break-unwind ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (use-local-map te-more-old-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (set-process-filter te-process te-more-old-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (goto-char te-more-old-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (setq mode-line-format te-more-old-mode-line-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (set-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (cond ((eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (terminal-more-break-insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (delete-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (+ (point) (length terminal-more-break-insertion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (te-insert-blank te-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (goto-char te-more-old-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (setq te-more-old-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (let ((te-more-count 259259))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (te-newline)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;(sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (te-process-output t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (defun te-set-more-count (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (let ((line (/ (- (point) (point-min)) (1+ te-width))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (if newline (setq line (1+ line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (cond ((= line te-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (setq te-more-count te-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;#### something is strange. Investigate this!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ((= line (1- te-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (setq te-more-count te-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ((or (< line (/ te-height 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (> (- te-height line) 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; break at end of this page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (setq te-more-count (- te-height line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;; migrate back towards top (ie bottom) of screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (setq te-more-count (- te-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (if (> te-height 10) 2 1)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;;;; More or less straight-forward terminal escapes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; ^j, meaning `newline' to non-display programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;; (Who would think of ever writing a system which doesn't understand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;; display terminals natively? Un*x: The Operating System of the Future.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (defun te-newline ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 "Move down a line, optionally do more processing, perhaps wrap/scroll,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 move to start of new line, clear to end of line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (cond ((not terminal-more-processing))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ((< (setq te-more-count (1- te-more-count)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (te-set-more-count t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ((eq te-more-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; this doesn't return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (te-more-break)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (delete-region (point-min) (+ (point-min) te-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (if terminal-scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (progn (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (insert ?\n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (delete-region (point) (+ (point) te-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (te-insert-blank te-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (te-set-window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ;; ^p ^j
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;; Handle the `do' or `nl' termcap capability.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ;;#### I am not sure why this broken, obsolete, capability is here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ;;#### Perhaps it is for VIle. No comment was made about why it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;;#### was added (in "Sun Dec 6 01:22:27 1987 Richard Stallman")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (defun te-down-vertically-or-scroll ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 "Move down a line vertically, or scroll at bottom."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (let ((column (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (delete-region (point-min) (+ (point-min) te-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (te-insert-blank te-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (move-to-column column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (te-set-window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ; ^p = x+32 y+32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (defun te-move-to-position ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; must offset by #o40 since cretinous unix won't send a 004 char through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (let ((y (- (te-get-char) 32))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (x (- (te-get-char) 32)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (or (> x te-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (> y te-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 () ;(error "fucked %d %d" x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (goto-char (+ (point-min) x (* y (1+ te-width))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;(te-set-window-start?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (setq te-more-count -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;; ^p c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (defun te-clear-rest-of-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (let ((n (- (point) (progn (end-of-line) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (delete-region (point) (+ (point) n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (te-insert-blank (- n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ;; ^p C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (defun te-clear-rest-of-screen ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (te-clear-rest-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (while (progn (end-of-line) (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (forward-char 1) (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (delete-region (- (point) te-width) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (te-insert-blank te-width))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;; ^p ^l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (defun te-clear-screen ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;; regenerate buffer to compensate for (nonexistent!!) bugs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (let ((i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (while (< i te-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (te-insert-blank te-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (insert ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (delete-region (1- (point-max)) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (setq te-more-count -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ;; ^p ^o count+32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (defun te-insert-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 ();(error "fooI")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (let* ((line (- te-height (/ (- (point) (point-min)) (1+ te-width)) -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (n (min (- (te-get-char) ?\ ) line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (delete-region (- (point-max) (* n (1+ te-width))) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (if (eq (point) (point-max)) (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (while (< i n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (te-insert-blank te-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (or (eq i line) (insert ?\n))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (setq te-more-count -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 ;; ^p ^k count+32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (defun te-delete-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 ();(error "fooD")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (let* ((line (- te-height (/ (- (point) (point-min)) (1+ te-width)) -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (n (min (- (te-get-char) ?\ ) line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (delete-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (min (+ (point) (* n (1+ te-width))) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (while (< i n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (te-insert-blank te-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (or (eq i line) (insert ?\n))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (setq te-more-count -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; ^p ^a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (defun te-beginning-of-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 ;; ^p ^b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (defun te-backward-char ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (backward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 ;; ^p ^f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (defun te-forward-char ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (if (not (eolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ;; ^p *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (defun te-change-attribute ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (let* ((attribute (te-get-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (on (= (te-get-char) ?1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (standout (assq 'standout te-current-attributes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (underline (assq 'underline te-current-attributes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (frob (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ;; This would be even more of a combinatorial mess if I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ;; decided I wanted to support anything more than the two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;; standout and underline attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (setq te-current-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (or (cdr (assoc te-current-attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 '((((standout . t) (underline . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 . terminal-standout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (((standout . nil) (underline . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 . terminal-standout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (((standout . t) (underline . nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 . terminal-standout-underline))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 'terminal-default))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (cond ((= attribute ?+) ;standout on/off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (setcdr standout on)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (funcall frob))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ((= attribute ?_) ;underline on/off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (setcdr underline on)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (funcall frob))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ;; reverse, blink, half-bright, double-bright, blank, protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 ;; ??Colours??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (t ;; #\space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (setcdr underline nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (setcdr standout nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (setq te-current-face 'terminal-default)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 ;; 0177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (defun te-delete ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (if (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (delete-region (1- (point)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (te-insert-blank 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (forward-char -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 ;; ^p ^g
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (defun te-beep ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 ;; ^p _ count+32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (defun te-insert-spaces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (let* ((p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (n (min (- (te-get-char) 32)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (- (progn (end-of-line) (point)) p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (if (<= n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (delete-char (- n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (insert-char ?\ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (goto-char p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;; ^p d count+32 (should be ^p ^d but cretinous un*x won't send ^d chars!!!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (defun te-delete-char ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (let* ((p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (n (min (- (te-get-char) 32)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (- (progn (end-of-line) (point)) p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (if (<= n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (te-insert-blank n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (delete-char n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (goto-char p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ;; disgusting unix-required shit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ;; Are we living twenty years in the past yet?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (defun te-losing-unix ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 ;(what lossage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 ;(message "fucking-unix: %d" char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ;; ^i
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (defun te-output-tab ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (let* ((p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (x (- p (progn (beginning-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (l (min (- 8 (logand x 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (progn (end-of-line) (- (point) p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (goto-char (+ p l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 ;; Also:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; ^m => beginning-of-line (for which it -should- be using ^p ^a, right?!!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; ^g => te-beep (for which it should use ^p ^g)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ;; ^h => te-backward-char (for which it should use ^p ^b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (defun te-filter (process string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (let* ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; can't use save-excursion, as that preserves point, which we don't want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (set-buffer (process-buffer process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (goto-char te-saved-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (and (bufferp te-log-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (if (null (buffer-name te-log-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ;; killed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (setq te-log-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (set-buffer te-log-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (insert-before-markers string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (set-buffer (process-buffer process))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (setq te-pending-output (nconc te-pending-output (list string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (te-update-pending-output-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (te-process-output (eq (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (window-buffer (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (set-buffer (process-buffer process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (setq te-saved-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (set-buffer obuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ;; fucking unix has -such- braindamaged lack of tty control...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (defun te-process-output (preemptable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;;#### There seems no good reason to ever disallow preemption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (setq preemptable t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (catch 'te-process-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (let ((buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (string nil) ostring start char (matchpos nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (while (cdr te-pending-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (setq ostring string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 start (car te-pending-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 string (car (cdr te-pending-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 char (aref string start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (if (eq (setq start (1+ start)) (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (progn (setq te-pending-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (cons 0 (cdr (cdr te-pending-output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 start 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 string (car (cdr te-pending-output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (te-update-pending-output-display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (setcar te-pending-output start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (if (and (> char ?\037) (< char ?\377))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (cond ((eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ;; unread char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (if (eq start 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (setq te-pending-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (cons 0 (cons (make-string 1 char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (cdr te-pending-output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (setcar te-pending-output (1- start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (te-newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ((null string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (delete-char 1) (insert char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (put-text-property (1- (point)) (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 'face te-current-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (te-redisplay-if-necessary 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (let ((end (or (and (eq ostring string) matchpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (setq matchpos (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 "[\000-\037\177-\377]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 string start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (length string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (delete-char 1) (insert char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (setq char (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (put-text-property (1- char) char 'face te-current-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (setq end (min end (+ start (- (point) char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (goto-char char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (if (eq end matchpos) (setq matchpos nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (delete-region (point) (+ (point) (- end start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (setq char (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (insert (if (and (eq start 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (eq end (length string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (substring string start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (put-text-property char (point) 'face te-current-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (if (eq end (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (setq te-pending-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (cons 0 (cdr (cdr te-pending-output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (setcar te-pending-output end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (te-redisplay-if-necessary (1+ (- end start))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 ;; I suppose if I split the guts of this out into a separate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 ;; function we could trivially emulate different terminals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ;; Who cares in any case? (Apart from stupid losers using rlogin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (funcall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (if (eq char ?\^p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (or (cdr (assq (te-get-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 '((?= . te-move-to-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (?c . te-clear-rest-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (?C . te-clear-rest-of-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (?\C-o . te-insert-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (?\C-k . te-delete-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (?* . te-change-attribute)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ;; not necessary, but help sometimes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (?\C-a . te-beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (?\C-b . te-backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;; should be C-d, but un*x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;; pty's won't send \004 through!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ;; Can you believe this?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (?d . te-delete-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (?_ . te-insert-spaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ;; random
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (?\C-f . te-forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (?\C-g . te-beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (?\C-j . te-down-vertically-or-scroll)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (?\C-l . te-clear-screen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 'te-losing-unix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (or (cdr (assq char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 '((?\C-j . te-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (?\177 . te-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ;; Did I ask to be sent these characters?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 ;; I don't remember doing so, either.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 ;; (Perhaps some operating system or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 ;; other is completely incompetent...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (?\C-m . te-beginning-of-line) ;fuck me harder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (?\C-g . te-beep) ;again and again!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (?\C-h . te-backward-char) ;wa12id!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (?\C-i . te-output-tab)))) ;(spiked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 'te-losing-unix))) ;That feels better
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (te-redisplay-if-necessary 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (and preemptable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (input-pending-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 ;; preemptable output! Oh my!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (throw 'te-process-output t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 ;; We must update window-point in every window displaying our buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (let* ((s (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (w s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (while (not (eq s (setq w (next-window w))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (if (eq (window-buffer w) (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (set-window-point w (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (defun te-get-char ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (if (cdr te-pending-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (let ((start (car te-pending-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (string (car (cdr te-pending-output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (prog1 (aref string start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (if (eq (setq start (1+ start)) (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (setq te-pending-output (cons 0 (cdr (cdr te-pending-output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (setcar te-pending-output start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (catch 'char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (let ((filter (process-filter te-process)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (set-process-filter te-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (function (lambda (p s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (or (eq (length s) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (setq te-pending-output (list 1 s)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (throw 'char (aref s 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (accept-process-output te-process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (set-process-filter te-process filter))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (defun te-redisplay-if-necessary (length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (and (<= (setq te-redisplay-count (- te-redisplay-count length)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (eq (current-buffer) (window-buffer (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (waiting-for-user-input-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (progn (te-update-pending-output-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (setq te-redisplay-count terminal-redisplay-interval))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (defun te-update-pending-output-display ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (if (null (cdr te-pending-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (setq te-pending-output-info "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (let ((length (te-pending-output-length)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (if (< length 1500)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (setq te-pending-output-info "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (setq te-pending-output-info (format "(%dK chars output pending) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (/ (+ length 512) 1024))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 ;; update mode line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (set-buffer-modified-p (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (defun te-sentinel (process message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (cond ((eq (process-status process) 'run))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 ((null (buffer-name (process-buffer process)))) ;deleted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (t (let ((b (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (set-buffer (process-buffer process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (fundamental-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (delete-blank-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (insert "\n*******\n" message "*******\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (if (and (eq b (process-buffer process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (waiting-for-user-input-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (progn (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (recenter -1)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (defvar te-stty-string "stty -nl new dec echo"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 "Command string (to be interpreted by \"sh\") which sets the modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 of the virtual terminal to be appropriate for interactive use.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (defvar explicit-shell-file-name nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 "*If non-nil, is file name to use for explicitly requested inferior shell.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (defun terminal-emulator (buffer program args &optional width height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 "Under a display-terminal emulator in BUFFER, run PROGRAM on arguments ARGS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ARGS is a list of argument-strings. Remaining arguments are WIDTH and HEIGHT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 BUFFER's contents are made an image of the display generated by that program,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 and any input typed when BUFFER is the current Emacs buffer is sent to that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 program an keyboard input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 Interactively, BUFFER defaults to \"*terminal*\" and PROGRAM and ARGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 are parsed from an input-string using your usual shell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 WIDTH and HEIGHT are determined from the size of the current window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 -- WIDTH will be one less than the window's width, HEIGHT will be its height.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 To switch buffers and leave the emulator, or to give commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 to the emulator itself (as opposed to the program running under it),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 type Control-^. The following character is an emulator command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 Type Control-^ twice to send it to the subprogram.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 This escape character may be changed using the variable `terminal-escape-char'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 `Meta' characters may not currently be sent through the terminal emulator.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 Here is a list of some of the variables which control the behaviour
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 of the emulator -- see their documentation for more information:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 terminal-escape-char, terminal-scrolling, terminal-more-processing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 terminal-redisplay-interval.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 This function calls the value of terminal-mode-hook if that exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 and is non-nil after the terminal buffer has been set up and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 subprocess started.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 Presently with `termcap' only; if somebody sends us code to make this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 work with `terminfo' we will try to use it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (cons (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (set-buffer (get-buffer-create "*terminal*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (buffer-name (if (or (not (boundp 'te-process))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (null te-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (not (eq (process-status te-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 'run)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (generate-new-buffer "*terminal*"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (let* ((default-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 ;; Default shell is same thing M-x shell uses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (or explicit-shell-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (getenv "ESHELL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (getenv "SHELL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 "/bin/sh"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (s (read-shell-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (format "Run program in emulator: (default %s) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 default-s))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (if (equal s "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (list default-s '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (te-parse-program-and-args s))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (switch-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (if (null width) (setq width (- (window-width (selected-window)) 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (if (null height) (setq height (- (window-height (selected-window)) 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (terminal-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (setq te-width width te-height height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (setq mode-line-buffer-identification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (list (format "Emacs terminal %dx%d: %%b " te-width te-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 'te-pending-output-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (te-clear-screen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (let (process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (while (setq process (get-buffer-process (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (if (y-or-n-p (format "Kill process %s? " (process-name process)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (delete-process process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (error "Process %s not killed" (process-name process)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (let ((termcap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;; Because of Unix Brain Death(tm), we can't change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;; the terminal type of a running process, and so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 ;; terminal size and scrollability are wired-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 ;; at this point. ("Detach? What's that?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (concat (format "emacs-virtual:co#%d:li#%d:%s:km:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 ;; Sigh. These can't be dynamically changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 te-width te-height (if terminal-scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 "" "ns:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 ;;-- Basic things
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 ;; cursor-motion, bol, forward/backward char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 "cm=^p=%+ %+ :cr=^p^a:le=^p^b:nd=^p^f:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 ;; newline, clear eof/eof, audible bell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 "nw=^j:ce=^pc:cd=^pC:cl=^p^l:bl=^p^g:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 ;; insert/delete char/line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 "IC=^p_%+ :DC=^pd%+ :AL=^p^o%+ :DL=^p^k%+ :"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 ;;-- Not-widely-known (ie nonstandard) flags, which mean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 ;; o writing in the last column of the last line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 ;; doesn't cause idiotic scrolling, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 ;; o don't use idiotische c-s/c-q sogenannte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 ;; ``flow control'' auf keinen Fall.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 "LP:NF:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 ;;-- For stupid or obsolete programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 "ic=^p_!:dc=^pd!:al=^p^o!:dl=^p^k!:ho=^p= :"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ;;-- For disgusting programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 ;; (VI? What losers need these, I wonder?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 "im=:ei=:dm=:ed=:mi:do=^p^j:nl=^p^j:bs:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 "ms:me=^p* :"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (if (face-equal 'terminal-default 'terminal-standout)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 "" "so=^p*+1:se=^p*+0")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (if (face-equal 'terminal-default 'terminal-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 "" "us=^p*_1:ue=^p*_0")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (if (fboundp 'start-subprocess)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 ;; this winning function would do everything, except that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 ;; rms doesn't want it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (setq te-process (start-subprocess "terminal-emulator"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 program args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 'channel-type 'terminal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 'filter 'te-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 'buffer (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 'sentinel 'te-sentinel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 'modify-environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (list (cons "TERM" "emacs-virtual")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (cons "TERMCAP" termcap))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 ;; so instead we resort to this...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (setq te-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (let ((process-environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (cons "TERM=emacs-virtual"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (cons (concat "TERMCAP=" termcap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 process-environment))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (start-process "terminal-emulator"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 "/bin/sh" "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 ;; Yuck!!! Start a shell to set some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 ;; terminal control characteristics.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 ;; Then exec the program we wanted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (format "%s; exec %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 te-stty-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (mapconcat 'te-quote-arg-for-sh
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (cons program args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 " ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (set-process-filter te-process 'te-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (set-process-sentinel te-process 'te-sentinel)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (error (fundamental-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (signal (car err) (cdr err))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 ;; sigh
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (setq inhibit-quit t) ;sport death
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (use-local-map terminal-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (run-hooks 'terminal-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (message "Entering emacs terminal-emulator... Type %s %s for help"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (single-key-description terminal-escape-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (mapconcat 'single-key-description
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (where-is-internal 'te-escape-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 terminal-escape-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (defun te-parse-program-and-args (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (cond ((string-match "\\`\\([a-zA-Z0-9-+=_.@/:]+[ \t]*\\)+\\'" s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (let ((l ()) (p 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (setq l (cons (if (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 "\\([a-zA-Z0-9-+=_.@/:]+\\)\\([ \t]+\\)*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 s p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (prog1 (substring s p (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (setq p (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (if (eq p (length s)) (setq p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (prog1 (substring s p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (setq p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (setq l (nreverse l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (list (car l) (cdr l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 ((and (string-match "[ \t]" s) (not (file-exists-p s)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (list shell-file-name (list "-c" (concat "exec " s))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (t (list s ()))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (put 'terminal-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;; This is only separated out from function terminal-emulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 ;; to keep the latter a little more managable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (defun terminal-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 "Set up variables for use f the terminal-emualtor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 One should not call this -- it is an internal function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 of the terminal-emulator"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (setq major-mode 'terminal-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (setq mode-name "terminal")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 ; (make-local-variable 'Helper-return-blurb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 ; (setq Helper-return-blurb "return to terminal simulator")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (setq mode-line-process '(": %s"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (make-local-variable 'terminal-escape-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (setq terminal-escape-char (default-value 'terminal-escape-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (make-local-variable 'terminal-scrolling)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (setq terminal-scrolling (default-value 'terminal-scrolling))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (make-local-variable 'terminal-more-processing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (setq terminal-more-processing (default-value 'terminal-more-processing))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (make-local-variable 'terminal-redisplay-interval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (setq terminal-redisplay-interval (default-value 'terminal-redisplay-interval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (make-local-variable 'te-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (make-local-variable 'te-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (make-local-variable 'te-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (make-local-variable 'te-pending-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (setq te-pending-output (list 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (make-local-variable 'te-saved-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (setq te-saved-point (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (make-local-variable 'te-pending-output-info) ;for the mode line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (setq te-pending-output-info "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (make-local-variable 'inhibit-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ;(setq inhibit-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (make-local-variable 'te-log-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (setq te-log-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (make-local-variable 'te-more-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (setq te-more-count -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (make-local-variable 'te-redisplay-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (setq te-redisplay-count terminal-redisplay-interval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (make-local-variable 'te-current-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (setq te-current-face 'terminal-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (make-local-variable 'te-current-attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (setq te-current-attributes (list (cons 'standout nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (cons 'underline nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 ;(use-local-map terminal-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 ;; terminal-mode-hook is called above in function terminal-emulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (make-local-variable 'meta-prefix-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (setq meta-prefix-char -1) ;death to ASCII lossage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 ;;;; what a complete loss
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (defun te-quote-arg-for-sh (fuckme)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (cond ((string-match "\\`[a-zA-Z0-9-+=_.@/:]+\\'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 fuckme)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 fuckme)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ((not (string-match "[$]" fuckme))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ;; "[\"\\]" are special to sh and the lisp reader in the same way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (prin1-to-string fuckme))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (let ((harder "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (cretin 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (stupid 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (while (cond ((>= cretin (length fuckme))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 ;; this is the set of chars magic with "..." in `sh'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 ((setq stupid (string-match "[\"\\$]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 fuckme cretin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (t (setq harder (concat harder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (substring fuckme cretin)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (setq harder (concat harder (substring fuckme cretin stupid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ;; Can't use ?\\ since `concat'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 ;; unfortunately does prin1-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 ;; on fixna. Amazing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 "\\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (substring fuckme
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 stupid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (1+ stupid)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 cretin (1+ stupid)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (concat "\"" harder "\"")))))