Commit 5009f85e authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Finish and debug display of invisible text.

 xdisp.c (handle_invisible_prop): If we are `reseat'ed, init the
 paragraph direction and set the `reversed_p' flag in the IT's
 glyph row.  Fix exit conditions of the loop that skips invisible
 text.  Update IT->prev_stop after skipping invisible text.  Check
 for additional overlays at IT->stop_charpos, not at start_pos.

Clean up the mess with setting the glyph row reversed_p flag.
 dispnew.c (prepare_desired_row): Preserve the reversed_p flag.

 bidi.c (bidi_cache_find): Use bidi_copy_it instead of copying
 the whole struct (which includes uninitialized parts).
 (bidi_init_it): Don't initialize bidi_it->paragraph_dir.

 xdisp.c (display_line): Remove misplaced setting of
 row->reversed_p flags.  Copy the reversed_p flag to the next glyph
 row.
 (next_element_from_buffer): Check bidi_it.paragraph_dir rather
 than level_stack[0].level.  Reset the reversed_p flag for non-R2L
 paragraphs.
parent 151b77c2
2010-01-25 Eli Zaretskii <eliz@gnu.org>
Clean up the mess with setting the glyph row reversed_p flag.
* dispnew.c (prepare_desired_row): Preserve the reversed_p flag.
* bidi.c (bidi_cache_find): Use bidi_copy_it instead of copying
the whole struct (which includes uninitialized parts).
(bidi_init_it): Don't initialize bidi_it->paragraph_dir.
* xdisp.c (display_line): Remove misplaced setting of
row->reversed_p flags. Copy the reversed_p flag to the next glyph
row.
(next_element_from_buffer): Check bidi_it.paragraph_dir rather
than level_stack[0].level. Reset the reversed_p flag for non-R2L
paragraphs.
Fix display of invisible text.
* xdisp.c (handle_invisible_prop): If we are `reseat'ed, init the
paragraph direction and set the `reversed_p' flag in the IT's
glyph row. Fix exit conditions of the loop that skips invisible
text. Update IT->prev_stop after skipping invisible text. Check
for additional overlays at IT->stop_charpos, not at start_pos.
(next_element_from_buffer):
2010-01-16 Eli Zaretskii <eliz@gnu.org> 2010-01-16 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (handle_invisible_prop): Under bidi iteration, skip * xdisp.c (handle_invisible_prop): Under bidi iteration, skip
......
...@@ -715,7 +715,7 @@ bidi_cache_find (int charpos, int level, struct bidi_it *bidi_it) ...@@ -715,7 +715,7 @@ bidi_cache_find (int charpos, int level, struct bidi_it *bidi_it)
{ {
bidi_dir_t current_scan_dir = bidi_it->scan_dir; bidi_dir_t current_scan_dir = bidi_it->scan_dir;
*bidi_it = bidi_cache[i]; bidi_copy_it (bidi_it, &bidi_cache[i]);
bidi_cache_last_idx = i; bidi_cache_last_idx = i;
/* Don't let scan direction from from the cached state override /* Don't let scan direction from from the cached state override
the current scan direction. */ the current scan direction. */
...@@ -971,7 +971,6 @@ bidi_init_it (EMACS_INT charpos, EMACS_INT bytepos, struct bidi_it *bidi_it) ...@@ -971,7 +971,6 @@ bidi_init_it (EMACS_INT charpos, EMACS_INT bytepos, struct bidi_it *bidi_it)
bidi_set_paragraph_end (bidi_it); bidi_set_paragraph_end (bidi_it);
bidi_it->new_paragraph = 1; bidi_it->new_paragraph = 1;
bidi_it->separator_limit = -1; bidi_it->separator_limit = -1;
bidi_it->paragraph_dir = NEUTRAL_DIR;
bidi_it->type = NEUTRAL_B; bidi_it->type = NEUTRAL_B;
bidi_it->type_after_w1 = UNKNOWN_BT; bidi_it->type_after_w1 = UNKNOWN_BT;
bidi_it->orig_type = UNKNOWN_BT; bidi_it->orig_type = UNKNOWN_BT;
......
...@@ -1388,8 +1388,11 @@ prepare_desired_row (row) ...@@ -1388,8 +1388,11 @@ prepare_desired_row (row)
{ {
if (!row->enabled_p) if (!row->enabled_p)
{ {
unsigned rp = row->reversed_p;
clear_glyph_row (row); clear_glyph_row (row);
row->enabled_p = 1; row->enabled_p = 1;
row->reversed_p = rp;
} }
} }
......
...@@ -3789,7 +3789,7 @@ handle_invisible_prop (it) ...@@ -3789,7 +3789,7 @@ handle_invisible_prop (it)
   
/* First of all, is there invisible text at this position? */ /* First of all, is there invisible text at this position? */
tem = start_charpos = IT_CHARPOS (*it); tem = start_charpos = IT_CHARPOS (*it);
pos = make_number (IT_CHARPOS (*it)); pos = make_number (tem);
prop = get_char_property_and_overlay (pos, Qinvisible, it->window, prop = get_char_property_and_overlay (pos, Qinvisible, it->window,
&overlay); &overlay);
invis_p = TEXT_PROP_MEANS_INVISIBLE (prop); invis_p = TEXT_PROP_MEANS_INVISIBLE (prop);
...@@ -3852,17 +3852,43 @@ handle_invisible_prop (it) ...@@ -3852,17 +3852,43 @@ handle_invisible_prop (it)
embedding level. Therefore, we need to skip embedding level. Therefore, we need to skip
invisible text using the bidi iterator, starting at invisible text using the bidi iterator, starting at
IT's current position, until we find ourselves IT's current position, until we find ourselves
outside the invisible text. This avoids affecting outside the invisible text. Skipping invisible text
the visual order of the displayed text when invisible _after_ bidi iteration avoids affecting the visual
properties are added or removed. */ order of the displayed text when invisible properties
are added or removed. */
if (it->bidi_it.first_elt)
{
/* If we were `reseat'ed to a new paragraph,
determine the paragraph base direction. We need
to do it now because next_element_from_buffer may
not have a chance to do it, if we are going to
skip any text at the beginning, which resets the
FIRST_ELT flag. */
bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
/* If the paragraph base direction is R2L, its
glyphs should be reversed. */
if (it->glyph_row)
{
if (it->bidi_it.paragraph_dir == R2L)
it->glyph_row->reversed_p = 1;
else
it->glyph_row->reversed_p = 0;
}
}
do do
{ {
bidi_get_next_char_visually (&it->bidi_it); bidi_get_next_char_visually (&it->bidi_it);
} }
while (start_charpos <= it->bidi_it.charpos while (it->stop_charpos <= it->bidi_it.charpos
&& it->bidi_it.charpos < newpos); && it->bidi_it.charpos < newpos);
IT_CHARPOS (*it) = it->bidi_it.charpos; IT_CHARPOS (*it) = it->bidi_it.charpos;
IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos); IT_BYTEPOS (*it) = it->bidi_it.bytepos;
/* If we overstepped NEWPOS, record its position in the
iterator, so that we skip invisible text if later the
bidi iteration lands us in the invisible region
again. */
if (IT_CHARPOS (*it) >= newpos)
it->prev_stop = newpos;
} }
else else
{ {
...@@ -3877,7 +3903,7 @@ handle_invisible_prop (it) ...@@ -3877,7 +3903,7 @@ handle_invisible_prop (it)
overlay property instead of a text property, this is overlay property instead of a text property, this is
already handled in the overlay code.) */ already handled in the overlay code.) */
if (NILP (overlay) if (NILP (overlay)
&& get_overlay_strings (it, start_charpos)) && get_overlay_strings (it, it->stop_charpos))
{ {
handled = HANDLED_RECOMPUTE_PROPS; handled = HANDLED_RECOMPUTE_PROPS;
it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p; it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p;
...@@ -6200,7 +6226,16 @@ set_iterator_to_next (it, reseat_p) ...@@ -6200,7 +6226,16 @@ set_iterator_to_next (it, reseat_p)
/* If this is a new paragraph, determine its base /* If this is a new paragraph, determine its base
direction (a.k.a. its base embedding level). */ direction (a.k.a. its base embedding level). */
if (it->bidi_it.new_paragraph) if (it->bidi_it.new_paragraph)
bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); {
bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
if (it->glyph_row)
{
if (it->bidi_it.paragraph_dir == R2L)
it->glyph_row->reversed_p = 1;
else
it->glyph_row->reversed_p = 0;
}
}
bidi_get_next_char_visually (&it->bidi_it); bidi_get_next_char_visually (&it->bidi_it);
IT_BYTEPOS (*it) = it->bidi_it.bytepos; IT_BYTEPOS (*it) = it->bidi_it.bytepos;
IT_CHARPOS (*it) = it->bidi_it.charpos; IT_CHARPOS (*it) = it->bidi_it.charpos;
...@@ -6663,8 +6698,13 @@ next_element_from_buffer (it) ...@@ -6663,8 +6698,13 @@ next_element_from_buffer (it)
bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
/* If the paragraph base direction is R2L, its glyphs should /* If the paragraph base direction is R2L, its glyphs should
be reversed. */ be reversed. */
if (it->glyph_row && (it->bidi_it.level_stack[0].level & 1) != 0) if (it->glyph_row)
it->glyph_row->reversed_p = 1; {
if (it->bidi_it.paragraph_dir == R2L)
it->glyph_row->reversed_p = 1;
else
it->glyph_row->reversed_p = 0;
}
bidi_get_next_char_visually (&it->bidi_it); bidi_get_next_char_visually (&it->bidi_it);
} }
else else
...@@ -6679,8 +6719,13 @@ next_element_from_buffer (it) ...@@ -6679,8 +6719,13 @@ next_element_from_buffer (it)
it->bidi_it.charpos = IT_CHARPOS (*it); it->bidi_it.charpos = IT_CHARPOS (*it);
it->bidi_it.bytepos = IT_BYTEPOS (*it); it->bidi_it.bytepos = IT_BYTEPOS (*it);
bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it); bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
if (it->glyph_row && (it->bidi_it.level_stack[0].level & 1) != 0) if (it->glyph_row)
it->glyph_row->reversed_p = 1; {
if (it->bidi_it.paragraph_dir == R2L)
it->glyph_row->reversed_p = 1;
else
it->glyph_row->reversed_p = 0;
}
do do
{ {
/* Now return to buffer position where we were asked to /* Now return to buffer position where we were asked to
...@@ -17028,10 +17073,6 @@ display_line (it) ...@@ -17028,10 +17073,6 @@ display_line (it)
row->displays_text_p = 1; row->displays_text_p = 1;
row->starts_in_middle_of_char_p = it->starts_in_middle_of_char_p; row->starts_in_middle_of_char_p = it->starts_in_middle_of_char_p;
it->starts_in_middle_of_char_p = 0; it->starts_in_middle_of_char_p = 0;
/* If the paragraph base direction is R2L, its glyphs should be
reversed. */
if (it->bidi_p && (it->bidi_it.level_stack[0].level & 1) != 0)
row->reversed_p = 1;
   
/* Arrange the overlays nicely for our purposes. Usually, we call /* Arrange the overlays nicely for our purposes. Usually, we call
display_line on only one line at a time, in which case this display_line on only one line at a time, in which case this
...@@ -17566,6 +17607,10 @@ display_line (it) ...@@ -17566,6 +17607,10 @@ display_line (it)
it->current_y += row->height; it->current_y += row->height;
++it->vpos; ++it->vpos;
++it->glyph_row; ++it->glyph_row;
/* The next row should use same value of the reversed_p flag as this
one. set_iterator_to_next decides when it's a new paragraph and
recomputes the value of the flag accordingly. */
it->glyph_row->reversed_p = row->reversed_p;
it->start = row_end; it->start = row_end;
return row->displays_text_p; return row->displays_text_p;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment