diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog.bidi | 8 | ||||
| -rw-r--r-- | src/xdisp.c | 63 |
2 files changed, 51 insertions, 20 deletions
diff --git a/src/ChangeLog.bidi b/src/ChangeLog.bidi index 08c51d2ee98..40a858b0320 100644 --- a/src/ChangeLog.bidi +++ b/src/ChangeLog.bidi | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2010-01-16 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * xdisp.c (handle_invisible_prop): Under bidi iteration, skip | ||
| 4 | invisible text using bidi_get_next_char_visually. | ||
| 5 | (handle_stop_backwards): Restore it->bidi_p, it->current and | ||
| 6 | it->position before calling handle_stop. | ||
| 7 | (next_element_from_buffer): Fix formatting. | ||
| 8 | |||
| 1 | 2010-01-09 Eli Zaretskii <eliz@gnu.org> | 9 | 2010-01-09 Eli Zaretskii <eliz@gnu.org> |
| 2 | 10 | ||
| 3 | * xdisp.c (handle_stop_backwards): Add a prototype. | 11 | * xdisp.c (handle_stop_backwards): Add a prototype. |
diff --git a/src/xdisp.c b/src/xdisp.c index de3d29d8633..2513c17c8b1 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -3784,18 +3784,18 @@ handle_invisible_prop (it) | |||
| 3784 | else | 3784 | else |
| 3785 | { | 3785 | { |
| 3786 | int invis_p; | 3786 | int invis_p; |
| 3787 | EMACS_INT newpos, next_stop, start_charpos; | 3787 | EMACS_INT newpos, next_stop, start_charpos, tem; |
| 3788 | Lisp_Object pos, prop, overlay; | 3788 | Lisp_Object pos, prop, overlay; |
| 3789 | 3789 | ||
| 3790 | /* First of all, is there invisible text at this position? */ | 3790 | /* First of all, is there invisible text at this position? */ |
| 3791 | start_charpos = IT_CHARPOS (*it); | 3791 | tem = start_charpos = IT_CHARPOS (*it); |
| 3792 | pos = make_number (IT_CHARPOS (*it)); | 3792 | pos = make_number (IT_CHARPOS (*it)); |
| 3793 | prop = get_char_property_and_overlay (pos, Qinvisible, it->window, | 3793 | prop = get_char_property_and_overlay (pos, Qinvisible, it->window, |
| 3794 | &overlay); | 3794 | &overlay); |
| 3795 | invis_p = TEXT_PROP_MEANS_INVISIBLE (prop); | 3795 | invis_p = TEXT_PROP_MEANS_INVISIBLE (prop); |
| 3796 | 3796 | ||
| 3797 | /* If we are on invisible text, skip over it. */ | 3797 | /* If we are on invisible text, skip over it. */ |
| 3798 | if (invis_p && IT_CHARPOS (*it) < it->end_charpos) | 3798 | if (invis_p && start_charpos < it->end_charpos) |
| 3799 | { | 3799 | { |
| 3800 | /* Record whether we have to display an ellipsis for the | 3800 | /* Record whether we have to display an ellipsis for the |
| 3801 | invisible text. */ | 3801 | invisible text. */ |
| @@ -3808,17 +3808,16 @@ handle_invisible_prop (it) | |||
| 3808 | do | 3808 | do |
| 3809 | { | 3809 | { |
| 3810 | /* Try to skip some invisible text. Return value is the | 3810 | /* Try to skip some invisible text. Return value is the |
| 3811 | position reached which can be equal to IT's position | 3811 | position reached which can be equal to where we start |
| 3812 | if there is nothing invisible here. This skips both | 3812 | if there is nothing invisible there. This skips both |
| 3813 | over invisible text properties and overlays with | 3813 | over invisible text properties and overlays with |
| 3814 | invisible property. */ | 3814 | invisible property. */ |
| 3815 | newpos = skip_invisible (IT_CHARPOS (*it), | 3815 | newpos = skip_invisible (tem, &next_stop, ZV, it->window); |
| 3816 | &next_stop, ZV, it->window); | ||
| 3817 | 3816 | ||
| 3818 | /* If we skipped nothing at all we weren't at invisible | 3817 | /* If we skipped nothing at all we weren't at invisible |
| 3819 | text in the first place. If everything to the end of | 3818 | text in the first place. If everything to the end of |
| 3820 | the buffer was skipped, end the loop. */ | 3819 | the buffer was skipped, end the loop. */ |
| 3821 | if (newpos == IT_CHARPOS (*it) || newpos >= ZV) | 3820 | if (newpos == tem || newpos >= ZV) |
| 3822 | invis_p = 0; | 3821 | invis_p = 0; |
| 3823 | else | 3822 | else |
| 3824 | { | 3823 | { |
| @@ -3836,7 +3835,7 @@ handle_invisible_prop (it) | |||
| 3836 | /* If we ended up on invisible text, proceed to | 3835 | /* If we ended up on invisible text, proceed to |
| 3837 | skip starting with next_stop. */ | 3836 | skip starting with next_stop. */ |
| 3838 | if (invis_p) | 3837 | if (invis_p) |
| 3839 | IT_CHARPOS (*it) = next_stop; | 3838 | tem = next_stop; |
| 3840 | 3839 | ||
| 3841 | /* If there are adjacent invisible texts, don't lose the | 3840 | /* If there are adjacent invisible texts, don't lose the |
| 3842 | second one's ellipsis. */ | 3841 | second one's ellipsis. */ |
| @@ -3846,8 +3845,30 @@ handle_invisible_prop (it) | |||
| 3846 | while (invis_p); | 3845 | while (invis_p); |
| 3847 | 3846 | ||
| 3848 | /* The position newpos is now either ZV or on visible text. */ | 3847 | /* The position newpos is now either ZV or on visible text. */ |
| 3849 | IT_CHARPOS (*it) = newpos; | 3848 | if (it->bidi_p && newpos < ZV) |
| 3850 | IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos); | 3849 | { |
| 3850 | /* With bidi iteration, the region of invisible text | ||
| 3851 | could start and/or end in the middle of a non-base | ||
| 3852 | embedding level. Therefore, we need to skip | ||
| 3853 | invisible text using the bidi iterator, starting at | ||
| 3854 | IT's current position, until we find ourselves | ||
| 3855 | outside the invisible text. This avoids affecting | ||
| 3856 | the visual order of the displayed text when invisible | ||
| 3857 | properties are added or removed. */ | ||
| 3858 | do | ||
| 3859 | { | ||
| 3860 | bidi_get_next_char_visually (&it->bidi_it); | ||
| 3861 | } | ||
| 3862 | while (start_charpos <= it->bidi_it.charpos | ||
| 3863 | && it->bidi_it.charpos < newpos); | ||
| 3864 | IT_CHARPOS (*it) = it->bidi_it.charpos; | ||
| 3865 | IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos); | ||
| 3866 | } | ||
| 3867 | else | ||
| 3868 | { | ||
| 3869 | IT_CHARPOS (*it) = newpos; | ||
| 3870 | IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos); | ||
| 3871 | } | ||
| 3851 | 3872 | ||
| 3852 | /* If there are before-strings at the start of invisible | 3873 | /* If there are before-strings at the start of invisible |
| 3853 | text, and the text is invisible because of a text | 3874 | text, and the text is invisible because of a text |
| @@ -3877,7 +3898,7 @@ handle_invisible_prop (it) | |||
| 3877 | first invisible character. */ | 3898 | first invisible character. */ |
| 3878 | if (!STRINGP (it->object)) | 3899 | if (!STRINGP (it->object)) |
| 3879 | { | 3900 | { |
| 3880 | it->position.charpos = IT_CHARPOS (*it) - 1; | 3901 | it->position.charpos = newpos - 1; |
| 3881 | it->position.bytepos = CHAR_TO_BYTE (it->position.charpos); | 3902 | it->position.bytepos = CHAR_TO_BYTE (it->position.charpos); |
| 3882 | } | 3903 | } |
| 3883 | it->ellipsis_p = 1; | 3904 | it->ellipsis_p = 1; |
| @@ -6604,11 +6625,11 @@ handle_stop_backwards (it, charpos) | |||
| 6604 | 6625 | ||
| 6605 | next_stop = it->stop_charpos; | 6626 | next_stop = it->stop_charpos; |
| 6606 | it->stop_charpos = it->prev_stop; | 6627 | it->stop_charpos = it->prev_stop; |
| 6607 | handle_stop (it); | ||
| 6608 | it->stop_charpos = next_stop; | ||
| 6609 | it->bidi_p = 1; | 6628 | it->bidi_p = 1; |
| 6610 | it->current = save_current; | 6629 | it->current = save_current; |
| 6611 | it->position = save_position; | 6630 | it->position = save_position; |
| 6631 | handle_stop (it); | ||
| 6632 | it->stop_charpos = next_stop; | ||
| 6612 | } | 6633 | } |
| 6613 | 6634 | ||
| 6614 | /* Load IT with the next display element from current_buffer. Value | 6635 | /* Load IT with the next display element from current_buffer. Value |
| @@ -6660,12 +6681,14 @@ next_element_from_buffer (it) | |||
| 6660 | bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); | 6681 | bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); |
| 6661 | if (it->glyph_row && (it->bidi_it.level_stack[0].level & 1) != 0) | 6682 | if (it->glyph_row && (it->bidi_it.level_stack[0].level & 1) != 0) |
| 6662 | it->glyph_row->reversed_p = 1; | 6683 | it->glyph_row->reversed_p = 1; |
| 6663 | do { | 6684 | do |
| 6664 | /* Now return to buffer position where we were asked to | 6685 | { |
| 6665 | get the next display element, and produce that. */ | 6686 | /* Now return to buffer position where we were asked to |
| 6666 | bidi_get_next_char_visually (&it->bidi_it); | 6687 | get the next display element, and produce that. */ |
| 6667 | } while (it->bidi_it.bytepos != orig_bytepos | 6688 | bidi_get_next_char_visually (&it->bidi_it); |
| 6668 | && it->bidi_it.bytepos < ZV_BYTE); | 6689 | } |
| 6690 | while (it->bidi_it.bytepos != orig_bytepos | ||
| 6691 | && it->bidi_it.bytepos < ZV_BYTE); | ||
| 6669 | } | 6692 | } |
| 6670 | 6693 | ||
| 6671 | it->bidi_it.first_elt = 0; /* paranoia: bidi.c does this */ | 6694 | it->bidi_it.first_elt = 0; /* paranoia: bidi.c does this */ |