[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

28.14 The Size of a Window

An Emacs window is rectangular, and its size information consists of the height (the number of lines) and the width (the number of character positions in each line). The mode line is included in the height. But the width does not count the scroll bar or the column of ‘|’ characters that separates side-by-side windows.

The following three functions return size information about a window:

Function: window-height &optional window

This function returns the number of lines in window, including its mode line and header line, if any. If window fills its entire frame except for the echo area, this is typically one less than the value of frame-height on that frame.

If window is nil, the function uses the selected window.

 
(window-height)
     ⇒ 23
(split-window-vertically)
     ⇒ #<window 4 on windows.texi>
(window-height)
     ⇒ 11
Function: window-body-height &optional window

Like window-height but the value does not include the mode line (if any) or the header line (if any).

Function: window-width &optional window

This function returns the number of columns in window. If window fills its entire frame, this is the same as the value of frame-width on that frame. The width does not include the window's scroll bar or the column of ‘|’ characters that separates side-by-side windows.

If window is nil, the function uses the selected window.

 
(window-width)
     ⇒ 80
Function: window-edges &optional window

This function returns a list of the edge coordinates of window. If window is nil, the selected window is used.

The order of the list is (left top right bottom), all elements relative to 0, 0 at the top left corner of the frame. The element right of the value is one more than the rightmost column used by window, and bottom is one more than the bottommost row used by window and its mode-line.

The edges include the space used by the window's scroll bar, display margins, fringes, header line, and mode line, if it has them. Also, if the window has a neighbor on the right, its right edge value includes the width of the separator line between the window and that neighbor. Since the width of the window does not include this separator, the width does not usually equal the difference between the right and left edges.

Function: window-inside-edges &optional window

This is similar to window-edges, but the edge values it returns include only the text area of the window. They do not include the header line, mode line, scroll bar or vertical separator, fringes, or display margins.

Here are the results obtained on a typical 24-line terminal with just one window, with menu bar enabled:

 
(window-edges (selected-window))
     ⇒ (0 1 80 23)
(window-inside-edges (selected-window))
     ⇒ (0 1 80 22)

The bottom edge is at line 23 because the last line is the echo area. The bottom inside edge is at line 22, which is the window's mode line.

If window is at the upper left corner of its frame, and there is no menu bar, then bottom returned by window-edges is the same as the value of (window-height), right is almost the same as the value of (window-width), and top and left are zero. For example, the edges of the following window are ‘0 0 8 5’. Assuming that the frame has more than 8 columns, the last column of the window (column 7) holds a border rather than text. The last row (row 4) holds the mode line, shown here with ‘xxxxxxxxx’.

 
           0
           _______
        0 |       |
          |       |
          |       |
          |       |
          xxxxxxxxx  4

                  7

In the following example, let's suppose that the frame is 7 columns wide. Then the edges of the left window are ‘0 0 4 3’ and the edges of the right window are ‘4 0 7 3’. The inside edges of the left window are ‘0 0 3 2’, and the inside edges of the right window are ‘4 0 7 2’,

 
           ___ ___
          |   |   |
          |   |   |
          xxxxxxxxx

           0  34  7
Function: window-pixel-edges &optional window

This function is like window-edges except that, on a graphical display, the edge values are measured in pixels instead of in character lines and columns.

Function: window-inside-pixel-edges &optional window

This function is like window-inside-edges except that, on a graphical display, the edge values are measured in pixels instead of in character lines and columns.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.