Next: Resizing Windows, Previous: Windows and Frames, Up: Windows
The following schematic shows the structure of a live window:
_________________________________________
^ |______________ Header Line_______________|
| |LS|LF|LM| |RM|RF|RS| ^
| | | | | | | | | |
Window | | | | Text Area | | | | Window
Total | | | | (Window Body) | | | | Body
Height | | | | | | | | Height
| | | | |<- Window Body Width ->| | | | |
| |__|__|__|_______________________|__|__|__| v
v |_______________ Mode Line _______________|
<----------- Window Total Width -------->
At the center of the window is the text area, or body, where the buffer text is displayed. On each side of the text area is a series of vertical areas; from innermost to outermost, these are the left and right margins, denoted by LM and RM in the schematic (see Display Margins); the left and right fringes, denoted by LF and RF (see Fringes); and the left or right scroll bar, only one of which is present at any time, denoted by LS and RS (see Scroll Bars). At the top of the window is an optional header line (see Header Lines), and at the bottom of the window is the mode line (see Mode Line Format).
Emacs provides several functions for finding the height and width of a window. Except where noted, Emacs reports window heights and widths as integer numbers of lines and columns, respectively. On a graphical display, each “line” and “column” actually corresponds to the height and width of a “default” character specified by the frame's default font. Thus, if a window is displaying text with a different font or size, the reported height and width for that window may differ from the actual number of text lines or columns displayed within it.
The total height of a window is the distance between the top and bottom of the window, including the header line (if one exists) and the mode line. The total width of a window is the distance between the left and right edges of the mode line. Note that the height of a frame is not the same as the height of its windows, since a frame may also contain an echo area, menu bar, and tool bar (see Size and Position).
This function returns the total height, in lines, of the window window. If window is omitted or
nil, it defaults to the selected window. If window is an internal window, the return value is the total height occupied by its descendant windows.
This function returns the total width, in columns, of the window window. If window is omitted or
nil, it defaults to the selected window. If window is internal, the return value is the total width occupied by its descendant windows.
This function returns either the total height or width of the window window. If horizontal is omitted or
nil, this is equivalent to callingwindow-total-heightfor window; otherwise it is equivalent to callingwindow-total-widthfor window.
The following functions can be used to determine whether a given window has any adjacent windows.
This function returns non-
nilif window has no other window above or below it in its frame, i.e., its total height equals the total height of the root window on that frame. If window is omitted ornil, it defaults to the selected window.
This function returns non-
nilif window has no other window to the left or right in its frame, i.e., its total width equals that of the root window on that frame. If window is omitted ornil, it defaults to the selected window.
The body height of a window is the height of its text area, which does not include the mode or header line. Similarly, the body width is the width of the text area, which does not include the scroll bar, fringes, or margins.
This function returns the body height, in lines, of the window window. If window is omitted or
nil, it defaults to the selected window; otherwise it must be a live window.If there is a partially-visible line at the bottom of the text area, that counts as a whole line; to exclude such a partially-visible line, use
window-text-height, below.
This function returns the body width, in columns, of the window window. If window is omitted or
nil, it defaults to the selected window; otherwise it must be a live window.
This function returns the body height or body width of window. If horizontal is omitted or
nil, it is equivalent to callingwindow-body-heightfor window; otherwise it is equivalent to callingwindow-body-width.
This function is like
window-body-height, except that any partially-visible line at the bottom of the text area is not counted.
For compatibility with previous versions of Emacs,
window-height is an alias for window-total-height, and
window-width is an alias for window-body-width. These
aliases are considered obsolete and will be removed in the future.
Commands that change the size of windows (see Resizing Windows),
or split them (see Splitting Windows), obey the variables
window-min-height and window-min-width, which specify
the smallest allowable window height and width. See Deleting and Rearranging Windows. They also obey the variable window-size-fixed, with
which a window can be fixed in size:
If this buffer-local variable is non-
nil, the size of any window displaying the buffer cannot normally be changed. Deleting a window or changing the frame's size may still change its size, if there is no choice.If the value is
height, then only the window's height is fixed; if the value iswidth, then only the window's width is fixed. Any other non-nilvalue fixes both the width and the height.
This function returns a non-
nilvalue if window's height is fixed. If window is omitted ornil, it defaults to the selected window. If the optional argument horizontal is non-nil, the return value is non-nilif window's width is fixed.A
nilreturn value does not necessarily mean that window can be resized in the desired direction. To determine that, use the functionwindow-resizable. See Resizing Windows.
See Coordinates and Windows, for more functions that report the
positions of various parts of a window relative to the frame, from
which you can calculate its size. In particular, you can use the
functions window-pixel-edges and
window-inside-pixel-edges to find the size in pixels, for
graphical displays.