Mercurial > emacs
comparison src/xdisp.c @ 85973:d3e87ee5aa0e
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-923
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 09 Nov 2007 09:45:30 +0000 |
parents | a89507976418 998a04e48f58 |
children | 72cbf2612765 |
comparison
equal
deleted
inserted
replaced
85972:51aa47312c4b | 85973:d3e87ee5aa0e |
---|---|
952 static void compute_string_pos P_ ((struct text_pos *, struct text_pos, | 952 static void compute_string_pos P_ ((struct text_pos *, struct text_pos, |
953 Lisp_Object)); | 953 Lisp_Object)); |
954 static int face_before_or_after_it_pos P_ ((struct it *, int)); | 954 static int face_before_or_after_it_pos P_ ((struct it *, int)); |
955 static int next_overlay_change P_ ((int)); | 955 static int next_overlay_change P_ ((int)); |
956 static int handle_single_display_spec P_ ((struct it *, Lisp_Object, | 956 static int handle_single_display_spec P_ ((struct it *, Lisp_Object, |
957 Lisp_Object, struct text_pos *, | 957 Lisp_Object, Lisp_Object, |
958 int)); | 958 struct text_pos *, int)); |
959 static int underlying_face_id P_ ((struct it *)); | 959 static int underlying_face_id P_ ((struct it *)); |
960 static int in_ellipses_for_invisible_text_p P_ ((struct display_pos *, | 960 static int in_ellipses_for_invisible_text_p P_ ((struct display_pos *, |
961 struct window *)); | 961 struct window *)); |
962 | 962 |
963 #define face_before_it_pos(IT) face_before_or_after_it_pos ((IT), 1) | 963 #define face_before_it_pos(IT) face_before_or_after_it_pos ((IT), 1) |
3058 /* Don't check for overlay strings below when set to deliver | 3058 /* Don't check for overlay strings below when set to deliver |
3059 characters from a display vector. */ | 3059 characters from a display vector. */ |
3060 if (it->method == GET_FROM_DISPLAY_VECTOR) | 3060 if (it->method == GET_FROM_DISPLAY_VECTOR) |
3061 handle_overlay_change_p = 0; | 3061 handle_overlay_change_p = 0; |
3062 | 3062 |
3063 /* Handle overlay changes. */ | 3063 /* Handle overlay changes. |
3064 This sets HANDLED to HANDLED_RECOMPUTE_PROPS | |
3065 if it finds overlays. */ | |
3064 if (handle_overlay_change_p) | 3066 if (handle_overlay_change_p) |
3065 handled = handle_overlay_change (it); | 3067 handled = handle_overlay_change (it); |
3066 | |
3067 /* Determine where to stop next. */ | |
3068 if (handled == HANDLED_NORMALLY) | |
3069 compute_stop_pos (it); | |
3070 } | 3068 } |
3071 } | 3069 } |
3072 while (handled == HANDLED_RECOMPUTE_PROPS); | 3070 while (handled == HANDLED_RECOMPUTE_PROPS); |
3071 | |
3072 /* Determine where to stop next. */ | |
3073 if (handled == HANDLED_NORMALLY) | |
3074 compute_stop_pos (it); | |
3073 } | 3075 } |
3074 | 3076 |
3075 | 3077 |
3076 /* Compute IT->stop_charpos from text property and overlay change | 3078 /* Compute IT->stop_charpos from text property and overlay change |
3077 information for IT's current position. */ | 3079 information for IT's current position. */ |
3348 } | 3350 } |
3349 } | 3351 } |
3350 else | 3352 else |
3351 { | 3353 { |
3352 int base_face_id, bufpos; | 3354 int base_face_id, bufpos; |
3353 | 3355 int i; |
3354 if (it->current.overlay_string_index >= 0) | 3356 Lisp_Object from_overlay |
3355 bufpos = IT_CHARPOS (*it); | 3357 = (it->current.overlay_string_index >= 0 |
3358 ? it->string_overlays[it->current.overlay_string_index] | |
3359 : Qnil); | |
3360 | |
3361 /* See if we got to this string directly or indirectly from | |
3362 an overlay property. That includes the before-string or | |
3363 after-string of an overlay, strings in display properties | |
3364 provided by an overlay, their text properties, etc. | |
3365 | |
3366 FROM_OVERLAY is the overlay that brought us here, or nil if none. */ | |
3367 if (! NILP (from_overlay)) | |
3368 for (i = it->sp - 1; i >= 0; i--) | |
3369 { | |
3370 if (it->stack[i].current.overlay_string_index >= 0) | |
3371 from_overlay | |
3372 = it->string_overlays[it->stack[i].current.overlay_string_index]; | |
3373 else if (! NILP (it->stack[i].from_overlay)) | |
3374 from_overlay = it->stack[i].from_overlay; | |
3375 | |
3376 if (!NILP (from_overlay)) | |
3377 break; | |
3378 } | |
3379 | |
3380 if (! NILP (from_overlay)) | |
3381 { | |
3382 bufpos = IT_CHARPOS (*it); | |
3383 /* For a string from an overlay, the base face depends | |
3384 only on text properties and ignores overlays. */ | |
3385 base_face_id | |
3386 = face_for_overlay_string (it->w, | |
3387 IT_CHARPOS (*it), | |
3388 it->region_beg_charpos, | |
3389 it->region_end_charpos, | |
3390 &next_stop, | |
3391 (IT_CHARPOS (*it) | |
3392 + TEXT_PROP_DISTANCE_LIMIT), | |
3393 0, | |
3394 from_overlay); | |
3395 } | |
3356 else | 3396 else |
3357 bufpos = 0; | 3397 { |
3358 | 3398 bufpos = 0; |
3359 /* For strings from a buffer, i.e. overlay strings or strings | 3399 |
3360 from a `display' property, use the face at IT's current | 3400 /* For strings from a `display' property, use the face at |
3361 buffer position as the base face to merge with, so that | 3401 IT's current buffer position as the base face to merge |
3362 overlay strings appear in the same face as surrounding | 3402 with, so that overlay strings appear in the same face as |
3363 text, unless they specify their own faces. */ | 3403 surrounding text, unless they specify their own |
3364 base_face_id = underlying_face_id (it); | 3404 faces. */ |
3405 base_face_id = underlying_face_id (it); | |
3406 } | |
3365 | 3407 |
3366 new_face_id = face_at_string_position (it->w, | 3408 new_face_id = face_at_string_position (it->w, |
3367 it->string, | 3409 it->string, |
3368 IT_STRING_CHARPOS (*it), | 3410 IT_STRING_CHARPOS (*it), |
3369 bufpos, | 3411 bufpos, |
3770 | 3812 |
3771 static enum prop_handled | 3813 static enum prop_handled |
3772 handle_display_prop (it) | 3814 handle_display_prop (it) |
3773 struct it *it; | 3815 struct it *it; |
3774 { | 3816 { |
3775 Lisp_Object prop, object; | 3817 Lisp_Object prop, object, overlay; |
3776 struct text_pos *position; | 3818 struct text_pos *position; |
3777 /* Nonzero if some property replaces the display of the text itself. */ | 3819 /* Nonzero if some property replaces the display of the text itself. */ |
3778 int display_replaced_p = 0; | 3820 int display_replaced_p = 0; |
3779 | 3821 |
3780 if (STRINGP (it->string)) | 3822 if (STRINGP (it->string)) |
3798 values that have a string `display' property, that have a string | 3840 values that have a string `display' property, that have a string |
3799 `display' property etc. */ | 3841 `display' property etc. */ |
3800 if (!it->string_from_display_prop_p) | 3842 if (!it->string_from_display_prop_p) |
3801 it->area = TEXT_AREA; | 3843 it->area = TEXT_AREA; |
3802 | 3844 |
3803 prop = Fget_char_property (make_number (position->charpos), | 3845 prop = get_char_property_and_overlay (make_number (position->charpos), |
3804 Qdisplay, object); | 3846 Qdisplay, object, &overlay); |
3805 if (NILP (prop)) | 3847 if (NILP (prop)) |
3806 return HANDLED_NORMALLY; | 3848 return HANDLED_NORMALLY; |
3849 /* Now OVERLAY is the overlay that gave us this property, or nil | |
3850 if it was a text property. */ | |
3807 | 3851 |
3808 if (!STRINGP (it->string)) | 3852 if (!STRINGP (it->string)) |
3809 object = it->w->buffer; | 3853 object = it->w->buffer; |
3810 | 3854 |
3811 if (CONSP (prop) | 3855 if (CONSP (prop) |
3823 && !EQ (XCAR (prop), Qright_fringe) | 3867 && !EQ (XCAR (prop), Qright_fringe) |
3824 && !NILP (XCAR (prop))) | 3868 && !NILP (XCAR (prop))) |
3825 { | 3869 { |
3826 for (; CONSP (prop); prop = XCDR (prop)) | 3870 for (; CONSP (prop); prop = XCDR (prop)) |
3827 { | 3871 { |
3828 if (handle_single_display_spec (it, XCAR (prop), object, | 3872 if (handle_single_display_spec (it, XCAR (prop), object, overlay, |
3829 position, display_replaced_p)) | 3873 position, display_replaced_p)) |
3830 { | 3874 { |
3831 display_replaced_p = 1; | 3875 display_replaced_p = 1; |
3832 /* If some text in a string is replaced, `position' no | 3876 /* If some text in a string is replaced, `position' no |
3833 longer points to the position of `object'. */ | 3877 longer points to the position of `object'. */ |
3838 } | 3882 } |
3839 else if (VECTORP (prop)) | 3883 else if (VECTORP (prop)) |
3840 { | 3884 { |
3841 int i; | 3885 int i; |
3842 for (i = 0; i < ASIZE (prop); ++i) | 3886 for (i = 0; i < ASIZE (prop); ++i) |
3843 if (handle_single_display_spec (it, AREF (prop, i), object, | 3887 if (handle_single_display_spec (it, AREF (prop, i), object, overlay, |
3844 position, display_replaced_p)) | 3888 position, display_replaced_p)) |
3845 { | 3889 { |
3846 display_replaced_p = 1; | 3890 display_replaced_p = 1; |
3847 /* If some text in a string is replaced, `position' no | 3891 /* If some text in a string is replaced, `position' no |
3848 longer points to the position of `object'. */ | 3892 longer points to the position of `object'. */ |
3850 break; | 3894 break; |
3851 } | 3895 } |
3852 } | 3896 } |
3853 else | 3897 else |
3854 { | 3898 { |
3855 int ret = handle_single_display_spec (it, prop, object, position, 0); | 3899 int ret = handle_single_display_spec (it, prop, object, overlay, |
3900 position, 0); | |
3856 if (ret < 0) /* Replaced by "", i.e. nothing. */ | 3901 if (ret < 0) /* Replaced by "", i.e. nothing. */ |
3857 return HANDLED_RECOMPUTE_PROPS; | 3902 return HANDLED_RECOMPUTE_PROPS; |
3858 if (ret) | 3903 if (ret) |
3859 display_replaced_p = 1; | 3904 display_replaced_p = 1; |
3860 } | 3905 } |
3892 is the position at which it was found. DISPLAY_REPLACED_P non-zero | 3937 is the position at which it was found. DISPLAY_REPLACED_P non-zero |
3893 means that we previously saw a display specification which already | 3938 means that we previously saw a display specification which already |
3894 replaced text display with something else, for example an image; | 3939 replaced text display with something else, for example an image; |
3895 we ignore such properties after the first one has been processed. | 3940 we ignore such properties after the first one has been processed. |
3896 | 3941 |
3942 OVERLAY is the overlay this `display' property came from, | |
3943 or nil if it was a text property. | |
3944 | |
3897 If PROP is a `space' or `image' specification, and in some other | 3945 If PROP is a `space' or `image' specification, and in some other |
3898 cases too, set *POSITION to the position where the `display' | 3946 cases too, set *POSITION to the position where the `display' |
3899 property ends. | 3947 property ends. |
3900 | 3948 |
3901 Value is non-zero if something was found which replaces the display | 3949 Value is non-zero if something was found which replaces the display |
3902 of buffer or string text. Specifically, the value is -1 if that | 3950 of buffer or string text. Specifically, the value is -1 if that |
3903 "something" is "nothing". */ | 3951 "something" is "nothing". */ |
3904 | 3952 |
3905 static int | 3953 static int |
3906 handle_single_display_spec (it, spec, object, position, | 3954 handle_single_display_spec (it, spec, object, overlay, position, |
3907 display_replaced_before_p) | 3955 display_replaced_before_p) |
3908 struct it *it; | 3956 struct it *it; |
3909 Lisp_Object spec; | 3957 Lisp_Object spec; |
3910 Lisp_Object object; | 3958 Lisp_Object object; |
3959 Lisp_Object overlay; | |
3911 struct text_pos *position; | 3960 struct text_pos *position; |
3912 int display_replaced_before_p; | 3961 int display_replaced_before_p; |
3913 { | 3962 { |
3914 Lisp_Object form; | 3963 Lisp_Object form; |
3915 Lisp_Object location, value; | 3964 Lisp_Object location, value; |
4015 } | 4064 } |
4016 | 4065 |
4017 return 0; | 4066 return 0; |
4018 } | 4067 } |
4019 | 4068 |
4020 /* Handle `(space_width WIDTH)'. */ | 4069 /* Handle `(space-width WIDTH)'. */ |
4021 if (CONSP (spec) | 4070 if (CONSP (spec) |
4022 && EQ (XCAR (spec), Qspace_width) | 4071 && EQ (XCAR (spec), Qspace_width) |
4023 && CONSP (XCDR (spec))) | 4072 && CONSP (XCDR (spec))) |
4024 { | 4073 { |
4025 if (!FRAME_WINDOW_P (it->f)) | 4074 if (!FRAME_WINDOW_P (it->f)) |
4139 it->what = IT_IMAGE; | 4188 it->what = IT_IMAGE; |
4140 it->image_id = -1; /* no image */ | 4189 it->image_id = -1; /* no image */ |
4141 it->position = start_pos; | 4190 it->position = start_pos; |
4142 it->object = NILP (object) ? it->w->buffer : object; | 4191 it->object = NILP (object) ? it->w->buffer : object; |
4143 it->method = GET_FROM_IMAGE; | 4192 it->method = GET_FROM_IMAGE; |
4193 it->from_overlay = Qnil; | |
4144 it->face_id = face_id; | 4194 it->face_id = face_id; |
4145 | 4195 |
4146 /* Say that we haven't consumed the characters with | 4196 /* Say that we haven't consumed the characters with |
4147 `display' property yet. The call to pop_it in | 4197 `display' property yet. The call to pop_it in |
4148 set_iterator_to_next will clean this up. */ | 4198 set_iterator_to_next will clean this up. */ |
4209 when we are finished with the glyph property value. */ | 4259 when we are finished with the glyph property value. */ |
4210 save_pos = it->position; | 4260 save_pos = it->position; |
4211 it->position = *position; | 4261 it->position = *position; |
4212 push_it (it); | 4262 push_it (it); |
4213 it->position = save_pos; | 4263 it->position = save_pos; |
4264 it->from_overlay = overlay; | |
4214 | 4265 |
4215 if (NILP (location)) | 4266 if (NILP (location)) |
4216 it->area = TEXT_AREA; | 4267 it->area = TEXT_AREA; |
4217 else if (EQ (location, Qleft_margin)) | 4268 else if (EQ (location, Qleft_margin)) |
4218 it->area = LEFT_MARGIN_AREA; | 4269 it->area = LEFT_MARGIN_AREA; |
4852 that have already been consumed by IT. Copy some of the | 4903 that have already been consumed by IT. Copy some of the |
4853 remaining overlay strings to IT->overlay_strings. */ | 4904 remaining overlay strings to IT->overlay_strings. */ |
4854 i = 0; | 4905 i = 0; |
4855 j = it->current.overlay_string_index; | 4906 j = it->current.overlay_string_index; |
4856 while (i < OVERLAY_STRING_CHUNK_SIZE && j < n) | 4907 while (i < OVERLAY_STRING_CHUNK_SIZE && j < n) |
4857 it->overlay_strings[i++] = entries[j++].string; | 4908 { |
4909 it->overlay_strings[i++] = entries[j++].string; | |
4910 it->string_overlays[i++] = entries[j++].overlay; | |
4911 } | |
4858 | 4912 |
4859 CHECK_IT (it); | 4913 CHECK_IT (it); |
4860 } | 4914 } |
4861 | 4915 |
4862 | 4916 |
4898 | 4952 |
4899 /* Set up IT to deliver display elements from the first overlay | 4953 /* Set up IT to deliver display elements from the first overlay |
4900 string. */ | 4954 string. */ |
4901 IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = 0; | 4955 IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = 0; |
4902 it->string = it->overlay_strings[0]; | 4956 it->string = it->overlay_strings[0]; |
4957 it->from_overlay = Qnil; | |
4903 it->stop_charpos = 0; | 4958 it->stop_charpos = 0; |
4904 xassert (STRINGP (it->string)); | 4959 xassert (STRINGP (it->string)); |
4905 it->end_charpos = SCHARS (it->string); | 4960 it->end_charpos = SCHARS (it->string); |
4906 it->multibyte_p = STRING_MULTIBYTE (it->string); | 4961 it->multibyte_p = STRING_MULTIBYTE (it->string); |
4907 it->method = GET_FROM_STRING; | 4962 it->method = GET_FROM_STRING; |
4951 p->stop_charpos = it->stop_charpos; | 5006 p->stop_charpos = it->stop_charpos; |
4952 xassert (it->face_id >= 0); | 5007 xassert (it->face_id >= 0); |
4953 p->face_id = it->face_id; | 5008 p->face_id = it->face_id; |
4954 p->string = it->string; | 5009 p->string = it->string; |
4955 p->method = it->method; | 5010 p->method = it->method; |
5011 p->from_overlay = it->from_overlay; | |
4956 switch (p->method) | 5012 switch (p->method) |
4957 { | 5013 { |
4958 case GET_FROM_IMAGE: | 5014 case GET_FROM_IMAGE: |
4959 p->u.image.object = it->object; | 5015 p->u.image.object = it->object; |
4960 p->u.image.image_id = it->image_id; | 5016 p->u.image.image_id = it->image_id; |
5004 it->stop_charpos = p->stop_charpos; | 5060 it->stop_charpos = p->stop_charpos; |
5005 it->face_id = p->face_id; | 5061 it->face_id = p->face_id; |
5006 it->current = p->current; | 5062 it->current = p->current; |
5007 it->position = p->position; | 5063 it->position = p->position; |
5008 it->string = p->string; | 5064 it->string = p->string; |
5065 it->from_overlay = p->from_overlay; | |
5009 if (NILP (it->string)) | 5066 if (NILP (it->string)) |
5010 SET_TEXT_POS (it->current.string_pos, -1, -1); | 5067 SET_TEXT_POS (it->current.string_pos, -1, -1); |
5011 it->method = p->method; | 5068 it->method = p->method; |
5012 switch (it->method) | 5069 switch (it->method) |
5013 { | 5070 { |
17386 | 17443 |
17387 if (NILP (buffer)) | 17444 if (NILP (buffer)) |
17388 buffer = w->buffer; | 17445 buffer = w->buffer; |
17389 CHECK_BUFFER (buffer); | 17446 CHECK_BUFFER (buffer); |
17390 | 17447 |
17391 if (NILP (format)) | 17448 /* Make formatting the modeline a non-op when noninteractive, otherwise |
17449 there will be problems later caused by a partially initialized frame. */ | |
17450 if (NILP (format) || noninteractive) | |
17392 return empty_unibyte_string; | 17451 return empty_unibyte_string; |
17393 | 17452 |
17394 if (no_props) | 17453 if (no_props) |
17395 face = Qnil; | 17454 face = Qnil; |
17396 | 17455 |