comparison src/xfaces.c @ 79327:72cdd210604a

(face_at_buffer_position_no_overlays): New function.
author Richard M. Stallman <rms@gnu.org>
date Sat, 03 Nov 2007 03:46:22 +0000
parents 00edecc1d311
children 6c386e3cec2a
comparison
equal deleted inserted replaced
79326:467360fde5e5 79327:72cdd210604a
7704 /* Look up a realized face with the given face attributes, 7704 /* Look up a realized face with the given face attributes,
7705 or realize a new one for ASCII characters. */ 7705 or realize a new one for ASCII characters. */
7706 return lookup_face (f, attrs, 0, NULL); 7706 return lookup_face (f, attrs, 0, NULL);
7707 } 7707 }
7708 7708
7709 /* Return the face ID associated with buffer position POS for
7710 displaying ASCII characters, but without overlays.
7711 Like face_at_buffer_position except it ignores overlays. */
7712
7713 int
7714 face_at_buffer_position_no_overlays (w, pos, region_beg, region_end,
7715 endptr, limit, mouse)
7716 struct window *w;
7717 int pos;
7718 int region_beg, region_end;
7719 int *endptr;
7720 int limit;
7721 int mouse;
7722 {
7723 struct frame *f = XFRAME (w->frame);
7724 Lisp_Object attrs[LFACE_VECTOR_SIZE];
7725 Lisp_Object prop, position;
7726 int i, noverlays;
7727 Lisp_Object *overlay_vec;
7728 Lisp_Object frame;
7729 int endpos;
7730 Lisp_Object propname = mouse ? Qmouse_face : Qface;
7731 Lisp_Object limit1, end;
7732 struct face *default_face;
7733
7734 /* W must display the current buffer. We could write this function
7735 to use the frame and buffer of W, but right now it doesn't. */
7736 /* xassert (XBUFFER (w->buffer) == current_buffer); */
7737
7738 XSETFRAME (frame, f);
7739 XSETFASTINT (position, pos);
7740
7741 endpos = ZV;
7742 if (pos < region_beg && region_beg < endpos)
7743 endpos = region_beg;
7744
7745 /* Get the `face' or `mouse_face' text property at POS, and
7746 determine the next position at which the property changes. */
7747 prop = Fget_text_property (position, propname, w->buffer);
7748 XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
7749 end = Fnext_single_property_change (position, propname, w->buffer, limit1);
7750 if (INTEGERP (end))
7751 endpos = XINT (end);
7752
7753 *endptr = endpos;
7754
7755 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
7756
7757 /* Optimize common cases where we can use the default face. */
7758 if (NILP (prop)
7759 && !(pos >= region_beg && pos < region_end))
7760 return DEFAULT_FACE_ID;
7761
7762 /* Begin with attributes from the default face. */
7763 bcopy (default_face->lface, attrs, sizeof attrs);
7764
7765 /* Merge in attributes specified via text properties. */
7766 if (!NILP (prop))
7767 merge_face_ref (f, prop, attrs, 1, 0);
7768
7769 /* If in the region, merge in the region face. */
7770 if (pos >= region_beg && pos < region_end)
7771 {
7772 merge_named_face (f, Qregion, attrs, 0);
7773
7774 if (region_end < endpos)
7775 endpos = region_end;
7776 }
7777
7778 *endptr = endpos;
7779
7780 /* Look up a realized face with the given face attributes,
7781 or realize a new one for ASCII characters. */
7782 return lookup_face (f, attrs, 0, NULL);
7783 }
7784
7709 7785
7710 /* Compute the face at character position POS in Lisp string STRING on 7786 /* Compute the face at character position POS in Lisp string STRING on
7711 window W, for ASCII characters. 7787 window W, for ASCII characters.
7712 7788
7713 If STRING is an overlay string, it comes from position BUFPOS in 7789 If STRING is an overlay string, it comes from position BUFPOS in