XEmacs 21.4.15
[chise/xemacs-chise.git.1] / info / term.info
1 This is ../info/term.info, produced by makeinfo version 4.6 from
2 term.texi.
3
4 INFO-DIR-SECTION XEmacs Editor
5 START-INFO-DIR-ENTRY
6 * Term mode: (term).            Emacs terminal emulator mode.
7 END-INFO-DIR-ENTRY
8
9 \1f
10 File: term.info,  Node: Top,  Prev: (DIR)
11
12 Terminal emulator mode
13 **********************
14
15    This is some notes about the term Emacs mode.
16
17 * Menu:
18
19 * term mode::
20
21 \1f
22 File: term.info,  Node: term mode,  Prev: Top,  Up: Top
23
24 Term Mode
25 *********
26
27 * Menu:
28
29 * Overview::
30 * Connecting to remote computers::
31 * Paging::
32 * Terminal escapes::
33
34    The `term' package includes the major modes `term', `shell', and
35 `gud' (for running gbd or another debugger).  It is a replacement for
36 the comint mode of Emacs 19, as well as shell, gdb, terminal, and
37 telnet modes.  The package works best with recent releases of Emacs 19,
38 but will also work reasonably well with Emacs 18 as well as Lucid Emacs
39 19.
40
41    The file `nshell.el' is a wrapper to use unless term mode is built
42 into Emacs.  If works around some of the missing in older Emacs
43 versions.  To use it, edit the paths in `nshell.el', appropriately, and
44 then `M-x load-file nshell.el RET'.  This will also load in replacement
45 shell and gud modes.
46
47 \1f
48 File: term.info,  Node: Overview,  Next: Connecting to remote computers,  Up: term mode
49
50 Overview
51 ========
52
53 The `term' mode is used to control a program (an "inferior process").
54 It sends most keyboard input characters to the program, and displays
55 output from the program in the buffer.  This is similar to the
56 traditional comint mode, and modes derived from it (such as shell and
57 gdb modes).  You can do with the new term-based shell the same sort of
58 things you could do with the old shell mode, using more or less the
59 same interface.  However, the new mode is more flexible, and works
60 somewhat differently.
61
62 * Menu:
63
64 * Output from the inferior::
65 * subbuffer:: The sub-buffer
66 * altsubbuffer:: The alternate sub-buffer
67 * Input to the inferior::
68
69 \1f
70 File: term.info,  Node: Output from the inferior,  Next: subbuffer,  Up: Overview
71
72 Output from the inferior
73 ------------------------
74
75 In typical usage, output from the inferior is added to the end of the
76 buffer.  If needed, the window will be scrolled, just like a regular
77 terminal.  (Only one line at a time will be scrolled, just like regular
78 terminals, and in contrast to the old shell mode.)  Thus the buffer
79 becomes a log of your interaction with the inferior, just like the old
80 shell mode.
81
82    Like a real terminal, term maintains a "cursor position."  This is
83 the `process-mark' of the inferior process.  If the process-mark is not
84 at the end of the buffer, output from the inferior will overwrite
85 existing text in the buffer.  This is like a real terminal, but unlike
86 the old shell mode (which inserts the output, instead of overwriting).
87
88    Some programs (such as Emacs itself) need to control the appearance
89 on the screen in detail.  They do this by sending special control
90 codes.  The exact control codes needed from terminal to terminal, but
91 nowadays most terminals and terminal emulators (including xterm)
92 understand the so-called "ANSI escape sequences" (first popularized by
93 the Digital's VT100 family of terminal).  The term mode also
94 understands these escape sequences, and for each control code does the
95 appropriate thing to change the buffer so that the appearance of the
96 window will match what it would be on a real terminal.  (In contrast,
97 the old shell mode doesn't handle terminal control codes at all.)
98
99    See <...> for the specific control codes.
100
101 \1f
102 File: term.info,  Node: subbuffer,  Next: altsubbuffer,  Prev: Output from the inferior,  Up: Overview
103
104 The sub-buffer
105 --------------
106
107 A program that talks to terminal expects the terminal to have a fixed
108 size.  If the program is talking a terminal emulator program such as
109 `xterm', that size can be changed (if the xterm window is re-sized),
110 but programs still assume a logical terminal that has a fixed size
111 independent of the amount of output transmitted by the programs.
112
113    To programs that use it, the Emacs terminal emulator acts as if it
114 too has a fixed size.  The "sub-buffer" is the part of a `term'-mode
115 buffer that corresponds to a "normal" terminal.  Most of the time
116 (unless you explicitly scroll the window displaying the buffer), the
117 sub-buffer is the part of the buffer that is displayed in a window.
118
119    The sub-buffer is defined in terms of three buffer-local-variable:
120
121  - Variable: term-height
122      The height of the sub-buffer, in screen lines.
123
124  - Variable: term-width
125      The width of the sub-buffer, in screen columns.
126
127  - Variable: term-home-marker
128      The "home" position, that is the top left corner of the sub-buffer.
129
130    The sub-buffer is assumed to be the end part of the buffer; the
131 `term-home-marker' should never be more than `term-height' screen lines
132 from the end of the buffer.
133
134 \1f
135 File: term.info,  Node: altsubbuffer,  Next: Input to the inferior,  Prev: subbuffer,  Up: Overview
136
137 The alternate sub-buffer
138 ------------------------
139
140 When a "graphical" program finishes, it is nice to restore the screen
141 state to what it was before the program started.  Many people are used
142 to this behavior from `xterm', and its also offered by the `term'
143 emulator.
144
145  - Function: term-switch-to-alternate-sub-buffer set
146      If SET is true, and we're not already using the alternate
147      sub-buffer, switch to it.  What this means is that the
148      `term-home-marker' is saved (in the variable
149      `term-saved-home-marker'), and the `term-home-marker' is set to
150      the end of the buffer.
151
152      If SET is false and we're using the alternate sub-buffer, switch
153      back to the saved sub-buffer.  What this means is that the
154      (current, alternate) sub-buffer is deleted (using `(delete-region
155      term-home-marker (point-max))'), and then the `term-home-marker'
156      is restored (from `term-saved-home-marker').
157
158 \1f
159 File: term.info,  Node: Input to the inferior,  Prev: altsubbuffer,  Up: Overview
160
161 Input to the inferior
162 ---------------------
163
164 Characters typed by the user are sent to the inferior.  How this is
165 done depends on whether the `term' buffer is in "character" mode or
166 "line" mode.  (A `term' buffer can also be in "pager" mode.  This is
167 discussed <later>.)  Which of these is currently active is specified in
168 the mode line.  The difference between them is the key-bindings
169 available.
170
171    In character mode, one character (by default <C-c>) is special, and
172 is a prefix for various commands.  All other characters are sent
173 directly to the inferior process, with no interpretation by Emacs.
174 Character mode looks and feels like a real terminal, or a conventional
175 terminal emulator such as xterm.
176
177    In line mode, key commands mostly have standard Emacs actions.
178 Regulars characters insert themselves into the buffer.  When return is
179 typed, the entire current line of the buffer (except possibly the
180 prompt) is sent to the inferior process.  Line mode is basically the
181 original shell mode from earlier Emacs versions.
182
183    To switch from line mode to character mode type `C-c C-k'.  To
184 switch from character mode to line mode type `C-c C-j'.
185
186    In either mode, "echoing" of user input is handled by the inferior.
187 Therefor, in line mode after an input line at the end of the buffer is
188 sent to the inferior, it is deleted from the buffer.  This is so that
189 the inferior can echo the input, if it wishes (which it normally does).
190
191 \1f
192 File: term.info,  Node: Connecting to remote computers,  Next: Paging,  Prev: Overview,  Up: term mode
193
194 Connecting to remote computers
195 ==============================
196
197 If you want to login to a remove computer, you can do that just as you
198 would expect, using whatever commands you would normally use.
199
200    (This is worth emphasizing, because earlier versions of `shell' mode
201 would not work properly if you tried to log in to some other computer,
202 because of the way echoing was handled.  That is why there was a
203 separate `telnet' mode to partially compensate for these problems.  The
204 `telnet' mode is no longer needed, and is basically obsolete.)
205
206    A program that asks you for a password will normally suppress
207 echoing of the password, so the password will not show up in the buffer.
208 This will happen just as if you were using a real terminal, if the
209 buffer is in char mode.  If it is in line mode, the password will be
210 temporarily visible, but will be erased when you hit return.  (This
211 happens automatically; there is no special password processing.)
212
213    When you log in to a different machine, you need to specify the type
214 of terminal your using.   If you are talking to a Bourne-compatible
215 shell, and your system understands the `TERMCAP' variable, you can use
216 the command `M-x shell-send-termcap', which sends a string specifying
217 the terminal type and size.  (This command is also useful after the
218 window has changed size.)
219
220    If you need to specify the terminal type manually, you can try the
221 terminal types "ansi" or "vt100".
222
223    You can of course run gdb on that remote computer.  One useful
224 trick:  If you invoke gdb with the `--fullname' option, it will send
225 special commands to Emacs that will cause Emacs to pop up the source
226 files you're debugging.  This will work whether or not gdb is running
227 on a different computer than Emacs, assuming can access the source
228 files specified by gdb.
229
230 \1f
231 File: term.info,  Node: Paging,  Next: Terminal escapes,  Prev: Connecting to remote computers,  Up: term mode
232
233 Paging
234 ======
235
236 When the pager is enabled, Emacs will "pause" after each screenful of
237 output (since the last input sent to the inferior).  It will enter
238 "pager" mode, which feels a lot like the "more" program:  Typing a
239 space requests another screenful of output.  Other commands request
240 more or less output, or scroll backwards in the `term' buffer.  In
241 pager mode, type `h' or `?' to display a help message listing all the
242 available pager mode commands.
243
244    In either character or line mode, type `C-c p' to enable paging, and
245 `C-c D' to disable it.
246
247 \1f
248 File: term.info,  Node: Terminal escapes,  Prev: Paging,  Up: term mode
249
250 Terminal Escape sequences
251 =========================
252
253 A program that does "graphics" on a terminal controls the terminal by
254 sending strings called "terminal escape sequences" that the terminal
255 (or terminal emulator) interprets as special commands.  The `term' mode
256 includes a terminal emulator that understands standard ANSI escape
257 sequences, originally popularized by VT100 terminals, and now used by
258 the `xterm' program and most modern terminal emulator software.
259
260 * Menu:
261
262 * Cursor motion:: Escape sequences to move the cursor
263 * Erasing:: Escape commands for erasing text
264 * Inserting and deleting:: Escape sequences to insert and delete text
265 * Scrolling:: Escape sequences to scroll part of the visible window
266 * Command hook::
267 * Miscellaneous escapes::
268
269    printing chars
270
271    tab
272
273    LF
274
275 \1f
276 File: term.info,  Node: Cursor motion,  Next: Erasing,  Up: Terminal escapes
277
278 Escape sequences to move the cursor
279 -----------------------------------
280
281 `RETURN'
282      Moves to the beginning of the current screen line.
283
284 `C-b'
285      Moves backwards one column.  (Tabs are broken up if needed.)
286
287 `Esc [ R ; C H'
288      Move to screen row R, screen column C, where (R=1) is the top row,
289      and (C=1) is the leftmost column.  Defaults are R=1 and C=1.
290
291 `Esc [ N A'
292      Move N (default 1) screen lines up.
293
294 `Esc [ N B'
295      Move N (default 1) screen lines down.
296
297 `Esc [ N C'
298      Move N (default 1) columns right.
299
300 `Esc [ N D'
301      Move N (default 1) columns left.
302
303 \1f
304 File: term.info,  Node: Erasing,  Next: Inserting and deleting,  Prev: Cursor motion,  Up: Terminal escapes
305
306 Escape commands for erasing text
307 --------------------------------
308
309 These commands "erase" part of the sub-buffer.  Erasing means replacing
310 by white space; it is not the same as deleting.  The relative screen
311 positions of things that are not erased remain unchanged with each
312 other, as does the relative cursor position.
313
314 `E [ J'
315      Erase from cursor to end of screen.
316
317 `E [ 0 J'
318      Same as E [ J.
319
320 `E [ 1 J'
321      Erase from home position to point.
322
323 `E [ 2 J'
324      Erase whole sub-buffer.
325
326 `E [ K'
327      Erase from point to end of screen line.
328
329 `E [ 0 K'
330      Same as E [ K.
331
332 `E [ 1 K'
333      Erase from beginning of screen line to point.
334
335 `E [ 2 K'
336      Erase whole screen line.
337
338 \1f
339 File: term.info,  Node: Inserting and deleting,  Next: Scrolling,  Prev: Erasing,  Up: Terminal escapes
340
341 Escape sequences to insert and delete text
342 ------------------------------------------
343
344 `Esc [ N L'
345      Insert N (default 1) blank lines.
346
347 `Esc [ N M'
348      Delete N (default 1) lines.
349
350 `Esc [ N P'
351      Delete N (default 1) characters.
352
353 `Esc [ N @'
354      Insert N (default 1) spaces.
355
356 \1f
357 File: term.info,  Node: Scrolling,  Next: Command hook,  Prev: Inserting and deleting,  Up: Terminal escapes
358
359 Escape sequences to scroll part of the visible window
360 -----------------------------------------------------
361
362 `Esc D'
363      Scroll forward one screen line.
364
365 `Esc M'
366      Scroll backwards one screen line.
367
368 `Esc [ T ; B r'
369      Set the scrolling region to be from lines T down to line B
370      inclusive, where line 1 is the topmost line.
371
372 \1f
373 File: term.info,  Node: Command hook,  Next: Miscellaneous escapes,  Prev: Scrolling,  Up: Terminal escapes
374
375 Command hook
376 ------------
377
378 If `C-z' is seen, any text up to a following <LF> is scanned.  The text
379 in between (not counting the initial C-z or the final LF) is passed to
380 the function that is the value of `term-command-hook'.
381
382    The default value of the `term-command-hook' variable is the
383 function `term-command-hook', which handles the following:
384
385 `C-z C-z FILENAME:LINENUMBER:IGNORED LF'
386      Set term-pending-frame to `(cons "FILENAME" LINENUMBER)'.  When
387      the buffer is displayed in the current window, show the FILENAME
388      in the other window, and show an arrow at LINENUMBER.  Gdb emits
389      these strings when invoked with the flag -fullname.  This is used
390      by gdb mode; you can also invoke gdb with this flag from shell
391      mode.
392
393 `C-z / DIRNAME LF'
394      Set the directory of the term buffer to DIRNAME
395
396 `C-z ! LEXPR LF'
397      Read and evaluate LEXPR as a Lisp expression.  The result is
398      ignored.
399
400 \1f
401 File: term.info,  Node: Miscellaneous escapes,  Prev: Command hook,  Up: Terminal escapes
402
403 Miscellaneous escapes
404 ---------------------
405
406 `C-g (Bell)'
407      Calls `(beep t)'.
408
409 `Esc 7'
410      Save cursor.
411
412 `Esc 8'
413      Restore cursor.
414
415 `Esc [ 47 h'
416      Switch to the alternate sub-buffer,
417
418 `Esc [ 47 l'
419      Switch back to the regular sub-buffer,
420
421
422 \1f
423 Tag Table:
424 Node: Top\7f201
425 Node: term mode\7f367
426 Node: Overview\7f1190
427 Node: Output from the inferior\7f1937
428 Node: subbuffer\7f3514
429 Node: altsubbuffer\7f4834
430 Node: Input to the inferior\7f5856
431 Node: Connecting to remote computers\7f7377
432 Node: Paging\7f9279
433 Node: Terminal escapes\7f9945
434 Node: Cursor motion\7f10810
435 Node: Erasing\7f11470
436 Node: Inserting and deleting\7f12262
437 Node: Scrolling\7f12652
438 Node: Command hook\7f13098
439 Node: Miscellaneous escapes\7f14131
440 \1f
441 End Tag Table