From f5b8df14c6d9c906eed548c694f23e5abcf6e403 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Fri, 15 Oct 2021 10:21:05 +0200 Subject: [PATCH] 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'. --- doc/lispref/display.texi | 12 ++++++------ lisp/window.el | 8 ++++++-- src/xdisp.c | 19 ++++++++----------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 2ae04a85218..4500795e45b 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -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 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 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 @@ -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 does not know the size of the buffer. -The optional argument @var{mode-and-header-line} @code{nil} or omitted -means to not include the height of the mode- or header-line of -@var{window} in the return value. If it is either the symbol -@code{mode-line} or @code{header-line}, include only the height of that +The optional argument @var{mode-lines} @code{nil} or omitted means to +not include the height of the mode-, tab- or header-line of @var{window} +in the return value. If it is either the symbol @code{mode-line}, +@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 -height of both, if present, in the return value. +height of all of these lines, if present, in the return value. @end defun @code{window-text-pixel-size} treats the text displayed in a window as a diff --git a/lisp/window.el b/lisp/window.el index 971264b6344..d12232641e3 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -1407,9 +1407,12 @@ before writing to it." (cadr fringes) (window-scroll-bar-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-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))))) (insert "\n"))) @@ -1691,6 +1694,7 @@ return the minimum pixel-size of WINDOW." ((let ((char-size (frame-char-size window)) (pixel-height (+ (window-safe-min-size window nil t) + (window-tab-line-height window) (window-header-line-height window) (window-scroll-bar-height window) (window-mode-line-height window) diff --git a/src/xdisp.c b/src/xdisp.c index d8aff5084c4..40d578ae9aa 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -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 argument if the size of the buffer is large or unknown. -Optional argument MODE-AND-HEADER-LINE nil or omitted means do not -include the height of the mode- or header-line of WINDOW in the return -value. If it is either the symbol `mode-line' or `header-line', include +Optional argument MODE-LINES nil or omitted means do not include the +height of the mode-, tab- or header-line of WINDOW in the return value. +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, -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 y_limit, Lisp_Object mode_and_header_line) + Lisp_Object y_limit, Lisp_Object mode_lines) { struct window *w = decode_live_window (window); Lisp_Object buffer = w->contents; @@ -10841,18 +10841,15 @@ include the height of both, if present, in the return value. */) if (y > max_y) y = max_y; - if (EQ (mode_and_header_line, Qtab_line) - || EQ (mode_and_header_line, Qt)) + if (EQ (mode_lines, Qtab_line) || EQ (mode_lines, Qt)) /* Re-add height of tab-line as requested. */ y = y + WINDOW_TAB_LINE_HEIGHT (w); - if (EQ (mode_and_header_line, Qheader_line) - || EQ (mode_and_header_line, Qt)) + if (EQ (mode_lines, Qheader_line) || EQ (mode_lines, Qt)) /* Re-add height of header-line as requested. */ y = y + WINDOW_HEADER_LINE_HEIGHT (w); - if (EQ (mode_and_header_line, Qmode_line) - || EQ (mode_and_header_line, Qt)) + if (EQ (mode_lines, Qmode_line) || EQ (mode_lines, Qt)) /* Add height of mode-line as requested. */ y = y + WINDOW_MODE_LINE_HEIGHT (w); -- 2.39.2