Mercurial > emacs
annotate lisp/terminal.el @ 105498:3cdeeb563149
Markus Rost <rost at math.uni-bielefeld.de>
(describe-no-warranty): Place point in a slightly better position in
the GPLv3 text.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 07 Oct 2009 02:52:37 +0000 |
parents | dbe70c3aa01d |
children | 009383a57ce8 |
rev | line source |
---|---|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
31168
diff
changeset
|
1 ;;; terminal.el --- terminal emulator for GNU Emacs |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
630
diff
changeset
|
2 |
74442 | 3 ;; Copyright (C) 1986, 1987, 1988, 1989, 1993, 1994, 2001, 2002, 2003, |
100908 | 4 ;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
5 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
751
diff
changeset
|
6 ;; Author: Richard Mlynarik <mly@eddie.mit.edu> |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
751
diff
changeset
|
7 ;; Maintainer: FSF |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2030
diff
changeset
|
8 ;; Keywords: comm, terminals |
161 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
161 | 13 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
161 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
161 | 24 |
14641 | 25 ;;; Commentary: |
26 | |
27 ;;; This file has been censored by the Communications Decency Act. | |
28 ;;; That law was passed under the guise of a ban on pornography, but | |
29 ;;; it bans far more than that. This file did not contain pornography, | |
30 ;;; but it was censored nonetheless. | |
31 | |
32 ;;; For information on US government censorship of the Internet, and | |
33 ;;; what you can do to bring back freedom of the press, see the web | |
34 ;;; site http://www.vtw.org/ | |
35 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
751
diff
changeset
|
36 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
751
diff
changeset
|
37 |
161 | 38 ;;>>TODO |
39 ;;>> ** Nothing can be done about emacs' meta-lossage ** | |
40 ;;>> (without redoing keymaps `sanely' -- ask Mly for details) | |
41 | |
42 ;;>> One probably wants to do setenv MORE -c when running with | |
43 ;;>> more-processing enabled. | |
44 | |
45 (require 'ehelp) | |
46 | |
17926
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
47 (defgroup terminal nil |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
48 "Terminal emulator for Emacs." |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
49 :group 'terminals) |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
50 |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
51 |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
52 (defcustom terminal-escape-char ?\C-^ |
100171 | 53 "All characters except for this are passed verbatim through the |
161 | 54 terminal-emulator. This character acts as a prefix for commands |
55 to the emulator program itself. Type this character twice to send | |
56 it through the emulator. Type ? after typing it for a list of | |
57 possible commands. | |
17926
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
58 This variable is local to each terminal-emulator buffer." |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
59 :type 'character |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
60 :group 'terminal) |
161 | 61 |
42206 | 62 (defcustom terminal-scrolling t ;;>> Setting this to t sort-of defeats my whole aim in writing this package... |
100171 | 63 "If non-nil, the terminal-emulator will losingly `scroll' when output occurs |
161 | 64 past the bottom of the screen. If nil, output will win and `wrap' to the top |
65 of the screen. | |
17926
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
66 This variable is local to each terminal-emulator buffer." |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
67 :type 'boolean |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
68 :group 'terminal) |
161 | 69 |
17926
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
70 (defcustom terminal-more-processing t |
100171 | 71 "If non-nil, do more-processing. |
17926
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
72 This variable is local to each terminal-emulator buffer." |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
73 :type 'boolean |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
74 :group 'terminal) |
161 | 75 |
76 ;; If you are the sort of loser who uses scrolling without more breaks | |
77 ;; and expects to actually see anything, you should probably set this to | |
78 ;; around 400 | |
17926
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
79 (defcustom terminal-redisplay-interval 5000 |
100171 | 80 "Maximum number of characters which will be processed by the |
161 | 81 terminal-emulator before a screen redisplay is forced. |
82 Set this to a large value for greater throughput, | |
83 set it smaller for more frequent updates but overall slower | |
17926
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
84 performance." |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
85 :type 'integer |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
86 :group 'terminal) |
161 | 87 |
88 (defvar terminal-more-break-insertion | |
89 "*** More break -- Press space to continue ***") | |
90 | |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
91 (defvar terminal-meta-map nil) |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
92 (if terminal-meta-map |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
93 nil |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
94 (let ((map (make-sparse-keymap))) |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
95 (define-key map [t] 'te-pass-through) |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
96 (setq terminal-meta-map map))) |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
97 |
161 | 98 (defvar terminal-map nil) |
99 (if terminal-map | |
100 nil | |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
101 (let ((map (make-sparse-keymap))) |
43171
b9b20fd684a4
(terminal-map): Define [menu-bar] so global def is seen.
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
102 ;; Prevent defining [menu-bar] as te-pass-through |
b9b20fd684a4
(terminal-map): Define [menu-bar] so global def is seen.
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
103 ;; so we allow the global menu bar to be visible. |
b9b20fd684a4
(terminal-map): Define [menu-bar] so global def is seen.
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
104 (define-key map [menu-bar] (make-sparse-keymap)) |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
105 (define-key map [t] 'te-pass-through) |
8852
90a35a24cde1
(terminal-map): Define switch-frame.
Richard M. Stallman <rms@gnu.org>
parents:
7374
diff
changeset
|
106 (define-key map [switch-frame] 'handle-switch-frame) |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
107 (define-key map "\e" terminal-meta-map) |
161 | 108 ;(define-key map "\C-l" |
109 ; '(lambda () (interactive) (te-pass-through) (redraw-display))) | |
110 (setq terminal-map map))) | |
111 | |
2587
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
112 (defvar terminal-escape-map nil) |
161 | 113 (if terminal-escape-map |
114 nil | |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
115 (let ((map (make-sparse-keymap))) |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
116 (define-key map [t] 'undefined) |
161 | 117 (let ((s "0")) |
118 (while (<= (aref s 0) ?9) | |
119 (define-key map s 'digit-argument) | |
120 (aset s 0 (1+ (aref s 0))))) | |
121 (define-key map "b" 'switch-to-buffer) | |
122 (define-key map "o" 'other-window) | |
123 (define-key map "e" 'te-set-escape-char) | |
124 (define-key map "\C-l" 'redraw-display) | |
125 (define-key map "\C-o" 'te-flush-pending-output) | |
126 (define-key map "m" 'te-toggle-more-processing) | |
127 (define-key map "x" 'te-escape-extended-command) | |
128 ;;>> What use is this? Why is it in the default terminal-emulator map? | |
129 (define-key map "w" 'te-edit) | |
130 (define-key map "?" 'te-escape-help) | |
131 (define-key map (char-to-string help-char) 'te-escape-help) | |
132 (setq terminal-escape-map map))) | |
133 | |
2587
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
134 (defvar te-escape-command-alist nil) |
161 | 135 (if te-escape-command-alist |
136 nil | |
137 (setq te-escape-command-alist | |
138 '(("Set Escape Character" . te-set-escape-char) | |
139 ;;>> What use is this? Why is it in the default terminal-emulator map? | |
140 ("Edit" . te-edit) | |
141 ("Refresh" . redraw-display) | |
142 ("Record Output" . te-set-output-log) | |
143 ("Photo" . te-set-output-log) | |
144 ("Tofu" . te-tofu) ;; confuse the uninitiated | |
145 ("Stuff Input" . te-stuff-string) | |
146 ("Flush Pending Output" . te-flush-pending-output) | |
147 ("Enable More Processing" . te-enable-more-processing) | |
148 ("Disable More Processing" . te-disable-more-processing) | |
149 ("Scroll at end of page" . te-do-scrolling) | |
150 ("Wrap at end of page" . te-do-wrapping) | |
151 ("Switch To Buffer" . switch-to-buffer) | |
152 ("Other Window" . other-window) | |
153 ("Kill Buffer" . kill-buffer) | |
154 ("Help" . te-escape-help) | |
155 ("Set Redisplay Interval" . te-set-redisplay-interval) | |
156 ))) | |
157 | |
2587
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
158 (defvar terminal-more-break-map nil) |
161 | 159 (if terminal-more-break-map |
160 nil | |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
161 (let ((map (make-sparse-keymap))) |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
162 (define-key map [t] 'te-more-break-unread) |
161 | 163 (define-key map (char-to-string help-char) 'te-more-break-help) |
164 (define-key map " " 'te-more-break-resume) | |
165 (define-key map "\C-l" 'redraw-display) | |
166 (define-key map "\C-o" 'te-more-break-flush-pending-output) | |
167 ;;>>> this isn't right | |
168 ;(define-key map "\^?" 'te-more-break-flush-pending-output) ;DEL | |
169 (define-key map "\r" 'te-more-break-advance-one-line) | |
170 | |
171 (setq terminal-more-break-map map))) | |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
172 |
161 | 173 |
2587
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
174 ;;; Pacify the byte compiler |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
175 (defvar te-process nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
176 (defvar te-log-buffer nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
177 (defvar te-height nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
178 (defvar te-width nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
179 (defvar te-more-count nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
180 (defvar te-redisplay-count nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
181 (defvar te-pending-output nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
182 (defvar te-saved-point) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
183 (defvar te-more-old-point nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
184 (defvar te-more-old-local-map nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
185 (defvar te-more-old-filter nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
186 (defvar te-more-old-mode-line-format nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
187 (defvar te-pending-output-info nil) |
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
188 |
10294 | 189 ;; Required to support terminfo systems |
14888
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
190 (defconst te-terminal-name-prefix "emacs-em" |
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
191 "Prefix used for terminal type names for Terminfo.") |
25417
28211e20b0e4
(te-terminfo-directory): Use temporary-file-directory.
Richard M. Stallman <rms@gnu.org>
parents:
24253
diff
changeset
|
192 (defconst te-terminfo-directory |
28211e20b0e4
(te-terminfo-directory): Use temporary-file-directory.
Richard M. Stallman <rms@gnu.org>
parents:
24253
diff
changeset
|
193 (file-name-as-directory |
28211e20b0e4
(te-terminfo-directory): Use temporary-file-directory.
Richard M. Stallman <rms@gnu.org>
parents:
24253
diff
changeset
|
194 (expand-file-name "emacs-terminfo" temporary-file-directory)) |
14888
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
195 "Directory used for run-time terminal definition files for Terminfo.") |
10294 | 196 (defvar te-terminal-name nil) |
2587
1cad2ff5ab80
I started to clean this up and make it work under System V, until I hit a wall.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
197 |
161 | 198 ;;;; escape map |
199 | |
200 (defun te-escape () | |
201 (interactive) | |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
202 (let (s |
13057
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
203 (local (current-local-map)) |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
204 (global (current-global-map))) |
161 | 205 (unwind-protect |
13057
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
206 (progn |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
207 (use-global-map terminal-escape-map) |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
208 (use-local-map terminal-escape-map) |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
209 (setq s (read-key-sequence |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
210 (if current-prefix-arg |
56928
b1d0e8312180
(te-escape): Show `?' in prompt for help key.
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
211 (format "Emacs Terminal escape[%s for help]> %d " |
b1d0e8312180
(te-escape): Show `?' in prompt for help key.
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
212 (substitute-command-keys |
b1d0e8312180
(te-escape): Show `?' in prompt for help key.
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
213 "\\<terminal-escape-map>\\[te-escape-help]") |
13057
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
214 (prefix-numeric-value current-prefix-arg)) |
56928
b1d0e8312180
(te-escape): Show `?' in prompt for help key.
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
215 (format "Emacs Terminal escape[%s for help]> " |
b1d0e8312180
(te-escape): Show `?' in prompt for help key.
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
216 (substitute-command-keys |
b1d0e8312180
(te-escape): Show `?' in prompt for help key.
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
217 "\\<terminal-escape-map>\\[te-escape-help]")))))) |
161 | 218 (use-global-map global) |
219 (use-local-map local)) | |
13057
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
220 |
161 | 221 (message "") |
13057
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
222 |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
223 (cond |
13057
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
224 ;; Certain keys give vector notation, like [escape] when |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
225 ;; you hit esc key... |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
226 ((and (stringp s) |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
227 (string= s (make-string 1 terminal-escape-char))) |
101010
4efc7ca085ce
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
228 (setq last-command-event terminal-escape-char) |
13057
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
229 (let ((terminal-escape-char -259)) |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
230 (te-pass-through))) |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
231 |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
232 ((setq s (lookup-key terminal-escape-map s)) |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
233 (call-interactively s))) |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
234 |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
235 )) |
5c78211aa9e0
(te-escape, te-escape-help): Handle non-ASCII events.
Karl Heuer <kwzh@gnu.org>
parents:
11569
diff
changeset
|
236 |
161 | 237 |
238 (defun te-escape-help () | |
239 "Provide help on commands available after terminal-escape-char is typed." | |
240 (interactive) | |
241 (message "Terminal emulator escape help...") | |
242 (let ((char (single-key-description terminal-escape-char))) | |
243 (with-electric-help | |
244 (function (lambda () | |
245 (princ (format "Terminal-emulator escape, invoked by \"%s\" | |
246 Type \"%s\" twice to send a single \"%s\" through. | |
247 | |
248 Other chars following \"%s\" are interpreted as follows:\n" | |
249 char char char char)) | |
250 | |
251 (princ (substitute-command-keys "\\{terminal-escape-map}\n")) | |
252 (princ (format "\nSubcommands of \"%s\" (%s)\n" | |
253 (where-is-internal 'te-escape-extended-command | |
5774
b57901dfbd40
(te-escape-help, te-more-break-help, terminal-emulator):
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
254 terminal-escape-map t) |
161 | 255 'te-escape-extended-command)) |
43171
b9b20fd684a4
(terminal-map): Define [menu-bar] so global def is seen.
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
256 (let ((l (sort (copy-sequence te-escape-command-alist) |
b9b20fd684a4
(terminal-map): Define [menu-bar] so global def is seen.
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
257 (function (lambda (a b) |
b9b20fd684a4
(terminal-map): Define [menu-bar] so global def is seen.
Richard M. Stallman <rms@gnu.org>
parents:
42206
diff
changeset
|
258 (string< (car a) (car b))))))) |
161 | 259 (while l |
260 (let ((doc (or (documentation (cdr (car l))) | |
261 "Not documented"))) | |
262 (if (string-match "\n" doc) | |
263 ;; just use first line of documentation | |
264 (setq doc (substring doc 0 (match-beginning 0)))) | |
265 (princ " \"") | |
266 (princ (car (car l))) | |
267 (princ "\":\n ") | |
268 (princ doc) | |
269 (write-char ?\n)) | |
270 (setq l (cdr l)))) | |
271 nil))))) | |
272 | |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
273 |
161 | 274 |
275 (defun te-escape-extended-command () | |
276 (interactive) | |
277 (let ((c (let ((completion-ignore-case t)) | |
278 (completing-read "terminal command: " | |
279 te-escape-command-alist | |
280 nil t)))) | |
281 (if c | |
282 (catch 'foo | |
283 (setq c (downcase c)) | |
284 (let ((l te-escape-command-alist)) | |
285 (while l | |
286 (if (string= c (downcase (car (car l)))) | |
287 (throw 'foo (call-interactively (cdr (car l)))) | |
288 (setq l (cdr l))))))))) | |
289 | |
290 ;; not used. | |
291 (defun te-escape-extended-command-unread () | |
292 (interactive) | |
2030
ffe1f05d5727
(te-escape-extended-command-unread): Handle any key sequence.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
293 (setq unread-command-events (listify-key-sequence (this-command-keys))) |
161 | 294 (te-escape-extended-command)) |
295 | |
296 (defun te-set-escape-char (c) | |
297 "Change the terminal-emulator escape character." | |
298 (interactive "cSet escape character to: ") | |
299 (let ((o terminal-escape-char)) | |
300 (message (if (= o c) | |
751
db46eb163798
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
301 "\"%s\" is the escape char" |
db46eb163798
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
302 "\"%s\" is now the escape; \"%s\" passes through") |
161 | 303 (single-key-description c) |
304 (single-key-description o)) | |
305 (setq terminal-escape-char c))) | |
306 | |
307 | |
308 (defun te-stuff-string (string) | |
309 "Read a string to send to through the terminal emulator | |
310 as though that string had been typed on the keyboard. | |
311 | |
312 Very poor man's file transfer protocol." | |
313 (interactive "sStuff string: ") | |
314 (process-send-string te-process string)) | |
315 | |
316 (defun te-set-output-log (name) | |
317 "Record output from the terminal emulator in a buffer." | |
318 (interactive (list (if te-log-buffer | |
319 nil | |
320 (read-buffer "Record output in buffer: " | |
321 (format "%s output-log" | |
322 (buffer-name (current-buffer))) | |
323 nil)))) | |
324 (if (or (null name) (equal name "")) | |
325 (progn (setq te-log-buffer nil) | |
326 (message "Output logging off.")) | |
327 (if (get-buffer name) | |
328 nil | |
329 (save-excursion | |
330 (set-buffer (get-buffer-create name)) | |
331 (fundamental-mode) | |
332 (buffer-disable-undo (current-buffer)) | |
333 (erase-buffer))) | |
334 (setq te-log-buffer (get-buffer name)) | |
335 (message "Recording terminal emulator output into buffer \"%s\"" | |
336 (buffer-name te-log-buffer)))) | |
337 | |
338 (defun te-tofu () | |
339 "Discontinue output log." | |
340 (interactive) | |
341 (te-set-output-log nil)) | |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
342 |
161 | 343 |
344 (defun te-toggle (sym arg) | |
345 (set sym (cond ((not (numberp arg)) arg) | |
346 ((= arg 1) (not (symbol-value sym))) | |
347 ((< arg 0) nil) | |
348 (t t)))) | |
349 | |
350 (defun te-toggle-more-processing (arg) | |
351 (interactive "p") | |
352 (message (if (te-toggle 'terminal-more-processing arg) | |
353 "More processing on" "More processing off")) | |
354 (if terminal-more-processing (setq te-more-count -1))) | |
355 | |
356 (defun te-toggle-scrolling (arg) | |
357 (interactive "p") | |
358 (message (if (te-toggle 'terminal-scrolling arg) | |
359 "Scroll at end of page" "Wrap at end of page"))) | |
360 | |
361 (defun te-enable-more-processing () | |
362 "Enable ** MORE ** processing" | |
363 (interactive) | |
364 (te-toggle-more-processing t)) | |
365 | |
366 (defun te-disable-more-processing () | |
367 "Disable ** MORE ** processing" | |
368 (interactive) | |
369 (te-toggle-more-processing nil)) | |
370 | |
371 (defun te-do-scrolling () | |
372 "Scroll at end of page (yuck)" | |
373 (interactive) | |
374 (te-toggle-scrolling t)) | |
375 | |
376 (defun te-do-wrapping () | |
377 "Wrap to top of window at end of page" | |
378 (interactive) | |
379 (te-toggle-scrolling nil)) | |
380 | |
381 | |
382 (defun te-set-redisplay-interval (arg) | |
383 "Set the maximum interval (in output characters) between screen updates. | |
384 Set this number to large value for greater throughput, | |
385 set it smaller for more frequent updates (but overall slower performance." | |
386 (interactive "NMax number of output chars between redisplay updates: ") | |
387 (setq arg (max arg 1)) | |
388 (setq terminal-redisplay-interval arg | |
389 te-redisplay-count 0)) | |
390 | |
391 ;;;; more map | |
392 | |
393 ;; every command -must- call te-more-break-unwind | |
394 ;; or grave lossage will result | |
395 | |
396 (put 'te-more-break-unread 'suppress-keymap t) | |
397 (defun te-more-break-unread () | |
398 (interactive) | |
101013
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
399 (if (eq last-input-event terminal-escape-char) |
161 | 400 (call-interactively 'te-escape) |
401 (message "Continuing from more break (\"%s\" typed, %d chars output pending...)" | |
101013
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
402 (single-key-description last-input-event) |
161 | 403 (te-pending-output-length)) |
404 (setq te-more-count 259259) | |
405 (te-more-break-unwind) | |
406 (let ((terminal-more-processing nil)) | |
407 (te-pass-through)))) | |
408 | |
409 (defun te-more-break-resume () | |
410 "Proceed past the **MORE** break, | |
411 allowing the next page of output to appear" | |
412 (interactive) | |
413 (message "Continuing from more break") | |
414 (te-more-break-unwind)) | |
415 | |
416 (defun te-more-break-help () | |
417 "Provide help on commands available in a terminal-emulator **MORE** break" | |
418 (interactive) | |
419 (message "Terminal-emulator more break help...") | |
420 (sit-for 0) | |
421 (with-electric-help | |
422 (function (lambda () | |
423 (princ "Terminal-emulator more break.\n\n") | |
424 (princ (format "Type \"%s\" (te-more-break-resume)\n%s\n" | |
425 (where-is-internal 'te-more-break-resume | |
5774
b57901dfbd40
(te-escape-help, te-more-break-help, terminal-emulator):
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
426 terminal-more-break-map t) |
161 | 427 (documentation 'te-more-break-resume))) |
428 (princ (substitute-command-keys "\\{terminal-more-break-map}\n")) | |
429 (princ "Any other key is passed through to the program | |
430 running under the terminal emulator and disables more processing until | |
431 all pending output has been dealt with.") | |
432 nil)))) | |
433 | |
434 | |
435 (defun te-more-break-advance-one-line () | |
436 "Allow one more line of text to be output before doing another more break." | |
437 (interactive) | |
438 (setq te-more-count 1) | |
439 (te-more-break-unwind)) | |
440 | |
441 (defun te-more-break-flush-pending-output () | |
442 "Discard any output which has been received by the terminal emulator but | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3387
diff
changeset
|
443 not yet processed and then proceed from the more break." |
161 | 444 (interactive) |
445 (te-more-break-unwind) | |
446 (te-flush-pending-output)) | |
447 | |
448 (defun te-flush-pending-output () | |
449 "Discard any as-yet-unprocessed output which has been received by | |
450 the terminal emulator." | |
451 (interactive) | |
452 ;; this could conceivably be confusing in the presence of | |
453 ;; escape-sequences spanning process-output chunks | |
454 (if (null (cdr te-pending-output)) | |
455 (message "(There is no output pending)") | |
456 (let ((length (te-pending-output-length))) | |
457 (message "Flushing %d chars of pending output" length) | |
458 (setq te-pending-output | |
459 (list 0 (format "\n*** %d chars of pending output flushed ***\n" | |
460 length))) | |
461 (te-update-pending-output-display) | |
462 (te-process-output nil) | |
463 (sit-for 0)))) | |
464 | |
465 | |
466 (defun te-pass-through () | |
467 "Character is passed to the program running under the terminal emulator. | |
468 One characters is treated specially: | |
469 the terminal escape character (normally C-^) | |
470 lets you type a terminal emulator command." | |
471 (interactive) | |
101013
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
472 (cond ((eq last-input-event terminal-escape-char) |
161 | 473 (call-interactively 'te-escape)) |
474 (t | |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
475 ;; Convert `return' to C-m, etc. |
101013
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
476 (if (and (symbolp last-input-event) |
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
477 (get last-input-event 'ascii-character)) |
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
478 (setq last-input-event (get last-input-event 'ascii-character))) |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
479 ;; Convert meta characters to 8-bit form for transmission. |
101013
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
480 (if (and (integerp last-input-event) |
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
481 (not (zerop (logand last-input-event ?\M-\^@)))) |
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
482 (setq last-input-event (+ 128 (logand last-input-event 127)))) |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
483 ;; Now ignore all but actual characters. |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
484 ;; (It ought to be possible to send through function |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
485 ;; keys as character sequences if we add a description |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
486 ;; to our termcap entry of what they should look like.) |
101013
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
487 (if (integerp last-input-event) |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
488 (progn |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
489 (and terminal-more-processing (null (cdr te-pending-output)) |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
490 (te-set-more-count nil)) |
101013
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
491 (process-send-string te-process (make-string 1 last-input-event)) |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
492 (te-process-output t)) |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
493 (message "Function key `%s' ignored" |
101013
dbe70c3aa01d
Replace last-input-char with last-input-event.
Glenn Morris <rgm@gnu.org>
parents:
101010
diff
changeset
|
494 (single-key-description last-input-event)))))) |
161 | 495 |
496 | |
497 (defun te-set-window-start () | |
498 (let* ((w (get-buffer-window (current-buffer))) | |
499 (h (if w (window-height w)))) | |
500 (cond ((not w)) ; buffer not displayed | |
501 ((>= h (/ (- (point) (point-min)) (1+ te-width))) | |
502 ;; this is the normal case | |
503 (set-window-start w (point-min))) | |
504 ;; this happens if some vandal shrinks our window. | |
505 ((>= h (/ (- (point-max) (point)) (1+ te-width))) | |
506 (set-window-start w (- (point-max) (* h (1+ te-width)) -1))) | |
507 ;; I give up. | |
508 (t nil)))) | |
509 | |
510 (defun te-pending-output-length () | |
511 (let ((length (car te-pending-output)) | |
512 (tem (cdr te-pending-output))) | |
513 (while tem | |
514 (setq length (+ length (length (car tem))) tem (cdr tem))) | |
515 length)) | |
516 | |
517 ;;>> What use is this terminal-edit stuff anyway? | |
518 ;;>> If nothing else, it was written by somebody who didn't | |
519 ;;>> competently understand the terminal-emulator... | |
520 | |
521 (defvar terminal-edit-map nil) | |
522 (if terminal-edit-map | |
523 nil | |
524 (setq terminal-edit-map (make-sparse-keymap)) | |
525 (define-key terminal-edit-map "\C-c\C-c" 'terminal-cease-edit)) | |
526 | |
527 ;; Terminal Edit mode is suitable only for specially formatted data. | |
528 (put 'terminal-edit-mode 'mode-class 'special) | |
529 | |
530 (defun terminal-edit-mode () | |
531 "Major mode for editing the contents of a terminal-emulator buffer. | |
532 The editing commands are the same as in Fundamental mode, | |
7374 | 533 together with a command \\<terminal-edit-map>to return to terminal emulation: \\[terminal-cease-edit]." |
161 | 534 (use-local-map terminal-edit-map) |
535 (setq major-mode 'terminal-edit-mode) | |
536 (setq mode-name "Terminal Edit") | |
537 (setq mode-line-modified (default-value 'mode-line-modified)) | |
538 (setq mode-line-process nil) | |
62745
76921bae4308
(terminal-edit-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents:
62460
diff
changeset
|
539 (run-mode-hooks 'terminal-edit-mode-hook)) |
161 | 540 |
541 (defun te-edit () | |
542 "Start editing the terminal emulator buffer with ordinary Emacs commands." | |
543 (interactive) | |
544 (terminal-edit-mode) | |
11569
a2b107c4f2f1
(te-edit, te-more-break-unwind): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
10848
diff
changeset
|
545 (force-mode-line-update) |
161 | 546 ;; Make mode line update. |
547 (if (eq (key-binding "\C-c\C-c") 'terminal-cease-edit) | |
548 (message "Editing: Type C-c C-c to return to Terminal") | |
14333
b14697aa6929
(te-edit): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
549 (message "%s" |
b14697aa6929
(te-edit): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
550 (substitute-command-keys |
161 | 551 "Editing: Type \\[terminal-cease-edit] to return to Terminal")))) |
552 | |
553 (defun terminal-cease-edit () | |
554 "Finish editing message; switch back to Terminal proper." | |
555 (interactive) | |
556 | |
557 ;;>> emulator will blow out if buffer isn't exactly te-width x te-height | |
558 (let ((buffer-read-only nil)) | |
559 (widen) | |
560 (let ((opoint (point-marker)) | |
561 (width te-width) | |
562 (h (1- te-height))) | |
563 (goto-char (point-min)) | |
564 (while (>= h 0) | |
565 (let ((p (point))) | |
566 (cond ((search-forward "\n" (+ p width) 'move) | |
567 (forward-char -1) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
568 (insert-char ?\s (- width (- (point) p))) |
161 | 569 (forward-char 1)) |
570 ((eobp) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
571 (insert-char ?\s (- width (- (point) p)))) |
161 | 572 ((= (following-char) ?\n) |
573 (forward-char 1)) | |
574 (t | |
575 (setq p (point)) | |
576 (if (search-forward "\n" nil t) | |
577 (delete-region p (1- (point))) | |
578 (delete-region p (point-max)))))) | |
579 (if (= h 0) | |
580 (if (not (eobp)) (delete-region (point) (point-max))) | |
581 (if (eobp) (insert ?\n))) | |
582 (setq h (1- h))) | |
583 (goto-char opoint) | |
584 (set-marker opoint nil nil) | |
585 (setq te-saved-point (point)) | |
586 (setq te-redisplay-count 0) | |
587 (setq te-more-count -1))) | |
588 | |
589 (setq mode-line-modified (default-value 'mode-line-modified)) | |
7374 | 590 (use-local-map terminal-map) |
161 | 591 (setq major-mode 'terminal-mode) |
592 (setq mode-name "terminal") | |
7077
4c0af7fbb42e
(terminal-cease-edit, terminal-mode):
Richard M. Stallman <rms@gnu.org>
parents:
6423
diff
changeset
|
593 (setq mode-line-process '(":%s"))) |
161 | 594 |
595 ;;;; more break hair | |
596 | |
597 (defun te-more-break () | |
598 (te-set-more-count t) | |
599 (make-local-variable 'te-more-old-point) | |
600 (setq te-more-old-point (point)) | |
601 (make-local-variable 'te-more-old-local-map) | |
602 (setq te-more-old-local-map (current-local-map)) | |
603 (use-local-map terminal-more-break-map) | |
604 (make-local-variable 'te-more-old-filter) | |
605 (setq te-more-old-filter (process-filter te-process)) | |
606 (make-local-variable 'te-more-old-mode-line-format) | |
607 (setq te-more-old-mode-line-format mode-line-format | |
608 mode-line-format (list "-- **MORE** " | |
609 mode-line-buffer-identification | |
610 "%-")) | |
611 (set-process-filter te-process | |
612 (function (lambda (process string) | |
613 (save-excursion | |
614 (set-buffer (process-buffer process)) | |
615 (setq te-pending-output (nconc te-pending-output | |
616 (list string)))) | |
617 (te-update-pending-output-display)))) | |
618 (te-update-pending-output-display) | |
619 (if (eq (window-buffer (selected-window)) (current-buffer)) | |
620 (message "More break ")) | |
621 (or (eobp) | |
622 (null terminal-more-break-insertion) | |
623 (save-excursion | |
624 (forward-char 1) | |
625 (delete-region (point) (+ (point) te-width)) | |
626 (insert terminal-more-break-insertion))) | |
627 (run-hooks 'terminal-more-break-hook) | |
628 (sit-for 0) ;get display to update | |
629 (throw 'te-process-output t)) | |
630 | |
631 (defun te-more-break-unwind () | |
632 (use-local-map te-more-old-local-map) | |
633 (set-process-filter te-process te-more-old-filter) | |
634 (goto-char te-more-old-point) | |
635 (setq mode-line-format te-more-old-mode-line-format) | |
11569
a2b107c4f2f1
(te-edit, te-more-break-unwind): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
10848
diff
changeset
|
636 (force-mode-line-update) |
161 | 637 (let ((buffer-read-only nil)) |
638 (cond ((eobp)) | |
639 (terminal-more-break-insertion | |
640 (forward-char 1) | |
641 (delete-region (point) | |
642 (+ (point) (length terminal-more-break-insertion))) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
643 (insert-char ?\s te-width) |
161 | 644 (goto-char te-more-old-point))) |
645 (setq te-more-old-point nil) | |
646 (let ((te-more-count 259259)) | |
647 (te-newline))) | |
648 ;(sit-for 0) | |
649 (te-process-output t)) | |
650 | |
651 (defun te-set-more-count (newline) | |
652 (let ((line (/ (- (point) (point-min)) (1+ te-width)))) | |
653 (if newline (setq line (1+ line))) | |
654 (cond ((= line te-height) | |
655 (setq te-more-count te-height)) | |
656 ;>>>> something is strange. Investigate this! | |
657 ((= line (1- te-height)) | |
658 (setq te-more-count te-height)) | |
659 ((or (< line (/ te-height 2)) | |
660 (> (- te-height line) 10)) | |
661 ;; break at end of this page | |
662 (setq te-more-count (- te-height line))) | |
663 (t | |
664 ;; migrate back towards top (ie bottom) of screen. | |
665 (setq te-more-count (- te-height | |
666 (if (> te-height 10) 2 1))))))) | |
667 | |
668 | |
669 ;;;; More or less straight-forward terminal escapes | |
670 | |
671 ;; ^j, meaning `newline' to non-display programs. | |
672 ;; (Who would think of ever writing a system which doesn't understand | |
673 ;; display terminals natively? Un*x: The Operating System of the Future.) | |
674 (defun te-newline () | |
675 "Move down a line, optionally do more processing, perhaps wrap/scroll, | |
676 move to start of new line, clear to end of line." | |
677 (end-of-line) | |
678 (cond ((not terminal-more-processing)) | |
679 ((< (setq te-more-count (1- te-more-count)) 0) | |
680 (te-set-more-count t)) | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
681 ((eq te-more-count 0) |
161 | 682 ;; this doesn't return |
683 (te-more-break))) | |
684 (if (eobp) | |
685 (progn | |
686 (delete-region (point-min) (+ (point-min) te-width)) | |
687 (goto-char (point-min)) | |
688 (if terminal-scrolling | |
689 (progn (delete-char 1) | |
690 (goto-char (point-max)) | |
691 (insert ?\n)))) | |
692 (forward-char 1) | |
693 (delete-region (point) (+ (point) te-width))) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
694 (insert-char ?\s te-width) |
161 | 695 (beginning-of-line) |
696 (te-set-window-start)) | |
697 | |
698 ; ^p = x+32 y+32 | |
699 (defun te-move-to-position () | |
700 ;; must offset by #o40 since cretinous unix won't send a 004 char through | |
701 (let ((y (- (te-get-char) 32)) | |
702 (x (- (te-get-char) 32))) | |
703 (if (or (> x te-width) | |
704 (> y te-height)) | |
705 () | |
706 (goto-char (+ (point-min) x (* y (1+ te-width)))) | |
707 ;(te-set-window-start?) | |
708 )) | |
709 (setq te-more-count -1)) | |
710 | |
711 | |
712 | |
713 ;; ^p c | |
714 (defun te-clear-rest-of-line () | |
715 (save-excursion | |
716 (let ((n (- (point) (progn (end-of-line) (point))))) | |
717 (delete-region (point) (+ (point) n)) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
718 (insert-char ?\s (- n))))) |
161 | 719 |
720 | |
721 ;; ^p C | |
722 (defun te-clear-rest-of-screen () | |
723 (save-excursion | |
724 (te-clear-rest-of-line) | |
725 (while (progn (end-of-line) (not (eobp))) | |
726 (forward-char 1) (end-of-line) | |
727 (delete-region (- (point) te-width) (point)) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
728 (insert-char ?\s te-width)))) |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
729 |
161 | 730 |
731 ;; ^p ^l | |
732 (defun te-clear-screen () | |
733 ;; regenerate buffer to compensate for (nonexistent!!) bugs. | |
734 (erase-buffer) | |
735 (let ((i 0)) | |
736 (while (< i te-height) | |
737 (setq i (1+ i)) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
738 (insert-char ?\s te-width) |
161 | 739 (insert ?\n))) |
740 (delete-region (1- (point-max)) (point-max)) | |
741 (goto-char (point-min)) | |
742 (setq te-more-count -1)) | |
743 | |
744 | |
745 ;; ^p ^o count+32 | |
746 (defun te-insert-lines () | |
747 (if (not (bolp)) | |
748 ();(error "fooI") | |
749 (save-excursion | |
750 (let* ((line (- te-height (/ (- (point) (point-min)) (1+ te-width)) -1)) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
751 (n (min (- (te-get-char) ?\s) line)) |
161 | 752 (i 0)) |
753 (delete-region (- (point-max) (* n (1+ te-width))) (point-max)) | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
754 (if (eq (point) (point-max)) (insert ?\n)) |
161 | 755 (while (< i n) |
756 (setq i (1+ i)) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
757 (insert-char ?\s te-width) |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
758 (or (eq i line) (insert ?\n)))))) |
161 | 759 (setq te-more-count -1)) |
760 | |
761 | |
762 ;; ^p ^k count+32 | |
763 (defun te-delete-lines () | |
764 (if (not (bolp)) | |
765 ();(error "fooD") | |
766 (let* ((line (- te-height (/ (- (point) (point-min)) (1+ te-width)) -1)) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
767 (n (min (- (te-get-char) ?\s) line)) |
161 | 768 (i 0)) |
769 (delete-region (point) | |
770 (min (+ (point) (* n (1+ te-width))) (point-max))) | |
771 (save-excursion | |
772 (goto-char (point-max)) | |
773 (while (< i n) | |
774 (setq i (1+ i)) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
775 (insert-char ?\s te-width) |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
776 (or (eq i line) (insert ?\n)))))) |
161 | 777 (setq te-more-count -1)) |
778 | |
779 ;; ^p ^a | |
780 (defun te-beginning-of-line () | |
781 (beginning-of-line)) | |
782 | |
783 ;; ^p ^b | |
784 (defun te-backward-char () | |
785 (if (not (bolp)) | |
786 (backward-char 1))) | |
787 | |
788 ;; ^p ^f | |
789 (defun te-forward-char () | |
790 (if (not (eolp)) | |
791 (forward-char 1))) | |
792 | |
793 | |
794 ;; 0177 | |
795 (defun te-delete () | |
796 (if (bolp) | |
797 () | |
798 (delete-region (1- (point)) (point)) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
799 (insert ?\s) |
161 | 800 (forward-char -1))) |
801 | |
802 ;; ^p ^g | |
803 (defun te-beep () | |
804 (beep)) | |
805 | |
806 | |
807 ;; ^p _ count+32 | |
808 (defun te-insert-spaces () | |
809 (let* ((p (point)) | |
810 (n (min (- (te-get-char) 32) | |
811 (- (progn (end-of-line) (point)) p)))) | |
812 (if (<= n 0) | |
813 nil | |
814 (delete-char (- n)) | |
815 (goto-char p) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
816 (insert-char ?\s n)) |
161 | 817 (goto-char p))) |
818 | |
819 ;; ^p d count+32 (should be ^p ^d but cretinous un*x won't send ^d chars!!!) | |
820 (defun te-delete-char () | |
821 (let* ((p (point)) | |
822 (n (min (- (te-get-char) 32) | |
823 (- (progn (end-of-line) (point)) p)))) | |
824 (if (<= n 0) | |
825 nil | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
826 (insert-char ?\s n) |
161 | 827 (goto-char p) |
828 (delete-char n)) | |
829 (goto-char p))) | |
830 | |
831 | |
832 | |
14641 | 833 ;; disgusting unix-required excrement |
161 | 834 ;; Are we living twenty years in the past yet? |
835 | |
836 (defun te-losing-unix () | |
837 nil) | |
838 | |
839 ;; ^i | |
840 (defun te-output-tab () | |
841 (let* ((p (point)) | |
842 (x (- p (progn (beginning-of-line) (point)))) | |
843 (l (min (- 8 (logand x 7)) | |
844 (progn (end-of-line) (- (point) p))))) | |
845 (goto-char (+ p l)))) | |
846 | |
847 ;; ^p ^j | |
848 ;; Handle the `do' or `nl' termcap capability. | |
849 ;;>> I am not sure why this broken, obsolete, capability is here. | |
850 ;;>> Perhaps it is for VIle. No comment was made about why it | |
851 ;;>> was added (in "Sun Dec 6 01:22:27 1987 Richard Stallman") | |
852 (defun te-down-vertically-or-scroll () | |
853 "Move down a line vertically, or scroll at bottom." | |
854 (let ((column (current-column))) | |
855 (end-of-line) | |
856 (if (eobp) | |
857 (progn | |
858 (delete-region (point-min) (+ (point-min) te-width)) | |
859 (goto-char (point-min)) | |
860 (delete-char 1) | |
861 (goto-char (point-max)) | |
862 (insert ?\n) | |
74244
d4c2b4add4ca
(terminal-cease-edit, te-more-break-unwind, te-newline, te-clear-rest-of-line,
Juanma Barranquero <lekktu@gmail.com>
parents:
73752
diff
changeset
|
863 (insert-char ?\s te-width) |
161 | 864 (beginning-of-line)) |
865 (forward-line 1)) | |
866 (move-to-column column)) | |
867 (te-set-window-start)) | |
868 | |
869 ;; Also: | |
870 ;; ^m => beginning-of-line (for which it -should- be using ^p ^a, right?!!) | |
871 ;; ^g => te-beep (for which it should use ^p ^g) | |
872 ;; ^h => te-backward-char (for which it should use ^p ^b) | |
873 | |
874 | |
875 | |
876 (defun te-filter (process string) | |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
877 (let* ((obuf (current-buffer))) |
161 | 878 ;; can't use save-excursion, as that preserves point, which we don't want |
879 (unwind-protect | |
880 (progn | |
881 (set-buffer (process-buffer process)) | |
882 (goto-char te-saved-point) | |
883 (and (bufferp te-log-buffer) | |
884 (if (null (buffer-name te-log-buffer)) | |
885 ;; killed | |
886 (setq te-log-buffer nil) | |
887 (set-buffer te-log-buffer) | |
888 (goto-char (point-max)) | |
889 (insert-before-markers string) | |
890 (set-buffer (process-buffer process)))) | |
891 (setq te-pending-output (nconc te-pending-output (list string))) | |
892 (te-update-pending-output-display) | |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
893 (te-process-output (eq (current-buffer) |
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
894 (window-buffer (selected-window)))) |
161 | 895 (set-buffer (process-buffer process)) |
896 (setq te-saved-point (point))) | |
897 (set-buffer obuf)))) | |
898 | |
899 ;; (A version of the following comment which might be distractingly offensive | |
900 ;; to some readers has been moved to term-nasty.el.) | |
901 ;; unix lacks ITS-style tty control... | |
13954
8fd57aba5a76
(te-process-output): Fix local var misspelling.
Karl Heuer <kwzh@gnu.org>
parents:
13101
diff
changeset
|
902 (defun te-process-output (preemptible) |
161 | 903 ;;>> There seems no good reason to ever disallow preemption |
13954
8fd57aba5a76
(te-process-output): Fix local var misspelling.
Karl Heuer <kwzh@gnu.org>
parents:
13101
diff
changeset
|
904 (setq preemptible t) |
161 | 905 (catch 'te-process-output |
906 (let ((buffer-read-only nil) | |
907 (string nil) ostring start char (matchpos nil)) | |
908 (while (cdr te-pending-output) | |
909 (setq ostring string | |
910 start (car te-pending-output) | |
911 string (car (cdr te-pending-output)) | |
912 char (aref string start)) | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
913 (if (eq (setq start (1+ start)) (length string)) |
161 | 914 (progn (setq te-pending-output |
915 (cons 0 (cdr (cdr te-pending-output))) | |
916 start 0 | |
917 string (car (cdr te-pending-output))) | |
918 (te-update-pending-output-display)) | |
919 (setcar te-pending-output start)) | |
920 (if (and (> char ?\037) (< char ?\377)) | |
921 (cond ((eolp) | |
922 ;; unread char | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
923 (if (eq start 0) |
161 | 924 (setq te-pending-output |
925 (cons 0 (cons (make-string 1 char) | |
926 (cdr te-pending-output)))) | |
927 (setcar te-pending-output (1- start))) | |
928 (te-newline)) | |
929 ((null string) | |
930 (delete-char 1) (insert char) | |
931 (te-redisplay-if-necessary 1)) | |
932 (t | |
933 (let ((end (or (and (eq ostring string) matchpos) | |
934 (setq matchpos (string-match | |
935 "[\000-\037\177-\377]" | |
936 string start)) | |
937 (length string)))) | |
938 (delete-char 1) (insert char) | |
939 (setq char (point)) (end-of-line) | |
940 (setq end (min end (+ start (- (point) char)))) | |
941 (goto-char char) | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
942 (if (eq end matchpos) (setq matchpos nil)) |
161 | 943 (delete-region (point) (+ (point) (- end start))) |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
944 (insert (if (and (eq start 0) |
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
945 (eq end (length string))) |
161 | 946 string |
947 (substring string start end))) | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
948 (if (eq end (length string)) |
161 | 949 (setq te-pending-output |
950 (cons 0 (cdr (cdr te-pending-output)))) | |
951 (setcar te-pending-output end)) | |
952 (te-redisplay-if-necessary (1+ (- end start)))))) | |
953 ;; I suppose if I split the guts of this out into a separate | |
954 ;; function we could trivially emulate different terminals | |
955 ;; Who cares in any case? (Apart from stupid losers using rlogin) | |
956 (funcall | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
957 (if (eq char ?\^p) |
161 | 958 (or (cdr (assq (te-get-char) |
959 '((?= . te-move-to-position) | |
960 (?c . te-clear-rest-of-line) | |
961 (?C . te-clear-rest-of-screen) | |
962 (?\C-o . te-insert-lines) | |
963 (?\C-k . te-delete-lines) | |
964 ;; not necessary, but help sometimes. | |
965 (?\C-a . te-beginning-of-line) | |
966 (?\C-b . te-backward-char) | |
967 ;; should be C-d, but un*x | |
968 ;; pty's won't send \004 through! | |
969 ;; Can you believe this? | |
970 (?d . te-delete-char) | |
971 (?_ . te-insert-spaces) | |
972 ;; random | |
973 (?\C-f . te-forward-char) | |
974 (?\C-g . te-beep) | |
975 (?\C-j . te-down-vertically-or-scroll) | |
976 (?\C-l . te-clear-screen) | |
977 ))) | |
978 'te-losing-unix) | |
979 (or (cdr (assq char | |
980 '((?\C-j . te-newline) | |
981 (?\177 . te-delete) | |
982 ;; Did I ask to be sent these characters? | |
983 ;; I don't remember doing so, either. | |
984 ;; (Perhaps some operating system or | |
985 ;; other is completely incompetent...) | |
986 (?\C-m . te-beginning-of-line) | |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
987 (?\C-g . te-beep) |
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
988 (?\C-h . te-backward-char) |
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
989 (?\C-i . te-output-tab)))) |
161 | 990 'te-losing-unix))) |
991 (te-redisplay-if-necessary 1)) | |
13954
8fd57aba5a76
(te-process-output): Fix local var misspelling.
Karl Heuer <kwzh@gnu.org>
parents:
13101
diff
changeset
|
992 (and preemptible |
161 | 993 (input-pending-p) |
13954
8fd57aba5a76
(te-process-output): Fix local var misspelling.
Karl Heuer <kwzh@gnu.org>
parents:
13101
diff
changeset
|
994 ;; preemptible output! Oh my!! |
161 | 995 (throw 'te-process-output t))))) |
996 ;; We must update window-point in every window displaying our buffer | |
30003
29a64f84d736
(te-process-output): Use walk-windows instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25417
diff
changeset
|
997 (walk-windows (lambda (w) |
29a64f84d736
(te-process-output): Use walk-windows instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25417
diff
changeset
|
998 (when (and (not (eq w (selected-window))) |
29a64f84d736
(te-process-output): Use walk-windows instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25417
diff
changeset
|
999 (eq (window-buffer w) (current-buffer))) |
29a64f84d736
(te-process-output): Use walk-windows instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25417
diff
changeset
|
1000 (set-window-point w (point)))))) |
161 | 1001 |
1002 (defun te-get-char () | |
1003 (if (cdr te-pending-output) | |
1004 (let ((start (car te-pending-output)) | |
1005 (string (car (cdr te-pending-output)))) | |
1006 (prog1 (aref string start) | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
1007 (if (eq (setq start (1+ start)) (length string)) |
161 | 1008 (setq te-pending-output (cons 0 (cdr (cdr te-pending-output)))) |
1009 (setcar te-pending-output start)))) | |
1010 (catch 'char | |
1011 (let ((filter (process-filter te-process))) | |
1012 (unwind-protect | |
1013 (progn | |
1014 (set-process-filter te-process | |
1015 (function (lambda (p s) | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
1016 (or (eq (length s) 1) |
161 | 1017 (setq te-pending-output (list 1 s))) |
1018 (throw 'char (aref s 0))))) | |
1019 (accept-process-output te-process)) | |
1020 (set-process-filter te-process filter)))))) | |
1021 | |
1022 | |
1023 (defun te-redisplay-if-necessary (length) | |
1024 (and (<= (setq te-redisplay-count (- te-redisplay-count length)) 0) | |
1025 (eq (current-buffer) (window-buffer (selected-window))) | |
1026 (waiting-for-user-input-p) | |
1027 (progn (te-update-pending-output-display) | |
1028 (sit-for 0) | |
1029 (setq te-redisplay-count terminal-redisplay-interval)))) | |
1030 | |
1031 (defun te-update-pending-output-display () | |
1032 (if (null (cdr te-pending-output)) | |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
1033 (setq te-pending-output-info "") |
161 | 1034 (let ((length (te-pending-output-length))) |
1035 (if (< length 1500) | |
1036 (setq te-pending-output-info "") | |
1037 (setq te-pending-output-info (format "(%dK chars output pending) " | |
1038 (/ (+ length 512) 1024)))))) | |
11569
a2b107c4f2f1
(te-edit, te-more-break-unwind): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
10848
diff
changeset
|
1039 (force-mode-line-update)) |
161 | 1040 |
1041 | |
1042 (defun te-sentinel (process message) | |
1043 (cond ((eq (process-status process) 'run)) | |
1044 ((null (buffer-name (process-buffer process)))) ;deleted | |
1045 (t (let ((b (current-buffer))) | |
1046 (save-excursion | |
1047 (set-buffer (process-buffer process)) | |
1048 (setq buffer-read-only nil) | |
1049 (fundamental-mode) | |
1050 (goto-char (point-max)) | |
1051 (delete-blank-lines) | |
1052 (delete-horizontal-space) | |
1053 (insert "\n*******\n" message "*******\n")) | |
1054 (if (and (eq b (process-buffer process)) | |
1055 (waiting-for-user-input-p)) | |
1056 (progn (goto-char (point-max)) | |
1057 (recenter -1))))))) | |
1058 | |
2748
fef642d4f5c0
(te-pass-through): Handle meta chars and non-char events.
Richard M. Stallman <rms@gnu.org>
parents:
2587
diff
changeset
|
1059 (defvar te-stty-string "stty -nl erase '^?' kill '^u' intr '^c' echo pass8" |
357 | 1060 "Shell command to set terminal modes for terminal emulator.") |
1061 ;; This used to have `new' in it, but that loses outside BSD | |
1062 ;; and it's apparently not needed in BSD. | |
161 | 1063 |
17926
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
1064 (defcustom explicit-shell-file-name nil |
100171 | 1065 "If non-nil, is file name to use for explicitly requested inferior shell." |
17926
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
1066 :type '(choice (const :tag "None" nil) |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
1067 file) |
8e3ea3086637
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
14888
diff
changeset
|
1068 :group 'terminal) |
161 | 1069 |
256 | 1070 ;;;###autoload |
161 | 1071 (defun terminal-emulator (buffer program args &optional width height) |
1072 "Under a display-terminal emulator in BUFFER, run PROGRAM on arguments ARGS. | |
1073 ARGS is a list of argument-strings. Remaining arguments are WIDTH and HEIGHT. | |
1074 BUFFER's contents are made an image of the display generated by that program, | |
1075 and any input typed when BUFFER is the current Emacs buffer is sent to that | |
24253 | 1076 program as keyboard input. |
161 | 1077 |
1078 Interactively, BUFFER defaults to \"*terminal*\" and PROGRAM and ARGS | |
1079 are parsed from an input-string using your usual shell. | |
1080 WIDTH and HEIGHT are determined from the size of the current window | |
1081 -- WIDTH will be one less than the window's width, HEIGHT will be its height. | |
1082 | |
1083 To switch buffers and leave the emulator, or to give commands | |
1084 to the emulator itself (as opposed to the program running under it), | |
1085 type Control-^. The following character is an emulator command. | |
1086 Type Control-^ twice to send it to the subprogram. | |
1087 This escape character may be changed using the variable `terminal-escape-char'. | |
1088 | |
1089 `Meta' characters may not currently be sent through the terminal emulator. | |
1090 | |
63260
9bcf1560e9f0
(terminal-emulator): Fix spellings in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62745
diff
changeset
|
1091 Here is a list of some of the variables which control the behavior |
161 | 1092 of the emulator -- see their documentation for more information: |
1093 terminal-escape-char, terminal-scrolling, terminal-more-processing, | |
1094 terminal-redisplay-interval. | |
1095 | |
1096 This function calls the value of terminal-mode-hook if that exists | |
1097 and is non-nil after the terminal buffer has been set up and the | |
10294 | 1098 subprocess started." |
161 | 1099 (interactive |
1100 (cons (save-excursion | |
1101 (set-buffer (get-buffer-create "*terminal*")) | |
1102 (buffer-name (if (or (not (boundp 'te-process)) | |
1103 (null te-process) | |
1104 (not (eq (process-status te-process) | |
1105 'run))) | |
1106 (current-buffer) | |
1107 (generate-new-buffer "*terminal*")))) | |
1108 (append | |
1109 (let* ((default-s | |
1110 ;; Default shell is same thing M-x shell uses. | |
1111 (or explicit-shell-file-name | |
1112 (getenv "ESHELL") | |
1113 (getenv "SHELL") | |
1114 "/bin/sh")) | |
1115 (s (read-string | |
65680
ed770a0a7846
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents:
64762
diff
changeset
|
1116 (format "Run program in emulator (default %s): " |
161 | 1117 default-s)))) |
1118 (if (equal s "") | |
1119 (list default-s '()) | |
1120 (te-parse-program-and-args s)))))) | |
1121 (switch-to-buffer buffer) | |
1122 (if (null width) (setq width (- (window-width (selected-window)) 1))) | |
1123 (if (null height) (setq height (- (window-height (selected-window)) 1))) | |
1124 (terminal-mode) | |
1125 (setq te-width width te-height height) | |
31168
e54aee254198
(terminal-emulator): Fix args to `concat'. Now concat doesn't accept
Kenichi Handa <handa@m17n.org>
parents:
30003
diff
changeset
|
1126 (setq te-terminal-name (concat te-terminal-name-prefix |
e54aee254198
(terminal-emulator): Fix args to `concat'. Now concat doesn't accept
Kenichi Handa <handa@m17n.org>
parents:
30003
diff
changeset
|
1127 (number-to-string te-width) |
e54aee254198
(terminal-emulator): Fix args to `concat'. Now concat doesn't accept
Kenichi Handa <handa@m17n.org>
parents:
30003
diff
changeset
|
1128 (number-to-string te-height))) |
161 | 1129 (setq mode-line-buffer-identification |
1130 (list (format "Emacs terminal %dx%d: %%b " te-width te-height) | |
1131 'te-pending-output-info)) | |
1132 (let ((buffer-read-only nil)) | |
1133 (te-clear-screen)) | |
1134 (let (process) | |
1135 (while (setq process (get-buffer-process (current-buffer))) | |
1136 (if (y-or-n-p (format "Kill process %s? " (process-name process))) | |
1137 (delete-process process) | |
1138 (error "Process %s not killed" (process-name process))))) | |
1139 (condition-case err | |
10294 | 1140 (let ((process-environment |
1141 (cons (concat "TERM=" te-terminal-name) | |
1142 (cons (concat "TERMCAP=" (te-create-termcap)) | |
1143 (cons (concat "TERMINFO=" (te-create-terminfo)) | |
1144 process-environment))))) | |
1145 (setq te-process | |
1146 (start-process "terminal-emulator" (current-buffer) | |
1147 "/bin/sh" "-c" | |
1148 ;; Yuck!!! Start a shell to set some terminal | |
1149 ;; control characteristics. Then start the | |
1150 ;; "env" program to setup the terminal type | |
1151 ;; Then finally start the program we wanted. | |
1152 (format "%s; exec %s" | |
1153 te-stty-string | |
1154 (mapconcat 'te-quote-arg-for-sh | |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
1155 (cons program args) " ")))) |
630
a904e831b60f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
584
diff
changeset
|
1156 (set-process-filter te-process 'te-filter) |
a904e831b60f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
584
diff
changeset
|
1157 (set-process-sentinel te-process 'te-sentinel)) |
161 | 1158 (error (fundamental-mode) |
1159 (signal (car err) (cdr err)))) | |
1160 (setq inhibit-quit t) ;sport death | |
1161 (use-local-map terminal-map) | |
1162 (run-hooks 'terminal-mode-hook) | |
73752
682027448d56
(terminal-emulator): Fix typo in message.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
1163 (message "Entering Emacs terminal-emulator... Type %s %s for help" |
161 | 1164 (single-key-description terminal-escape-char) |
1165 (mapconcat 'single-key-description | |
5774
b57901dfbd40
(te-escape-help, te-more-break-help, terminal-emulator):
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1166 (where-is-internal 'te-escape-help terminal-escape-map t) |
161 | 1167 " "))) |
1168 | |
1169 | |
1170 (defun te-parse-program-and-args (s) | |
6310
c40e283c262b
Put hyphen in a safer place in the character class.
Karl Heuer <kwzh@gnu.org>
parents:
5774
diff
changeset
|
1171 (cond ((string-match "\\`\\([-a-zA-Z0-9+=_.@/:]+[ \t]*\\)+\\'" s) |
161 | 1172 (let ((l ()) (p 0)) |
1173 (while p | |
1174 (setq l (cons (if (string-match | |
6310
c40e283c262b
Put hyphen in a safer place in the character class.
Karl Heuer <kwzh@gnu.org>
parents:
5774
diff
changeset
|
1175 "\\([-a-zA-Z0-9+=_.@/:]+\\)\\([ \t]+\\)*" |
161 | 1176 s p) |
1177 (prog1 (substring s p (match-end 1)) | |
1178 (setq p (match-end 0)) | |
18932
aff82880eaf1
(te-newline): Change eql to eq.
Richard M. Stallman <rms@gnu.org>
parents:
17926
diff
changeset
|
1179 (if (eq p (length s)) (setq p nil))) |
161 | 1180 (prog1 (substring s p) |
1181 (setq p nil))) | |
1182 l))) | |
1183 (setq l (nreverse l)) | |
1184 (list (car l) (cdr l)))) | |
1185 ((and (string-match "[ \t]" s) (not (file-exists-p s))) | |
1186 (list shell-file-name (list "-c" (concat "exec " s)))) | |
1187 (t (list s ())))) | |
1188 | |
1189 (put 'terminal-mode 'mode-class 'special) | |
1190 ;; This is only separated out from function terminal-emulator | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3387
diff
changeset
|
1191 ;; to keep the latter a little more manageable. |
161 | 1192 (defun terminal-mode () |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3387
diff
changeset
|
1193 "Set up variables for use with the terminal-emulator. |
161 | 1194 One should not call this -- it is an internal function |
1195 of the terminal-emulator" | |
1196 (kill-all-local-variables) | |
1197 (buffer-disable-undo (current-buffer)) | |
1198 (setq major-mode 'terminal-mode) | |
1199 (setq mode-name "terminal") | |
1200 ; (make-local-variable 'Helper-return-blurb) | |
1201 ; (setq Helper-return-blurb "return to terminal simulator") | |
7077
4c0af7fbb42e
(terminal-cease-edit, terminal-mode):
Richard M. Stallman <rms@gnu.org>
parents:
6423
diff
changeset
|
1202 (setq mode-line-process '(":%s")) |
161 | 1203 (setq buffer-read-only t) |
1204 (setq truncate-lines t) | |
1205 (make-local-variable 'terminal-escape-char) | |
1206 (setq terminal-escape-char (default-value 'terminal-escape-char)) | |
1207 (make-local-variable 'terminal-scrolling) | |
1208 (setq terminal-scrolling (default-value 'terminal-scrolling)) | |
1209 (make-local-variable 'terminal-more-processing) | |
1210 (setq terminal-more-processing (default-value 'terminal-more-processing)) | |
1211 (make-local-variable 'terminal-redisplay-interval) | |
1212 (setq terminal-redisplay-interval (default-value 'terminal-redisplay-interval)) | |
1213 (make-local-variable 'te-width) | |
1214 (make-local-variable 'te-height) | |
1215 (make-local-variable 'te-process) | |
1216 (make-local-variable 'te-pending-output) | |
1217 (setq te-pending-output (list 0)) | |
1218 (make-local-variable 'te-saved-point) | |
1219 (setq te-saved-point (point-min)) | |
1220 (make-local-variable 'te-pending-output-info) ;for the mode line | |
1221 (setq te-pending-output-info "") | |
1222 (make-local-variable 'inhibit-quit) | |
1223 ;(setq inhibit-quit t) | |
1224 (make-local-variable 'te-log-buffer) | |
1225 (setq te-log-buffer nil) | |
1226 (make-local-variable 'te-more-count) | |
1227 (setq te-more-count -1) | |
1228 (make-local-variable 'te-redisplay-count) | |
1229 (setq te-redisplay-count terminal-redisplay-interval) | |
1230 ;(use-local-map terminal-mode-map) | |
1231 ;; terminal-mode-hook is called above in function terminal-emulator | |
1232 ) | |
1233 | |
1234 ;;;; what a complete loss | |
1235 | |
1236 (defun te-quote-arg-for-sh (string) | |
6310
c40e283c262b
Put hyphen in a safer place in the character class.
Karl Heuer <kwzh@gnu.org>
parents:
5774
diff
changeset
|
1237 (cond ((string-match "\\`[-a-zA-Z0-9+=_.@/:]+\\'" |
161 | 1238 string) |
1239 string) | |
1240 ((not (string-match "[$]" string)) | |
1241 ;; "[\"\\]" are special to sh and the lisp reader in the same way | |
1242 (prin1-to-string string)) | |
1243 (t | |
1244 (let ((harder "") | |
1245 (start 0) | |
1246 (end 0)) | |
1247 (while (cond ((>= start (length string)) | |
1248 nil) | |
1249 ;; this is the set of chars magic with "..." in `sh' | |
1250 ((setq end (string-match "[\"\\$]" | |
1251 string start)) | |
1252 t) | |
1253 (t (setq harder (concat harder | |
1254 (substring string start))) | |
1255 nil)) | |
1256 (setq harder (concat harder (substring string start end) | |
1257 ;; Can't use ?\\ since `concat' | |
1258 ;; unfortunately does prin1-to-string | |
1259 ;; on fixna. Amazing. | |
1260 "\\" | |
1261 (substring string | |
1262 end | |
1263 (1+ end))) | |
1264 start (1+ end))) | |
256 | 1265 (concat "\"" harder "\""))))) |
584 | 1266 |
10294 | 1267 (defun te-create-terminfo () |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
1268 "Create and compile a terminfo entry for the virtual terminal. This is kept |
14888
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
1269 in the directory specified by `te-terminfo-directory'." |
43678
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1270 (when (and system-uses-terminfo |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1271 (not (file-exists-p (concat te-terminfo-directory |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1272 (substring te-terminal-name-prefix 0 1) |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1273 "/" te-terminal-name)))) |
13101
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
1274 (let ( (terminfo |
32381faf1489
(te-escape): Remove spurious partial duplicate definition.
Noah Friedman <friedman@splode.com>
parents:
13057
diff
changeset
|
1275 (concat |
14888
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
1276 ;; The first newline avoids trouble with ncurses. |
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
1277 (format "%s,\n\tmir, xon,cols#%d, lines#%d," |
10294 | 1278 te-terminal-name te-width te-height) |
1279 "bel=^P^G, clear=^P\\f, cr=^P^A, cub1=^P^B, cud1=^P\\n," | |
1280 "cuf1=^P^F, cup=^P=%p1%'\\s'%+%c%p2%'\\s'%+%c," | |
1281 "dch=^Pd%p1%'\\s'%+%c, dch1=^Pd!, dl=^P^K%p1%'\\s'%+%c," | |
1282 "dl1=^P^K!, ed=^PC, el=^Pc, home=^P=\\s\\s," | |
1283 "ich=^P_%p1%'\\s'%+%c, ich1=^P_!, il=^P^O%p1%'\\s'%+%c," | |
43678
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1284 ;; The last newline avoids trouble with ncurses. |
14888
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
1285 "il1=^P^O!, ind=^P\\n, nel=\\n,\n")) |
43678
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1286 ;; This is the desired name for the source file. |
14888
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
1287 (file-name (concat te-terminfo-directory te-terminal-name ".tif")) ) |
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
1288 (make-directory te-terminfo-directory t) |
43678
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1289 (let ((temp-file |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1290 (make-temp-file (expand-file-name "tif" te-terminfo-directory)))) |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1291 ;; Store the source file under a random temp name. |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1292 (with-temp-file temp-file |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1293 (insert terminfo)) |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1294 ;; Rename it to the desired name. |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1295 ;; We use this roundabout approach |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1296 ;; to avoid any risk of writing a name that |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1297 ;; was michievouslyt set up as a symlink. |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1298 (rename-file temp-file file-name)) |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1299 ;; Now compile that source to make the binary that the |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1300 ;; programs actually use. |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1301 (let ((process-environment |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1302 (cons (concat "TERMINFO=" |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1303 (directory-file-name te-terminfo-directory)) |
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1304 process-environment))) |
10294 | 1305 (set-process-sentinel (start-process "tic" nil "tic" file-name) |
1306 'te-tic-sentinel)))) | |
43678
402411174ef9
(te-create-terminfo): Use make-temp-file
Richard M. Stallman <rms@gnu.org>
parents:
43171
diff
changeset
|
1307 (directory-file-name te-terminfo-directory)) |
10294 | 1308 |
1309 (defun te-create-termcap () | |
1310 "Create a termcap entry for the virtual terminal" | |
1311 ;; Because of Unix Brain Death(tm), we can't change | |
1312 ;; the terminal type of a running process, and so | |
1313 ;; terminal size and scrollability are wired-down | |
1314 ;; at this point. ("Detach? What's that?") | |
1315 (concat (format "%s:co#%d:li#%d:%s" | |
1316 ;; Sigh. These can't be dynamically changed. | |
1317 te-terminal-name te-width te-height (if terminal-scrolling | |
1318 "" "ns:")) | |
1319 ;;-- Basic things | |
1320 ;; cursor-motion, bol, forward/backward char | |
1321 "cm=^p=%+ %+ :cr=^p^a:le=^p^b:nd=^p^f:" | |
1322 ;; newline, clear eof/eof, audible bell | |
1323 "nw=^j:ce=^pc:cd=^pC:cl=^p^l:bl=^p^g:" | |
1324 ;; insert/delete char/line | |
1325 "IC=^p_%+ :DC=^pd%+ :AL=^p^o%+ :DL=^p^k%+ :" | |
1326 ;;-- Not-widely-known (ie nonstandard) flags, which mean | |
1327 ;; o writing in the last column of the last line | |
1328 ;; doesn't cause idiotic scrolling, and | |
1329 ;; o don't use idiotische c-s/c-q sogenannte | |
1330 ;; ``flow control'' auf keinen Fall. | |
1331 "LP:NF:" | |
1332 ;;-- For stupid or obsolete programs | |
1333 "ic=^p_!:dc=^pd!:al=^p^o!:dl=^p^k!:ho=^p= :" | |
1334 ;;-- For disgusting programs. | |
1335 ;; (VI? What losers need these, I wonder?) | |
1336 "im=:ei=:dm=:ed=:mi:do=^p^j:nl=^p^j:bs:") | |
1337 ) | |
1338 | |
1339 (defun te-tic-sentinel (proc state-change) | |
1340 "If tic has finished, delete the .tif file" | |
1341 (if (equal state-change "finished | |
1342 ") | |
14888
b256ebb2110a
(te-terminal-name-prefix): Change from
Richard M. Stallman <rms@gnu.org>
parents:
14641
diff
changeset
|
1343 (delete-file (concat te-terminfo-directory te-terminal-name ".tif")))) |
10294 | 1344 |
584 | 1345 (provide 'terminal) |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
630
diff
changeset
|
1346 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
1347 ;; arch-tag: 0ae1d7d7-90ef-4566-a531-6e7ff8c79b2f |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
630
diff
changeset
|
1348 ;;; terminal.el ends here |