- if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
- /* Scroll bars occupy a few columns. */
- width -= WINDOW_CONFIG_SCROLL_BAR_COLS (w);
- else if (!FRAME_WINDOW_P (f)
- && !WINDOW_RIGHTMOST_P (w) && !WINDOW_FULL_WIDTH_P (w))
- /* The column of `|' characters separating side-by-side windows
- occupies one column only. */
- width -= 1;
-
- if (FRAME_WINDOW_P (f))
- /* On window-systems, fringes and display margins cannot be
- used for normal text. */
- width -= (WINDOW_FRINGE_COLS (w)
- + WINDOW_LEFT_MARGIN_COLS (w)
- + WINDOW_RIGHT_MARGIN_COLS (w));
-
- return width;
+ int width = (w->pixel_width
+ - WINDOW_RIGHT_DIVIDER_WIDTH (w)
+ - (WINDOW_HAS_VERTICAL_SCROLL_BAR (w)
+ ? WINDOW_SCROLL_BAR_AREA_WIDTH (w)
+ : ((!FRAME_WINDOW_P (f)
+ && !WINDOW_RIGHTMOST_P (w)
+ && !WINDOW_RIGHT_DIVIDER_WIDTH (w))
+ /* A vertical bar is either 1 or 0. */
+ ? 1 : 0))
+ - WINDOW_MARGINS_WIDTH (w)
+ - (FRAME_WINDOW_P (f)
+ ? WINDOW_FRINGES_WIDTH (w)
+ : 0));
+
+ /* Don't return a negative value. */
+ return max (pixelwise
+ ? width
+ : width / FRAME_COLUMN_WIDTH (WINDOW_XFRAME (w)),
+ 0);
+}
+
+DEFUN ("window-body-height", Fwindow_body_height, Swindow_body_height, 0, 2, 0,
+ doc: /* Return the height of WINDOW's text area.
+WINDOW must be a live window and defaults to the selected one. Optional
+argument PIXELWISE non-nil means return the height of WINDOW's text area
+in pixels. The return value does not include the mode line or header
+line or any horizontal divider.
+
+If PIXELWISE is nil, return the largest integer smaller than WINDOW's
+pixel height divided by the character height of WINDOW's frame. This
+means that if a line at the bottom of the text area is only partially
+visible, that line is not counted. */)
+ (Lisp_Object window, Lisp_Object pixelwise)
+{
+ return make_number (window_body_height (decode_live_window (window),
+ NILP (pixelwise) ? 0 : 1));
+}
+
+DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 2, 0,
+ doc: /* Return the width of WINDOW's text area.
+WINDOW must be a live window and defaults to the selected one. Optional
+argument PIXELWISE non-nil means return the width in pixels. The return
+value does not include any vertical dividers, fringes or marginal areas,
+or scroll bars.
+
+If PIXELWISE is nil, return the largest integer smaller than WINDOW's
+pixel width divided by the character width of WINDOW's frame. This
+means that if a column at the right of the text area is only partially
+visible, that column is not counted.
+
+Note that the returned value includes the column reserved for the
+continuation glyph. */)
+ (Lisp_Object window, Lisp_Object pixelwise)
+{
+ return make_number (window_body_width (decode_live_window (window),
+ NILP (pixelwise) ? 0 : 1));
+}
+
+DEFUN ("window-mode-line-height", Fwindow_mode_line_height,
+ Swindow_mode_line_height, 0, 1, 0,
+ doc: /* Return the height in pixels of WINDOW's mode-line.
+WINDOW must be a live window and defaults to the selected one. */)
+ (Lisp_Object window)
+{
+ return (make_number (WINDOW_MODE_LINE_HEIGHT (decode_live_window (window))));