aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2005-07-13 10:02:42 +0000
committerKim F. Storm2005-07-13 10:02:42 +0000
commite0e9a80e8b2bb71201afe00b44585a58a08573d5 (patch)
treec3edc1bdc3faa9eca0991eae951d3caf28f261f4 /src
parente3ea3a51e67a51bfcd1b4f7f53ded25fd3a0507a (diff)
downloademacs-e0e9a80e8b2bb71201afe00b44585a58a08573d5.tar.gz
emacs-e0e9a80e8b2bb71201afe00b44585a58a08573d5.zip
* xdisp.c (start_display): Don't reseat to next visible line start
if current start position is in a string or image. (move_it_vertically_backward): Be sure to move out of strings and images when moving it2 forward. (move_it_by_lines): When moving forward, move to next buffer position if we end up in a string or image. When moving backward, count rows moved over when moving to start of current row in case row starts in middle of a string or image. Also move further backward if we end up in a string or image. (try_cursor_movement): if overlay string spans multiple lines, move backward to set cursor on start of an overlay string. (cursor_row_p): Row is ok if cursor is at newline from string, but string starts on this line (so we always position cursor at start of string).
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index adb19b28ec4..4bc68ce58fc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2408,7 +2408,9 @@ start_display (it, w, pos)
2408 init_iterator (it, w, CHARPOS (pos), BYTEPOS (pos), row, DEFAULT_FACE_ID); 2408 init_iterator (it, w, CHARPOS (pos), BYTEPOS (pos), row, DEFAULT_FACE_ID);
2409 it->first_vpos = first_vpos; 2409 it->first_vpos = first_vpos;
2410 2410
2411 if (!it->truncate_lines_p) 2411 /* Don't reseat to previous visible line start if current start
2412 position is in a string or image. */
2413 if (it->method == GET_FROM_BUFFER && !it->truncate_lines_p)
2412 { 2414 {
2413 int start_at_line_beg_p; 2415 int start_at_line_beg_p;
2414 int first_y = it->current_y; 2416 int first_y = it->current_y;
@@ -6379,8 +6381,12 @@ move_it_vertically_backward (it, dy)
6379 y-distance. */ 6381 y-distance. */
6380 it2 = *it; 6382 it2 = *it;
6381 it2.max_ascent = it2.max_descent = 0; 6383 it2.max_ascent = it2.max_descent = 0;
6382 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1, 6384 do
6383 MOVE_TO_POS | MOVE_TO_VPOS); 6385 {
6386 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1,
6387 MOVE_TO_POS | MOVE_TO_VPOS);
6388 }
6389 while (it2.method != GET_FROM_BUFFER);
6384 xassert (IT_CHARPOS (*it) >= BEGV); 6390 xassert (IT_CHARPOS (*it) >= BEGV);
6385 it3 = it2; 6391 it3 = it2;
6386 6392
@@ -6578,21 +6584,45 @@ move_it_by_lines (it, dvpos, need_y_p)
6578 last_height = 0; 6584 last_height = 0;
6579 } 6585 }
6580 else if (dvpos > 0) 6586 else if (dvpos > 0)
6581 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS); 6587 {
6588 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS);
6589 if (it->method != GET_FROM_BUFFER)
6590 move_it_to (it, IT_CHARPOS (*it) + 1, -1, -1, -1, MOVE_TO_POS);
6591 }
6582 else 6592 else
6583 { 6593 {
6584 struct it it2; 6594 struct it it2;
6585 int start_charpos, i; 6595 int start_charpos, i;
6586 6596
6587 /* Start at the beginning of the screen line containing IT's 6597 /* Start at the beginning of the screen line containing IT's
6588 position. */ 6598 position. This may actually move vertically backwards,
6599 in case of overlays, so adjust dvpos accordingly. */
6600 dvpos += it->vpos;
6589 move_it_vertically_backward (it, 0); 6601 move_it_vertically_backward (it, 0);
6602 dvpos -= it->vpos;
6590 6603
6591 /* Go back -DVPOS visible lines and reseat the iterator there. */ 6604 /* Go back -DVPOS visible lines and reseat the iterator there. */
6592 start_charpos = IT_CHARPOS (*it); 6605 start_charpos = IT_CHARPOS (*it);
6593 for (i = -dvpos; i && IT_CHARPOS (*it) > BEGV; --i) 6606 for (i = -dvpos; i > 0 && IT_CHARPOS (*it) > BEGV; --i)
6594 back_to_previous_visible_line_start (it); 6607 back_to_previous_visible_line_start (it);
6595 reseat (it, it->current.pos, 1); 6608 reseat (it, it->current.pos, 1);
6609
6610 /* Move further back if we end up in a string or an image. */
6611 while (it->method != GET_FROM_BUFFER)
6612 {
6613 /* First try to move to start of display line. */
6614 dvpos += it->vpos;
6615 move_it_vertically_backward (it, 0);
6616 dvpos -= it->vpos;
6617 if (it->method == GET_FROM_BUFFER)
6618 break;
6619 /* If start of line is still in string or image,
6620 move further back. */
6621 back_to_previous_visible_line_start (it);
6622 reseat (it, it->current.pos, 1);
6623 dvpos--;
6624 }
6625
6596 it->current_x = it->hpos = 0; 6626 it->current_x = it->hpos = 0;
6597 6627
6598 /* Above call may have moved too far if continuation lines 6628 /* Above call may have moved too far if continuation lines
@@ -11824,7 +11854,10 @@ try_cursor_movement (window, startp, scroll_step)
11824 while (!row->mode_line_p 11854 while (!row->mode_line_p
11825 && (MATRIX_ROW_START_CHARPOS (row) > PT 11855 && (MATRIX_ROW_START_CHARPOS (row) > PT
11826 || (MATRIX_ROW_START_CHARPOS (row) == PT 11856 || (MATRIX_ROW_START_CHARPOS (row) == PT
11827 && MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P (row))) 11857 && (MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P (row)
11858 || (/* STARTS_IN_MIDDLE_OF_STRING_P (row) */
11859 row > w->current_matrix->rows
11860 && (row-1)->ends_in_newline_from_string_p))))
11828 && (row->y > top_scroll_margin 11861 && (row->y > top_scroll_margin
11829 || CHARPOS (startp) == BEGV)) 11862 || CHARPOS (startp) == BEGV))
11830 { 11863 {
@@ -14995,10 +15028,12 @@ cursor_row_p (w, row)
14995 if (PT == MATRIX_ROW_END_CHARPOS (row)) 15028 if (PT == MATRIX_ROW_END_CHARPOS (row))
14996 { 15029 {
14997 /* If the row ends with a newline from a string, we don't want 15030 /* If the row ends with a newline from a string, we don't want
14998 the cursor there (if the row is continued it doesn't end in a 15031 the cursor there, but we still want it at the start of the
14999 newline). */ 15032 string if the string starts in this row.
15033 If the row is continued it doesn't end in a newline. */
15000 if (CHARPOS (row->end.string_pos) >= 0) 15034 if (CHARPOS (row->end.string_pos) >= 0)
15001 cursor_row_p = row->continued_p; 15035 cursor_row_p = (row->continued_p
15036 || PT >= MATRIX_ROW_START_CHARPOS (row));
15002 else if (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row)) 15037 else if (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))
15003 { 15038 {
15004 /* If the row ends in middle of a real character, 15039 /* If the row ends in middle of a real character,