annotate lisp/terminal.el @ 79642:01fcad3cc628

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