From d99aa9461b1348741ee2df7b6c7a197005191716 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 18 Dec 2021 13:56:10 +0200 Subject: ; Fix last change * src/xdisp.c (window_text_pixel_size): Fix whitespace and braces. * src/xdisp.c (Fwindow_text_pixel_size): * etc/NEWS: * doc/lispref/display.texi (Size of Displayed Text): Improve wording of the documentation of the new argument of 'window-text-pixel-size'. --- doc/lispref/display.texi | 4 +++- etc/NEWS | 7 ++++--- src/xdisp.c | 15 +++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 92bfd2fea19..1460e070a0a 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -2138,7 +2138,9 @@ height of all of these lines, if present, in the return value. The optional argument @var{ignore-line-at-end} controls whether or not to count the height of text in @var{to}'s screen line as part of -the returned pixel-height. +the returned pixel-height. This is useful if your Lisp program is +only interested in the dimensions of text up to and excluding the +visual beginning of @var{to}'s screen line. @code{window-text-pixel-size} treats the text displayed in a window as a whole and does not care about the size of individual lines. The diff --git a/etc/NEWS b/etc/NEWS index 20056b30c58..e3665b918a3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -985,9 +985,10 @@ This can be used to check whether a specific font has a glyph for a character. +++ -** 'window-text-pixel-size' now accepts a new argument `ignore-line-at-end'. -This controls whether or not the screen line at the end of the -measured area will be counted during the height calculation. +** 'window-text-pixel-size' now accepts a new argument 'ignore-line-at-end'. +This controls whether or not the last screen line of the text being +measured will be counted for the purpose of calculating the text +dimensions. ** XDG support diff --git a/src/xdisp.c b/src/xdisp.c index 473c9f3f143..6dcfe3573a9 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10832,8 +10832,9 @@ in_display_vector_p (struct it *it) set WINDOW's buffer to the buffer specified by its BUFFER_OR_NAME argument. */ static Lisp_Object -window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_limit, - Lisp_Object y_limit, Lisp_Object mode_lines, Lisp_Object ignore_line_at_end) +window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, + Lisp_Object x_limit, Lisp_Object y_limit, + Lisp_Object mode_lines, Lisp_Object ignore_line_at_end) { struct window *w = decode_live_window (window); struct it it; @@ -10973,10 +10974,8 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, Li /* DTRT if ignore_line_at_end is t. */ if (!NILP (ignore_line_at_end)) - { - doff = (max (it.max_ascent, it.ascent) - + max (it.max_descent, it.descent)); - } + doff = (max (it.max_ascent, it.ascent) + + max (it.max_descent, it.descent)); else { it.max_ascent = max (it.max_ascent, it.ascent); @@ -11105,8 +11104,8 @@ 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 any of these, if present, in the return value. -IGNORE-LINE-AT-END means to not add the height of the screen line at -TO to the returned height. */) +IGNORE-LINE-AT-END, if non-nil, means to not add the height of the +screen line that includes TO to the returned height of the text. */) (Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_limit, Lisp_Object y_limit, Lisp_Object mode_lines, Lisp_Object ignore_line_at_end) { -- cgit v1.2.3