Commit 11117830 authored by Eli Zaretskii's avatar Eli Zaretskii

Redesign bidi-aware edge positions of glyph rows, fix bug #6036.

 dispextern.h (struct glyph_row): New members minpos and maxpos.
 (MATRIX_ROW_START_CHARPOS, MATRIX_ROW_START_BYTEPOS)
 (MATRIX_ROW_END_CHARPOS, MATRIX_ROW_END_BYTEPOS): Reference minpos
 and maxpos members instead of start.pos and end.pos, respectively.
 xdisp.c (display_line): Compare IT_CHARPOS with the position in
 row->start.pos, rather than with MATRIX_ROW_START_CHARPOS.
 (cursor_row_p): Use row->end.pos rather than MATRIX_ROW_END_CHARPOS.
 (try_window_reusing_current_matrix, try_window_id): Use
 ROW->minpos rather than ROW->start.pos.
 (init_from_display_pos, init_iterator): Use EMACS_INT for
 character and byte positions.
 (find_row_edges): Renamed from find_row_end.  Accept additional
 arguments for minimum and maximum buffer positions seen by
 display_line for this row.  Don't use iterator to find the
 position following the maximum one; instead, increment the
 position found by display_line directly.  Fix logic; eol_pos
 should be tested before the rest.  Handle the case of characters
 delivered from display vector (bug#6036).  Fix tests related to
 it->method.  Handle the truncated_on_right_p rows.
 (RECORD_MAX_MIN_POS): New macro.
 (display_line): Use it to record the minimum and maximum buffer
 positions for glyphs in the row being assembled.  Record the
 position of the newline that terminates the line.  If word wrap is
 in effect, restore minimum and maximum positions seen up to the
 wrap point, when iterator returns to it.
 (try_window_reusing_current_matrix): Give up if in bidi-reordered
 row and cursor not already at point.  Restore original pre-bidi
 code for unidirectional buffers.
 dispnew.c (increment_row_positions, check_matrix_invariants):
 Increment and check row->start.pos and row->end.pos, in addition
 to MATRIX_ROW_START_CHARPOS and MATRIX_ROW_END_CHARPOS.
 .gdbinit (prowlims): Display row->minpos and row->maxpos.
 Display truncated_on_left_p and truncated_on_right_p flags.
 Formatting fixes.
 (pmtxrows): Display the ordinal number of each row.  Don't display
 rows beyond the last one.
 bidi.c (bidi_cache_iterator_state): Don't zero out new_paragraph:
 it is not copied by bidi_copy_it.
parents 6e83d800 a9f86045
......@@ -616,7 +616,7 @@ Pretty print all glyphs in it->glyph_row.
end
define prowlims
printf "start=%d,end=%d,reversed=%d,cont=%d,at_zv=%d\n", $arg0->start.pos.charpos, $arg0->end.pos.charpos, $arg0->reversed_p, $arg0->continued_p, $arg0->ends_at_zv_p
printf "edges=(%d,%d),r2l=%d,cont=%d,trunc=(%d,%d),at_zv=%d\n", $arg0->minpos.charpos, $arg0->maxpos.charpos, $arg0->reversed_p, $arg0->continued_p, $arg0->truncated_on_left_p, $arg0->truncated_on_right_p, $arg0->ends_at_zv_p
end
document prowlims
Print important attributes of a glyph_row structure.
......@@ -626,10 +626,13 @@ end
define pmtxrows
set $mtx = $arg0
set $gl = $mtx->rows
set $glend = $mtx->rows + $mtx->nrows
set $glend = $mtx->rows + $mtx->nrows - 1
set $i = 0
while ($gl < $glend)
printf "%d: ", $i
prowlims $gl
set $gl = $gl + 1
set $i = $i + 1
end
end
document pmtxrows
......
2010-05-19 Eli Zaretskii <eliz@gnu.org>
Redesign and reimplement bidi-aware edge positions of glyph rows.
* dispextern.h (struct glyph_row): New members minpos and maxpos.
(MATRIX_ROW_START_CHARPOS, MATRIX_ROW_START_BYTEPOS)
(MATRIX_ROW_END_CHARPOS, MATRIX_ROW_END_BYTEPOS): Reference minpos
and maxpos members instead of start.pos and end.pos, respectively.
* xdisp.c (display_line): Compare IT_CHARPOS with the position in
row->start.pos, rather than with MATRIX_ROW_START_CHARPOS.
(cursor_row_p): Use row->end.pos rather than MATRIX_ROW_END_CHARPOS.
(try_window_reusing_current_matrix, try_window_id): Use
ROW->minpos rather than ROW->start.pos.
(init_from_display_pos, init_iterator): Use EMACS_INT for
character and byte positions.
(find_row_edges): Renamed from find_row_end. Accept additional
arguments for minimum and maximum buffer positions seen by
display_line for this row. Don't use iterator to find the
position following the maximum one; instead, increment the
position found by display_line directly. Fix logic; eol_pos
should be tested before the rest. Handle the case of characters
delivered from display vector (bug#6036). Fix tests related to
it->method. Handle the truncated_on_right_p rows.
(RECORD_MAX_MIN_POS): New macro.
(display_line): Use it to record the minimum and maximum buffer
positions for glyphs in the row being assembled. Record the
position of the newline that terminates the line. If word wrap is
in effect, restore minimum and maximum positions seen up to the
wrap point, when iterator returns to it.
(try_window_reusing_current_matrix): Give up if in bidi-reordered
row and cursor not already at point. Restore original pre-bidi
code for unidirectional buffers.
* dispnew.c (increment_row_positions, check_matrix_invariants):
Increment and check row->start.pos and row->end.pos, in addition
to MATRIX_ROW_START_CHARPOS and MATRIX_ROW_END_CHARPOS.
* .gdbinit (prowlims): Display row->minpos and row->maxpos.
Display truncated_on_left_p and truncated_on_right_p flags.
Formatting fixes.
(pmtxrows): Display the ordinal number of each row. Don't display
rows beyond the last one.
* bidi.c (bidi_cache_iterator_state): Don't zero out new_paragraph:
it is not copied by bidi_copy_it.
2010-05-22 Eli Zaretskii <eliz@gnu.org>
* w32.c (sys_write): Break writes into chunks smaller than 32MB.
......@@ -51,8 +98,6 @@
Move static/dynamic dependency stuff to deps.mk/autodeps.mk.
* deps.mk, autodeps.mk: New files, extracted from Makefile.in.
2010-05-19 Eli Zaretskii <eliz@gnu.org>
* bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix
reallocation of the cache. (Bug#6210)
......@@ -175,6 +220,8 @@
* xdisp.c (Fcurrent_bidi_paragraph_direction): New function.
(syms_of_xdisp): Defsubr it.
* cmds.c (Fforward_char, Fbackward_char): Doc fix.
* Makefile.in: Fix MSDOS-related comments.
2010-05-15 Glenn Morris <rgm@gnu.org>
......
......@@ -707,7 +707,6 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved)
bidi_copy_it (&bidi_cache[idx], bidi_it);
if (!resolved)
bidi_cache[idx].resolved_level = -1;
bidi_cache[idx].new_paragraph = 0;
}
else
{
......
......@@ -748,21 +748,29 @@ struct glyph_row
/* First position in this row. This is the text position, including
overlay position information etc, where the display of this row
started, and can thus be less the position of the first glyph
(e.g. due to invisible text or horizontal scrolling). BIDI Note:
This is the smallest character position in the row, but not
necessarily the character that is the leftmost on the display. */
started, and can thus be less than the position of the first
glyph (e.g. due to invisible text or horizontal scrolling).
BIDI Note: In R2L rows, that have its reversed_p flag set, this
position is at or beyond the right edge of the row. */
struct display_pos start;
/* Text position at the end of this row. This is the position after
the last glyph on this row. It can be greater than the last
glyph position + 1, due to truncation, invisible text etc. In an
up-to-date display, this should always be equal to the start
position of the next row. BIDI Note: this is the character whose
buffer position is the largest, but not necessarily the rightmost
one on the display. */
glyph position + 1, due to a newline that ends the line,
truncation, invisible text etc. In an up-to-date display, this
should always be equal to the start position of the next row.
BIDI Note: In R2L rows, this position is at or beyond the left
edge of the row. */
struct display_pos end;
/* The smallest and the largest buffer positions that contributed to
glyphs in this row. Note that due to bidi reordering, these are
in general different from the text positions stored in `start'
and `end' members above, and also different from the buffer
positions recorded in the glyphs displayed the leftmost and
rightmost on the screen. */
struct text_pos minpos, maxpos;
/* Non-zero means the overlay arrow bitmap is on this line.
-1 means use default overlay arrow bitmap, else
it specifies actual fringe bitmap number. */
......@@ -947,16 +955,16 @@ struct glyph_row *matrix_row P_ ((struct glyph_matrix *, int));
displayed by ROW, which is not necessarily the smallest horizontal
position. */
#define MATRIX_ROW_START_CHARPOS(ROW) ((ROW)->start.pos.charpos)
#define MATRIX_ROW_START_BYTEPOS(ROW) ((ROW)->start.pos.bytepos)
#define MATRIX_ROW_START_CHARPOS(ROW) ((ROW)->minpos.charpos)
#define MATRIX_ROW_START_BYTEPOS(ROW) ((ROW)->minpos.bytepos)
/* Return the character/ byte position at which ROW ends. BIDI Note:
this is the largest character/byte position among characters in
ROW, i.e. the last logical-order character displayed by ROW, which
is not necessarily the largest horizontal position. */
#define MATRIX_ROW_END_CHARPOS(ROW) ((ROW)->end.pos.charpos)
#define MATRIX_ROW_END_BYTEPOS(ROW) ((ROW)->end.pos.bytepos)
#define MATRIX_ROW_END_CHARPOS(ROW) ((ROW)->maxpos.charpos)
#define MATRIX_ROW_END_BYTEPOS(ROW) ((ROW)->maxpos.bytepos)
/* Return the vertical position of ROW in MATRIX. */
......@@ -1789,7 +1797,7 @@ struct bidi_it {
EMACS_INT next_en_pos; /* position of next EN char for ET */
EMACS_INT ignore_bn_limit; /* position until which to ignore BNs */
bidi_dir_t sor; /* direction of start-of-run in effect */
int scan_dir; /* direction of text scan */
int scan_dir; /* direction of text scan, 1: forw, -1: back */
int stack_idx; /* index of current data on the stack */
/* Note: Everything from here on is not copied/saved when the bidi
iterator state is saved, pushed, or popped. So only put here
......
......@@ -1188,6 +1188,10 @@ increment_row_positions (row, delta, delta_bytes)
MATRIX_ROW_START_BYTEPOS (row) += delta_bytes;
MATRIX_ROW_END_CHARPOS (row) += delta;
MATRIX_ROW_END_BYTEPOS (row) += delta_bytes;
CHARPOS (row->start.pos) += delta;
BYTEPOS (row->start.pos) += delta_bytes;
CHARPOS (row->end.pos) += delta;
BYTEPOS (row->end.pos) += delta_bytes;
if (!row->enabled_p)
return;
......@@ -1748,13 +1752,19 @@ check_matrix_invariants (w)
/* Check that character and byte positions are in sync. */
xassert (MATRIX_ROW_START_BYTEPOS (row)
== CHAR_TO_BYTE (MATRIX_ROW_START_CHARPOS (row)));
xassert (BYTEPOS (row->start.pos)
== CHAR_TO_BYTE (CHARPOS (row->start.pos)));
/* CHAR_TO_BYTE aborts when invoked for a position > Z. We can
have such a position temporarily in case of a minibuffer
displaying something like `[Sole completion]' at its end. */
if (MATRIX_ROW_END_CHARPOS (row) < BUF_ZV (current_buffer))
xassert (MATRIX_ROW_END_BYTEPOS (row)
== CHAR_TO_BYTE (MATRIX_ROW_END_CHARPOS (row)));
{
xassert (MATRIX_ROW_END_BYTEPOS (row)
== CHAR_TO_BYTE (MATRIX_ROW_END_CHARPOS (row)));
xassert (BYTEPOS (row->end.pos)
== CHAR_TO_BYTE (CHARPOS (row->end.pos)));
}
/* Check that end position of `row' is equal to start position
of next row. */
......@@ -1764,6 +1774,8 @@ check_matrix_invariants (w)
== MATRIX_ROW_START_CHARPOS (next));
xassert (MATRIX_ROW_END_BYTEPOS (row)
== MATRIX_ROW_START_BYTEPOS (next));
xassert (CHARPOS (row->end.pos) == CHARPOS (next->start.pos));
xassert (BYTEPOS (row->end.pos) == BYTEPOS (next->start.pos));
}
row = next;
}
......
This diff is collapsed.
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