comparison src/xdisp.c @ 64340:ed5290d55baa

Fix redisplay loop in last change. (IT_POS_VALID_AFTER_MOVE_P): New macro. (move_it_vertically_backward, move_it_by_lines): Use it.
author Kim F. Storm <storm@cua.dk>
date Fri, 15 Jul 2005 11:32:15 +0000
parents 6d94773592af
children 9bb757d6c7df
comparison
equal deleted inserted replaced
64339:c62fc2db1d41 64340:ed5290d55baa
5871 5871
5872 /*********************************************************************** 5872 /***********************************************************************
5873 Moving an iterator without producing glyphs 5873 Moving an iterator without producing glyphs
5874 ***********************************************************************/ 5874 ***********************************************************************/
5875 5875
5876 /* Check if iterator is at a position corresponding to a valid buffer
5877 position after some move_it_ call. */
5878
5879 #define IT_POS_VALID_AFTER_MOVE_P(it) \
5880 ((it)->method == GET_FROM_STRING \
5881 ? IT_STRING_CHARPOS (*it) == 0 \
5882 : 1)
5883
5884
5876 /* Move iterator IT to a specified buffer or X position within one 5885 /* Move iterator IT to a specified buffer or X position within one
5877 line on the display without producing glyphs. 5886 line on the display without producing glyphs.
5878 5887
5879 OP should be a bit mask including some or all of these bits: 5888 OP should be a bit mask including some or all of these bits:
5880 MOVE_TO_X: Stop on reaching x-position TO_X. 5889 MOVE_TO_X: Stop on reaching x-position TO_X.
6384 do 6393 do
6385 { 6394 {
6386 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1, 6395 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1,
6387 MOVE_TO_POS | MOVE_TO_VPOS); 6396 MOVE_TO_POS | MOVE_TO_VPOS);
6388 } 6397 }
6389 while (it2.method != GET_FROM_BUFFER); 6398 while (!IT_POS_VALID_AFTER_MOVE_P (&it2));
6390 xassert (IT_CHARPOS (*it) >= BEGV); 6399 xassert (IT_CHARPOS (*it) >= BEGV);
6391 it3 = it2; 6400 it3 = it2;
6392 6401
6393 move_it_to (&it2, start_pos, -1, -1, -1, MOVE_TO_POS); 6402 move_it_to (&it2, start_pos, -1, -1, -1, MOVE_TO_POS);
6394 xassert (IT_CHARPOS (*it) >= BEGV); 6403 xassert (IT_CHARPOS (*it) >= BEGV);
6584 last_height = 0; 6593 last_height = 0;
6585 } 6594 }
6586 else if (dvpos > 0) 6595 else if (dvpos > 0)
6587 { 6596 {
6588 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS); 6597 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS);
6589 if (it->method != GET_FROM_BUFFER) 6598 if (!IT_POS_VALID_AFTER_MOVE_P (it))
6590 move_it_to (it, IT_CHARPOS (*it) + 1, -1, -1, -1, MOVE_TO_POS); 6599 move_it_to (it, IT_CHARPOS (*it) + 1, -1, -1, -1, MOVE_TO_POS);
6591 } 6600 }
6592 else 6601 else
6593 { 6602 {
6594 struct it it2; 6603 struct it it2;
6606 for (i = -dvpos; i > 0 && IT_CHARPOS (*it) > BEGV; --i) 6615 for (i = -dvpos; i > 0 && IT_CHARPOS (*it) > BEGV; --i)
6607 back_to_previous_visible_line_start (it); 6616 back_to_previous_visible_line_start (it);
6608 reseat (it, it->current.pos, 1); 6617 reseat (it, it->current.pos, 1);
6609 6618
6610 /* Move further back if we end up in a string or an image. */ 6619 /* Move further back if we end up in a string or an image. */
6611 while (it->method != GET_FROM_BUFFER) 6620 while (!IT_POS_VALID_AFTER_MOVE_P (it))
6612 { 6621 {
6613 /* First try to move to start of display line. */ 6622 /* First try to move to start of display line. */
6614 dvpos += it->vpos; 6623 dvpos += it->vpos;
6615 move_it_vertically_backward (it, 0); 6624 move_it_vertically_backward (it, 0);
6616 dvpos -= it->vpos; 6625 dvpos -= it->vpos;
6617 if (it->method == GET_FROM_BUFFER) 6626 if (IT_POS_VALID_AFTER_MOVE_P (it))
6618 break; 6627 break;
6619 /* If start of line is still in string or image, 6628 /* If start of line is still in string or image,
6620 move further back. */ 6629 move further back. */
6621 back_to_previous_visible_line_start (it); 6630 back_to_previous_visible_line_start (it);
6622 reseat (it, it->current.pos, 1); 6631 reseat (it, it->current.pos, 1);