aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorDaniel Mendler2026-01-07 17:39:16 +0100
committerEli Zaretskii2026-01-24 13:32:44 +0200
commite8f26d554b64ed63fe2b7f110d5247648b7322ed (patch)
treee2ccf11382272f44ee1bca37eac42858b1180bb8 /src/window.c
parent21455197343ff912d9544b4663ad383009a816e5 (diff)
downloademacs-e8f26d554b64ed63fe2b7f110d5247648b7322ed.tar.gz
emacs-e8f26d554b64ed63fe2b7f110d5247648b7322ed.zip
Support cons cell for 'line-spacing'
* etc/NEWS: Announce the change. * src/dispextern.h (struct glyph_row): Add 'extra_line_spacing_above' member. (struct it): Add 'extra_line_spacing_above' member. * src/frame.h (struct frame): Add 'extra_line_spacing_above' member. Update comment for 'extra_line_spacing.' * src/buffer.c (syms_of_buffer): Update the docstring of 'line-spacing' to describe the cons cell usage. * src/buffer.h (struct buffer): Update comment for 'extra_line_spacing'. * src/frame.c (gui_set_line_spacing): Handle cons cell value for 'line-spacing'. Calculate and set 'extra_line_spacing_above' for both integer and float pairs. * src/xdisp.c (init_iterator): Initialize 'extra_line_spacing_above' from buffer or frame 'line-spacing', handling cons cells for both integer and float values. (gui_produce_glyphs): Use 'extra_line_spacing_above' to distribute spacing between ascent and descent. Update 'max_extra_line_spacing' calculation. (resize_mini_window): Take line spacing into account when resizing the mini window. Pass height of a single line to 'grow_mini_window' and 'shrink_mini_window'. * src/window.c (grow_mini_window, shrink_mini_window): Add unit argument which defines height of a single line. * src/window.h (grow_mini_window, shrink_mini_window): Adjust function prototypes accordingly with unit argument. * lisp/subr.el (total-line-spacing): New function to calculate total spacing from a number or cons cell. (posn-col-row): Use total-line-spacing. * lisp/simple.el (default-line-height): Use 'total-line-spacing'. * lisp/textmodes/picture.el (picture-mouse-set-point): Use 'total-line-spacing'. * lisp/window.el (window-default-line-height): Use 'total-line-spacing'. (window--resize-mini-window): Take 'line-spacing' into account. * test/lisp/subr-tests.el (total-line-spacing): New test. * test/src/buffer-tests.el (test-line-spacing): New test. * doc/emacs/display.texi (Display Custom): Document that 'line-spacing' can be a cons cell. (Line Height): Document the new cons cell format for 'line-spacing' to allow vertical centering. Co-authored-by: Przemysław Alexander Kamiński <alexander@kaminski.se> Co-authored-by: Daniel Mendler <mail@daniel-mendler.de>
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/window.c b/src/window.c
index 497c587b167..c4f2e4e491f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5894,11 +5894,11 @@ resize_mini_window_apply (struct window *w, int delta)
5894 * line of text. 5894 * line of text.
5895 */ 5895 */
5896void 5896void
5897grow_mini_window (struct window *w, int delta) 5897grow_mini_window (struct window *w, int delta, int unit)
5898{ 5898{
5899 struct frame *f = XFRAME (w->frame); 5899 struct frame *f = XFRAME (w->frame);
5900 int old_height = window_body_height (w, WINDOW_BODY_IN_PIXELS); 5900 int old_height = window_body_height (w, WINDOW_BODY_IN_PIXELS);
5901 int min_height = FRAME_LINE_HEIGHT (f); 5901 int min_height = unit;
5902 5902
5903 eassert (MINI_WINDOW_P (w)); 5903 eassert (MINI_WINDOW_P (w));
5904 5904
@@ -5926,7 +5926,7 @@ grow_mini_window (struct window *w, int delta)
5926 resize_mini_window_apply (w, -XFIXNUM (grow)); 5926 resize_mini_window_apply (w, -XFIXNUM (grow));
5927 } 5927 }
5928 FRAME_WINDOWS_FROZEN (f) 5928 FRAME_WINDOWS_FROZEN (f)
5929 = window_body_height (w, WINDOW_BODY_IN_PIXELS) > FRAME_LINE_HEIGHT (f); 5929 = window_body_height (w, WINDOW_BODY_IN_PIXELS) > unit;
5930} 5930}
5931 5931
5932/** 5932/**
@@ -5936,11 +5936,10 @@ grow_mini_window (struct window *w, int delta)
5936 * line of text. 5936 * line of text.
5937 */ 5937 */
5938void 5938void
5939shrink_mini_window (struct window *w) 5939shrink_mini_window (struct window *w, int unit)
5940{ 5940{
5941 struct frame *f = XFRAME (w->frame); 5941 struct frame *f = XFRAME (w->frame);
5942 int delta = (window_body_height (w, WINDOW_BODY_IN_PIXELS) 5942 int delta = (window_body_height (w, WINDOW_BODY_IN_PIXELS) - unit);
5943 - FRAME_LINE_HEIGHT (f));
5944 5943
5945 eassert (MINI_WINDOW_P (w)); 5944 eassert (MINI_WINDOW_P (w));
5946 5945
@@ -5959,10 +5958,10 @@ shrink_mini_window (struct window *w)
5959 else if (delta < 0) 5958 else if (delta < 0)
5960 /* delta can be less than zero after adding horizontal scroll 5959 /* delta can be less than zero after adding horizontal scroll
5961 bar. */ 5960 bar. */
5962 grow_mini_window (w, -delta); 5961 grow_mini_window (w, -delta, unit);
5963 5962
5964 FRAME_WINDOWS_FROZEN (f) 5963 FRAME_WINDOWS_FROZEN (f)
5965 = window_body_height (w, WINDOW_BODY_IN_PIXELS) > FRAME_LINE_HEIGHT (f); 5964 = window_body_height (w, WINDOW_BODY_IN_PIXELS) > unit;
5966} 5965}
5967 5966
5968DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, 5967DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal,