aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2000-06-22 19:32:09 +0000
committerGerd Moellmann2000-06-22 19:32:09 +0000
commit2970b9beee8fb931dae6d37b52e6dd195506bd3c (patch)
tree9df2507d7e94d546c706f5402793cebb048889c1 /src
parenta3a7ff330f78a4c36df10ffbf5dd7a3617061001 (diff)
downloademacs-2970b9beee8fb931dae6d37b52e6dd195506bd3c.tar.gz
emacs-2970b9beee8fb931dae6d37b52e6dd195506bd3c.zip
(handle_stop): Initialize it->add_overlay_start to zero.
(handle_invisible_prop): Record the start of invisible text in it->add_overlay_start. (struct overlay_entry): Add member `overlay'. (handle_overlay_change): Simplify. (next_overlay_string): After having processed overlay strings at the end of the buffer, record that fact in it->overlay_strings_at_end_processed_p. (compare_overlay_entries): If before- and after-strings come from the same overlay, let before-strings come first. (RECORD_OVERLAY_STRING): Record the overlay that strings come from. (load_overlay_strings): Take it->add_overlay_start into account when adding overlay strings.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c73
1 files changed, 49 insertions, 24 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 1822e81f386..7b6eb35fcdc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1597,6 +1597,7 @@ handle_stop (it)
1597 1597
1598 it->dpvec = NULL; 1598 it->dpvec = NULL;
1599 it->current.dpvec_index = -1; 1599 it->current.dpvec_index = -1;
1600 it->add_overlay_start = 0;
1600 1601
1601 do 1602 do
1602 { 1603 {
@@ -1606,7 +1607,7 @@ handle_stop (it)
1606 for (p = it_props; p->handler; ++p) 1607 for (p = it_props; p->handler; ++p)
1607 { 1608 {
1608 handled = p->handler (it); 1609 handled = p->handler (it);
1609 1610
1610 if (handled == HANDLED_RECOMPUTE_PROPS) 1611 if (handled == HANDLED_RECOMPUTE_PROPS)
1611 break; 1612 break;
1612 else if (handled == HANDLED_RETURN) 1613 else if (handled == HANDLED_RETURN)
@@ -2115,6 +2116,7 @@ handle_invisible_prop (it)
2115 = TEXT_PROP_MEANS_INVISIBLE_WITH_ELLIPSIS (prop); 2116 = TEXT_PROP_MEANS_INVISIBLE_WITH_ELLIPSIS (prop);
2116 2117
2117 handled = HANDLED_RECOMPUTE_PROPS; 2118 handled = HANDLED_RECOMPUTE_PROPS;
2119 it->add_overlay_start = IT_CHARPOS (*it);
2118 2120
2119 /* Loop skipping over invisible text. The loop is left at 2121 /* Loop skipping over invisible text. The loop is left at
2120 ZV or with IT on the first char being visible again. */ 2122 ZV or with IT on the first char being visible again. */
@@ -2700,6 +2702,7 @@ handle_composition_prop (it)
2700 2702
2701struct overlay_entry 2703struct overlay_entry
2702{ 2704{
2705 Lisp_Object overlay;
2703 Lisp_Object string; 2706 Lisp_Object string;
2704 int priority; 2707 int priority;
2705 int after_string_p; 2708 int after_string_p;
@@ -2713,13 +2716,10 @@ static enum prop_handled
2713handle_overlay_change (it) 2716handle_overlay_change (it)
2714 struct it *it; 2717 struct it *it;
2715{ 2718{
2716 /* Overlays are handled in current_buffer only. */ 2719 if (!STRINGP (it->string) && get_overlay_strings (it))
2717 if (STRINGP (it->string)) 2720 return HANDLED_RECOMPUTE_PROPS;
2718 return HANDLED_NORMALLY;
2719 else 2721 else
2720 return (get_overlay_strings (it) 2722 return HANDLED_NORMALLY;
2721 ? HANDLED_RECOMPUTE_PROPS
2722 : HANDLED_NORMALLY);
2723} 2723}
2724 2724
2725 2725
@@ -2748,6 +2748,12 @@ next_overlay_string (it)
2748 SET_TEXT_POS (it->current.string_pos, -1, -1); 2748 SET_TEXT_POS (it->current.string_pos, -1, -1);
2749 it->n_overlay_strings = 0; 2749 it->n_overlay_strings = 0;
2750 it->method = next_element_from_buffer; 2750 it->method = next_element_from_buffer;
2751
2752 /* If we're at the end of the buffer, record that we have
2753 processed the overlay strings there already, so that
2754 next_element_from_buffer doesn't try it again. */
2755 if (IT_CHARPOS (*it) >= it->end_charpos)
2756 it->overlay_strings_at_end_processed_p = 1;
2751 } 2757 }
2752 else 2758 else
2753 { 2759 {
@@ -2777,7 +2783,8 @@ next_overlay_string (it)
2777 comparison function for qsort in load_overlay_strings. Overlay 2783 comparison function for qsort in load_overlay_strings. Overlay
2778 strings for the same position are sorted so that 2784 strings for the same position are sorted so that
2779 2785
2780 1. All after-strings come in front of before-strings. 2786 1. All after-strings come in front of before-strings, except
2787 when they come from the same overlay.
2781 2788
2782 2. Within after-strings, strings are sorted so that overlay strings 2789 2. Within after-strings, strings are sorted so that overlay strings
2783 from overlays with higher priorities come first. 2790 from overlays with higher priorities come first.
@@ -2797,8 +2804,14 @@ compare_overlay_entries (e1, e2)
2797 int result; 2804 int result;
2798 2805
2799 if (entry1->after_string_p != entry2->after_string_p) 2806 if (entry1->after_string_p != entry2->after_string_p)
2800 /* Let after-strings appear in front of before-strings. */ 2807 {
2801 result = entry1->after_string_p ? -1 : 1; 2808 /* Let after-strings appear in front of before-strings if
2809 they come from different overlays. */
2810 if (EQ (entry1->overlay, entry2->overlay))
2811 result = entry1->after_string_p ? 1 : -1;
2812 else
2813 result = entry1->after_string_p ? -1 : 1;
2814 }
2802 else if (entry1->after_string_p) 2815 else if (entry1->after_string_p)
2803 /* After-strings sorted in order of decreasing priority. */ 2816 /* After-strings sorted in order of decreasing priority. */
2804 result = entry2->priority - entry1->priority; 2817 result = entry2->priority - entry1->priority;
@@ -2820,6 +2833,15 @@ compare_overlay_entries (e1, e2)
2820 strings that have already been loaded by previous calls to this 2833 strings that have already been loaded by previous calls to this
2821 function. 2834 function.
2822 2835
2836 IT->add_overlay_start contains an additional overlay start
2837 position to consider for taking overlay strings from, if non-zero.
2838 This position comes into play when the overlay has an `invisible'
2839 property, and both before and after-strings. When we've skipped to
2840 the end of the overlay, because of its `invisible' property, we
2841 nevertheless want its before-string to appear.
2842 IT->add_overlay_start will contain the overlay start position
2843 in this case.
2844
2823 Overlay strings are sorted so that after-string strings come in 2845 Overlay strings are sorted so that after-string strings come in
2824 front of before-string strings. Within before and after-strings, 2846 front of before-string strings. Within before and after-strings,
2825 strings are sorted by overlay priority. See also function 2847 strings are sorted by overlay priority. See also function
@@ -2858,18 +2880,16 @@ load_overlay_strings (it)
2858 } \ 2880 } \
2859 \ 2881 \
2860 entries[n].string = (STRING); \ 2882 entries[n].string = (STRING); \
2883 entries[n].overlay = (OVERLAY); \
2861 priority = Foverlay_get ((OVERLAY), Qpriority); \ 2884 priority = Foverlay_get ((OVERLAY), Qpriority); \
2862 entries[n].priority \ 2885 entries[n].priority = INTEGERP (priority) ? XINT (priority) : 0; \
2863 = INTEGERP (priority) ? XFASTINT (priority) : 0; \
2864 entries[n].after_string_p = (AFTER_P); \ 2886 entries[n].after_string_p = (AFTER_P); \
2865 ++n; \ 2887 ++n; \
2866 } \ 2888 } \
2867 while (0) 2889 while (0)
2868 2890
2869 /* Process overlay before the overlay center. */ 2891 /* Process overlay before the overlay center. */
2870 for (ov = current_buffer->overlays_before; 2892 for (ov = current_buffer->overlays_before; CONSP (ov); ov = XCDR (ov))
2871 CONSP (ov);
2872 ov = XCDR (ov))
2873 { 2893 {
2874 overlay = XCAR (ov); 2894 overlay = XCAR (ov);
2875 xassert (OVERLAYP (overlay)); 2895 xassert (OVERLAYP (overlay));
@@ -2881,7 +2901,9 @@ load_overlay_strings (it)
2881 2901
2882 /* Skip this overlay if it doesn't start or end at IT's current 2902 /* Skip this overlay if it doesn't start or end at IT's current
2883 position. */ 2903 position. */
2884 if (end != IT_CHARPOS (*it) && start != IT_CHARPOS (*it)) 2904 if (end != IT_CHARPOS (*it)
2905 && start != IT_CHARPOS (*it)
2906 && it->add_overlay_start != IT_CHARPOS (*it))
2885 continue; 2907 continue;
2886 2908
2887 /* Skip this overlay if it doesn't apply to IT->w. */ 2909 /* Skip this overlay if it doesn't apply to IT->w. */
@@ -2890,7 +2912,8 @@ load_overlay_strings (it)
2890 continue; 2912 continue;
2891 2913
2892 /* If overlay has a non-empty before-string, record it. */ 2914 /* If overlay has a non-empty before-string, record it. */
2893 if (start == IT_CHARPOS (*it) 2915 if ((start == IT_CHARPOS (*it)
2916 || start == it->add_overlay_start)
2894 && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str)) 2917 && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))
2895 && XSTRING (str)->size) 2918 && XSTRING (str)->size)
2896 RECORD_OVERLAY_STRING (overlay, str, 0); 2919 RECORD_OVERLAY_STRING (overlay, str, 0);
@@ -2903,9 +2926,7 @@ load_overlay_strings (it)
2903 } 2926 }
2904 2927
2905 /* Process overlays after the overlay center. */ 2928 /* Process overlays after the overlay center. */
2906 for (ov = current_buffer->overlays_after; 2929 for (ov = current_buffer->overlays_after; CONSP (ov); ov = XCDR (ov))
2907 CONSP (ov);
2908 ov = XCDR (ov))
2909 { 2930 {
2910 overlay = XCAR (ov); 2931 overlay = XCAR (ov);
2911 xassert (OVERLAYP (overlay)); 2932 xassert (OVERLAYP (overlay));
@@ -2917,7 +2938,9 @@ load_overlay_strings (it)
2917 2938
2918 /* Skip this overlay if it doesn't start or end at IT's current 2939 /* Skip this overlay if it doesn't start or end at IT's current
2919 position. */ 2940 position. */
2920 if (end != IT_CHARPOS (*it) && start != IT_CHARPOS (*it)) 2941 if (end != IT_CHARPOS (*it)
2942 && start != IT_CHARPOS (*it)
2943 && it->add_overlay_start != IT_CHARPOS (*it))
2921 continue; 2944 continue;
2922 2945
2923 /* Skip this overlay if it doesn't apply to IT->w. */ 2946 /* Skip this overlay if it doesn't apply to IT->w. */
@@ -2926,7 +2949,8 @@ load_overlay_strings (it)
2926 continue; 2949 continue;
2927 2950
2928 /* If overlay has a non-empty before-string, record it. */ 2951 /* If overlay has a non-empty before-string, record it. */
2929 if (start == IT_CHARPOS (*it) 2952 if ((start == IT_CHARPOS (*it)
2953 || start == it->add_overlay_start)
2930 && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str)) 2954 && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))
2931 && XSTRING (str)->size) 2955 && XSTRING (str)->size)
2932 RECORD_OVERLAY_STRING (overlay, str, 0); 2956 RECORD_OVERLAY_STRING (overlay, str, 0);
@@ -2941,7 +2965,8 @@ load_overlay_strings (it)
2941#undef RECORD_OVERLAY_STRING 2965#undef RECORD_OVERLAY_STRING
2942 2966
2943 /* Sort entries. */ 2967 /* Sort entries. */
2944 qsort (entries, n, sizeof *entries, compare_overlay_entries); 2968 if (n)
2969 qsort (entries, n, sizeof *entries, compare_overlay_entries);
2945 2970
2946 /* Record the total number of strings to process. */ 2971 /* Record the total number of strings to process. */
2947 it->n_overlay_strings = n; 2972 it->n_overlay_strings = n;
@@ -2953,7 +2978,7 @@ load_overlay_strings (it)
2953 j = it->current.overlay_string_index; 2978 j = it->current.overlay_string_index;
2954 while (i < OVERLAY_STRING_CHUNK_SIZE && j < n) 2979 while (i < OVERLAY_STRING_CHUNK_SIZE && j < n)
2955 it->overlay_strings[i++] = entries[j++].string; 2980 it->overlay_strings[i++] = entries[j++].string;
2956 2981
2957 CHECK_IT (it); 2982 CHECK_IT (it);
2958} 2983}
2959 2984