Commit 523aeb6c authored by Jimmy Aguilar Mena's avatar Jimmy Aguilar Mena

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.
parent 53ebec24
......@@ -1564,6 +1564,7 @@ enum lface_attribute_index
LFACE_INHERIT_INDEX,
LFACE_FONTSET_INDEX,
LFACE_DISTANT_FOREGROUND_INDEX,
LFACE_EXTEND_INDEX,
LFACE_VECTOR_SIZE
};
......@@ -1589,6 +1590,7 @@ enum face_box_type
enum face_underline_type
{
FACE_NO_UNDERLINE = 0,
FACE_UNDER_LINE,
FACE_UNDER_WAVE
};
......@@ -1663,7 +1665,7 @@ struct face
ENUM_BF (face_box_type) box : 2;
/* Style of underlining. */
ENUM_BF (face_underline_type) underline_type : 1;
ENUM_BF (face_underline_type) underline : 2;
/* If `box' above specifies a 3D type, true means use box_color for
drawing shadows. */
......@@ -1671,7 +1673,6 @@ struct face
/* Non-zero if text in this face should be underlined, overlined,
strike-through or have a box drawn around it. */
bool_bf underline_p : 1;
bool_bf overline_p : 1;
bool_bf strike_through_p : 1;
......@@ -1681,14 +1682,10 @@ struct face
bool_bf foreground_defaulted_p : 1;
bool_bf background_defaulted_p : 1;
/* True means that either no color is specified for underlining or that
the specified color couldn't be loaded. Use the foreground
color when drawing in that case. */
bool_bf underline_defaulted_p : 1;
/* True means that either no color is specified for the corresponding
attribute or that the specified color couldn't be loaded.
Use the foreground color when drawing in that case. */
bool_bf underline_defaulted_p : 1;
bool_bf overline_color_defaulted_p : 1;
bool_bf strike_through_color_defaulted_p : 1;
bool_bf box_color_defaulted_p : 1;
......
......@@ -3404,9 +3404,9 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
return;
/* Do underline. */
if (face->underline_p)
if (face->underline)
{
if (s->face->underline_type == FACE_UNDER_WAVE)
if (s->face->underline == FACE_UNDER_WAVE)
{
if (face->underline_defaulted_p)
[defaultCol set];
......@@ -3415,15 +3415,15 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
ns_draw_underwave (s, width, x);
}
else if (s->face->underline_type == FACE_UNDER_LINE)
else if (s->face->underline == FACE_UNDER_LINE)
{
NSRect r;
unsigned long thickness, position;
/* If the prev was underlined, match its appearance. */
if (s->prev && s->prev->face->underline_p
&& s->prev->face->underline_type == FACE_UNDER_LINE
if (s->prev
&& s->prev->face->underline == FACE_UNDER_LINE
&& s->prev->underline_thickness > 0)
{
thickness = s->prev->underline_thickness;
......
......@@ -2479,9 +2479,9 @@ w32_draw_glyph_string (struct glyph_string *s)
if (!s->for_overlaps)
{
/* Draw underline. */
if (s->face->underline_p)
if (s->face->underline)
{
if (s->face->underline_type == FACE_UNDER_WAVE)
if (s->face->underline == FACE_UNDER_WAVE)
{
COLORREF color;
......@@ -2492,13 +2492,13 @@ w32_draw_glyph_string (struct glyph_string *s)
w32_draw_underwave (s, color);
}
else if (s->face->underline_type == FACE_UNDER_LINE)
else if (s->face->underline == FACE_UNDER_LINE)
{
unsigned long thickness, position;
int y;
if (s->prev && s->prev->face->underline_p
&& s->prev->face->underline_type == FACE_UNDER_LINE)
if (s->prev
&& s->prev->face->underline == FACE_UNDER_LINE)
{
/* We use the same underline style as the previous one. */
thickness = s->prev->underline_thickness;
......@@ -2512,7 +2512,7 @@ w32_draw_glyph_string (struct glyph_string *s)
BOOL use_underline_position_properties;
Lisp_Object val
= buffer_local_value (Qunderline_minimum_offset,
s->w->contents);
s->w->contents);
if (FIXNUMP (val))
minimum_offset = max (0, XFIXNUM (val));
else
......
......@@ -27367,7 +27367,7 @@ font_for_underline_metrics (struct glyph_string *s)
for (g = s->first_glyph - 1; g >= g0; g--)
{
struct face *prev_face = FACE_FROM_ID (s->f, g->face_id);
if (!(prev_face && prev_face->underline_p))
if (!(prev_face && prev_face->underline != FACE_NO_UNDERLINE))
break;
}
......@@ -1209,7 +1209,7 @@ free_face_colors (struct frame *f, struct face *face)
IF_DEBUG (--ncolors_allocated);
}
if (face->underline_p
if (face->underline
&& !face->underline_defaulted_p)
{
x_free_colors (f, &face->underline_color, 1);
......@@ -5694,16 +5694,14 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
if (EQ (underline, Qt))
{
/* Use default color (same as foreground color). */
face->underline_p = true;
face->underline_type = FACE_UNDER_LINE;
face->underline = FACE_UNDER_LINE;
face->underline_defaulted_p = true;
face->underline_color = 0;
}
else if (STRINGP (underline))
{
/* Use specified color. */
face->underline_p = true;
face->underline_type = FACE_UNDER_LINE;
face->underline = FACE_UNDER_LINE;
face->underline_defaulted_p = false;
face->underline_color
= load_color (f, face, underline,
......@@ -5711,7 +5709,7 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
}
else if (NILP (underline))
{
face->underline_p = false;
face->underline = FACE_NO_UNDERLINE;
face->underline_defaulted_p = false;
face->underline_color = 0;
}
......@@ -5719,10 +5717,9 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
{
/* `(:color COLOR :style STYLE)'.
STYLE being one of `line' or `wave'. */
face->underline_p = true;
face->underline = FACE_UNDER_LINE;
face->underline_color = 0;
face->underline_defaulted_p = true;
face->underline_type = FACE_UNDER_LINE;
/* FIXME? This is also not robust about checking the precise form.
See comments in Finternal_set_lisp_face_attribute. */
......@@ -5755,9 +5752,9 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
else if (EQ (keyword, QCstyle))
{
if (EQ (value, Qline))
face->underline_type = FACE_UNDER_LINE;
face->underline = FACE_UNDER_LINE;
else if (EQ (value, Qwave))
face->underline_type = FACE_UNDER_WAVE;
face->underline = FACE_UNDER_WAVE;
}
}
}
......@@ -6292,9 +6289,8 @@ merge_faces (struct window *w, Lisp_Object face_name, int face_id,
{
struct frame *f = WINDOW_XFRAME (w);
Lisp_Object attrs[LFACE_VECTOR_SIZE];
struct face *base_face;
struct face *base_face = FACE_FROM_ID_OR_NULL (f, base_face_id);
base_face = FACE_FROM_ID_OR_NULL (f, base_face_id);
if (!base_face)
return base_face_id;
......@@ -6319,12 +6315,14 @@ merge_faces (struct window *w, Lisp_Object face_name, int face_id,
}
else
{
struct face *face;
if (face_id < 0)
return base_face_id;
face = FACE_FROM_ID_OR_NULL (f, face_id);
struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
if (!face)
return base_face_id;
merge_face_vectors (w, f, face->lface, attrs, 0);
}
......@@ -6412,7 +6410,7 @@ dump_realized_face (struct face *face)
#endif
fprintf (stderr, "fontset: %d\n", face->fontset);
fprintf (stderr, "underline: %d (%s)\n",
face->underline_p,
face->underline,
SDATA (Fsymbol_name (face->lface[LFACE_UNDERLINE_INDEX])));
fprintf (stderr, "hash: %" PRIuPTR "\n", face->hash);
}
......
......@@ -3798,9 +3798,9 @@ x_draw_glyph_string (struct glyph_string *s)
if (!s->for_overlaps)
{
/* Draw underline. */
if (s->face->underline_p)
if (s->face->underline)
{
if (s->face->underline_type == FACE_UNDER_WAVE)
if (s->face->underline == FACE_UNDER_WAVE)
{
if (s->face->underline_defaulted_p)
x_draw_underwave (s);
......@@ -3814,13 +3814,13 @@ x_draw_glyph_string (struct glyph_string *s)
XSetForeground (display, s->gc, xgcv.foreground);
}
}
else if (s->face->underline_type == FACE_UNDER_LINE)
else if (s->face->underline == FACE_UNDER_LINE)
{
unsigned long thickness, position;
int y;
if (s->prev && s->prev->face->underline_p
&& s->prev->face->underline_type == FACE_UNDER_LINE)
if (s->prev &&
s->prev->face->underline == FACE_UNDER_LINE)
{
/* We use the same underline style as the previous one. */
thickness = s->prev->underline_thickness;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment