aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1994-02-09 03:25:25 +0000
committerKarl Heuer1994-02-09 03:25:25 +0000
commit4d6ebff8044176762f8b65da6912a31530e4cbeb (patch)
tree6c19009fe551228c9faa11fc6c3e8e5a6f90b46c /src
parent5985d248dbe5ca68243057a39b4f3d7197c6f138 (diff)
downloademacs-4d6ebff8044176762f8b65da6912a31530e4cbeb.tar.gz
emacs-4d6ebff8044176762f8b65da6912a31530e4cbeb.zip
(compute_char_face): Extract overlay-sorting code as a separate function,
which is now in buffer.c.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c73
1 files changed, 4 insertions, 69 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index a3c2eecebbd..5d296319d97 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -170,7 +170,7 @@ int region_face;
170 does not specify that display aspect. */ 170 does not specify that display aspect. */
171#define FACE_DEFAULT (~0) 171#define FACE_DEFAULT (~0)
172 172
173Lisp_Object Qface, Qwindow, Qpriority; 173Lisp_Object Qface;
174 174
175static void build_face ( /* FRAME_PTR, struct face * */ ); 175static void build_face ( /* FRAME_PTR, struct face * */ );
176int face_name_id_number ( /* FRAME_PTR, Lisp_Object name */ ); 176int face_name_id_number ( /* FRAME_PTR, Lisp_Object name */ );
@@ -700,26 +700,6 @@ compute_base_face (f, face)
700} 700}
701 701
702 702
703struct sortvec
704{
705 Lisp_Object overlay;
706 int beg, end;
707 int priority;
708};
709
710static int
711sort_overlays (s1, s2)
712 struct sortvec *s1, *s2;
713{
714 if (s1->priority != s2->priority)
715 return s1->priority - s2->priority;
716 if (s1->beg != s2->beg)
717 return s1->beg - s2->beg;
718 if (s1->end != s2->end)
719 return s2->end - s1->end;
720 return 0;
721}
722
723/* Return the face ID associated with a buffer position POS. 703/* Return the face ID associated with a buffer position POS.
724 Store into *ENDPTR the position at which a different face is needed. 704 Store into *ENDPTR the position at which a different face is needed.
725 This does not take account of glyphs that specify their own face codes. 705 This does not take account of glyphs that specify their own face codes.
@@ -745,7 +725,6 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr, limit)
745 int i, j, noverlays; 725 int i, j, noverlays;
746 int facecode; 726 int facecode;
747 Lisp_Object *overlay_vec; 727 Lisp_Object *overlay_vec;
748 struct sortvec *sortvec;
749 Lisp_Object frame; 728 Lisp_Object frame;
750 int endpos; 729 int endpos;
751 730
@@ -811,52 +790,12 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr, limit)
811 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face); 790 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
812 } 791 }
813 792
814 /* Put the valid and relevant overlays into sortvec. */ 793 noverlays = sort_overlays (overlay_vec, noverlays, w);
815 sortvec = (struct sortvec *) alloca (noverlays * sizeof (struct sortvec));
816
817 for (i = 0, j = 0; i < noverlays; i++)
818 {
819 Lisp_Object overlay = overlay_vec[i];
820
821 if (OVERLAY_VALID (overlay)
822 && OVERLAY_POSITION (OVERLAY_START (overlay)) > 0
823 && OVERLAY_POSITION (OVERLAY_END (overlay)) > 0)
824 {
825 Lisp_Object window;
826 window = Foverlay_get (overlay, Qwindow);
827
828 /* Also ignore overlays limited to one window
829 if it's not the window we are using. */
830 if (XTYPE (window) != Lisp_Window
831 || XWINDOW (window) == w)
832 {
833 Lisp_Object tem;
834
835 /* This overlay is good and counts:
836 put it in sortvec. */
837 sortvec[j].overlay = overlay;
838 sortvec[j].beg = OVERLAY_POSITION (OVERLAY_START (overlay));
839 sortvec[j].end = OVERLAY_POSITION (OVERLAY_END (overlay));
840 tem = Foverlay_get (overlay, Qpriority);
841 if (INTEGERP (tem))
842 sortvec[j].priority = XINT (tem);
843 else
844 sortvec[j].priority = 0;
845 j++;
846 }
847 }
848 }
849 noverlays = j;
850
851 /* Sort the overlays into the proper order: increasing priority. */
852
853 if (noverlays > 1)
854 qsort (sortvec, noverlays, sizeof (struct sortvec), sort_overlays);
855 794
856 /* Now merge the overlay data in that order. */ 795 /* Now merge the overlay data in that order. */
857 for (i = 0; i < noverlays; i++) 796 for (i = 0; i < noverlays; i++)
858 { 797 {
859 prop = Foverlay_get (sortvec[i].overlay, Qface); 798 prop = Foverlay_get (overlay_vec[i], Qface);
860 if (!NILP (prop)) 799 if (!NILP (prop))
861 { 800 {
862 Lisp_Object oend; 801 Lisp_Object oend;
@@ -867,7 +806,7 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr, limit)
867 && FRAME_PARAM_FACES (f) [facecode] != 0) 806 && FRAME_PARAM_FACES (f) [facecode] != 0)
868 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face); 807 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
869 808
870 oend = OVERLAY_END (sortvec[i].overlay); 809 oend = OVERLAY_END (overlay_vec[i]);
871 oendpos = OVERLAY_POSITION (oend); 810 oendpos = OVERLAY_POSITION (oend);
872 if (oendpos < endpos) 811 if (oendpos < endpos)
873 endpos = oendpos; 812 endpos = oendpos;
@@ -1102,12 +1041,8 @@ face_name_id_number (f, name)
1102void 1041void
1103syms_of_xfaces () 1042syms_of_xfaces ()
1104{ 1043{
1105 Qwindow = intern ("window");
1106 staticpro (&Qwindow);
1107 Qface = intern ("face"); 1044 Qface = intern ("face");
1108 staticpro (&Qface); 1045 staticpro (&Qface);
1109 Qpriority = intern ("priority");
1110 staticpro (&Qpriority);
1111 1046
1112 DEFVAR_INT ("region-face", &region_face, 1047 DEFVAR_INT ("region-face", &region_face,
1113 "Face number to use to highlight the region\n\ 1048 "Face number to use to highlight the region\n\