aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJimmy Aguilar Mena2019-08-28 11:47:50 +0200
committerJimmy Aguilar Mena2019-10-14 14:18:39 +0200
commitf9206f34d63104c50659a15d3615646a09df87bf (patch)
tree15f0161f62d0956c9a1f30cfb24a64110b2f9e32 /src
parenta122ca690798cf3cd8e2c65d373e45b5e6b30d4f (diff)
downloademacs-f9206f34d63104c50659a15d3615646a09df87bf.tar.gz
emacs-f9206f34d63104c50659a15d3615646a09df87bf.zip
Simplify struct face to use only underline.
* src/dispextern.h (enum face_underline_type): Add FACE_NO_UNDERLINE = 0. (struct face): Merge `underline_type` and `underline_p` into `underline`. Update all the occurrences in src/xdisp.c, src/xfaces.c, and src/xterm.c.
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h11
-rw-r--r--src/nsterm.m10
-rw-r--r--src/w32term.c12
-rw-r--r--src/xdisp.c2
-rw-r--r--src/xfaces.c28
-rw-r--r--src/xterm.c10
6 files changed, 34 insertions, 39 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index 7a15e2745b5..57400ae047a 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1607,6 +1607,7 @@ enum lface_attribute_index
1607 LFACE_INHERIT_INDEX, 1607 LFACE_INHERIT_INDEX,
1608 LFACE_FONTSET_INDEX, 1608 LFACE_FONTSET_INDEX,
1609 LFACE_DISTANT_FOREGROUND_INDEX, 1609 LFACE_DISTANT_FOREGROUND_INDEX,
1610 LFACE_EXTEND_INDEX,
1610 LFACE_VECTOR_SIZE 1611 LFACE_VECTOR_SIZE
1611}; 1612};
1612 1613
@@ -1632,6 +1633,7 @@ enum face_box_type
1632 1633
1633enum face_underline_type 1634enum face_underline_type
1634{ 1635{
1636 FACE_NO_UNDERLINE = 0,
1635 FACE_UNDER_LINE, 1637 FACE_UNDER_LINE,
1636 FACE_UNDER_WAVE 1638 FACE_UNDER_WAVE
1637}; 1639};
@@ -1706,7 +1708,7 @@ struct face
1706 ENUM_BF (face_box_type) box : 2; 1708 ENUM_BF (face_box_type) box : 2;
1707 1709
1708 /* Style of underlining. */ 1710 /* Style of underlining. */
1709 ENUM_BF (face_underline_type) underline_type : 1; 1711 ENUM_BF (face_underline_type) underline : 2;
1710 1712
1711 /* If `box' above specifies a 3D type, true means use box_color for 1713 /* If `box' above specifies a 3D type, true means use box_color for
1712 drawing shadows. */ 1714 drawing shadows. */
@@ -1714,7 +1716,6 @@ struct face
1714 1716
1715 /* Non-zero if text in this face should be underlined, overlined, 1717 /* Non-zero if text in this face should be underlined, overlined,
1716 strike-through or have a box drawn around it. */ 1718 strike-through or have a box drawn around it. */
1717 bool_bf underline_p : 1;
1718 bool_bf overline_p : 1; 1719 bool_bf overline_p : 1;
1719 bool_bf strike_through_p : 1; 1720 bool_bf strike_through_p : 1;
1720 1721
@@ -1724,14 +1725,10 @@ struct face
1724 bool_bf foreground_defaulted_p : 1; 1725 bool_bf foreground_defaulted_p : 1;
1725 bool_bf background_defaulted_p : 1; 1726 bool_bf background_defaulted_p : 1;
1726 1727
1727 /* True means that either no color is specified for underlining or that
1728 the specified color couldn't be loaded. Use the foreground
1729 color when drawing in that case. */
1730 bool_bf underline_defaulted_p : 1;
1731
1732 /* True means that either no color is specified for the corresponding 1728 /* True means that either no color is specified for the corresponding
1733 attribute or that the specified color couldn't be loaded. 1729 attribute or that the specified color couldn't be loaded.
1734 Use the foreground color when drawing in that case. */ 1730 Use the foreground color when drawing in that case. */
1731 bool_bf underline_defaulted_p : 1;
1735 bool_bf overline_color_defaulted_p : 1; 1732 bool_bf overline_color_defaulted_p : 1;
1736 bool_bf strike_through_color_defaulted_p : 1; 1733 bool_bf strike_through_color_defaulted_p : 1;
1737 bool_bf box_color_defaulted_p : 1; 1734 bool_bf box_color_defaulted_p : 1;
diff --git a/src/nsterm.m b/src/nsterm.m
index c8094d0ee37..5583c6105cb 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3404,9 +3404,9 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face,
3404 return; 3404 return;
3405 3405
3406 /* Do underline. */ 3406 /* Do underline. */
3407 if (face->underline_p) 3407 if (face->underline)
3408 { 3408 {
3409 if (s->face->underline_type == FACE_UNDER_WAVE) 3409 if (s->face->underline == FACE_UNDER_WAVE)
3410 { 3410 {
3411 if (face->underline_defaulted_p) 3411 if (face->underline_defaulted_p)
3412 [defaultCol set]; 3412 [defaultCol set];
@@ -3415,15 +3415,15 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face,
3415 3415
3416 ns_draw_underwave (s, width, x); 3416 ns_draw_underwave (s, width, x);
3417 } 3417 }
3418 else if (s->face->underline_type == FACE_UNDER_LINE) 3418 else if (s->face->underline == FACE_UNDER_LINE)
3419 { 3419 {
3420 3420
3421 NSRect r; 3421 NSRect r;
3422 unsigned long thickness, position; 3422 unsigned long thickness, position;
3423 3423
3424 /* If the prev was underlined, match its appearance. */ 3424 /* If the prev was underlined, match its appearance. */
3425 if (s->prev && s->prev->face->underline_p 3425 if (s->prev
3426 && s->prev->face->underline_type == FACE_UNDER_LINE 3426 && s->prev->face->underline == FACE_UNDER_LINE
3427 && s->prev->underline_thickness > 0) 3427 && s->prev->underline_thickness > 0)
3428 { 3428 {
3429 thickness = s->prev->underline_thickness; 3429 thickness = s->prev->underline_thickness;
diff --git a/src/w32term.c b/src/w32term.c
index 82256db1721..9da0845836a 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -2481,9 +2481,9 @@ w32_draw_glyph_string (struct glyph_string *s)
2481 if (!s->for_overlaps) 2481 if (!s->for_overlaps)
2482 { 2482 {
2483 /* Draw underline. */ 2483 /* Draw underline. */
2484 if (s->face->underline_p) 2484 if (s->face->underline)
2485 { 2485 {
2486 if (s->face->underline_type == FACE_UNDER_WAVE) 2486 if (s->face->underline == FACE_UNDER_WAVE)
2487 { 2487 {
2488 COLORREF color; 2488 COLORREF color;
2489 2489
@@ -2494,13 +2494,13 @@ w32_draw_glyph_string (struct glyph_string *s)
2494 2494
2495 w32_draw_underwave (s, color); 2495 w32_draw_underwave (s, color);
2496 } 2496 }
2497 else if (s->face->underline_type == FACE_UNDER_LINE) 2497 else if (s->face->underline == FACE_UNDER_LINE)
2498 { 2498 {
2499 unsigned long thickness, position; 2499 unsigned long thickness, position;
2500 int y; 2500 int y;
2501 2501
2502 if (s->prev && s->prev->face->underline_p 2502 if (s->prev
2503 && s->prev->face->underline_type == FACE_UNDER_LINE) 2503 && s->prev->face->underline == FACE_UNDER_LINE)
2504 { 2504 {
2505 /* We use the same underline style as the previous one. */ 2505 /* We use the same underline style as the previous one. */
2506 thickness = s->prev->underline_thickness; 2506 thickness = s->prev->underline_thickness;
@@ -2514,7 +2514,7 @@ w32_draw_glyph_string (struct glyph_string *s)
2514 BOOL use_underline_position_properties; 2514 BOOL use_underline_position_properties;
2515 Lisp_Object val 2515 Lisp_Object val
2516 = buffer_local_value (Qunderline_minimum_offset, 2516 = buffer_local_value (Qunderline_minimum_offset,
2517 s->w->contents); 2517 s->w->contents);
2518 if (FIXNUMP (val)) 2518 if (FIXNUMP (val))
2519 minimum_offset = max (0, XFIXNUM (val)); 2519 minimum_offset = max (0, XFIXNUM (val));
2520 else 2520 else
diff --git a/src/xdisp.c b/src/xdisp.c
index 1cfd7ef7601..38a2ff66c5b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -28502,7 +28502,7 @@ font_for_underline_metrics (struct glyph_string *s)
28502 for (g = s->first_glyph - 1; g >= g0; g--) 28502 for (g = s->first_glyph - 1; g >= g0; g--)
28503 { 28503 {
28504 struct face *prev_face = FACE_FROM_ID (s->f, g->face_id); 28504 struct face *prev_face = FACE_FROM_ID (s->f, g->face_id);
28505 if (!(prev_face && prev_face->underline_p)) 28505 if (!(prev_face && prev_face->underline != FACE_NO_UNDERLINE))
28506 break; 28506 break;
28507 } 28507 }
28508 28508
diff --git a/src/xfaces.c b/src/xfaces.c
index 0c99eea1567..c7d6990f505 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1209,7 +1209,7 @@ free_face_colors (struct frame *f, struct face *face)
1209 IF_DEBUG (--ncolors_allocated); 1209 IF_DEBUG (--ncolors_allocated);
1210 } 1210 }
1211 1211
1212 if (face->underline_p 1212 if (face->underline
1213 && !face->underline_defaulted_p) 1213 && !face->underline_defaulted_p)
1214 { 1214 {
1215 x_free_colors (f, &face->underline_color, 1); 1215 x_free_colors (f, &face->underline_color, 1);
@@ -5698,16 +5698,14 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
5698 if (EQ (underline, Qt)) 5698 if (EQ (underline, Qt))
5699 { 5699 {
5700 /* Use default color (same as foreground color). */ 5700 /* Use default color (same as foreground color). */
5701 face->underline_p = true; 5701 face->underline = FACE_UNDER_LINE;
5702 face->underline_type = FACE_UNDER_LINE;
5703 face->underline_defaulted_p = true; 5702 face->underline_defaulted_p = true;
5704 face->underline_color = 0; 5703 face->underline_color = 0;
5705 } 5704 }
5706 else if (STRINGP (underline)) 5705 else if (STRINGP (underline))
5707 { 5706 {
5708 /* Use specified color. */ 5707 /* Use specified color. */
5709 face->underline_p = true; 5708 face->underline = FACE_UNDER_LINE;
5710 face->underline_type = FACE_UNDER_LINE;
5711 face->underline_defaulted_p = false; 5709 face->underline_defaulted_p = false;
5712 face->underline_color 5710 face->underline_color
5713 = load_color (f, face, underline, 5711 = load_color (f, face, underline,
@@ -5715,7 +5713,7 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
5715 } 5713 }
5716 else if (NILP (underline)) 5714 else if (NILP (underline))
5717 { 5715 {
5718 face->underline_p = false; 5716 face->underline = FACE_NO_UNDERLINE;
5719 face->underline_defaulted_p = false; 5717 face->underline_defaulted_p = false;
5720 face->underline_color = 0; 5718 face->underline_color = 0;
5721 } 5719 }
@@ -5723,10 +5721,9 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
5723 { 5721 {
5724 /* `(:color COLOR :style STYLE)'. 5722 /* `(:color COLOR :style STYLE)'.
5725 STYLE being one of `line' or `wave'. */ 5723 STYLE being one of `line' or `wave'. */
5726 face->underline_p = true; 5724 face->underline = FACE_UNDER_LINE;
5727 face->underline_color = 0; 5725 face->underline_color = 0;
5728 face->underline_defaulted_p = true; 5726 face->underline_defaulted_p = true;
5729 face->underline_type = FACE_UNDER_LINE;
5730 5727
5731 /* FIXME? This is also not robust about checking the precise form. 5728 /* FIXME? This is also not robust about checking the precise form.
5732 See comments in Finternal_set_lisp_face_attribute. */ 5729 See comments in Finternal_set_lisp_face_attribute. */
@@ -5759,9 +5756,9 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
5759 else if (EQ (keyword, QCstyle)) 5756 else if (EQ (keyword, QCstyle))
5760 { 5757 {
5761 if (EQ (value, Qline)) 5758 if (EQ (value, Qline))
5762 face->underline_type = FACE_UNDER_LINE; 5759 face->underline = FACE_UNDER_LINE;
5763 else if (EQ (value, Qwave)) 5760 else if (EQ (value, Qwave))
5764 face->underline_type = FACE_UNDER_WAVE; 5761 face->underline = FACE_UNDER_WAVE;
5765 } 5762 }
5766 } 5763 }
5767 } 5764 }
@@ -6296,9 +6293,8 @@ merge_faces (struct window *w, Lisp_Object face_name, int face_id,
6296{ 6293{
6297 struct frame *f = WINDOW_XFRAME (w); 6294 struct frame *f = WINDOW_XFRAME (w);
6298 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 6295 Lisp_Object attrs[LFACE_VECTOR_SIZE];
6299 struct face *base_face; 6296 struct face *base_face = FACE_FROM_ID_OR_NULL (f, base_face_id);
6300 6297
6301 base_face = FACE_FROM_ID_OR_NULL (f, base_face_id);
6302 if (!base_face) 6298 if (!base_face)
6303 return base_face_id; 6299 return base_face_id;
6304 6300
@@ -6323,12 +6319,14 @@ merge_faces (struct window *w, Lisp_Object face_name, int face_id,
6323 } 6319 }
6324 else 6320 else
6325 { 6321 {
6326 struct face *face;
6327 if (face_id < 0) 6322 if (face_id < 0)
6328 return base_face_id; 6323 return base_face_id;
6329 face = FACE_FROM_ID_OR_NULL (f, face_id); 6324
6325 struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
6326
6330 if (!face) 6327 if (!face)
6331 return base_face_id; 6328 return base_face_id;
6329
6332 merge_face_vectors (w, f, face->lface, attrs, 0); 6330 merge_face_vectors (w, f, face->lface, attrs, 0);
6333 } 6331 }
6334 6332
@@ -6416,7 +6414,7 @@ dump_realized_face (struct face *face)
6416#endif 6414#endif
6417 fprintf (stderr, "fontset: %d\n", face->fontset); 6415 fprintf (stderr, "fontset: %d\n", face->fontset);
6418 fprintf (stderr, "underline: %d (%s)\n", 6416 fprintf (stderr, "underline: %d (%s)\n",
6419 face->underline_p, 6417 face->underline,
6420 SDATA (Fsymbol_name (face->lface[LFACE_UNDERLINE_INDEX]))); 6418 SDATA (Fsymbol_name (face->lface[LFACE_UNDERLINE_INDEX])));
6421 fprintf (stderr, "hash: %" PRIuPTR "\n", face->hash); 6419 fprintf (stderr, "hash: %" PRIuPTR "\n", face->hash);
6422} 6420}
diff --git a/src/xterm.c b/src/xterm.c
index b49c9d6893a..5d8b1482a6d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3813,9 +3813,9 @@ x_draw_glyph_string (struct glyph_string *s)
3813 if (!s->for_overlaps) 3813 if (!s->for_overlaps)
3814 { 3814 {
3815 /* Draw underline. */ 3815 /* Draw underline. */
3816 if (s->face->underline_p) 3816 if (s->face->underline)
3817 { 3817 {
3818 if (s->face->underline_type == FACE_UNDER_WAVE) 3818 if (s->face->underline == FACE_UNDER_WAVE)
3819 { 3819 {
3820 if (s->face->underline_defaulted_p) 3820 if (s->face->underline_defaulted_p)
3821 x_draw_underwave (s); 3821 x_draw_underwave (s);
@@ -3829,13 +3829,13 @@ x_draw_glyph_string (struct glyph_string *s)
3829 XSetForeground (display, s->gc, xgcv.foreground); 3829 XSetForeground (display, s->gc, xgcv.foreground);
3830 } 3830 }
3831 } 3831 }
3832 else if (s->face->underline_type == FACE_UNDER_LINE) 3832 else if (s->face->underline == FACE_UNDER_LINE)
3833 { 3833 {
3834 unsigned long thickness, position; 3834 unsigned long thickness, position;
3835 int y; 3835 int y;
3836 3836
3837 if (s->prev && s->prev->face->underline_p 3837 if (s->prev &&
3838 && s->prev->face->underline_type == FACE_UNDER_LINE) 3838 s->prev->face->underline == FACE_UNDER_LINE)
3839 { 3839 {
3840 /* We use the same underline style as the previous one. */ 3840 /* We use the same underline style as the previous one. */
3841 thickness = s->prev->underline_thickness; 3841 thickness = s->prev->underline_thickness;