GNU Info

Info Node: (elisp)Size of Window

(elisp)Size of Window


Next: Resizing Windows Prev: Horizontal Scrolling Up: Windows
Enter node , (file) or (file)node

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.  If WINDOW fills its entire frame, this is typically
     one less than the value of `frame-height' on that frame (since the
     last line is always reserved for the minibuffer).

     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-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.

     If a window has a scroll bar, the right edge value includes the
     width of the scroll bar.  Otherwise, 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.

     Here is the result obtained on a typical 24-line terminal with
     just one window:

          (window-edges (selected-window))
               => (0 0 80 23)

     The bottom edge is at line 23 because the last line is the echo
     area.

     If WINDOW is at the upper left corner of its frame, then BOTTOM 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 8 3'.

                     ___ ___
                    |   |   |
                    |   |   |
                    xxxxxxxxx
          
                     0  34  7


automatically generated by info2www version 1.2.2.9