aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index a876828da82..e037d703812 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -133,6 +133,9 @@ int nfaces_allocated;
133/* The number of face-id's in use (same for all frames). */ 133/* The number of face-id's in use (same for all frames). */
134int next_face_id; 134int next_face_id;
135 135
136/* The number of the face to use to indicate the region. */
137int region_face;
138
136#define FACE_DEFAULT (~0) 139#define FACE_DEFAULT (~0)
137 140
138Lisp_Object Qface, Qwindow, Qpriority; 141Lisp_Object Qface, Qwindow, Qpriority;
@@ -616,12 +619,16 @@ sort_overlays (s1, s2)
616 Store into *ENDPTR the position at which a different face is needed. 619 Store into *ENDPTR the position at which a different face is needed.
617 This does not take account of glyphs that specify their own face codes. 620 This does not take account of glyphs that specify their own face codes.
618 F is the frame in use for display, and W is a window displaying 621 F is the frame in use for display, and W is a window displaying
619 the current buffer. */ 622 the current buffer.
623
624 REGION_BEG, REGION_END delimit the region, so it can be highlighted. */
625
620int 626int
621compute_char_face (f, w, pos, endptr) 627compute_char_face (f, w, pos, region_beg, region_end, endptr)
622 struct frame *f; 628 struct frame *f;
623 struct window *w; 629 struct window *w;
624 int pos; 630 int pos;
631 int region_beg, region_end;
625 int *endptr; 632 int *endptr;
626{ 633{
627 struct face face; 634 struct face face;
@@ -642,6 +649,8 @@ compute_char_face (f, w, pos, endptr)
642 XSET (frame, Lisp_Frame, f); 649 XSET (frame, Lisp_Frame, f);
643 650
644 endpos = ZV; 651 endpos = ZV;
652 if (pos < region_beg && region_beg < endpos)
653 endpos = region_beg;
645 654
646 XFASTINT (position) = pos; 655 XFASTINT (position) = pos;
647 prop = Fget_text_property (position, Qface, w->buffer); 656 prop = Fget_text_property (position, Qface, w->buffer);
@@ -666,7 +675,8 @@ compute_char_face (f, w, pos, endptr)
666 *endptr = endpos; 675 *endptr = endpos;
667 676
668 /* Optimize the default case. */ 677 /* Optimize the default case. */
669 if (noverlays == 0 && NILP (prop)) 678 if (noverlays == 0 && NILP (prop)
679 && !(pos >= region_beg && pos < region_end))
670 return 0; 680 return 0;
671 681
672 bcopy (FRAME_DEFAULT_FACE (f), &face, sizeof (struct face)); 682 bcopy (FRAME_DEFAULT_FACE (f), &face, sizeof (struct face));
@@ -719,7 +729,8 @@ compute_char_face (f, w, pos, endptr)
719 729
720 /* Sort the overlays into the proper order: increasing priority. */ 730 /* Sort the overlays into the proper order: increasing priority. */
721 731
722 qsort (sortvec, noverlays, sizeof (struct sortvec), sort_overlays); 732 if (noverlays > 1)
733 qsort (sortvec, noverlays, sizeof (struct sortvec), sort_overlays);
723 734
724 /* Now merge the overlay data in that order. */ 735 /* Now merge the overlay data in that order. */
725 for (i = 0; i < noverlays; i++) 736 for (i = 0; i < noverlays; i++)
@@ -742,6 +753,14 @@ compute_char_face (f, w, pos, endptr)
742 } 753 }
743 } 754 }
744 755
756 if (pos >= region_beg && pos < region_end)
757 {
758 if (region_end < endpos)
759 endpos = region_end;
760 if (region_face >= 0 && region_face < next_face_id)
761 merge_faces (FRAME_FACES (f) [region_face], &face);
762 }
763
745 xfree (overlay_vec); 764 xfree (overlay_vec);
746 765
747 *endptr = endpos; 766 *endptr = endpos;
@@ -939,6 +958,11 @@ syms_of_xfaces ()
939 Qpriority = intern ("priority"); 958 Qpriority = intern ("priority");
940 staticpro (&Qpriority); 959 staticpro (&Qpriority);
941 960
961 DEFVAR_INT ("region-face", &region_face,
962 "Face number to use to highlight the region\n\
963The region is highlighted with this face\n\
964when Transient Mark mode is enabled and the mark is active.");
965
942 defsubr (&Sframe_face_alist); 966 defsubr (&Sframe_face_alist);
943 defsubr (&Sset_frame_face_alist); 967 defsubr (&Sset_frame_face_alist);
944 defsubr (&Smake_face_internal); 968 defsubr (&Smake_face_internal);