From 91004049759c848b217a947f5043983bbc25f791 Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Tue, 6 Jun 2000 20:02:39 +0000 Subject: [PATCH] (display_line): Set row's and iterator's starts_in_middle_of_char_p and ends_in_middle_of_char_p flags. Set cursor even if row ends in the middle of a character. (dump_glyph_row): Print values of new flags. (redisplay_window) : When point has been moved forward, and PT is at the end of the cursor row, don't place the cursor in the next row if the cursor row ends in the middle of a character or at ZV. --- src/xdisp.c | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 3affc6e132b..d6b8ed694b3 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -8835,20 +8835,26 @@ redisplay_window (window, just_this_one_p) /* Point has moved forward. */ int last_y = window_text_bottom_y (w) - this_scroll_margin; - while ((MATRIX_ROW_END_CHARPOS (row) < PT - /* The end position of a row equals the start - position of the next row. If PT is there, we - would rather display it in the next line, except - when this line ends in ZV. */ - || (MATRIX_ROW_END_CHARPOS (row) == PT - && (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row) - || !row->ends_at_zv_p))) + while (MATRIX_ROW_END_CHARPOS (row) < PT && MATRIX_ROW_BOTTOM_Y (row) < last_y) { xassert (row->enabled_p); ++row; } + /* The end position of a row equals the start position of + the next row. If PT is there, we would rather display it + in the next line. Exceptions are when the row ends in + the middle of a character, or ends in ZV. */ + if (MATRIX_ROW_BOTTOM_Y (row) < last_y + && MATRIX_ROW_END_CHARPOS (row) == PT + && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row) + && !row->ends_at_zv_p) + { + xassert (row->enabled_p); + ++row; + } + /* If within the scroll margin, scroll. Note that MATRIX_ROW_BOTTOM_Y gives the pixel position at which the next line would be drawn, and that this_scroll_margin can @@ -10586,10 +10592,10 @@ dump_glyph_row (matrix, vpos, with_glyphs_p) row = MATRIX_ROW (matrix, vpos); - fprintf (stderr, "Row Start End Used oEI>rows, MATRIX_ROW_START_CHARPOS (row), MATRIX_ROW_END_CHARPOS (row), @@ -10605,6 +10611,8 @@ dump_glyph_row (matrix, vpos, with_glyphs_p) row->displays_text_p, row->ends_at_zv_p, row->fill_line_p, + row->ends_in_middle_of_char_p, + row->starts_in_middle_of_char_p, row->x, row->y, row->pixel_width); @@ -11203,6 +11211,8 @@ display_line (it) row->start = it->current; row->continuation_lines_width = it->continuation_lines_width; row->displays_text_p = 1; + row->starts_in_middle_of_char_p = it->starts_in_middle_of_char_p; + it->starts_in_middle_of_char_p = 0; /* Arrange the overlays nicely for our purposes. Usually, we call display_line on only one line at a time, in which case this @@ -11387,6 +11397,11 @@ display_line (it) it->current_x = x; it->continuation_lines_width += x; + if (nglyphs > 1 && i > 0) + { + row->ends_in_middle_of_char_p = 1; + it->starts_in_middle_of_char_p = 1; + } /* Restore the height to what it was before the element not fitting on the line. */ @@ -11538,15 +11553,15 @@ display_line (it) /* Remember the position at which this line ends. */ row->end = it->current; - /* Maybe set the cursor. If you change this, it's probably a good - idea to also change the code in redisplay_window for cursor - movement in an unchanged window. */ + /* Maybe set the cursor. We want to set the cursor on the first + glyph having position PT. This means it doesn't matter if the + row is continued and ends in the middle of the character at PT. + If some glyphs of that character are in this row, this is the + right row to put the cursor on. */ if (it->w->cursor.vpos < 0 && PT >= MATRIX_ROW_START_CHARPOS (row) - && MATRIX_ROW_END_CHARPOS (row) >= PT - && !(MATRIX_ROW_END_CHARPOS (row) == PT - && (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row) - || !row->ends_at_zv_p))) + && PT <= MATRIX_ROW_END_CHARPOS (row) + && !(PT == ZV && !row->ends_at_zv_p)) set_cursor_from_row (it->w, row, it->w->desired_matrix, 0, 0, 0, 0); /* Highlight trailing whitespace. */ -- 2.39.2