aboutsummaryrefslogtreecommitdiffstats
path: root/src/xfaces.c
diff options
context:
space:
mode:
authorMiles Bader2007-11-09 09:45:30 +0000
committerMiles Bader2007-11-09 09:45:30 +0000
commitc12ecb0af9679cc0e2fa0409931c34c035763469 (patch)
treebd118c7ebc571de0dab542f48ad0c1648c6ccf72 /src/xfaces.c
parente83d1fe87564d06d2fcbb4006dfd9133bc340aa8 (diff)
parent9d2185d10e3da9062672d96d3b59fcea31ff17ed (diff)
downloademacs-c12ecb0af9679cc0e2fa0409931c34c035763469.tar.gz
emacs-c12ecb0af9679cc0e2fa0409931c34c035763469.zip
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.c79
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,
7732 return lookup_face (f, attrs, 0, NULL); 7732 return lookup_face (f, attrs, 0, NULL);
7733} 7733}
7734 7734
7735/* Return the face ID at buffer position POS for displaying ASCII
7736 characters associated with overlay strings for overlay OVERLAY.
7737
7738 Like face_at_buffer_position except for OVERLAY. Currently it
7739 simply disregards the `face' properties of all overlays. */
7740
7741int
7742face_for_overlay_string (w, pos, region_beg, region_end,
7743 endptr, limit, mouse, overlay)
7744 struct window *w;
7745 int pos;
7746 int region_beg, region_end;
7747 int *endptr;
7748 int limit;
7749 int mouse;
7750 Lisp_Object overlay;
7751{
7752 struct frame *f = XFRAME (w->frame);
7753 Lisp_Object attrs[LFACE_VECTOR_SIZE];
7754 Lisp_Object prop, position;
7755 int i, noverlays;
7756 Lisp_Object *overlay_vec;
7757 Lisp_Object frame;
7758 int endpos;
7759 Lisp_Object propname = mouse ? Qmouse_face : Qface;
7760 Lisp_Object limit1, end;
7761 struct face *default_face;
7762
7763 /* W must display the current buffer. We could write this function
7764 to use the frame and buffer of W, but right now it doesn't. */
7765 /* xassert (XBUFFER (w->buffer) == current_buffer); */
7766
7767 XSETFRAME (frame, f);
7768 XSETFASTINT (position, pos);
7769
7770 endpos = ZV;
7771 if (pos < region_beg && region_beg < endpos)
7772 endpos = region_beg;
7773
7774 /* Get the `face' or `mouse_face' text property at POS, and
7775 determine the next position at which the property changes. */
7776 prop = Fget_text_property (position, propname, w->buffer);
7777 XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
7778 end = Fnext_single_property_change (position, propname, w->buffer, limit1);
7779 if (INTEGERP (end))
7780 endpos = XINT (end);
7781
7782 *endptr = endpos;
7783
7784 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
7785
7786 /* Optimize common cases where we can use the default face. */
7787 if (NILP (prop)
7788 && !(pos >= region_beg && pos < region_end))
7789 return DEFAULT_FACE_ID;
7790
7791 /* Begin with attributes from the default face. */
7792 bcopy (default_face->lface, attrs, sizeof attrs);
7793
7794 /* Merge in attributes specified via text properties. */
7795 if (!NILP (prop))
7796 merge_face_ref (f, prop, attrs, 1, 0);
7797
7798 /* If in the region, merge in the region face. */
7799 if (pos >= region_beg && pos < region_end)
7800 {
7801 merge_named_face (f, Qregion, attrs, 0);
7802
7803 if (region_end < endpos)
7804 endpos = region_end;
7805 }
7806
7807 *endptr = endpos;
7808
7809 /* Look up a realized face with the given face attributes,
7810 or realize a new one for ASCII characters. */
7811 return lookup_face (f, attrs, 0, NULL);
7812}
7813
7735 7814
7736/* Compute the face at character position POS in Lisp string STRING on 7815/* Compute the face at character position POS in Lisp string STRING on
7737 window W, for ASCII characters. 7816 window W, for ASCII characters.