changeset 2795:e97e96fb0cb8

(compute_char_face): New args REGION_BEG, REGION_END. Don't sort if noverlays is 0 or 1.
author Richard M. Stallman <rms@gnu.org>
date Sat, 15 May 1993 18:45:14 +0000
parents 9163e4e4752c
children e0a9c4815584
files src/xfaces.c
diffstat 1 files changed, 28 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Sat May 15 18:44:46 1993 +0000
+++ b/src/xfaces.c	Sat May 15 18:45:14 1993 +0000
@@ -133,6 +133,9 @@
 /* The number of face-id's in use (same for all frames).  */
 int next_face_id;
 
+/* The number of the face to use to indicate the region.  */
+int region_face;
+
 #define FACE_DEFAULT (~0)
 
 Lisp_Object Qface, Qwindow, Qpriority;
@@ -616,12 +619,16 @@
    Store into *ENDPTR the position at which a different face is needed.
    This does not take account of glyphs that specify their own face codes.
    F is the frame in use for display, and W is a window displaying
-   the current buffer.  */
+   the current buffer.
+
+   REGION_BEG, REGION_END delimit the region, so it can be highlighted.  */
+
 int
-compute_char_face (f, w, pos, endptr)
+compute_char_face (f, w, pos, region_beg, region_end, endptr)
      struct frame *f;
      struct window *w;
      int pos;
+     int region_beg, region_end;
      int *endptr;
 {
   struct face face;
@@ -642,6 +649,8 @@
   XSET (frame, Lisp_Frame, f);
 
   endpos = ZV;
+  if (pos < region_beg && region_beg < endpos)
+    endpos = region_beg;
 
   XFASTINT (position) = pos;
   prop = Fget_text_property (position, Qface, w->buffer);
@@ -666,7 +675,8 @@
   *endptr = endpos;
 
   /* Optimize the default case.  */
-  if (noverlays == 0 && NILP (prop))
+  if (noverlays == 0 && NILP (prop)
+      && !(pos >= region_beg && pos < region_end))
     return 0;
 
   bcopy (FRAME_DEFAULT_FACE (f), &face, sizeof (struct face));
@@ -719,7 +729,8 @@
 
   /* Sort the overlays into the proper order: increasing priority.  */
 
-  qsort (sortvec, noverlays, sizeof (struct sortvec), sort_overlays);
+  if (noverlays > 1)
+    qsort (sortvec, noverlays, sizeof (struct sortvec), sort_overlays);
 
   /* Now merge the overlay data in that order.  */
   for (i = 0; i < noverlays; i++)
@@ -742,6 +753,14 @@
 	}
     }
 
+  if (pos >= region_beg && pos < region_end)
+    {
+      if (region_end < endpos)
+	endpos = region_end;
+      if (region_face >= 0 && region_face < next_face_id)
+	merge_faces (FRAME_FACES (f) [region_face], &face);
+    }
+
   xfree (overlay_vec);
 
   *endptr = endpos;
@@ -939,6 +958,11 @@
   Qpriority = intern ("priority");
   staticpro (&Qpriority);
 
+  DEFVAR_INT ("region-face", &region_face,
+    "Face number to use to highlight the region\n\
+The region is highlighted with this face\n\
+when Transient Mark mode is enabled and the mark is active.");
+
   defsubr (&Sframe_face_alist);
   defsubr (&Sset_frame_face_alist);
   defsubr (&Smake_face_internal);