diff options
author | Miles Bader <miles@gnu.org> | 2007-11-09 09:45:30 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2007-11-09 09:45:30 +0000 |
commit | 0c21a7199feb4054e47b5628ad9f0149c30b7173 (patch) | |
tree | 089f4142507efe5e79999f78247f3b744c4208a4 /src/xfaces.c | |
parent | 6cdc40891134a954b34a9434ac8f308ee80e17ea (diff) | |
parent | e80aafce5f445c45069bddff3c3f33df76993ec8 (diff) | |
download | emacs-0c21a7199feb4054e47b5628ad9f0149c30b7173.tar.gz |
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-923
Diffstat (limited to 'src/xfaces.c')
-rw-r--r-- | src/xfaces.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index 5e396d8bf6e..36bbacb84ce 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -7732,6 +7732,85 @@ face_at_buffer_position (w, pos, region_beg, region_end, return lookup_face (f, attrs, 0, NULL); } +/* Return the face ID at buffer position POS for displaying ASCII + characters associated with overlay strings for overlay OVERLAY. + + Like face_at_buffer_position except for OVERLAY. Currently it + simply disregards the `face' properties of all overlays. */ + +int +face_for_overlay_string (w, pos, region_beg, region_end, + endptr, limit, mouse, overlay) + struct window *w; + int pos; + int region_beg, region_end; + int *endptr; + int limit; + int mouse; + Lisp_Object overlay; +{ + struct frame *f = XFRAME (w->frame); + Lisp_Object attrs[LFACE_VECTOR_SIZE]; + Lisp_Object prop, position; + int i, noverlays; + Lisp_Object *overlay_vec; + Lisp_Object frame; + int endpos; + Lisp_Object propname = mouse ? Qmouse_face : Qface; + Lisp_Object limit1, end; + struct face *default_face; + + /* W must display the current buffer. We could write this function + to use the frame and buffer of W, but right now it doesn't. */ + /* xassert (XBUFFER (w->buffer) == current_buffer); */ + + XSETFRAME (frame, f); + XSETFASTINT (position, pos); + + endpos = ZV; + if (pos < region_beg && region_beg < endpos) + endpos = region_beg; + + /* Get the `face' or `mouse_face' text property at POS, and + determine the next position at which the property changes. */ + prop = Fget_text_property (position, propname, w->buffer); + XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); + end = Fnext_single_property_change (position, propname, w->buffer, limit1); + if (INTEGERP (end)) + endpos = XINT (end); + + *endptr = endpos; + + default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); + + /* Optimize common cases where we can use the default face. */ + if (NILP (prop) + && !(pos >= region_beg && pos < region_end)) + return DEFAULT_FACE_ID; + + /* Begin with attributes from the default face. */ + bcopy (default_face->lface, attrs, sizeof attrs); + + /* Merge in attributes specified via text properties. */ + if (!NILP (prop)) + merge_face_ref (f, prop, attrs, 1, 0); + + /* If in the region, merge in the region face. */ + if (pos >= region_beg && pos < region_end) + { + merge_named_face (f, Qregion, attrs, 0); + + if (region_end < endpos) + endpos = region_end; + } + + *endptr = endpos; + + /* Look up a realized face with the given face attributes, + or realize a new one for ASCII characters. */ + return lookup_face (f, attrs, 0, NULL); +} + /* Compute the face at character position POS in Lisp string STRING on window W, for ASCII characters. |