Next: , Previous: , Up: Windows   [Contents][Index]


38.13 The Size of a Window

A SXEmacs window is rectangular, and its size information consists of the height (in lines or pixels) and the width (in character positions or pixels). The modeline is included in the height. The pixel width and height values include scrollbars and margins, while the line/character-position values do not.

Note that the height in lines, and the width in characters, are determined by dividing the corresponding pixel value by the height or width of the default font in that window (if this is a variable-width font, the average width is used). The resulting values may or may not represent the actual number of lines in the window, or the actual number of character positions in any particular line, esp. if there are pixmaps or various different fonts in the window.

The following functions return size information about a window:

Function: window-height &optional window

This function returns the number of lines in window, including its modeline but not including the horizontal scrollbar, if any (this is different from window-pixel-height). If window is nil, the function uses the selected window.

(window-height)
     ⇒ 40
(split-window-vertically)
     ⇒ #<window on "windows.texi" 0x679b>
(window-height)
     ⇒ 20
Function: window-width &optional window

This function returns the number of columns in window, not including any left margin, right margin, or vertical scrollbar (this is different from window-pixel-width). If window is nil, the function uses the selected window.

(window-width)
     ⇒ 80
(window-height)
     ⇒ 40
(split-window-horizontally)
     ⇒ #<window on "windows.texi" 0x7538>
(window-width)
     ⇒ 39

Note that after splitting the window into two side-by-side windows, the width of each window is less the half the width of the original window because a vertical scrollbar appeared between the windows, occupying two columns worth of space. Also, the height shrunk by one because horizontal scrollbars appeared that weren’t there before. (Horizontal scrollbars appear only when lines are truncated, not when they wrap. This is usually the case for horizontally split windows but not for full-frame windows. You can change this using the variables truncate-lines and truncate-partial-width-windows.)

Function: window-pixel-height &optional window

This function returns the height of window in pixels, including its modeline and horizontal scrollbar, if any. If window is nil, the function uses the selected window.

(window-pixel-height)
     ⇒ 600
(split-window-vertically)
     ⇒ #<window on "windows.texi" 0x68a6>
(window-pixel-height)
     ⇒ 300
Function: window-pixel-width &optional window

This function returns the width of window in pixels, including any left margin, right margin, or vertical scrollbar that may be displayed alongside it. If window is nil, the function uses the selected window.

(window-pixel-width)
     ⇒ 735
(window-pixel-height)
     ⇒ 600
(split-window-horizontally)
     ⇒ #<window on "windows.texi" 0x7538>
(window-pixel-width)
     ⇒ 367
(window-pixel-height)
     ⇒ 600
Function: window-text-area-pixel-height &optional window

This function returns the height in pixels of the text displaying portion of window, which defaults to the selected window. Unlike window-pixel-height, the space occupied by the modeline and horizontal scrollbar, if any, is not counted.

Function: window-text-area-pixel-width &optional window

This function returns the width in pixels of the text displaying portion of window, which defaults to the selected window. Unlike window-pixel-width, the space occupied by the vertical scrollbar and divider, if any, is not counted.

Function: window-displayed-text-pixel-height &optional window noclipped

This function returns the height in pixels of the text displayed in window, which defaults to the selected window. Unlike window-text-area-pixel-height, any blank space below the end of the buffer is not included. If optional argument noclipped is non-nil, any space occupied by clipped lines will not be included.


Next: , Previous: , Up: Windows   [Contents][Index]