Commit 7f278818 authored by Jimmy Aguilar Mena's avatar Jimmy Aguilar Mena

Conditional merged face to extend after eol.

The face used in extend_face_to_end_of_line is not the same than in
the text before anymore.
The display engine uses the :extend parameter in the faces to
conditionally merge and create a new id if needed.
parent bc703078
Pipeline #3078 failed with stage
in 65 minutes and 23 seconds
......@@ -3459,8 +3459,8 @@ int lookup_derived_face (struct window *, struct frame *,
void init_frame_faces (struct frame *);
void free_frame_faces (struct frame *);
void recompute_basic_faces (struct frame *);
int face_at_buffer_position (struct window *, ptrdiff_t, ptrdiff_t *, ptrdiff_t,
bool, int);
int face_at_buffer_position (struct window *, ptrdiff_t, ptrdiff_t *,
ptrdiff_t, bool, int, enum lface_attribute_index);
int face_for_overlay_string (struct window *, ptrdiff_t, ptrdiff_t *, ptrdiff_t,
bool, Lisp_Object);
int face_at_string_position (struct window *, Lisp_Object, ptrdiff_t, ptrdiff_t,
......
......@@ -3781,10 +3781,10 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
if (STRINGP (string))
face_id = face_at_string_position (w, string, pos, 0, &endptr,
DEFAULT_FACE_ID, false);
DEFAULT_FACE_ID, 0);
else
face_id = face_at_buffer_position (w, pos, &endptr,
pos + 100, false, -1);
pos + 100, false, -1, 0);
face = FACE_FROM_ID (f, face_id);
}
if (multibyte)
......@@ -3828,7 +3828,7 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
if (NILP (string))
face_id = face_at_buffer_position (w, pos, &ignore, *limit,
false, -1);
false, -1, 0);
else
{
face_id =
......@@ -4614,7 +4614,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
w = XWINDOW (window);
f = XFRAME (w->frame);
face_id = face_at_buffer_position (w, pos, &dummy,
pos + 100, false, -1);
pos + 100, false, -1, 0);
}
if (! CHAR_VALID_P (c))
return Qnil;
......
This diff is collapsed.
......@@ -347,7 +347,8 @@ static struct face_cache *make_face_cache (struct frame *);
static void free_face_cache (struct face_cache *);
static bool merge_face_ref (struct window *w,
struct frame *, Lisp_Object, Lisp_Object *,
bool, struct named_merge_point *);
bool, struct named_merge_point *,
enum lface_attribute_index);
static int color_distance (Emacs_Color *x, Emacs_Color *y);
#ifdef HAVE_WINDOW_SYSTEM
......@@ -1910,7 +1911,8 @@ get_lface_attributes (struct window *w,
attrs[i] = Qunspecified;
return merge_face_ref (w, f, XCDR (face_remapping), attrs,
signal_p, named_merge_points);
signal_p, named_merge_points,
0);
}
}
......@@ -2065,7 +2067,8 @@ merge_face_vectors (struct window *w,
if (!UNSPECIFIEDP (from[LFACE_INHERIT_INDEX])
&& !NILP (from[LFACE_INHERIT_INDEX]))
merge_face_ref (w, f, from[LFACE_INHERIT_INDEX],
to, false, named_merge_points);
to, false, named_merge_points,
0);
if (FONT_SPEC_P (from[LFACE_FONT_INDEX]))
{
......@@ -2131,7 +2134,8 @@ merge_face_vectors (struct window *w,
static bool
merge_named_face (struct window *w,
struct frame *f, Lisp_Object face_name, Lisp_Object *to,
struct named_merge_point *named_merge_points)
struct named_merge_point *named_merge_points,
enum lface_attribute_index attr_filter)
{
struct named_merge_point named_merge_point;
......@@ -2141,9 +2145,13 @@ merge_named_face (struct window *w,
{
Lisp_Object from[LFACE_VECTOR_SIZE];
bool ok = get_lface_attributes (w, f, face_name, from, false,
named_merge_points);
named_merge_points);
if (ok)
eassert (attr_filter < LFACE_VECTOR_SIZE);
if (ok && (attr_filter == 0
|| (!NILP (from[attr_filter])
&& !UNSPECIFIEDP (from[attr_filter]))))
merge_face_vectors (w, f, from, to, named_merge_points);
return ok;
......@@ -2274,6 +2282,11 @@ filter_face_ref (Lisp_Object face_ref,
of ERR_MSGS). Use NAMED_MERGE_POINTS to detect loops in face
inheritance or list structure; it may be 0 for most callers.
attr_filter is the index of a parameter that conditions the merging
for named faces (case 1) to only the face_ref where
lface[merge_face_ref] is non-nil. To merge unconditionally set this
value to 0.
FACE_REF may be a single face specification or a list of such
specifications. Each face specification can be:
......@@ -2302,7 +2315,8 @@ filter_face_ref (Lisp_Object face_ref,
static bool
merge_face_ref (struct window *w,
struct frame *f, Lisp_Object face_ref, Lisp_Object *to,
bool err_msgs, struct named_merge_point *named_merge_points)
bool err_msgs, struct named_merge_point *named_merge_points,
enum lface_attribute_index attr_filter)
{
bool ok = true; /* Succeed without an error? */
Lisp_Object filtered_face_ref;
......@@ -2514,7 +2528,8 @@ merge_face_ref (struct window *w,
/* This is not really very useful; it's just like a
normal face reference. */
if (! merge_face_ref (w, f, value, to,
err_msgs, named_merge_points))
err_msgs, named_merge_points,
0))
err = true;
}
else if (EQ (keyword, QCextend))
......@@ -2544,16 +2559,19 @@ merge_face_ref (struct window *w,
Lisp_Object next = XCDR (face_ref);
if (! NILP (next))
ok = merge_face_ref (w, f, next, to, err_msgs, named_merge_points);
ok = merge_face_ref (w, f, next, to, err_msgs,
named_merge_points, 0);
if (! merge_face_ref (w, f, first, to, err_msgs, named_merge_points))
if (! merge_face_ref (w, f, first, to, err_msgs,
named_merge_points, 0))
ok = false;
}
}
else
{
/* FACE_REF ought to be a face name. */
ok = merge_named_face (w, f, face_ref, to, named_merge_points);
ok = merge_named_face (w, f, face_ref, to, named_merge_points,
attr_filter);
if (!ok && err_msgs)
add_to_log ("Invalid face reference: %s", face_ref);
}
......@@ -4534,7 +4552,8 @@ lookup_face (struct frame *f, Lisp_Object *attr)
suitable face is found, realize a new one. */
int
face_for_font (struct frame *f, Lisp_Object font_object, struct face *base_face)
face_for_font (struct frame *f, Lisp_Object font_object,
struct face *base_face)
{
struct face_cache *cache = FRAME_FACE_CACHE (f);
unsigned hash;
......@@ -4767,7 +4786,7 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector,
Lisp_Object lface = make_vector (LFACE_VECTOR_SIZE, Qunspecified);
merge_face_ref (NULL, XFRAME (selected_frame),
plist, XVECTOR (lface)->contents,
true, 0);
true, NULL, 0);
return lface;
}
......@@ -5124,7 +5143,7 @@ face for italic. */)
for (i = 0; i < LFACE_VECTOR_SIZE; i++)
attrs[i] = Qunspecified;
merge_face_ref (NULL, f, attributes, attrs, true, 0);
merge_face_ref (NULL, f, attributes, attrs, true, NULL, 0);
def_face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
if (def_face == NULL)
......@@ -6008,7 +6027,7 @@ compute_char_face (struct frame *f, int ch, Lisp_Object prop)
Lisp_Object attrs[LFACE_VECTOR_SIZE];
struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
memcpy (attrs, default_face->lface, sizeof attrs);
merge_face_ref (NULL, f, prop, attrs, true, 0);
merge_face_ref (NULL, f, prop, attrs, true, NULL, 0);
face_id = lookup_face (f, attrs);
}
......@@ -6020,6 +6039,8 @@ compute_char_face (struct frame *f, int ch, Lisp_Object prop)
which a different face is needed, as far as text properties and
overlays are concerned. W is a window displaying current_buffer.
attr_filter is passed merge_face_ref.
REGION_BEG, REGION_END delimit the region, so it can be
highlighted.
......@@ -6039,7 +6060,8 @@ compute_char_face (struct frame *f, int ch, Lisp_Object prop)
int
face_at_buffer_position (struct window *w, ptrdiff_t pos,
ptrdiff_t *endptr, ptrdiff_t limit,
bool mouse, int base_face_id)
bool mouse, int base_face_id,
enum lface_attribute_index attr_filter)
{
struct frame *f = XFRAME (w->frame);
Lisp_Object attrs[LFACE_VECTOR_SIZE];
......@@ -6100,8 +6122,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
}
/* Optimize common cases where we can use the default face. */
if (noverlays == 0
&& NILP (prop))
if (noverlays == 0 && NILP (prop))
{
SAFE_FREE ();
return default_face->id;
......@@ -6112,7 +6133,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
/* Merge in attributes specified via text properties. */
if (!NILP (prop))
merge_face_ref (w, f, prop, attrs, true, 0);
merge_face_ref (w, f, prop, attrs, true, NULL, 0);
/* Now merge the overlay data. */
noverlays = sort_overlays (overlay_vec, noverlays, w);
......@@ -6132,7 +6153,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
so discard the mouse-face text property, if any, and
use the overlay property instead. */
memcpy (attrs, default_face->lface, sizeof attrs);
merge_face_ref (w, f, prop, attrs, true, 0);
merge_face_ref (w, f, prop, attrs, true, NULL, attr_filter);
}
oend = OVERLAY_END (overlay_vec[i]);
......@@ -6149,8 +6170,9 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
ptrdiff_t oendpos;
prop = Foverlay_get (overlay_vec[i], propname);
if (!NILP (prop))
merge_face_ref (w, f, prop, attrs, true, 0);
merge_face_ref (w, f, prop, attrs, true, NULL, attr_filter);
oend = OVERLAY_END (overlay_vec[i]);
oendpos = OVERLAY_POSITION (oend);
......@@ -6216,7 +6238,7 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
/* Merge in attributes specified via text properties. */
if (!NILP (prop))
merge_face_ref (w, f, prop, attrs, true, 0);
merge_face_ref (w, f, prop, attrs, true, NULL, 0);
*endptr = endpos;
......@@ -6251,7 +6273,7 @@ int
face_at_string_position (struct window *w, Lisp_Object string,
ptrdiff_t pos, ptrdiff_t bufpos,
ptrdiff_t *endptr, enum face_id base_face_id,
bool mouse_p)
bool mouse_p)
{
Lisp_Object prop, position, end, limit;
struct frame *f = XFRAME (WINDOW_FRAME (w));
......@@ -6295,7 +6317,7 @@ face_at_string_position (struct window *w, Lisp_Object string,
/* Merge in attributes specified via text properties. */
if (!NILP (prop))
merge_face_ref (w, f, prop, attrs, true, 0);
merge_face_ref (w, f, prop, attrs, true, NULL, 0);
/* Look up a realized face with the given face attributes,
or realize a new one for ASCII characters. */
......@@ -6345,7 +6367,7 @@ merge_faces (struct window *w, Lisp_Object face_name, int face_id,
if (!NILP (face_name))
{
if (!merge_named_face (w, f, face_name, attrs, 0))
if (!merge_named_face (w, f, face_name, attrs, NULL, 0))
return base_face_id;
}
else
......
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