Mercurial > emacs
comparison src/xfaces.c @ 91085:880960b70474
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-283
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 11 Nov 2007 00:56:44 +0000 |
parents | a0e466c4d599 d3e87ee5aa0e |
children | 66f982c3b25e |
comparison
equal
deleted
inserted
replaced
91084:a4347a111894 | 91085:880960b70474 |
---|---|
8214 /* Look up a realized face with the given face attributes, | 8214 /* Look up a realized face with the given face attributes, |
8215 or realize a new one for ASCII characters. */ | 8215 or realize a new one for ASCII characters. */ |
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 | |
8225 int | |
8226 face_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. |
8222 | 8301 |
8223 If STRING is an overlay string, it comes from position BUFPOS in | 8302 If STRING is an overlay string, it comes from position BUFPOS in |