Avoid aborts in cm.c due to too small TTY frame
[emacs.git] / doc / emacs / screen.texi
blob19a4a9e4b6c7878f6898541d9130fe89cd07471e
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
3 @c Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Screen
6 @chapter The Organization of the Screen
7 @cindex screen
8 @cindex frame
10   On a graphical display, such as on GNU/Linux using the X Window
11 System, Emacs occupies a graphical window.  On a text terminal,
12 Emacs occupies the entire terminal screen.  We will use the term
13 @dfn{frame} to mean a graphical window or terminal screen occupied by
14 Emacs.  Emacs behaves very similarly on both kinds of frames.  It
15 normally starts out with just one frame, but you can create additional
16 frames if you wish (@pxref{Frames}).
18   Each frame consists of several distinct regions.  At the top of the
19 frame is a @dfn{menu bar}, which allows you to access commands via a
20 series of menus.  On a graphical display, directly below the menu bar
21 is a @dfn{tool bar}, a row of icons that perform editing commands when
22 you click on them.  At the very bottom of the frame is an @dfn{echo
23 area}, where informative messages are displayed and where you enter
24 information when Emacs asks for it.
26   The main area of the frame, below the tool bar (if one exists) and
27 above the echo area, is called @dfn{the window}.  Henceforth in this
28 manual, we will use the word ``window'' in this sense.  Graphical
29 display systems commonly use the word ``window'' with a different
30 meaning; but, as stated above, we refer to those graphical windows
31 as ``frames''.
33   An Emacs window is where the @dfn{buffer}---the text or other
34 graphics you are editing or viewing---is displayed.  On a graphical
35 display, the window possesses a @dfn{scroll bar} on one side, which
36 can be used to scroll through the buffer.  The last line of the window
37 is a @dfn{mode line}.  This displays various information about what is
38 going on in the buffer, such as whether there are unsaved changes, the
39 editing modes that are in use, the current line number, and so forth.
41   When you start Emacs, there is normally only one window in the
42 frame.  However, you can subdivide this window horizontally or
43 vertically to create multiple windows, each of which can independently
44 display a buffer (@pxref{Windows}).
46   At any time, one window is the @dfn{selected window}.  On a
47 graphical display, the selected window shows a more prominent cursor
48 (usually solid and blinking); other windows show a less prominent
49 cursor (usually a hollow box).  On a text terminal, there is only one
50 cursor, which is shown in the selected window.  The buffer displayed
51 in the selected window is called the @dfn{current buffer}, and it is
52 where editing happens.  Most Emacs commands implicitly apply to the
53 current buffer; the text displayed in unselected windows is mostly
54 visible for reference.  If you use multiple frames on a graphical
55 display, selecting a particular frame selects a window in that frame.
57 @menu
58 * Point::             The place in the text where editing commands operate.
59 * Echo Area::         Short messages appear at the bottom of the screen.
60 * Mode Line::         Interpreting the mode line.
61 * Menu Bar::          How to use the menu bar.
62 @end menu
64 @node Point
65 @section Point
66 @cindex point
67 @cindex cursor
69   The cursor in the selected window shows the location where most
70 editing commands take effect, which is called @dfn{point}@footnote{The
71 term ``point'' comes from the character @samp{.}, which was the
72 command in TECO (the language in which the original Emacs was written)
73 for accessing the editing position.}.  Many Emacs commands move point
74 to different places in the buffer; for example, you can place point by
75 clicking mouse button 1 (normally the left button) at the desired
76 location.
78   By default, the cursor in the selected window is drawn as a solid
79 block and appears to be @emph{on} a character, but you should think of
80 point as @emph{between} two characters; it is situated @emph{before}
81 the character under the cursor.  For example, if your text looks like
82 @samp{frob} with the cursor over the @samp{b}, then point is between
83 the @samp{o} and the @samp{b}.  If you insert the character @samp{!}
84 at that position, the result is @samp{fro!b}, with point between the
85 @samp{!}  and the @samp{b}.  Thus, the cursor remains over the
86 @samp{b}, as before.
88   If you are editing several files in Emacs, each in its own buffer,
89 each buffer has its own value of point.  A buffer that is not
90 currently displayed remembers its value of point if you later display
91 it again.  Furthermore, if a buffer is displayed in multiple windows,
92 each of those windows has its own value of point.
94   @xref{Cursor Display}, for options that control how Emacs displays
95 the cursor.
97 @node Echo Area
98 @section The Echo Area
99 @cindex echo area
101   The line at the very bottom of the frame is the @dfn{echo area}.  It
102 is used to display small amounts of text for various purposes.
104 @cindex echoing
105   The echo area is so-named because one of the things it is used for
106 is @dfn{echoing}, which means displaying the characters of a
107 multi-character command as you type.  Single-character commands are
108 not echoed.  Multi-character commands (@pxref{Keys}) are echoed if you
109 pause for more than a second in the middle of a command.  Emacs then
110 echoes all the characters of the command so far, to prompt you for the
111 rest.  Once echoing has started, the rest of the command echoes
112 immediately as you type it.  This behavior is designed to give
113 confident users fast response, while giving hesitant users maximum
114 feedback.
116 @cindex error message
117 @cindex echo area message
118   The echo area is also used to display an @dfn{error message} when a
119 command cannot do its job.  Error messages may be accompanied by
120 beeping or by flashing the screen.
122   Some commands display informative messages in the echo area to tell
123 you what the command has done, or to provide you with some specific
124 information.  These @dfn{informative} messages, unlike error messages,
125 are not accompanied with a beep or flash.  For example, @kbd{C-x =}
126 (hold down @key{Ctrl} and type @kbd{x}, then let go of @key{Ctrl} and
127 type @kbd{=}) displays a message describing the character at point,
128 its position in the buffer, and its current column in the window.
129 Commands that take a long time often display messages ending in
130 @samp{...} while they are working (sometimes also indicating how much
131 progress has been made, as a percentage), and add @samp{done} when
132 they are finished.
134 @cindex @file{*Messages*} buffer
135 @cindex saved echo area messages
136 @cindex messages saved from echo area
137 @vindex message-log-max
138   Informative echo area messages are saved in a special buffer named
139 @file{*Messages*}.  (We have not explained buffers yet; see
140 @ref{Buffers}, for more information about them.)  If you miss a
141 message that appeared briefly on the screen, you can switch to the
142 @file{*Messages*} buffer to see it again.  The @file{*Messages*}
143 buffer is limited to a certain number of lines, specified by the
144 variable @code{message-log-max}.  (We have not explained variables
145 either; see @ref{Variables}, for more information about them.)  Beyond
146 this limit, one line is deleted from the beginning whenever a new
147 message line is added at the end.
149   @xref{Display Custom}, for options that control how Emacs uses the
150 echo area.
152   The echo area is also used to display the @dfn{minibuffer}, a
153 special window where you can input arguments to commands, such as the
154 name of a file to be edited.  When the minibuffer is in use, the text
155 displayed in the echo area begins with a @dfn{prompt string}, and the
156 active cursor appears within the minibuffer, which is temporarily
157 considered the selected window.  You can always get out of the
158 minibuffer by typing @kbd{C-g}.  @xref{Minibuffer}.
160 @node Mode Line
161 @section The Mode Line
162 @cindex mode line
163 @cindex top level
165   At the bottom of each window is a @dfn{mode line}, which describes
166 what is going on in the current buffer.  When there is only one
167 window, the mode line appears right above the echo area; it is the
168 next-to-last line in the frame.  On a graphical display, the mode line
169 is drawn with a 3D box appearance.  Emacs also usually draws the mode
170 line of the selected window with a different color than that of
171 unselected windows, in order to make it stand out.
173   The text displayed in the mode line has the following format:
175 @example
176  @var{cs}:@var{ch}-@var{fr}  @var{buf}      @var{pos} @var{line}   (@var{major} @var{minor})
177 @end example
179 @noindent
180 On a text terminal, this text is followed by a series of dashes
181 extending to the right edge of the window.  These dashes are omitted
182 on a graphical display.
184 The @var{cs} string and the colon character after it describe the
185 character set and newline convention used for the current buffer.
186 Normally, Emacs automatically handles these settings for you, but it
187 is sometimes useful to have this information.
189   @var{cs} describes the character set of the text in the buffer
190 (@pxref{Coding Systems}).  If it is a dash (@samp{-}), that indicates
191 no special character set handling (with the possible exception of
192 end-of-line conventions, described in the next paragraph).  @samp{=}
193 means no conversion whatsoever, and is usually used for files
194 containing non-textual data.  Other characters represent various
195 @dfn{coding systems}---for example, @samp{1} represents ISO Latin-1.
197   On a text terminal, @var{cs} is preceded by two additional
198 characters that describe the coding systems for keyboard input and
199 terminal output.  Furthermore, if you are using an input method,
200 @var{cs} is preceded by a string that identifies the input method
201 (@pxref{Input Methods}).
203 @cindex end-of-line convention, mode-line indication
204   The character after @var{cs} is usually a colon.  If a different
205 string is displayed, that indicates a nontrivial end-of-line
206 convention for encoding a file.  Usually, lines of text are separated
207 by @dfn{newline characters} in a file, but two other conventions are
208 sometimes used.  The MS-DOS convention uses a carriage-return
209 character followed by a linefeed character; when editing such
210 files, the colon changes to either a backslash (@samp{\}) or
211 @samp{(DOS)}, depending on the operating system.  Another convention,
212 employed by older Macintosh systems, uses a carriage-return
213 character instead of a newline; when editing such files, the colon
214 changes to either a forward slash (@samp{/}) or @samp{(Mac)}.  On some
215 systems, Emacs displays @samp{(Unix)} instead of the colon for files
216 that use newline as the line separator.
218   On frames created for @command{emacsclient} (@pxref{Invoking
219 emacsclient}), the next character is @samp{@@}.  This indication is
220 typical for frames of an Emacs process running as a daemon
221 (@pxref{Emacs Server}).
223   The next element on the mode line is the string indicated by
224 @var{ch}.  This shows two dashes (@samp{--}) if the buffer displayed
225 in the window has the same contents as the corresponding file on the
226 disk; i.e., if the buffer is unmodified.  If the buffer is
227 modified, it shows two stars (@samp{**}).  For a read-only buffer, it
228 shows @samp{%*} if the buffer is modified, and @samp{%%} otherwise.
230   The character after @var{ch} is normally a dash (@samp{-}).
231 However, if @code{default-directory} (@pxref{File Names}) for the
232 current buffer is on a remote machine, @samp{@@} is displayed instead.
234   @var{fr} gives the selected frame name (@pxref{Frames}).  It appears
235 only on text terminals.  The initial frame's name is @samp{F1}.
237   @var{buf} is the name of the buffer displayed in the window.
238 Usually, this is the same as the name of a file you are editing.
239 @xref{Buffers}.
241   @var{pos} tells you whether there is additional text above the top
242 of the window, or below the bottom.  If your buffer is small and all
243 of it is visible in the window, @var{pos} is @samp{All}.  Otherwise,
244 it is @samp{Top} if you are looking at the beginning of the buffer,
245 @samp{Bot} if you are looking at the end of the buffer, or
246 @samp{@var{nn}%}, where @var{nn} is the percentage of the buffer above
247 the top of the window.  With Size Indication mode, you can display the
248 size of the buffer as well.  @xref{Optional Mode Line}.
250   @var{line} is the character @samp{L} followed by the line number at
251 point.  (You can display the current column number too, by turning on
252 Column Number mode.  @xref{Optional Mode Line}.)
254   @var{major} is the name of the @dfn{major mode} used in the buffer.
255 A major mode is a principal editing mode for the buffer, such as Text
256 mode, Lisp mode, C mode, and so forth.  @xref{Major Modes}.  Some
257 major modes display additional information after the major mode name.
258 For example, Compilation buffers and Shell buffers display the status
259 of the subprocess.
261   @var{minor} is a list of some of the enabled @dfn{minor modes},
262 which are optional editing modes that provide additional features on
263 top of the major mode.  @xref{Minor Modes}.
265   Some features are listed together with the minor modes whenever they
266 are turned on, even though they are not really minor modes.
267 @samp{Narrow} means that the buffer being displayed has editing
268 restricted to only a portion of its text (@pxref{Narrowing}).
269 @samp{Def} means that a keyboard macro is currently being defined
270 (@pxref{Keyboard Macros}).
272   In addition, if Emacs is inside a recursive editing level, square
273 brackets (@samp{[@dots{}]}) appear around the parentheses that
274 surround the modes.  If Emacs is in one recursive editing level within
275 another, double square brackets appear, and so on.  Since recursive
276 editing levels affect Emacs globally, such square brackets appear in
277 the mode line of every window.  @xref{Recursive Edit}.
279   You can change the appearance of the mode line as well as the format
280 of its contents.  @xref{Optional Mode Line}.  In addition, the mode
281 line is mouse-sensitive; clicking on different parts of the mode line
282 performs various commands.  @xref{Mode Line Mouse}.  Also, hovering
283 the mouse pointer above mouse-sensitive portions of the mode line
284 shows tooltips (@pxref{Tooltips}) with information about commands you
285 can invoke by clicking on the mode line.
287 @node Menu Bar
288 @section The Menu Bar
289 @cindex menu bar
291   Each Emacs frame normally has a @dfn{menu bar} at the top which you
292 can use to perform common operations.  There's no need to list them
293 here, as you can more easily see them yourself.
295   On a display that supports a mouse, you can use the mouse to choose a
296 command from the menu bar.  An arrow on the right edge of a menu item
297 means it leads to a subsidiary menu, or @dfn{submenu}.  A @samp{...}
298 at the end of a menu item means that the command will prompt you for
299 further input before it actually does anything.
301   Some of the commands in the menu bar have ordinary key bindings as
302 well; if so, a key binding is shown after the item itself.  To view
303 the full command name and documentation for a menu item, type
304 @kbd{C-h k}, and then select the menu bar with the mouse in the usual
305 way (@pxref{Key Help}).
307 @kindex F10
308 @findex menu-bar-open
309 @cindex menu bar access using keyboard
310   Instead of using the mouse, you can also invoke the first menu bar
311 item by pressing @key{F10} (to run the command @code{menu-bar-open}).
312 You can then navigate the menus with the arrow keys or with @kbd{C-b},
313 @kbd{C-f} (left/right), @kbd{C-p}, and @kbd{C-n} (up/down).  To
314 activate a selected menu item, press @key{RET}; to cancel menu
315 navigation, press @kbd{C-g} or @kbd{@key{ESC} @key{ESC} @key{ESC}}.
316 (However, note that when Emacs was built with a GUI toolkit, the menus
317 are drawn and controlled by the toolkit, and the key sequences to
318 cancel menu navigation might be different from the above description.)
320 @kindex M-`
321 @findex tmm-menubar
322 @vindex tty-menu-open-use-tmm
323   On a text terminal, you can optionally access the menu-bar menus in
324 the echo area.  To this end, customize the variable
325 @code{tty-menu-open-use-tmm} to a non-@code{nil} value.  Then typing
326 @key{F10} will run the command @code{tmm-menubar} instead of dropping
327 down the menu.  (You can also type @kbd{M-`}, which always invokes
328 @code{tmm-menubar}.)  @code{tmm-menubar} lets you select a menu item
329 with the keyboard.  A provisional choice appears in the echo area.
330 You can use the up and down arrow keys to move through the menu to
331 different items, and then you can type @key{RET} to select the item.
332 Each menu item is also designated by a letter or digit (usually the
333 initial of some word in the item's name).  This letter or digit is
334 separated from the item name by @samp{==>}.  You can type the item's
335 letter or digit to select the item.