Fixes to account for windows' tab lines

* doc/lispref/display.texi (Size of Displayed Text): Fix entry
on 'window-text-pixel-size'.
* lisp/window.el (window--dump-window): Dump tab-line-height and
scroll-bar-height too.
(window--min-size-1): Take 'window-tab-line-height' into account.
* src/xdisp.c (Fwindow_text_pixel_size): Fix doc-string of
'window-text-pixel-size'.  Rename last argument to 'MODE-LINES'.
This commit is contained in:
Martin Rudalics 2021-10-15 10:21:05 +02:00
parent ced72b6e4c
commit f5b8df14c6
3 changed files with 20 additions and 19 deletions

View file

@ -2050,7 +2050,7 @@ displayed in a given window. This function is used by
(@pxref{Resizing Windows}) to make a window exactly as large as the text (@pxref{Resizing Windows}) to make a window exactly as large as the text
it contains. it contains.
@defun window-text-pixel-size &optional window from to x-limit y-limit mode-and-header-line @defun window-text-pixel-size &optional window from to x-limit y-limit mode-lines
This function returns the size of the text of @var{window}'s buffer in This function returns the size of the text of @var{window}'s buffer in
pixels. @var{window} must be a live window and defaults to the pixels. @var{window} must be a live window and defaults to the
selected one. The return value is a cons of the maximum pixel-width selected one. The return value is a cons of the maximum pixel-width
@ -2092,12 +2092,12 @@ calculating the pixel-height of a large buffer can take some time, it
makes sense to specify this argument; in particular, if the caller makes sense to specify this argument; in particular, if the caller
does not know the size of the buffer. does not know the size of the buffer.
The optional argument @var{mode-and-header-line} @code{nil} or omitted The optional argument @var{mode-lines} @code{nil} or omitted means to
means to not include the height of the mode- or header-line of not include the height of the mode-, tab- or header-line of @var{window}
@var{window} in the return value. If it is either the symbol in the return value. If it is either the symbol @code{mode-line},
@code{mode-line} or @code{header-line}, include only the height of that @code{tab-line} or @code{header-line}, include only the height of that
line, if present, in the return value. If it is @code{t}, include the line, if present, in the return value. If it is @code{t}, include the
height of both, if present, in the return value. height of all of these lines, if present, in the return value.
@end defun @end defun
@code{window-text-pixel-size} treats the text displayed in a window as a @code{window-text-pixel-size} treats the text displayed in a window as a

View file

@ -1407,9 +1407,12 @@ before writing to it."
(cadr fringes) (cadr fringes)
(window-scroll-bar-width window) (window-scroll-bar-width window)
(window-right-divider-width window)) (window-right-divider-width window))
(format "height header-line: %s mode-line: %s divider: %s\n" (format "height tab-line: %s header-line: %s mode-line: %s\n"
(window-tab-line-height window)
(window-header-line-height window) (window-header-line-height window)
(window-mode-line-height window) (window-mode-line-height window))
(format "height scroll-bar: %s divider: %s"
(window-scroll-bar-height window)
(window-bottom-divider-width window))))) (window-bottom-divider-width window)))))
(insert "\n"))) (insert "\n")))
@ -1691,6 +1694,7 @@ return the minimum pixel-size of WINDOW."
((let ((char-size (frame-char-size window)) ((let ((char-size (frame-char-size window))
(pixel-height (pixel-height
(+ (window-safe-min-size window nil t) (+ (window-safe-min-size window nil t)
(window-tab-line-height window)
(window-header-line-height window) (window-header-line-height window)
(window-scroll-bar-height window) (window-scroll-bar-height window)
(window-mode-line-height window) (window-mode-line-height window)

View file

@ -10661,13 +10661,13 @@ position specified by TO. Since calculating the text height of a
large buffer can take some time, it makes sense to specify this large buffer can take some time, it makes sense to specify this
argument if the size of the buffer is large or unknown. argument if the size of the buffer is large or unknown.
Optional argument MODE-AND-HEADER-LINE nil or omitted means do not Optional argument MODE-LINES nil or omitted means do not include the
include the height of the mode- or header-line of WINDOW in the return height of the mode-, tab- or header-line of WINDOW in the return value.
value. If it is either the symbol `mode-line' or `header-line', include If it is the symbol `mode-line', 'tab-line' or `header-line', include
only the height of that line, if present, in the return value. If t, only the height of that line, if present, in the return value. If t,
include the height of both, if present, in the return value. */) include the height of any of these, if present, in the return value. */)
(Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_limit, (Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_limit,
Lisp_Object y_limit, Lisp_Object mode_and_header_line) Lisp_Object y_limit, Lisp_Object mode_lines)
{ {
struct window *w = decode_live_window (window); struct window *w = decode_live_window (window);
Lisp_Object buffer = w->contents; Lisp_Object buffer = w->contents;
@ -10841,18 +10841,15 @@ include the height of both, if present, in the return value. */)
if (y > max_y) if (y > max_y)
y = max_y; y = max_y;
if (EQ (mode_and_header_line, Qtab_line) if (EQ (mode_lines, Qtab_line) || EQ (mode_lines, Qt))
|| EQ (mode_and_header_line, Qt))
/* Re-add height of tab-line as requested. */ /* Re-add height of tab-line as requested. */
y = y + WINDOW_TAB_LINE_HEIGHT (w); y = y + WINDOW_TAB_LINE_HEIGHT (w);
if (EQ (mode_and_header_line, Qheader_line) if (EQ (mode_lines, Qheader_line) || EQ (mode_lines, Qt))
|| EQ (mode_and_header_line, Qt))
/* Re-add height of header-line as requested. */ /* Re-add height of header-line as requested. */
y = y + WINDOW_HEADER_LINE_HEIGHT (w); y = y + WINDOW_HEADER_LINE_HEIGHT (w);
if (EQ (mode_and_header_line, Qmode_line) if (EQ (mode_lines, Qmode_line) || EQ (mode_lines, Qt))
|| EQ (mode_and_header_line, Qt))
/* Add height of mode-line as requested. */ /* Add height of mode-line as requested. */
y = y + WINDOW_MODE_LINE_HEIGHT (w); y = y + WINDOW_MODE_LINE_HEIGHT (w);