comparison src/xdisp.c @ 108760:f528b6459bdd

merge trunk
author Kenichi Handa <handa@etlken>
date Tue, 25 May 2010 09:35:50 +0900
parents 0bb727f1d547 3339da3cfeb3
children 78199a49c4bf
comparison
equal deleted inserted replaced
108759:0bb727f1d547 108760:f528b6459bdd
2596 2596
2597 void 2597 void
2598 init_iterator (it, w, charpos, bytepos, row, base_face_id) 2598 init_iterator (it, w, charpos, bytepos, row, base_face_id)
2599 struct it *it; 2599 struct it *it;
2600 struct window *w; 2600 struct window *w;
2601 int charpos, bytepos; 2601 EMACS_INT charpos, bytepos;
2602 struct glyph_row *row; 2602 struct glyph_row *row;
2603 enum face_id base_face_id; 2603 enum face_id base_face_id;
2604 { 2604 {
2605 int highlight_region_p; 2605 int highlight_region_p;
2606 enum face_id remapped_base_face_id = base_face_id; 2606 enum face_id remapped_base_face_id = base_face_id;
3010 init_from_display_pos (it, w, pos) 3010 init_from_display_pos (it, w, pos)
3011 struct it *it; 3011 struct it *it;
3012 struct window *w; 3012 struct window *w;
3013 struct display_pos *pos; 3013 struct display_pos *pos;
3014 { 3014 {
3015 int charpos = CHARPOS (pos->pos), bytepos = BYTEPOS (pos->pos); 3015 EMACS_INT charpos = CHARPOS (pos->pos), bytepos = BYTEPOS (pos->pos);
3016 int i, overlay_strings_with_newlines = 0; 3016 int i, overlay_strings_with_newlines = 0;
3017 3017
3018 /* If POS specifies a position in a display vector, this might 3018 /* If POS specifies a position in a display vector, this might
3019 be for an ellipsis displayed for invisible text. We won't 3019 be for an ellipsis displayed for invisible text. We won't
3020 get the iterator set up for delivering that ellipsis unless 3020 get the iterator set up for delivering that ellipsis unless
12484 /* If we just did a pending size change, or have additional 12484 /* If we just did a pending size change, or have additional
12485 visible frames, redisplay again. */ 12485 visible frames, redisplay again. */
12486 if (windows_or_buffers_changed && !pause) 12486 if (windows_or_buffers_changed && !pause)
12487 goto retry; 12487 goto retry;
12488 12488
12489 /* Clear the face cache eventually. */ 12489 /* Clear the face and image caches.
12490 if (consider_all_windows_p) 12490
12491 { 12491 We used to do this only if consider_all_windows_p. But the cache
12492 if (clear_face_cache_count > CLEAR_FACE_CACHE_COUNT) 12492 needs to be cleared if a timer creates images in the current
12493 { 12493 buffer (e.g. the test case in Bug#6230). */
12494 clear_face_cache (0); 12494
12495 clear_face_cache_count = 0; 12495 if (clear_face_cache_count > CLEAR_FACE_CACHE_COUNT)
12496 } 12496 {
12497 clear_face_cache (0);
12498 clear_face_cache_count = 0;
12499 }
12500
12497 #ifdef HAVE_WINDOW_SYSTEM 12501 #ifdef HAVE_WINDOW_SYSTEM
12498 if (clear_image_cache_count > CLEAR_IMAGE_CACHE_COUNT) 12502 if (clear_image_cache_count > CLEAR_IMAGE_CACHE_COUNT)
12499 { 12503 {
12500 clear_image_caches (Qnil); 12504 clear_image_caches (Qnil);
12501 clear_image_cache_count = 0; 12505 clear_image_cache_count = 0;
12502 } 12506 }
12503 #endif /* HAVE_WINDOW_SYSTEM */ 12507 #endif /* HAVE_WINDOW_SYSTEM */
12504 }
12505 12508
12506 end_of_redisplay: 12509 end_of_redisplay:
12507 unbind_to (count, Qnil); 12510 unbind_to (count, Qnil);
12508 RESUME_POLLING; 12511 RESUME_POLLING;
12509 } 12512 }
14957 return 0; 14960 return 0;
14958 14961
14959 /* The variable new_start now holds the new window start. The old 14962 /* The variable new_start now holds the new window start. The old
14960 start `start' can be determined from the current matrix. */ 14963 start `start' can be determined from the current matrix. */
14961 SET_TEXT_POS_FROM_MARKER (new_start, w->start); 14964 SET_TEXT_POS_FROM_MARKER (new_start, w->start);
14962 start = start_row->start.pos; 14965 start = start_row->minpos;
14963 start_vpos = MATRIX_ROW_VPOS (start_row, w->current_matrix); 14966 start_vpos = MATRIX_ROW_VPOS (start_row, w->current_matrix);
14964 14967
14965 /* Clear the desired matrix for the display below. */ 14968 /* Clear the desired matrix for the display below. */
14966 clear_glyph_matrix (w->desired_matrix); 14969 clear_glyph_matrix (w->desired_matrix);
14967 14970
14996 work to start copying with the following row. */ 14999 work to start copying with the following row. */
14997 while (IT_CHARPOS (it) > CHARPOS (start)) 15000 while (IT_CHARPOS (it) > CHARPOS (start))
14998 { 15001 {
14999 /* Advance to the next row as the "start". */ 15002 /* Advance to the next row as the "start". */
15000 start_row++; 15003 start_row++;
15001 start = start_row->start.pos; 15004 start = start_row->minpos;
15002 /* If there are no more rows to try, or just one, give up. */ 15005 /* If there are no more rows to try, or just one, give up. */
15003 if (start_row == MATRIX_MODE_LINE_ROW (w->current_matrix) - 1 15006 if (start_row == MATRIX_MODE_LINE_ROW (w->current_matrix) - 1
15004 || w->vscroll || MATRIX_ROW_PARTIALLY_VISIBLE_P (w, start_row) 15007 || w->vscroll || MATRIX_ROW_PARTIALLY_VISIBLE_P (w, start_row)
15005 || CHARPOS (start) == ZV) 15008 || CHARPOS (start) == ZV)
15006 { 15009 {
15278 } 15281 }
15279 if (row < bottom_row) 15282 if (row < bottom_row)
15280 { 15283 {
15281 struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos; 15284 struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos;
15282 struct glyph *end = glyph + row->used[TEXT_AREA]; 15285 struct glyph *end = glyph + row->used[TEXT_AREA];
15283 struct glyph *orig_glyph = glyph; 15286
15284 struct cursor_pos orig_cursor = w->cursor; 15287 /* Can't use this optimization with bidi-reordered glyph
15285 15288 rows, unless cursor is already at point. */
15286 for (; glyph < end 15289 if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering))
15287 && (!BUFFERP (glyph->object)
15288 || glyph->charpos != PT);
15289 glyph++)
15290 { 15290 {
15291 w->cursor.hpos++; 15291 if (!(w->cursor.hpos >= 0
15292 w->cursor.x += glyph->pixel_width; 15292 && w->cursor.hpos < row->used[TEXT_AREA]
15293 && BUFFERP (glyph->object)
15294 && glyph->charpos == PT))
15295 return 0;
15293 } 15296 }
15294 /* With bidi reordering, charpos changes non-linearly 15297 else
15295 with hpos, so the right glyph could be to the 15298 for (; glyph < end
15296 left. */ 15299 && (!BUFFERP (glyph->object)
15297 if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering) 15300 || glyph->charpos < PT);
15298 && (!BUFFERP (glyph->object) || glyph->charpos != PT)) 15301 glyph++)
15299 { 15302 {
15300 struct glyph *start_glyph = row->glyphs[TEXT_AREA]; 15303 w->cursor.hpos++;
15301 15304 w->cursor.x += glyph->pixel_width;
15302 glyph = orig_glyph - 1; 15305 }
15303 orig_cursor.hpos--;
15304 orig_cursor.x -= glyph->pixel_width;
15305 for (; glyph >= start_glyph
15306 && (!BUFFERP (glyph->object)
15307 || glyph->charpos != PT);
15308 glyph--)
15309 {
15310 w->cursor.hpos--;
15311 w->cursor.x -= glyph->pixel_width;
15312 }
15313 if (BUFFERP (glyph->object) && glyph->charpos == PT)
15314 w->cursor = orig_cursor;
15315 }
15316 } 15306 }
15317 } 15307 }
15318 15308
15319 /* Adjust window end. A null value of last_text_row means that 15309 /* Adjust window end. A null value of last_text_row means that
15320 the window end is in reused rows which in turn means that 15310 the window end is in reused rows which in turn means that
15890 15880
15891 /* If window start is unchanged, we can reuse the whole matrix 15881 /* If window start is unchanged, we can reuse the whole matrix
15892 as is, without changing glyph positions since no text has 15882 as is, without changing glyph positions since no text has
15893 been added/removed in front of the window end. */ 15883 been added/removed in front of the window end. */
15894 r0 = MATRIX_FIRST_TEXT_ROW (current_matrix); 15884 r0 = MATRIX_FIRST_TEXT_ROW (current_matrix);
15895 if (TEXT_POS_EQUAL_P (start, r0->start.pos) 15885 if (TEXT_POS_EQUAL_P (start, r0->minpos)
15896 /* PT must not be in a partially visible line. */ 15886 /* PT must not be in a partially visible line. */
15897 && !(PT >= MATRIX_ROW_START_CHARPOS (row) 15887 && !(PT >= MATRIX_ROW_START_CHARPOS (row)
15898 && MATRIX_ROW_BOTTOM_Y (row) > window_text_bottom_y (w))) 15888 && MATRIX_ROW_BOTTOM_Y (row) > window_text_bottom_y (w)))
15899 { 15889 {
15900 /* We have to compute the window end anew since text 15890 /* We have to compute the window end anew since text
15901 can have been added/removed after it. */ 15891 could have been added/removed after it. */
15902 w->window_end_pos 15892 w->window_end_pos
15903 = make_number (Z - MATRIX_ROW_END_CHARPOS (row)); 15893 = make_number (Z - MATRIX_ROW_END_CHARPOS (row));
15904 w->window_end_bytepos 15894 w->window_end_bytepos
15905 = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row); 15895 = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
15906 15896
15928 /* Check that window start agrees with the start of the first glyph 15918 /* Check that window start agrees with the start of the first glyph
15929 row in its current matrix. Check this after we know the window 15919 row in its current matrix. Check this after we know the window
15930 start is not in changed text, otherwise positions would not be 15920 start is not in changed text, otherwise positions would not be
15931 comparable. */ 15921 comparable. */
15932 row = MATRIX_FIRST_TEXT_ROW (current_matrix); 15922 row = MATRIX_FIRST_TEXT_ROW (current_matrix);
15933 if (!TEXT_POS_EQUAL_P (start, row->start.pos)) 15923 if (!TEXT_POS_EQUAL_P (start, row->minpos))
15934 GIVE_UP (16); 15924 GIVE_UP (16);
15935 15925
15936 /* Give up if the window ends in strings. Overlay strings 15926 /* Give up if the window ends in strings. Overlay strings
15937 at the end are difficult to handle, so don't try. */ 15927 at the end are difficult to handle, so don't try. */
15938 row = MATRIX_ROW (current_matrix, XFASTINT (w->window_end_vpos)); 15928 row = MATRIX_ROW (current_matrix, XFASTINT (w->window_end_vpos));
17320 struct window *w; 17310 struct window *w;
17321 struct glyph_row *row; 17311 struct glyph_row *row;
17322 { 17312 {
17323 int cursor_row_p = 1; 17313 int cursor_row_p = 1;
17324 17314
17325 if (PT == MATRIX_ROW_END_CHARPOS (row)) 17315 if (PT == CHARPOS (row->end.pos))
17326 { 17316 {
17327 /* Suppose the row ends on a string. 17317 /* Suppose the row ends on a string.
17328 Unless the row is continued, that means it ends on a newline 17318 Unless the row is continued, that means it ends on a newline
17329 in the string. If it's anything other than a display string 17319 in the string. If it's anything other than a display string
17330 (e.g. a before-string from an overlay), we don't want the 17320 (e.g. a before-string from an overlay), we don't want the
17357 } 17347 }
17358 else if (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row)) 17348 else if (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))
17359 { 17349 {
17360 /* If the row ends in middle of a real character, 17350 /* If the row ends in middle of a real character,
17361 and the line is continued, we want the cursor here. 17351 and the line is continued, we want the cursor here.
17362 That's because MATRIX_ROW_END_CHARPOS would equal 17352 That's because CHARPOS (ROW->end.pos) would equal
17363 PT if PT is before the character. */ 17353 PT if PT is before the character. */
17364 if (!row->ends_in_ellipsis_p) 17354 if (!row->ends_in_ellipsis_p)
17365 cursor_row_p = row->continued_p; 17355 cursor_row_p = row->continued_p;
17366 else 17356 else
17367 /* If the row ends in an ellipsis, then 17357 /* If the row ends in an ellipsis, then
17368 MATRIX_ROW_END_CHARPOS will equal point after the invisible text. 17358 CHARPOS (ROW->end.pos) will equal point after the
17369 We want that position to be displayed after the ellipsis. */ 17359 invisible text. We want that position to be displayed
17360 after the ellipsis. */
17370 cursor_row_p = 0; 17361 cursor_row_p = 0;
17371 } 17362 }
17372 /* If the row ends at ZV, display the cursor at the end of that 17363 /* If the row ends at ZV, display the cursor at the end of that
17373 row instead of at the start of the row below. */ 17364 row instead of at the start of the row below. */
17374 else if (row->ends_at_zv_p) 17365 else if (row->ends_at_zv_p)
17500 end = it->glyph_row->glyphs[TEXT_AREA] + it->glyph_row->used[TEXT_AREA]; 17491 end = it->glyph_row->glyphs[TEXT_AREA] + it->glyph_row->used[TEXT_AREA];
17501 for ( ; glyph < end; glyph++) 17492 for ( ; glyph < end; glyph++)
17502 glyph[-n] = *glyph; 17493 glyph[-n] = *glyph;
17503 } 17494 }
17504 17495
17505 /* Find the positions in a bidi-reordered ROW to serve as ROW->start 17496 /* Find the positions in a bidi-reordered ROW to serve as ROW->minpos
17506 and ROW->end. */ 17497 and ROW->maxpos. */
17507 static struct display_pos 17498 static void
17508 find_row_end (it, row) 17499 find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos)
17509 struct it *it; 17500 struct it *it;
17510 struct glyph_row *row; 17501 struct glyph_row *row;
17502 EMACS_INT min_pos, min_bpos, max_pos, max_bpos;
17511 { 17503 {
17512 /* FIXME: Revisit this when glyph ``spilling'' in continuation 17504 /* FIXME: Revisit this when glyph ``spilling'' in continuation
17513 lines' rows is implemented for bidi-reordered rows. */ 17505 lines' rows is implemented for bidi-reordered rows. */
17514 EMACS_INT min_pos = ZV + 1, max_pos = 0; 17506
17515 struct glyph *g; 17507 /* ROW->minpos is the value of min_pos, the minimal buffer position
17516 struct it save_it;
17517 struct text_pos tpos;
17518 struct display_pos row_end = it->current;
17519
17520 for (g = row->glyphs[TEXT_AREA];
17521 g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
17522 g++)
17523 {
17524 if (BUFFERP (g->object))
17525 {
17526 if (g->charpos > 0 && g->charpos < min_pos)
17527 min_pos = g->charpos;
17528 if (g->charpos > max_pos)
17529 max_pos = g->charpos;
17530 }
17531 }
17532 /* Empty lines have a valid buffer position at their first
17533 glyph, but that glyph's OBJECT is zero, as if it didn't come
17534 from a buffer. If we didn't find any valid buffer positions
17535 in this row, maybe we have such an empty line. */
17536 if (max_pos == 0 && row->used[TEXT_AREA])
17537 {
17538 for (g = row->glyphs[TEXT_AREA];
17539 g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
17540 g++)
17541 {
17542 if (INTEGERP (g->object))
17543 {
17544 if (g->charpos > 0 && g->charpos < min_pos)
17545 min_pos = g->charpos;
17546 if (g->charpos > max_pos)
17547 max_pos = g->charpos;
17548 }
17549 }
17550 }
17551
17552 /* ROW->start is the value of min_pos, the minimal buffer position
17553 we have in ROW. */ 17508 we have in ROW. */
17554 if (min_pos <= ZV) 17509 if (min_pos <= ZV)
17555 { 17510 SET_TEXT_POS (row->minpos, min_pos, min_bpos);
17556 /* Avoid calling the costly CHAR_TO_BYTE if possible. */ 17511 else
17557 if (min_pos != row->start.pos.charpos) 17512 {
17558 SET_TEXT_POS (row->start.pos, min_pos, CHAR_TO_BYTE (min_pos)); 17513 /* We didn't find _any_ valid buffer positions in any of the
17559 if (max_pos == 0) 17514 glyphs, so we must trust the iterator's computed
17560 max_pos = min_pos; 17515 positions. */
17561 } 17516 row->minpos = row->start.pos;
17562 17517 max_pos = CHARPOS (it->current.pos);
17563 /* For ROW->end, we need the position that is _after_ max_pos, in 17518 max_bpos = BYTEPOS (it->current.pos);
17564 the logical order, unless we are at ZV. */ 17519 }
17520
17521 if (!max_pos)
17522 abort ();
17523
17524 /* Here are the various use-cases for ending the row, and the
17525 corresponding values for ROW->maxpos:
17526
17527 Line ends in a newline from buffer eol_pos + 1
17528 Line is continued from buffer max_pos + 1
17529 Line is truncated on right it->current.pos
17530 Line ends in a newline from string max_pos
17531 Line is continued from string max_pos
17532 Line is continued from display vector max_pos
17533 Line is entirely from a string min_pos == max_pos
17534 Line is entirely from a display vector min_pos == max_pos
17535 Line that ends at ZV ZV
17536
17537 If you discover other use-cases, please add them here as
17538 appropriate. */
17565 if (row->ends_at_zv_p) 17539 if (row->ends_at_zv_p)
17566 { 17540 row->maxpos = it->current.pos;
17567 if (!row->used[TEXT_AREA]) 17541 else if (row->used[TEXT_AREA])
17568 row->start.pos = row_end.pos; 17542 {
17569 } 17543 if (row->ends_in_newline_from_string_p)
17570 else if (row->used[TEXT_AREA] && max_pos) 17544 SET_TEXT_POS (row->maxpos, max_pos, max_bpos);
17571 { 17545 else if (CHARPOS (it->eol_pos) > 0)
17572 int at_eol_p; 17546 SET_TEXT_POS (row->maxpos,
17573 17547 CHARPOS (it->eol_pos) + 1, BYTEPOS (it->eol_pos) + 1);
17574 SET_TEXT_POS (tpos, max_pos, CHAR_TO_BYTE (max_pos)); 17548 else if (row->continued_p)
17575 save_it = *it; 17549 {
17576 it->bidi_p = 0; 17550 /* If max_pos is different from IT's current position, it
17577 reseat (it, tpos, 0); 17551 means IT->method does not belong to the display element
17578 if (!get_next_display_element (it)) 17552 at max_pos. However, it also means that the display
17579 abort (); /* this row cannot be at ZV, see above */ 17553 element at max_pos was displayed in its entirety on this
17580 at_eol_p = ITERATOR_AT_END_OF_LINE_P (it); 17554 line, which is equivalent to saying that the next line
17581 set_iterator_to_next (it, 1); 17555 starts at the next buffer position. */
17582 row_end = it->current; 17556 if (IT_CHARPOS (*it) == max_pos && it->method != GET_FROM_BUFFER)
17583 /* If the character at max_pos is not a newline and the 17557 SET_TEXT_POS (row->maxpos, max_pos, max_bpos);
17584 characters at max_pos+1 is a newline, skip that newline as
17585 well. Note that this may skip some invisible text. */
17586 if (!at_eol_p
17587 && get_next_display_element (it)
17588 && ITERATOR_AT_END_OF_LINE_P (it))
17589 {
17590 set_iterator_to_next (it, 1);
17591 /* Record the position after the newline of a continued row.
17592 We will need that to set ROW->end of the last row
17593 produced for a continued line. */
17594 if (row->continued_p)
17595 save_it.eol_pos = it->current.pos;
17596 else 17558 else
17597 { 17559 {
17598 row_end = it->current; 17560 INC_BOTH (max_pos, max_bpos);
17599 save_it.eol_pos.charpos = save_it.eol_pos.bytepos = 0; 17561 SET_TEXT_POS (row->maxpos, max_pos, max_bpos);
17600 } 17562 }
17601 } 17563 }
17602 else if (!row->continued_p 17564 else if (row->truncated_on_right_p)
17603 && MATRIX_ROW_CONTINUATION_LINE_P (row) 17565 /* display_line already called reseat_at_next_visible_line_start,
17604 && it->eol_pos.charpos > 0) 17566 which puts the iterator at the beginning of the next line, in
17605 { 17567 the logical order. */
17606 /* Last row of a continued line. Use the position recorded 17568 row->maxpos = it->current.pos;
17607 in IT->eol_pos, to the effect that the newline belongs to 17569 else if (max_pos == min_pos && it->method != GET_FROM_BUFFER)
17608 this row, not to the row which displays the character 17570 /* A line that is entirely from a string/image/stretch... */
17609 with the largest buffer position before the newline. */ 17571 row->maxpos = row->minpos;
17610 row_end.pos = it->eol_pos; 17572 else
17611 it->eol_pos.charpos = it->eol_pos.bytepos = 0; 17573 abort ();
17612 } 17574 }
17613 *it = save_it; 17575 else
17614 /* The members of ROW->end that are not taken from buffer 17576 row->maxpos = it->current.pos;
17615 positions are copied from IT->current. */
17616 row_end.string_pos = it->current.string_pos;
17617 row_end.overlay_string_index = it->current.overlay_string_index;
17618 row_end.dpvec_index = it->current.dpvec_index;
17619 }
17620 return row_end;
17621 } 17577 }
17622 17578
17623 /* Construct the glyph row IT->glyph_row in the desired matrix of 17579 /* Construct the glyph row IT->glyph_row in the desired matrix of
17624 IT->w from text at the current position of IT. See dispextern.h 17580 IT->w from text at the current position of IT. See dispextern.h
17625 for an overview of struct it. Value is non-zero if 17581 for an overview of struct it. Value is non-zero if
17635 struct it wrap_it; 17591 struct it wrap_it;
17636 int may_wrap = 0, wrap_x; 17592 int may_wrap = 0, wrap_x;
17637 int wrap_row_used = -1, wrap_row_ascent, wrap_row_height; 17593 int wrap_row_used = -1, wrap_row_ascent, wrap_row_height;
17638 int wrap_row_phys_ascent, wrap_row_phys_height; 17594 int wrap_row_phys_ascent, wrap_row_phys_height;
17639 int wrap_row_extra_line_spacing; 17595 int wrap_row_extra_line_spacing;
17596 EMACS_INT wrap_row_min_pos, wrap_row_min_bpos;
17597 EMACS_INT wrap_row_max_pos, wrap_row_max_bpos;
17640 int cvpos; 17598 int cvpos;
17599 EMACS_INT min_pos = ZV + 1, min_bpos, max_pos = 0, max_bpos;
17641 17600
17642 /* We always start displaying at hpos zero even if hscrolled. */ 17601 /* We always start displaying at hpos zero even if hscrolled. */
17643 xassert (it->hpos == 0 && it->current_x == 0); 17602 xassert (it->hpos == 0 && it->current_x == 0);
17644 17603
17645 if (MATRIX_ROW_VPOS (row, it->w->desired_matrix) 17604 if (MATRIX_ROW_VPOS (row, it->w->desired_matrix)
17691 row->ascent = it->max_ascent; 17650 row->ascent = it->max_ascent;
17692 row->height = it->max_ascent + it->max_descent; 17651 row->height = it->max_ascent + it->max_descent;
17693 row->phys_ascent = it->max_phys_ascent; 17652 row->phys_ascent = it->max_phys_ascent;
17694 row->phys_height = it->max_phys_ascent + it->max_phys_descent; 17653 row->phys_height = it->max_phys_ascent + it->max_phys_descent;
17695 row->extra_line_spacing = it->max_extra_line_spacing; 17654 row->extra_line_spacing = it->max_extra_line_spacing;
17655
17656 /* Utility macro to record max and min buffer positions seen until now. */
17657 #define RECORD_MAX_MIN_POS(IT) \
17658 do \
17659 { \
17660 if (IT_CHARPOS (*(IT)) < min_pos) \
17661 { \
17662 min_pos = IT_CHARPOS (*(IT)); \
17663 min_bpos = IT_BYTEPOS (*(IT)); \
17664 } \
17665 if (IT_CHARPOS (*(IT)) > max_pos) \
17666 { \
17667 max_pos = IT_CHARPOS (*(IT)); \
17668 max_bpos = IT_BYTEPOS (*(IT)); \
17669 } \
17670 } \
17671 while (0)
17696 17672
17697 /* Loop generating characters. The loop is left with IT on the next 17673 /* Loop generating characters. The loop is left with IT on the next
17698 character to display. */ 17674 character to display. */
17699 while (1) 17675 while (1)
17700 { 17676 {
17726 17702
17727 it->continuation_lines_width = 0; 17703 it->continuation_lines_width = 0;
17728 row->ends_at_zv_p = 1; 17704 row->ends_at_zv_p = 1;
17729 /* A row that displays right-to-left text must always have 17705 /* A row that displays right-to-left text must always have
17730 its last face extended all the way to the end of line, 17706 its last face extended all the way to the end of line,
17731 even if this row ends in ZV. */ 17707 even if this row ends in ZV, because we still write to th
17708 screen left to right. */
17732 if (row->reversed_p) 17709 if (row->reversed_p)
17733 extend_face_to_end_of_line (it); 17710 extend_face_to_end_of_line (it);
17734 break; 17711 break;
17735 } 17712 }
17736 17713
17760 wrap_row_ascent = row->ascent; 17737 wrap_row_ascent = row->ascent;
17761 wrap_row_height = row->height; 17738 wrap_row_height = row->height;
17762 wrap_row_phys_ascent = row->phys_ascent; 17739 wrap_row_phys_ascent = row->phys_ascent;
17763 wrap_row_phys_height = row->phys_height; 17740 wrap_row_phys_height = row->phys_height;
17764 wrap_row_extra_line_spacing = row->extra_line_spacing; 17741 wrap_row_extra_line_spacing = row->extra_line_spacing;
17742 wrap_row_min_pos = min_pos;
17743 wrap_row_min_bpos = min_bpos;
17744 wrap_row_max_pos = max_pos;
17745 wrap_row_max_bpos = max_bpos;
17765 may_wrap = 0; 17746 may_wrap = 0;
17766 } 17747 }
17767 } 17748 }
17768 } 17749 }
17769 17750
17810 it->max_phys_ascent + it->max_phys_descent); 17791 it->max_phys_ascent + it->max_phys_descent);
17811 row->extra_line_spacing = max (row->extra_line_spacing, 17792 row->extra_line_spacing = max (row->extra_line_spacing,
17812 it->max_extra_line_spacing); 17793 it->max_extra_line_spacing);
17813 if (it->current_x - it->pixel_width < it->first_visible_x) 17794 if (it->current_x - it->pixel_width < it->first_visible_x)
17814 row->x = x - it->first_visible_x; 17795 row->x = x - it->first_visible_x;
17796 /* Record the maximum and minimum buffer positions seen so
17797 far in glyphs that will be displayed by this row. */
17798 if (it->bidi_p)
17799 RECORD_MAX_MIN_POS (it);
17815 } 17800 }
17816 else 17801 else
17817 { 17802 {
17818 int new_x; 17803 int new_x;
17819 struct glyph *glyph; 17804 struct glyph *glyph;
17843 after the glyph. */ 17828 after the glyph. */
17844 row->continued_p = 1; 17829 row->continued_p = 1;
17845 it->current_x = new_x; 17830 it->current_x = new_x;
17846 it->continuation_lines_width += new_x; 17831 it->continuation_lines_width += new_x;
17847 ++it->hpos; 17832 ++it->hpos;
17833 /* Record the maximum and minimum buffer
17834 positions seen so far in glyphs that will be
17835 displayed by this row. */
17836 if (it->bidi_p)
17837 RECORD_MAX_MIN_POS (it);
17848 if (i == nglyphs - 1) 17838 if (i == nglyphs - 1)
17849 { 17839 {
17850 /* If line-wrap is on, check if a previous 17840 /* If line-wrap is on, check if a previous
17851 wrap point was found. */ 17841 wrap point was found. */
17852 if (wrap_row_used > 0 17842 if (wrap_row_used > 0
17917 row->ascent = wrap_row_ascent; 17907 row->ascent = wrap_row_ascent;
17918 row->height = wrap_row_height; 17908 row->height = wrap_row_height;
17919 row->phys_ascent = wrap_row_phys_ascent; 17909 row->phys_ascent = wrap_row_phys_ascent;
17920 row->phys_height = wrap_row_phys_height; 17910 row->phys_height = wrap_row_phys_height;
17921 row->extra_line_spacing = wrap_row_extra_line_spacing; 17911 row->extra_line_spacing = wrap_row_extra_line_spacing;
17912 min_pos = wrap_row_min_pos;
17913 min_bpos = wrap_row_min_bpos;
17914 max_pos = wrap_row_max_pos;
17915 max_bpos = wrap_row_max_bpos;
17922 row->continued_p = 1; 17916 row->continued_p = 1;
17923 row->ends_at_zv_p = 0; 17917 row->ends_at_zv_p = 0;
17924 row->exact_window_width_line_p = 0; 17918 row->exact_window_width_line_p = 0;
17925 it->continuation_lines_width += x; 17919 it->continuation_lines_width += x;
17926 17920
17979 else if (new_x > it->first_visible_x) 17973 else if (new_x > it->first_visible_x)
17980 { 17974 {
17981 /* Increment number of glyphs actually displayed. */ 17975 /* Increment number of glyphs actually displayed. */
17982 ++it->hpos; 17976 ++it->hpos;
17983 17977
17978 /* Record the maximum and minimum buffer positions
17979 seen so far in glyphs that will be displayed by
17980 this row. */
17981 if (it->bidi_p)
17982 RECORD_MAX_MIN_POS (it);
17983
17984 if (x < it->first_visible_x) 17984 if (x < it->first_visible_x)
17985 /* Glyph is partially visible, i.e. row starts at 17985 /* Glyph is partially visible, i.e. row starts at
17986 negative X position. */ 17986 negative X position. */
17987 row->x = x - it->first_visible_x; 17987 row->x = x - it->first_visible_x;
17988 } 17988 }
18029 extend_face_to_end_of_line (it); 18029 extend_face_to_end_of_line (it);
18030 18030
18031 /* Make sure we have the position. */ 18031 /* Make sure we have the position. */
18032 if (used_before == 0) 18032 if (used_before == 0)
18033 row->glyphs[TEXT_AREA]->charpos = CHARPOS (it->position); 18033 row->glyphs[TEXT_AREA]->charpos = CHARPOS (it->position);
18034
18035 /* Record the position of the newline, for use in
18036 find_row_edges. */
18037 it->eol_pos = it->current.pos;
18034 18038
18035 /* Consume the line end. This skips over invisible lines. */ 18039 /* Consume the line end. This skips over invisible lines. */
18036 set_iterator_to_next (it, 1); 18040 set_iterator_to_next (it, 1);
18037 it->continuation_lines_width = 0; 18041 it->continuation_lines_width = 0;
18038 break; 18042 break;
18109 } 18113 }
18110 18114
18111 /* If line is not empty and hscrolled, maybe insert truncation glyphs 18115 /* If line is not empty and hscrolled, maybe insert truncation glyphs
18112 at the left window margin. */ 18116 at the left window margin. */
18113 if (it->first_visible_x 18117 if (it->first_visible_x
18114 && IT_CHARPOS (*it) != MATRIX_ROW_START_CHARPOS (row)) 18118 && IT_CHARPOS (*it) != CHARPOS (row->start.pos))
18115 { 18119 {
18116 if (!FRAME_WINDOW_P (it->f)) 18120 if (!FRAME_WINDOW_P (it->f))
18117 insert_left_trunc_glyphs (it); 18121 insert_left_trunc_glyphs (it);
18118 row->truncated_on_left_p = 1; 18122 row->truncated_on_left_p = 1;
18119 } 18123 }
18163 /* Compute pixel dimensions of this line. */ 18167 /* Compute pixel dimensions of this line. */
18164 compute_line_metrics (it); 18168 compute_line_metrics (it);
18165 18169
18166 /* Remember the position at which this line ends. */ 18170 /* Remember the position at which this line ends. */
18167 row->end = it->current; 18171 row->end = it->current;
18168 /* ROW->start and ROW->end must be the smallest and the largest 18172 if (!it->bidi_p)
18169 buffer positions in ROW. But if ROW was bidi-reordered, these 18173 {
18170 two positions can be anywhere in the row, so we must rescan all 18174 row->minpos = row->start.pos;
18171 of the ROW's glyphs to find them. */ 18175 row->maxpos = row->end.pos;
18172 if (it->bidi_p) 18176 }
18173 row->end = find_row_end (it, row); 18177 else
18178 {
18179 /* ROW->minpos and ROW->maxpos must be the smallest and
18180 `1 + the largest' buffer positions in ROW. But if ROW was
18181 bidi-reordered, these two positions can be anywhere in the
18182 row, so we must determine them now. */
18183 find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos);
18184 }
18174 18185
18175 /* Record whether this row ends inside an ellipsis. */ 18186 /* Record whether this row ends inside an ellipsis. */
18176 row->ends_in_ellipsis_p 18187 row->ends_in_ellipsis_p
18177 = (it->method == GET_FROM_DISPLAY_VECTOR 18188 = (it->method == GET_FROM_DISPLAY_VECTOR
18178 && it->ellipsis_p); 18189 && it->ellipsis_p);
18214 HPOS) = (0 0). Vertical positions are incremented. As a 18225 HPOS) = (0 0). Vertical positions are incremented. As a
18215 convenience for the caller, IT->glyph_row is set to the next 18226 convenience for the caller, IT->glyph_row is set to the next
18216 row to be used. */ 18227 row to be used. */
18217 it->current_x = it->hpos = 0; 18228 it->current_x = it->hpos = 0;
18218 it->current_y += row->height; 18229 it->current_y += row->height;
18230 SET_TEXT_POS (it->eol_pos, 0, 0);
18219 ++it->vpos; 18231 ++it->vpos;
18220 ++it->glyph_row; 18232 ++it->glyph_row;
18221 /* The next row should by default use the same value of the 18233 /* The next row should by default use the same value of the
18222 reversed_p flag as this one. set_iterator_to_next decides when 18234 reversed_p flag as this one. set_iterator_to_next decides when
18223 it's a new paragraph, and PRODUCE_GLYPHS recomputes the value of 18235 it's a new paragraph, and PRODUCE_GLYPHS recomputes the value of
18224 the flag accordingly. */ 18236 the flag accordingly. */
18225 if (it->glyph_row < MATRIX_BOTTOM_TEXT_ROW (it->w->desired_matrix, it->w)) 18237 if (it->glyph_row < MATRIX_BOTTOM_TEXT_ROW (it->w->desired_matrix, it->w))
18226 it->glyph_row->reversed_p = row->reversed_p; 18238 it->glyph_row->reversed_p = row->reversed_p;
18227 it->start = row->end; 18239 it->start = row->end;
18228 return row->displays_text_p; 18240 return row->displays_text_p;
18241
18242 #undef RECORD_MAX_MIN_POS
18229 } 18243 }
18230 18244
18231 DEFUN ("current-bidi-paragraph-direction", Fcurrent_bidi_paragraph_direction, 18245 DEFUN ("current-bidi-paragraph-direction", Fcurrent_bidi_paragraph_direction,
18232 Scurrent_bidi_paragraph_direction, 0, 1, 0, 18246 Scurrent_bidi_paragraph_direction, 0, 1, 0,
18233 doc: /* Return paragraph direction at point in BUFFER. 18247 doc: /* Return paragraph direction at point in BUFFER.