aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAaron Jensen2018-03-10 13:14:28 +0200
committerEli Zaretskii2018-03-10 13:14:28 +0200
commitbbf53d99b57bd3d7fc0427d378df2efc6fa10e00 (patch)
tree0d3074b8c6ad4acff71383fa8be427a03a63d8df /src
parent461e681822ff86132a6dc18b65eb2070cb006800 (diff)
downloademacs-bbf53d99b57bd3d7fc0427d378df2efc6fa10e00.tar.gz
emacs-bbf53d99b57bd3d7fc0427d378df2efc6fa10e00.zip
Allow underline position variables be buffer-local
* src/nsterm.m (ns_draw_text_decoration): * src/w32term.c (x_draw_glyph_string): * src/xterm.c (x_draw_glyph_string): Allow underline-minimum-offset, underline-at-descent-line, and x-use-underline-position-properties be buffer local variables. (Bug#30553) * src/xdisp.c (syms_of_xdisp) <underline-minimum-offset>: Add DEFSYM.
Diffstat (limited to 'src')
-rw-r--r--src/nsterm.m26
-rw-r--r--src/w32term.c36
-rw-r--r--src/xdisp.c1
-rw-r--r--src/xterm.c37
4 files changed, 83 insertions, 17 deletions
diff --git a/src/nsterm.m b/src/nsterm.m
index 1919c6defaf..75e0b837c67 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3487,23 +3487,38 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face,
3487 { 3487 {
3488 struct font *font = font_for_underline_metrics (s); 3488 struct font *font = font_for_underline_metrics (s);
3489 unsigned long descent = s->y + s->height - s->ybase; 3489 unsigned long descent = s->y + s->height - s->ybase;
3490 unsigned long minimum_offset;
3491 BOOL underline_at_descent_line, use_underline_position_properties;
3492 Lisp_Object val = buffer_local_value (Qunderline_minimum_offset,
3493 s->w->contents);
3494 if (INTEGERP (val))
3495 minimum_offset = XFASTINT (val);
3496 else
3497 minimum_offset = 1;
3498 val = buffer_local_value (Qx_underline_at_descent_line,
3499 s->w->contents);
3500 underline_at_descent_line = !(NILP (val) || EQ (val, Qunbound));
3501 val = buffer_local_value (Qx_use_underline_position_properties,
3502 s->w->contents);
3503 use_underline_position_properties =
3504 !(NILP (val) || EQ (val, Qunbound));
3490 3505
3491 /* Use underline thickness of font, defaulting to 1. */ 3506 /* Use underline thickness of font, defaulting to 1. */
3492 thickness = (font && font->underline_thickness > 0) 3507 thickness = (font && font->underline_thickness > 0)
3493 ? font->underline_thickness : 1; 3508 ? font->underline_thickness : 1;
3494 3509
3495 /* Determine the offset of underlining from the baseline. */ 3510 /* Determine the offset of underlining from the baseline. */
3496 if (x_underline_at_descent_line) 3511 if (underline_at_descent_line)
3497 position = descent - thickness; 3512 position = descent - thickness;
3498 else if (x_use_underline_position_properties 3513 else if (use_underline_position_properties
3499 && font && font->underline_position >= 0) 3514 && font && font->underline_position >= 0)
3500 position = font->underline_position; 3515 position = font->underline_position;
3501 else if (font) 3516 else if (font)
3502 position = lround (font->descent / 2); 3517 position = lround (font->descent / 2);
3503 else 3518 else
3504 position = underline_minimum_offset; 3519 position = minimum_offset;
3505 3520
3506 position = max (position, underline_minimum_offset); 3521 position = max (position, minimum_offset);
3507 3522
3508 /* Ensure underlining is not cropped. */ 3523 /* Ensure underlining is not cropped. */
3509 if (descent <= position) 3524 if (descent <= position)
@@ -9465,11 +9480,14 @@ This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */);
9465 x_use_underline_position_properties, 9480 x_use_underline_position_properties,
9466 doc: /* SKIP: real doc in xterm.c. */); 9481 doc: /* SKIP: real doc in xterm.c. */);
9467 x_use_underline_position_properties = 0; 9482 x_use_underline_position_properties = 0;
9483 DEFSYM (Qx_use_underline_position_properties,
9484 "x-use-underline-position-properties");
9468 9485
9469 DEFVAR_BOOL ("x-underline-at-descent-line", 9486 DEFVAR_BOOL ("x-underline-at-descent-line",
9470 x_underline_at_descent_line, 9487 x_underline_at_descent_line,
9471 doc: /* SKIP: real doc in xterm.c. */); 9488 doc: /* SKIP: real doc in xterm.c. */);
9472 x_underline_at_descent_line = 0; 9489 x_underline_at_descent_line = 0;
9490 DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
9473 9491
9474 /* Tell Emacs about this window system. */ 9492 /* Tell Emacs about this window system. */
9475 Fprovide (Qns, Qnil); 9493 Fprovide (Qns, Qnil);
diff --git a/src/w32term.c b/src/w32term.c
index 97afb678c1d..24950dd25ec 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -2475,31 +2475,52 @@ x_draw_glyph_string (struct glyph_string *s)
2475 else 2475 else
2476 { 2476 {
2477 struct font *font = font_for_underline_metrics (s); 2477 struct font *font = font_for_underline_metrics (s);
2478 unsigned long minimum_offset;
2479 BOOL underline_at_descent_line;
2480 BOOL use_underline_position_properties;
2481 Lisp_Object val
2482 = buffer_local_value (Qunderline_minimum_offset,
2483 s->w->contents);
2484 if (INTEGERP (val))
2485 minimum_offset = XFASTINT (val);
2486 else
2487 minimum_offset = 1;
2488 val = buffer_local_value (Qx_underline_at_descent_line,
2489 s->w->contents);
2490 underline_at_descent_line
2491 = !(NILP (val) || EQ (val, Qunbound));
2492 val
2493 = buffer_local_value (Qx_use_underline_position_properties,
2494 s->w->contents);
2495 use_underline_position_properties
2496 = !(NILP (val) || EQ (val, Qunbound));
2478 2497
2479 /* Get the underline thickness. Default is 1 pixel. */ 2498 /* Get the underline thickness. Default is 1 pixel. */
2480 if (font && font->underline_thickness > 0) 2499 if (font && font->underline_thickness > 0)
2481 thickness = font->underline_thickness; 2500 thickness = font->underline_thickness;
2482 else 2501 else
2483 thickness = 1; 2502 thickness = 1;
2484 if (x_underline_at_descent_line || !font) 2503 if (underline_at_descent_line
2504 || !font)
2485 position = (s->height - thickness) - (s->ybase - s->y); 2505 position = (s->height - thickness) - (s->ybase - s->y);
2486 else 2506 else
2487 { 2507 {
2488 /* Get the underline position. This is the recommended 2508 /* Get the underline position. This is the
2489 vertical offset in pixels from the baseline to the top of 2509 recommended vertical offset in pixels from
2490 the underline. This is a signed value according to the 2510 the baseline to the top of the underline.
2511 This is a signed value according to the
2491 specs, and its default is 2512 specs, and its default is
2492 2513
2493 ROUND ((maximum_descent) / 2), with 2514 ROUND ((maximum_descent) / 2), with
2494 ROUND (x) = floor (x + 0.5) */ 2515 ROUND (x) = floor (x + 0.5) */
2495 2516
2496 if (x_use_underline_position_properties 2517 if (use_underline_position_properties
2497 && font->underline_position >= 0) 2518 && font->underline_position >= 0)
2498 position = font->underline_position; 2519 position = font->underline_position;
2499 else 2520 else
2500 position = (font->descent + 1) / 2; 2521 position = (font->descent + 1) / 2;
2501 } 2522 }
2502 position = max (position, underline_minimum_offset); 2523 position = max (position, minimum_offset);
2503 } 2524 }
2504 /* Check the sanity of thickness and position. We should 2525 /* Check the sanity of thickness and position. We should
2505 avoid drawing underline out of the current line area. */ 2526 avoid drawing underline out of the current line area. */
@@ -7385,11 +7406,14 @@ the cursor have no effect. */);
7385 x_use_underline_position_properties, 7406 x_use_underline_position_properties,
7386 doc: /* SKIP: real doc in xterm.c. */); 7407 doc: /* SKIP: real doc in xterm.c. */);
7387 x_use_underline_position_properties = 0; 7408 x_use_underline_position_properties = 0;
7409 DEFSYM (Qx_use_underline_position_properties,
7410 "x-use-underline-position-properties");
7388 7411
7389 DEFVAR_BOOL ("x-underline-at-descent-line", 7412 DEFVAR_BOOL ("x-underline-at-descent-line",
7390 x_underline_at_descent_line, 7413 x_underline_at_descent_line,
7391 doc: /* SKIP: real doc in xterm.c. */); 7414 doc: /* SKIP: real doc in xterm.c. */);
7392 x_underline_at_descent_line = 0; 7415 x_underline_at_descent_line = 0;
7416 DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
7393 7417
7394 DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars, 7418 DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars,
7395 doc: /* SKIP: real doc in xterm.c. */); 7419 doc: /* SKIP: real doc in xterm.c. */);
diff --git a/src/xdisp.c b/src/xdisp.c
index c2b3f5d954c..44eb1ebf059 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -33040,6 +33040,7 @@ particularly when using variable `x-use-underline-position-properties'
33040with fonts that specify an UNDERLINE_POSITION relatively close to the 33040with fonts that specify an UNDERLINE_POSITION relatively close to the
33041baseline. The default value is 1. */); 33041baseline. The default value is 1. */);
33042 underline_minimum_offset = 1; 33042 underline_minimum_offset = 1;
33043 DEFSYM (Qunderline_minimum_offset, "underline-minimum-offset");
33043 33044
33044 DEFVAR_BOOL ("display-hourglass", display_hourglass_p, 33045 DEFVAR_BOOL ("display-hourglass", display_hourglass_p,
33045 doc: /* Non-nil means show an hourglass pointer, when Emacs is busy. 33046 doc: /* Non-nil means show an hourglass pointer, when Emacs is busy.
diff --git a/src/xterm.c b/src/xterm.c
index 0d25c7f1a26..db5ea4ac55e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3707,33 +3707,53 @@ x_draw_glyph_string (struct glyph_string *s)
3707 else 3707 else
3708 { 3708 {
3709 struct font *font = font_for_underline_metrics (s); 3709 struct font *font = font_for_underline_metrics (s);
3710 unsigned long minimum_offset;
3711 bool underline_at_descent_line;
3712 bool use_underline_position_properties;
3713 Lisp_Object val
3714 = buffer_local_value (Qunderline_minimum_offset,
3715 s->w->contents);
3716 if (INTEGERP (val))
3717 minimum_offset = XFASTINT (val);
3718 else
3719 minimum_offset = 1;
3720 val = buffer_local_value (Qx_underline_at_descent_line,
3721 s->w->contents);
3722 underline_at_descent_line
3723 = !(NILP (val) || EQ (val, Qunbound));
3724 val
3725 = buffer_local_value (Qx_use_underline_position_properties,
3726 s->w->contents);
3727 use_underline_position_properties
3728 = !(NILP (val) || EQ (val, Qunbound));
3710 3729
3711 /* Get the underline thickness. Default is 1 pixel. */ 3730 /* Get the underline thickness. Default is 1 pixel. */
3712 if (font && font->underline_thickness > 0) 3731 if (font && font->underline_thickness > 0)
3713 thickness = font->underline_thickness; 3732 thickness = font->underline_thickness;
3714 else 3733 else
3715 thickness = 1; 3734 thickness = 1;
3716 if (x_underline_at_descent_line) 3735 if (underline_at_descent_line)
3717 position = (s->height - thickness) - (s->ybase - s->y); 3736 position = (s->height - thickness) - (s->ybase - s->y);
3718 else 3737 else
3719 { 3738 {
3720 /* Get the underline position. This is the recommended 3739 /* Get the underline position. This is the
3721 vertical offset in pixels from the baseline to the top of 3740 recommended vertical offset in pixels from
3722 the underline. This is a signed value according to the 3741 the baseline to the top of the underline.
3742 This is a signed value according to the
3723 specs, and its default is 3743 specs, and its default is
3724 3744
3725 ROUND ((maximum descent) / 2), with 3745 ROUND ((maximum descent) / 2), with
3726 ROUND(x) = floor (x + 0.5) */ 3746 ROUND(x) = floor (x + 0.5) */
3727 3747
3728 if (x_use_underline_position_properties 3748 if (use_underline_position_properties
3729 && font && font->underline_position >= 0) 3749 && font && font->underline_position >= 0)
3730 position = font->underline_position; 3750 position = font->underline_position;
3731 else if (font) 3751 else if (font)
3732 position = (font->descent + 1) / 2; 3752 position = (font->descent + 1) / 2;
3733 else 3753 else
3734 position = underline_minimum_offset; 3754 position = minimum_offset;
3735 } 3755 }
3736 position = max (position, underline_minimum_offset); 3756 position = max (position, minimum_offset);
3737 } 3757 }
3738 /* Check the sanity of thickness and position. We should 3758 /* Check the sanity of thickness and position. We should
3739 avoid drawing underline out of the current line area. */ 3759 avoid drawing underline out of the current line area. */
@@ -13246,6 +13266,8 @@ UNDERLINE_POSITION font properties, set this to nil. You can also use
13246`underline-minimum-offset' to override the font's UNDERLINE_POSITION for 13266`underline-minimum-offset' to override the font's UNDERLINE_POSITION for
13247small font display sizes. */); 13267small font display sizes. */);
13248 x_use_underline_position_properties = true; 13268 x_use_underline_position_properties = true;
13269 DEFSYM (Qx_use_underline_position_properties,
13270 "x-use-underline-position-properties");
13249 13271
13250 DEFVAR_BOOL ("x-underline-at-descent-line", 13272 DEFVAR_BOOL ("x-underline-at-descent-line",
13251 x_underline_at_descent_line, 13273 x_underline_at_descent_line,
@@ -13256,6 +13278,7 @@ A value of nil means to draw the underline according to the value of the
13256variable `x-use-underline-position-properties', which is usually at the 13278variable `x-use-underline-position-properties', which is usually at the
13257baseline level. The default value is nil. */); 13279baseline level. The default value is nil. */);
13258 x_underline_at_descent_line = false; 13280 x_underline_at_descent_line = false;
13281 DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
13259 13282
13260 DEFVAR_BOOL ("x-mouse-click-focus-ignore-position", 13283 DEFVAR_BOOL ("x-mouse-click-focus-ignore-position",
13261 x_mouse_click_focus_ignore_position, 13284 x_mouse_click_focus_ignore_position,