aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2006-08-24 20:52:00 +0000
committerKim F. Storm2006-08-24 20:52:00 +0000
commit30f27523567516a324d042e10bde5dd14d7da90f (patch)
treef605b0d4a7b6d5701e8081abcd2bd26b0952896b /src
parentdaa0e79b0a84b14d29a033d5e005ea186e5b1d6a (diff)
downloademacs-30f27523567516a324d042e10bde5dd14d7da90f.tar.gz
emacs-30f27523567516a324d042e10bde5dd14d7da90f.zip
(x_underline_at_descent_line): New variable.
(syms_of_xterm): DEFVAR_BOOL it. (x_draw_glyph_string): Use it. Draw underline and overline up to the end of line if the face extends to the end of line.
Diffstat (limited to 'src')
-rw-r--r--src/macterm.c8
-rw-r--r--src/w32term.c36
-rw-r--r--src/xterm.c51
3 files changed, 64 insertions, 31 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 97e3b743469..04b55d9fa80 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -3679,14 +3679,14 @@ x_draw_glyph_string (s)
3679 3679
3680 if (s->face->underline_defaulted_p) 3680 if (s->face->underline_defaulted_p)
3681 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3681 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3682 s->width, h); 3682 s->background_width, h);
3683 else 3683 else
3684 { 3684 {
3685 XGCValues xgcv; 3685 XGCValues xgcv;
3686 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3686 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3687 XSetForeground (s->display, s->gc, s->face->underline_color); 3687 XSetForeground (s->display, s->gc, s->face->underline_color);
3688 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3688 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3689 s->width, h); 3689 s->background_width, h);
3690 XSetForeground (s->display, s->gc, xgcv.foreground); 3690 XSetForeground (s->display, s->gc, xgcv.foreground);
3691 } 3691 }
3692 } 3692 }
@@ -3698,14 +3698,14 @@ x_draw_glyph_string (s)
3698 3698
3699 if (s->face->overline_color_defaulted_p) 3699 if (s->face->overline_color_defaulted_p)
3700 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3700 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3701 s->width, h); 3701 s->background_width, h);
3702 else 3702 else
3703 { 3703 {
3704 XGCValues xgcv; 3704 XGCValues xgcv;
3705 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3705 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3706 XSetForeground (s->display, s->gc, s->face->overline_color); 3706 XSetForeground (s->display, s->gc, s->face->overline_color);
3707 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 3707 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3708 s->width, h); 3708 s->background_width, h);
3709 XSetForeground (s->display, s->gc, xgcv.foreground); 3709 XSetForeground (s->display, s->gc, xgcv.foreground);
3710 } 3710 }
3711 } 3711 }
diff --git a/src/w32term.c b/src/w32term.c
index 5e33c3af7b9..93a697bbd8c 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -91,6 +91,10 @@ static Lisp_Object last_window;
91 (Not yet supported, see TODO in x_draw_glyph_string.) */ 91 (Not yet supported, see TODO in x_draw_glyph_string.) */
92int x_use_underline_position_properties; 92int x_use_underline_position_properties;
93 93
94/* Non-zero means to draw the underline at the same place as the descent line. */
95
96int x_underline_at_descent_line;
97
94extern unsigned int msh_mousewheel; 98extern unsigned int msh_mousewheel;
95 99
96extern void free_frame_menubar (); 100extern void free_frame_menubar ();
@@ -2509,21 +2513,27 @@ x_draw_glyph_string (s)
2509 && (s->font->bdf || !s->font->tm.tmUnderlined)) 2513 && (s->font->bdf || !s->font->tm.tmUnderlined))
2510 { 2514 {
2511 unsigned long h = 1; 2515 unsigned long h = 1;
2512 unsigned long dy = s->height - h; 2516 unsigned long dy = 0;
2513 2517
2514 /* TODO: Use font information for positioning and thickness 2518 if (x_underline_at_descent_line)
2515 of underline. See OUTLINETEXTMETRIC, and xterm.c. 2519 dy = s->height - h;
2516 Note: If you make this work, don't forget to change the 2520 else
2517 doc string of x-use-underline-position-properties below. */ 2521 {
2522 /* TODO: Use font information for positioning and thickness of
2523 underline. See OUTLINETEXTMETRIC, and xterm.c. Note: If
2524 you make this work, don't forget to change the doc string of
2525 x-use-underline-position-properties below. */
2526 dy = s->height - h;
2527 }
2518 if (s->face->underline_defaulted_p) 2528 if (s->face->underline_defaulted_p)
2519 { 2529 {
2520 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, 2530 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x,
2521 s->y + dy, s->width, 1); 2531 s->y + dy, s->background_width, 1);
2522 } 2532 }
2523 else 2533 else
2524 { 2534 {
2525 w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x, 2535 w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x,
2526 s->y + dy, s->width, 1); 2536 s->y + dy, s->background_width, 1);
2527 } 2537 }
2528 } 2538 }
2529 2539
@@ -2535,12 +2545,12 @@ x_draw_glyph_string (s)
2535 if (s->face->overline_color_defaulted_p) 2545 if (s->face->overline_color_defaulted_p)
2536 { 2546 {
2537 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, 2547 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x,
2538 s->y + dy, s->width, h); 2548 s->y + dy, s->background_width, h);
2539 } 2549 }
2540 else 2550 else
2541 { 2551 {
2542 w32_fill_area (s->f, s->hdc, s->face->overline_color, s->x, 2552 w32_fill_area (s->f, s->hdc, s->face->overline_color, s->x,
2543 s->y + dy, s->width, h); 2553 s->y + dy, s->background_width, h);
2544 } 2554 }
2545 } 2555 }
2546 2556
@@ -6510,6 +6520,14 @@ to 4.1, set this to nil.
6510NOTE: Not supported on MS-Windows yet. */); 6520NOTE: Not supported on MS-Windows yet. */);
6511 x_use_underline_position_properties = 0; 6521 x_use_underline_position_properties = 0;
6512 6522
6523 DEFVAR_BOOL ("x-underline-at-descent-line",
6524 &x_underline_at_descent_line,
6525 doc: /* *Non-nil means to draw the underline at the same place as the descent line.
6526nil means to draw the underline according to the value of the variable
6527`x-use-underline-position-properties', which is usually at the baseline
6528level. The default value is nil. */);
6529 x_underline_at_descent_line = 0;
6530
6513 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 6531 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
6514 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 6532 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
6515 Vx_toolkit_scroll_bars = Qt; 6533 Vx_toolkit_scroll_bars = Qt;
diff --git a/src/xterm.c b/src/xterm.c
index 9cea615ca1e..c2cf2721881 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -182,6 +182,10 @@ static Lisp_Object last_window;
182 182
183int x_use_underline_position_properties; 183int x_use_underline_position_properties;
184 184
185/* Non-zero means to draw the underline at the same place as the descent line. */
186
187int x_underline_at_descent_line;
188
185/* This is a chain of structures for all the X displays currently in 189/* This is a chain of structures for all the X displays currently in
186 use. */ 190 use. */
187 191
@@ -2685,32 +2689,35 @@ x_draw_glyph_string (s)
2685 if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h)) 2689 if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h))
2686 h = 1; 2690 h = 1;
2687 2691
2688 /* Get the underline position. This is the recommended 2692 if (x_underline_at_descent_line)
2689 vertical offset in pixels from the baseline to the top of
2690 the underline. This is a signed value according to the
2691 specs, and its default is
2692
2693 ROUND ((maximum descent) / 2), with
2694 ROUND(x) = floor (x + 0.5) */
2695
2696 if (x_use_underline_position_properties
2697 && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
2698 y = s->ybase + (long) tem;
2699 else if (s->face->font)
2700 y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
2701 else
2702 y = s->y + s->height - h; 2693 y = s->y + s->height - h;
2694 else
2695 {
2696 /* Get the underline position. This is the recommended
2697 vertical offset in pixels from the baseline to the top of
2698 the underline. This is a signed value according to the
2699 specs, and its default is
2700
2701 ROUND ((maximum descent) / 2), with
2702 ROUND(x) = floor (x + 0.5) */
2703
2704 if (x_use_underline_position_properties
2705 && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
2706 y = s->ybase + (long) tem;
2707 else if (s->face->font)
2708 y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
2709 }
2703 2710
2704 if (s->face->underline_defaulted_p) 2711 if (s->face->underline_defaulted_p)
2705 XFillRectangle (s->display, s->window, s->gc, 2712 XFillRectangle (s->display, s->window, s->gc,
2706 s->x, y, s->width, h); 2713 s->x, y, s->background_width, h);
2707 else 2714 else
2708 { 2715 {
2709 XGCValues xgcv; 2716 XGCValues xgcv;
2710 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 2717 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
2711 XSetForeground (s->display, s->gc, s->face->underline_color); 2718 XSetForeground (s->display, s->gc, s->face->underline_color);
2712 XFillRectangle (s->display, s->window, s->gc, 2719 XFillRectangle (s->display, s->window, s->gc,
2713 s->x, y, s->width, h); 2720 s->x, y, s->background_width, h);
2714 XSetForeground (s->display, s->gc, xgcv.foreground); 2721 XSetForeground (s->display, s->gc, xgcv.foreground);
2715 } 2722 }
2716 } 2723 }
@@ -2722,14 +2729,14 @@ x_draw_glyph_string (s)
2722 2729
2723 if (s->face->overline_color_defaulted_p) 2730 if (s->face->overline_color_defaulted_p)
2724 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 2731 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
2725 s->width, h); 2732 s->background_width, h);
2726 else 2733 else
2727 { 2734 {
2728 XGCValues xgcv; 2735 XGCValues xgcv;
2729 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 2736 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
2730 XSetForeground (s->display, s->gc, s->face->overline_color); 2737 XSetForeground (s->display, s->gc, s->face->overline_color);
2731 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 2738 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
2732 s->width, h); 2739 s->background_width, h);
2733 XSetForeground (s->display, s->gc, xgcv.foreground); 2740 XSetForeground (s->display, s->gc, xgcv.foreground);
2734 } 2741 }
2735 } 2742 }
@@ -10979,6 +10986,14 @@ UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
10979to 4.1, set this to nil. */); 10986to 4.1, set this to nil. */);
10980 x_use_underline_position_properties = 1; 10987 x_use_underline_position_properties = 1;
10981 10988
10989 DEFVAR_BOOL ("x-underline-at-descent-line",
10990 &x_underline_at_descent_line,
10991 doc: /* *Non-nil means to draw the underline at the same place as the descent line.
10992nil means to draw the underline according to the value of the variable
10993`x-use-underline-position-properties', which is usually at the baseline
10994level. The default value is nil. */);
10995 x_underline_at_descent_line = 0;
10996
10982 DEFVAR_BOOL ("x-mouse-click-focus-ignore-position", 10997 DEFVAR_BOOL ("x-mouse-click-focus-ignore-position",
10983 &x_mouse_click_focus_ignore_position, 10998 &x_mouse_click_focus_ignore_position,
10984 doc: /* Non-nil means that a mouse click to focus a frame does not move point. 10999 doc: /* Non-nil means that a mouse click to focus a frame does not move point.