From a1344e7d125a094bf49460f1a356f98fa86a8f9f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 25 Jun 2011 19:14:01 +0300 Subject: [PATCH] Initial version of display/overlay strings is working. src/xdisp.c (set_iterator_to_next, get_visually_first_element): Use it->bidi_it.string.schars rather than it->string_nchars when testing whether we're beyond string end, because string_nchars is zero for strings that come from overlays and display properties. src/bidi.c (bidi_cache_iterator_state): Fix a bug with testing character positions against the cached range, when we use a stacked cache. src/dispextern.h (struct iterator_stack_entry): New member paragraph_embedding. src/xdisp.c (push_it, pop_it): Save and restore it. --- src/ChangeLog | 14 ++++++++++++++ src/bidi.c | 2 +- src/dispextern.h | 1 + src/xdisp.c | 12 +++++++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 083aaaaa4bd..8d5275f9702 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,19 @@ 2011-06-25 Eli Zaretskii + * xdisp.c (set_iterator_to_next, get_visually_first_element): Use + it->bidi_it.string.schars rather than it->string_nchars when + testing whether we're beyond string end, because string_nchars is + zero for strings that come from overlays and display properties. + + * bidi.c (bidi_cache_iterator_state): Fix a bug with testing + character positions against the cached range, when we use a + stacked cache. + + * xdisp.c (push_it, pop_it): Save and restore it. + + * dispextern.h (struct iterator_stack_entry): New member + paragraph_embedding. + * xdisp.c (handle_single_display_spec, next_overlay_string) (get_overlay_strings_1, push_display_prop): Set up the bidi iterator for displaying display or overlay strings. diff --git a/src/bidi.c b/src/bidi.c index b518dd45782..0cd8deb47c0 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -481,7 +481,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved) if (idx > bidi_cache_start && (bidi_it->charpos > (bidi_cache[idx - 1].charpos + bidi_cache[idx - 1].nchars) - || bidi_it->charpos < bidi_cache[0].charpos)) + || bidi_it->charpos < bidi_cache[bidi_cache_start].charpos)) { bidi_cache_reset (); idx = bidi_cache_start; diff --git a/src/dispextern.h b/src/dispextern.h index d5479c7a64e..16fa3abdd19 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2251,6 +2251,7 @@ struct it Lisp_Object from_overlay; enum glyph_row_area area; enum it_method method; + bidi_dir_t paragraph_embedding; unsigned multibyte_p : 1; unsigned string_from_display_prop_p : 1; unsigned display_ellipsis_p : 1; diff --git a/src/xdisp.c b/src/xdisp.c index dc9a62fc0b6..3b934547471 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -5255,6 +5255,7 @@ push_it (struct it *it, struct text_pos *position) p->display_ellipsis_p = 0; p->line_wrap = it->line_wrap; p->bidi_p = it->bidi_p; + p->paragraph_embedding = it->paragraph_embedding; ++it->sp; /* Save the state of the bidi iterator as well. */ @@ -5360,6 +5361,7 @@ pop_it (struct it *it) it->string_from_display_prop_p = p->string_from_display_prop_p; it->line_wrap = p->line_wrap; it->bidi_p = p->bidi_p; + it->paragraph_embedding = p->paragraph_embedding; if (it->bidi_p) { bidi_pop_it (&it->bidi_it); @@ -6511,11 +6513,11 @@ set_iterator_to_next (struct it *it, int reseat_p) case GET_FROM_C_STRING: /* Current display element of IT is from a C string. */ if (!it->bidi_p - /* If the string position is beyond string_nchars, it means + /* If the string position is beyond string's end, it means next_element_from_c_string is padding the string with blanks, in which case we bypass the bidi iterator, because it cannot deal with such virtual characters. */ - || IT_CHARPOS (*it) >= it->string_nchars) + || IT_CHARPOS (*it) >= it->bidi_it.string.schars) { IT_BYTEPOS (*it) += it->len; IT_CHARPOS (*it) += 1; @@ -6639,12 +6641,12 @@ set_iterator_to_next (struct it *it, int reseat_p) else { if (!it->bidi_p - /* If the string position is beyond string_nchars, it + /* If the string position is beyond string's end, it means next_element_from_string is padding the string with blanks, in which case we bypass the bidi iterator, because it cannot deal with such virtual characters. */ - || IT_STRING_CHARPOS (*it) >= it->string_nchars) + || IT_STRING_CHARPOS (*it) >= it->bidi_it.string.schars) { IT_STRING_BYTEPOS (*it) += it->len; IT_STRING_CHARPOS (*it) += 1; @@ -6779,7 +6781,7 @@ static void get_visually_first_element (struct it *it) { int string_p = STRINGP (it->string) || it->s; - EMACS_INT eob = (string_p ? it->string_nchars : ZV); + EMACS_INT eob = (string_p ? it->bidi_it.string.schars : ZV); EMACS_INT bob = (string_p ? 0 : BEGV); if (STRINGP (it->string)) -- 2.39.5