aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2010-05-19 23:24:21 +0300
committerEli Zaretskii2010-05-19 23:24:21 +0300
commit0416466c4d8c8cc3011f81cd488ba4f629e70288 (patch)
treefcd565e80e4046bd065c77105e54841a2627122a /src
parentd36fe2375ad338a799038a5afee82d00e6b6b7ac (diff)
downloademacs-0416466c4d8c8cc3011f81cd488ba4f629e70288.tar.gz
emacs-0416466c4d8c8cc3011f81cd488ba4f629e70288.zip
Completed initial debugging and testing of reimplemented cursor motion.
.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. xdisp.c (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. If word wrap is in effect, restore minimum and maximum positions seen up to the wrap point, when iterator returns to it. (find_row_edges): Fix logic; eol_pos should be tested before the rest. (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. bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix reallocation of the cache. (Bug#6210) (bidi_cache_iterator_state): Don't zero out new_paragraph (it is not copied by bidi_copy_it).
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit7
-rw-r--r--src/ChangeLog24
-rw-r--r--src/bidi.c11
-rw-r--r--src/xdisp.c149
4 files changed, 97 insertions, 94 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index 5ecdaa4a572..1fd7e288736 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -616,7 +616,7 @@ Pretty print all glyphs in it->glyph_row.
616end 616end
617 617
618define prowlims 618define prowlims
619 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 619 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
620end 620end
621document prowlims 621document prowlims
622Print important attributes of a glyph_row structure. 622Print important attributes of a glyph_row structure.
@@ -626,10 +626,13 @@ end
626define pmtxrows 626define pmtxrows
627 set $mtx = $arg0 627 set $mtx = $arg0
628 set $gl = $mtx->rows 628 set $gl = $mtx->rows
629 set $glend = $mtx->rows + $mtx->nrows 629 set $glend = $mtx->rows + $mtx->nrows - 1
630 set $i = 0
630 while ($gl < $glend) 631 while ($gl < $glend)
632 printf "%d: ", $i
631 prowlims $gl 633 prowlims $gl
632 set $gl = $gl + 1 634 set $gl = $gl + 1
635 set $i = $i + 1
633 end 636 end
634end 637end
635document pmtxrows 638document pmtxrows
diff --git a/src/ChangeLog b/src/ChangeLog
index fe30d07692a..1947f9598f0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,27 @@
12010-05-19 Eli Zaretskii <eliz@gnu.org>
2
3 * .gdbinit (prowlims): Display row->minpos and row->maxpos.
4 Display truncated_on_left_p and truncated_on_right_p flags.
5 Formatting fixes.
6 (pmtxrows): Display the ordinal number of each row. Don't display
7 rows beyond the last one.
8
9 * xdisp.c (RECORD_MAX_MIN_POS): New macro.
10 (display_line): Use it to record the minimum and maximum buffer
11 positions for glyphs in the row being assembled. If word wrap is
12 in effect, restore minimum and maximum positions seen up to the
13 wrap point, when iterator returns to it.
14 (find_row_edges): Fix logic; eol_pos should be tested before the
15 rest.
16 (try_window_reusing_current_matrix): Give up if in bidi-reordered
17 row and cursor not already at point. Restore original pre-bidi
18 code for unidirectional buffers.
19
20 * bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix
21 reallocation of the cache. (Bug#6210)
22 (bidi_cache_iterator_state): Don't zero out new_paragraph (it is
23 not copied by bidi_copy_it).
24
12010-05-18 Eli Zaretskii <eliz@gnu.org> 252010-05-18 Eli Zaretskii <eliz@gnu.org>
2 26
3 * dispextern.h (struct glyph_row): New members minpos and maxpos. 27 * dispextern.h (struct glyph_row): New members minpos and maxpos.
diff --git a/src/bidi.c b/src/bidi.c
index dbc95608fea..bdeccfee97c 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -543,6 +543,7 @@ bidi_copy_it (struct bidi_it *to, struct bidi_it *from)
543#define BIDI_CACHE_CHUNK 200 543#define BIDI_CACHE_CHUNK 200
544static struct bidi_it *bidi_cache; 544static struct bidi_it *bidi_cache;
545static size_t bidi_cache_size = 0; 545static size_t bidi_cache_size = 0;
546static size_t elsz = sizeof (struct bidi_it);
546static int bidi_cache_idx; /* next unused cache slot */ 547static int bidi_cache_idx; /* next unused cache slot */
547static int bidi_cache_last_idx; /* slot of last cache hit */ 548static int bidi_cache_last_idx; /* slot of last cache hit */
548 549
@@ -558,8 +559,9 @@ bidi_cache_shrink (void)
558{ 559{
559 if (bidi_cache_size > BIDI_CACHE_CHUNK) 560 if (bidi_cache_size > BIDI_CACHE_CHUNK)
560 { 561 {
561 bidi_cache_size = BIDI_CACHE_CHUNK * sizeof (struct bidi_it); 562 bidi_cache_size = BIDI_CACHE_CHUNK;
562 bidi_cache = (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size); 563 bidi_cache =
564 (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz);
563 } 565 }
564 bidi_cache_reset (); 566 bidi_cache_reset ();
565} 567}
@@ -688,9 +690,9 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved)
688 /* Enlarge the cache as needed. */ 690 /* Enlarge the cache as needed. */
689 if (idx >= bidi_cache_size) 691 if (idx >= bidi_cache_size)
690 { 692 {
691 bidi_cache_size += BIDI_CACHE_CHUNK * sizeof (struct bidi_it); 693 bidi_cache_size += BIDI_CACHE_CHUNK;
692 bidi_cache = 694 bidi_cache =
693 (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size); 695 (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz);
694 } 696 }
695 /* Character positions should correspond to cache positions 1:1. 697 /* Character positions should correspond to cache positions 1:1.
696 If we are outside the range of cached positions, the cache is 698 If we are outside the range of cached positions, the cache is
@@ -705,7 +707,6 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved)
705 bidi_copy_it (&bidi_cache[idx], bidi_it); 707 bidi_copy_it (&bidi_cache[idx], bidi_it);
706 if (!resolved) 708 if (!resolved)
707 bidi_cache[idx].resolved_level = -1; 709 bidi_cache[idx].resolved_level = -1;
708 bidi_cache[idx].new_paragraph = 0;
709 } 710 }
710 else 711 else
711 { 712 {
diff --git a/src/xdisp.c b/src/xdisp.c
index 9cd562e8e3d..47c08d0df79 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -15293,39 +15293,26 @@ try_window_reusing_current_matrix (w)
15293 { 15293 {
15294 struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos; 15294 struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos;
15295 struct glyph *end = glyph + row->used[TEXT_AREA]; 15295 struct glyph *end = glyph + row->used[TEXT_AREA];
15296 struct glyph *orig_glyph = glyph;
15297 struct cursor_pos orig_cursor = w->cursor;
15298 15296
15299 for (; glyph < end 15297 /* Can't use this optimization with bidi-reordered glyph
15300 && (!BUFFERP (glyph->object) 15298 rows, unless cursor is already at point. */
15301 || glyph->charpos != PT); 15299 if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering))
15302 glyph++)
15303 { 15300 {
15304 w->cursor.hpos++; 15301 if (!(w->cursor.hpos >= 0
15305 w->cursor.x += glyph->pixel_width; 15302 && w->cursor.hpos < row->used[TEXT_AREA]
15306 } 15303 && BUFFERP (glyph->object)
15307 /* With bidi reordering, charpos changes non-linearly 15304 && glyph->charpos == PT))
15308 with hpos, so the right glyph could be to the 15305 return 0;
15309 left. */
15310 if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering)
15311 && (!BUFFERP (glyph->object) || glyph->charpos != PT))
15312 {
15313 struct glyph *start_glyph = row->glyphs[TEXT_AREA];
15314
15315 glyph = orig_glyph - 1;
15316 orig_cursor.hpos--;
15317 orig_cursor.x -= glyph->pixel_width;
15318 for (; glyph >= start_glyph
15319 && (!BUFFERP (glyph->object)
15320 || glyph->charpos != PT);
15321 glyph--)
15322 {
15323 w->cursor.hpos--;
15324 w->cursor.x -= glyph->pixel_width;
15325 }
15326 if (BUFFERP (glyph->object) && glyph->charpos == PT)
15327 w->cursor = orig_cursor;
15328 } 15306 }
15307 else
15308 for (; glyph < end
15309 && (!BUFFERP (glyph->object)
15310 || glyph->charpos < PT);
15311 glyph++)
15312 {
15313 w->cursor.hpos++;
15314 w->cursor.x += glyph->pixel_width;
15315 }
15329 } 15316 }
15330 } 15317 }
15331 15318
@@ -17530,14 +17517,7 @@ find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos)
17530 /* ROW->minpos is the value of min_pos, the minimal buffer position 17517 /* ROW->minpos is the value of min_pos, the minimal buffer position
17531 we have in ROW. */ 17518 we have in ROW. */
17532 if (min_pos <= ZV) 17519 if (min_pos <= ZV)
17533 { 17520 SET_TEXT_POS (row->minpos, min_pos, min_bpos);
17534 SET_TEXT_POS (row->minpos, min_pos, min_bpos);
17535 if (max_pos == 0)
17536 {
17537 max_pos = min_pos;
17538 max_bpos = min_bpos;
17539 }
17540 }
17541 else 17521 else
17542 { 17522 {
17543 /* We didn't find _any_ valid buffer positions in any of the 17523 /* We didn't find _any_ valid buffer positions in any of the
@@ -17554,12 +17534,11 @@ find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos)
17554 /* Here are the various use-cases for ending the row, and the 17534 /* Here are the various use-cases for ending the row, and the
17555 corresponding values for ROW->maxpos: 17535 corresponding values for ROW->maxpos:
17556 17536
17557 Empty line min_pos + 1
17558 Line ends in a newline from buffer eol_pos + 1 17537 Line ends in a newline from buffer eol_pos + 1
17559 Line is continued from buffer max_pos + 1 17538 Line is continued from buffer max_pos + 1
17560 Line ends in a newline from string max_pos 17539 Line ends in a newline from string max_pos
17561 Line is continued from string max_pos 17540 Line is continued from string max_pos
17562 Line is entirely from a string min_pos 17541 Line is entirely from a string min_pos == max_pos
17563 Line that ends at ZV ZV 17542 Line that ends at ZV ZV
17564 17543
17565 If you discover other use-cases, please add them here as 17544 If you discover other use-cases, please add them here as
@@ -17568,16 +17547,7 @@ find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos)
17568 row->maxpos = it->current.pos; 17547 row->maxpos = it->current.pos;
17569 else if (row->used[TEXT_AREA]) 17548 else if (row->used[TEXT_AREA])
17570 { 17549 {
17571 if (max_pos == min_pos) 17550 if (CHARPOS (it->eol_pos) > 0)
17572 {
17573 if (it->method == GET_FROM_BUFFER)
17574 /* Empty line, which stands for a newline. */
17575 SET_TEXT_POS (row->maxpos, min_pos + 1, min_bpos + 1);
17576 else
17577 /* A line that is entirely from a string. */
17578 row->maxpos = row->minpos;
17579 }
17580 else if (CHARPOS (it->eol_pos) > 0)
17581 SET_TEXT_POS (row->maxpos, 17551 SET_TEXT_POS (row->maxpos,
17582 CHARPOS (it->eol_pos) + 1, BYTEPOS (it->eol_pos) + 1); 17552 CHARPOS (it->eol_pos) + 1, BYTEPOS (it->eol_pos) + 1);
17583 else if (row->continued_p) 17553 else if (row->continued_p)
@@ -17592,6 +17562,9 @@ find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos)
17592 } 17562 }
17593 else if (row->ends_in_newline_from_string_p) 17563 else if (row->ends_in_newline_from_string_p)
17594 SET_TEXT_POS (row->maxpos, max_pos, max_bpos); 17564 SET_TEXT_POS (row->maxpos, max_pos, max_bpos);
17565 else if (max_pos == min_pos && it->method != GET_FROM_BUFFER)
17566 /* A line that is entirely from a string/image/stretch... */
17567 row->maxpos = row->minpos;
17595 else 17568 else
17596 abort (); 17569 abort ();
17597 } 17570 }
@@ -17616,6 +17589,8 @@ display_line (it)
17616 int wrap_row_used = -1, wrap_row_ascent, wrap_row_height; 17589 int wrap_row_used = -1, wrap_row_ascent, wrap_row_height;
17617 int wrap_row_phys_ascent, wrap_row_phys_height; 17590 int wrap_row_phys_ascent, wrap_row_phys_height;
17618 int wrap_row_extra_line_spacing; 17591 int wrap_row_extra_line_spacing;
17592 EMACS_INT wrap_row_min_pos, wrap_row_min_bpos;
17593 EMACS_INT wrap_row_max_pos, wrap_row_max_bpos;
17619 int cvpos; 17594 int cvpos;
17620 EMACS_INT min_pos = ZV + 1, min_bpos, max_pos = 0, max_bpos; 17595 EMACS_INT min_pos = ZV + 1, min_bpos, max_pos = 0, max_bpos;
17621 17596
@@ -17674,6 +17649,23 @@ display_line (it)
17674 row->phys_height = it->max_phys_ascent + it->max_phys_descent; 17649 row->phys_height = it->max_phys_ascent + it->max_phys_descent;
17675 row->extra_line_spacing = it->max_extra_line_spacing; 17650 row->extra_line_spacing = it->max_extra_line_spacing;
17676 17651
17652/* Utility macro to record max and min buffer positions seen until now. */
17653#define RECORD_MAX_MIN_POS(IT) \
17654 do \
17655 { \
17656 if (IT_CHARPOS (*(IT)) < min_pos) \
17657 { \
17658 min_pos = IT_CHARPOS (*(IT)); \
17659 min_bpos = IT_BYTEPOS (*(IT)); \
17660 } \
17661 if (IT_CHARPOS (*(IT)) > max_pos) \
17662 { \
17663 max_pos = IT_CHARPOS (*(IT)); \
17664 max_bpos = IT_BYTEPOS (*(IT)); \
17665 } \
17666 } \
17667 while (0)
17668
17677 /* Loop generating characters. The loop is left with IT on the next 17669 /* Loop generating characters. The loop is left with IT on the next
17678 character to display. */ 17670 character to display. */
17679 while (1) 17671 while (1)
@@ -17743,6 +17735,10 @@ display_line (it)
17743 wrap_row_phys_ascent = row->phys_ascent; 17735 wrap_row_phys_ascent = row->phys_ascent;
17744 wrap_row_phys_height = row->phys_height; 17736 wrap_row_phys_height = row->phys_height;
17745 wrap_row_extra_line_spacing = row->extra_line_spacing; 17737 wrap_row_extra_line_spacing = row->extra_line_spacing;
17738 wrap_row_min_pos = min_pos;
17739 wrap_row_min_bpos = min_bpos;
17740 wrap_row_max_pos = max_pos;
17741 wrap_row_max_bpos = max_bpos;
17746 may_wrap = 0; 17742 may_wrap = 0;
17747 } 17743 }
17748 } 17744 }
@@ -17793,6 +17789,10 @@ display_line (it)
17793 it->max_extra_line_spacing); 17789 it->max_extra_line_spacing);
17794 if (it->current_x - it->pixel_width < it->first_visible_x) 17790 if (it->current_x - it->pixel_width < it->first_visible_x)
17795 row->x = x - it->first_visible_x; 17791 row->x = x - it->first_visible_x;
17792 /* Record the maximum and minimum buffer positions seen so
17793 far in glyphs that will be displayed by this row. */
17794 if (it->bidi_p)
17795 RECORD_MAX_MIN_POS (it);
17796 } 17796 }
17797 else 17797 else
17798 { 17798 {
@@ -17826,6 +17826,11 @@ display_line (it)
17826 it->current_x = new_x; 17826 it->current_x = new_x;
17827 it->continuation_lines_width += new_x; 17827 it->continuation_lines_width += new_x;
17828 ++it->hpos; 17828 ++it->hpos;
17829 /* Record the maximum and minimum buffer
17830 positions seen so far in glyphs that will be
17831 displayed by this row. */
17832 if (it->bidi_p)
17833 RECORD_MAX_MIN_POS (it);
17829 if (i == nglyphs - 1) 17834 if (i == nglyphs - 1)
17830 { 17835 {
17831 /* If line-wrap is on, check if a previous 17836 /* If line-wrap is on, check if a previous
@@ -17857,27 +17862,6 @@ display_line (it)
17857 } 17862 }
17858 } 17863 }
17859 } 17864 }
17860
17861 /* Record the maximum and minimum buffer
17862 positions seen so far in glyphs that will be
17863 displayed by this row. */
17864 if (it->bidi_p)
17865 {
17866 if (BUFFERP (glyph->object)
17867 || INTEGERP (glyph->object))
17868 {
17869 if (IT_CHARPOS (*it) < min_pos)
17870 {
17871 min_pos = IT_CHARPOS (*it);
17872 min_bpos = IT_BYTEPOS (*it);
17873 }
17874 if (IT_CHARPOS (*it) > max_pos)
17875 {
17876 max_pos = IT_CHARPOS (*it);
17877 max_bpos = IT_BYTEPOS (*it);
17878 }
17879 }
17880 }
17881 } 17865 }
17882 else if (CHAR_GLYPH_PADDING_P (*glyph) 17866 else if (CHAR_GLYPH_PADDING_P (*glyph)
17883 && !FRAME_WINDOW_P (it->f)) 17867 && !FRAME_WINDOW_P (it->f))
@@ -17921,6 +17905,10 @@ display_line (it)
17921 row->phys_ascent = wrap_row_phys_ascent; 17905 row->phys_ascent = wrap_row_phys_ascent;
17922 row->phys_height = wrap_row_phys_height; 17906 row->phys_height = wrap_row_phys_height;
17923 row->extra_line_spacing = wrap_row_extra_line_spacing; 17907 row->extra_line_spacing = wrap_row_extra_line_spacing;
17908 min_pos = wrap_row_min_pos;
17909 min_bpos = wrap_row_min_bpos;
17910 max_pos = wrap_row_max_pos;
17911 max_bpos = wrap_row_max_bpos;
17924 row->continued_p = 1; 17912 row->continued_p = 1;
17925 row->ends_at_zv_p = 0; 17913 row->ends_at_zv_p = 0;
17926 row->exact_window_width_line_p = 0; 17914 row->exact_window_width_line_p = 0;
@@ -17987,22 +17975,7 @@ display_line (it)
17987 seen so far in glyphs that will be displayed by 17975 seen so far in glyphs that will be displayed by
17988 this row. */ 17976 this row. */
17989 if (it->bidi_p) 17977 if (it->bidi_p)
17990 { 17978 RECORD_MAX_MIN_POS (it);
17991 if (BUFFERP (glyph->object)
17992 || INTEGERP (glyph->object))
17993 {
17994 if (IT_CHARPOS (*it) < min_pos)
17995 {
17996 min_pos = IT_CHARPOS (*it);
17997 min_bpos = IT_BYTEPOS (*it);
17998 }
17999 if (IT_CHARPOS (*it) > max_pos)
18000 {
18001 max_pos = IT_CHARPOS (*it);
18002 max_bpos = IT_BYTEPOS (*it);
18003 }
18004 }
18005 }
18006 17979
18007 if (x < it->first_visible_x) 17980 if (x < it->first_visible_x)
18008 /* Glyph is partially visible, i.e. row starts at 17981 /* Glyph is partially visible, i.e. row starts at
@@ -18261,6 +18234,8 @@ display_line (it)
18261 it->glyph_row->reversed_p = row->reversed_p; 18234 it->glyph_row->reversed_p = row->reversed_p;
18262 it->start = row->end; 18235 it->start = row->end;
18263 return row->displays_text_p; 18236 return row->displays_text_p;
18237
18238#undef RECORD_MAX_MIN_POS
18264} 18239}
18265 18240
18266DEFUN ("current-bidi-paragraph-direction", Fcurrent_bidi_paragraph_direction, 18241DEFUN ("current-bidi-paragraph-direction", Fcurrent_bidi_paragraph_direction,