aboutsummaryrefslogtreecommitdiffstats
path: root/src/xfaces.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xfaces.c')
-rw-r--r--src/xfaces.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 50d733c7d0b..fd7dbb88133 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -8216,6 +8216,85 @@ face_at_buffer_position (w, pos, region_beg, region_end,
8216 return lookup_face (f, attrs); 8216 return lookup_face (f, attrs);
8217} 8217}
8218 8218
8219/* Return the face ID at buffer position POS for displaying ASCII
8220 characters associated with overlay strings for overlay OVERLAY.
8221
8222 Like face_at_buffer_position except for OVERLAY. Currently it
8223 simply disregards the `face' properties of all overlays. */
8224
8225int
8226face_for_overlay_string (w, pos, region_beg, region_end,
8227 endptr, limit, mouse, overlay)
8228 struct window *w;
8229 int pos;
8230 int region_beg, region_end;
8231 int *endptr;
8232 int limit;
8233 int mouse;
8234 Lisp_Object overlay;
8235{
8236 struct frame *f = XFRAME (w->frame);
8237 Lisp_Object attrs[LFACE_VECTOR_SIZE];
8238 Lisp_Object prop, position;
8239 int i, noverlays;
8240 Lisp_Object *overlay_vec;
8241 Lisp_Object frame;
8242 int endpos;
8243 Lisp_Object propname = mouse ? Qmouse_face : Qface;
8244 Lisp_Object limit1, end;
8245 struct face *default_face;
8246
8247 /* W must display the current buffer. We could write this function
8248 to use the frame and buffer of W, but right now it doesn't. */
8249 /* xassert (XBUFFER (w->buffer) == current_buffer); */
8250
8251 XSETFRAME (frame, f);
8252 XSETFASTINT (position, pos);
8253
8254 endpos = ZV;
8255 if (pos < region_beg && region_beg < endpos)
8256 endpos = region_beg;
8257
8258 /* Get the `face' or `mouse_face' text property at POS, and
8259 determine the next position at which the property changes. */
8260 prop = Fget_text_property (position, propname, w->buffer);
8261 XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
8262 end = Fnext_single_property_change (position, propname, w->buffer, limit1);
8263 if (INTEGERP (end))
8264 endpos = XINT (end);
8265
8266 *endptr = endpos;
8267
8268 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
8269
8270 /* Optimize common cases where we can use the default face. */
8271 if (NILP (prop)
8272 && !(pos >= region_beg && pos < region_end))
8273 return DEFAULT_FACE_ID;
8274
8275 /* Begin with attributes from the default face. */
8276 bcopy (default_face->lface, attrs, sizeof attrs);
8277
8278 /* Merge in attributes specified via text properties. */
8279 if (!NILP (prop))
8280 merge_face_ref (f, prop, attrs, 1, 0);
8281
8282 /* If in the region, merge in the region face. */
8283 if (pos >= region_beg && pos < region_end)
8284 {
8285 merge_named_face (f, Qregion, attrs, 0);
8286
8287 if (region_end < endpos)
8288 endpos = region_end;
8289 }
8290
8291 *endptr = endpos;
8292
8293 /* Look up a realized face with the given face attributes,
8294 or realize a new one for ASCII characters. */
8295 return lookup_face (f, attrs, 0, NULL);
8296}
8297
8219 8298
8220/* Compute the face at character position POS in Lisp string STRING on 8299/* Compute the face at character position POS in Lisp string STRING on
8221 window W, for ASCII characters. 8300 window W, for ASCII characters.