aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2004-06-15 10:35:05 +0000
committerKim F. Storm2004-06-15 10:35:05 +0000
commit38793d6a3efa6a1f9de740a6736f07bdfe7f3317 (patch)
treec7c8d082987c5241f8f2b9e0dca239147e2cd122 /src
parentc4a5739cd32849a02d0d0524d7634fa505b30cf2 (diff)
downloademacs-38793d6a3efa6a1f9de740a6736f07bdfe7f3317.tar.gz
emacs-38793d6a3efa6a1f9de740a6736f07bdfe7f3317.zip
(try_cursor_movement): Exclude header line from scroll
margin at top of window. (try_window_reusing_current_matrix): Calculate proper cursor position after scrolling up with non-zero scroll margin, as the old cursor position corresponds to value of PT before executing this command. (try_window_id): Consider scroll margin at bottom of window too; otherwise we fail to scroll when hl-line-mode is enabled.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 447f4dfbf79..cd712ac7485 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -11267,7 +11267,7 @@ try_cursor_movement (window, startp, scroll_step)
11267 && (FRAME_WINDOW_P (f) 11267 && (FRAME_WINDOW_P (f)
11268 || !overlay_arrow_in_current_buffer_p ())) 11268 || !overlay_arrow_in_current_buffer_p ()))
11269 { 11269 {
11270 int this_scroll_margin; 11270 int this_scroll_margin, top_scroll_margin;
11271 struct glyph_row *row = NULL; 11271 struct glyph_row *row = NULL;
11272 11272
11273#if GLYPH_DEBUG 11273#if GLYPH_DEBUG
@@ -11280,6 +11280,10 @@ try_cursor_movement (window, startp, scroll_step)
11280 this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 11280 this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 4);
11281 this_scroll_margin *= FRAME_LINE_HEIGHT (f); 11281 this_scroll_margin *= FRAME_LINE_HEIGHT (f);
11282 11282
11283 top_scroll_margin = this_scroll_margin;
11284 if (WINDOW_WANTS_HEADER_LINE_P (w))
11285 top_scroll_margin += CURRENT_HEADER_LINE_HEIGHT (w);
11286
11283 /* Start with the row the cursor was displayed during the last 11287 /* Start with the row the cursor was displayed during the last
11284 not paused redisplay. Give up if that row is not valid. */ 11288 not paused redisplay. Give up if that row is not valid. */
11285 if (w->last_cursor.vpos < 0 11289 if (w->last_cursor.vpos < 0
@@ -11340,7 +11344,7 @@ try_cursor_movement (window, startp, scroll_step)
11340 && (MATRIX_ROW_START_CHARPOS (row) > PT 11344 && (MATRIX_ROW_START_CHARPOS (row) > PT
11341 || (MATRIX_ROW_START_CHARPOS (row) == PT 11345 || (MATRIX_ROW_START_CHARPOS (row) == PT
11342 && MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P (row))) 11346 && MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P (row)))
11343 && (row->y > this_scroll_margin 11347 && (row->y > top_scroll_margin
11344 || CHARPOS (startp) == BEGV)) 11348 || CHARPOS (startp) == BEGV))
11345 { 11349 {
11346 xassert (row->enabled_p); 11350 xassert (row->enabled_p);
@@ -11368,7 +11372,7 @@ try_cursor_movement (window, startp, scroll_step)
11368 ++row; 11372 ++row;
11369 11373
11370 /* If within the scroll margin, scroll. */ 11374 /* If within the scroll margin, scroll. */
11371 if (row->y < this_scroll_margin 11375 if (row->y < top_scroll_margin
11372 && CHARPOS (startp) != BEGV) 11376 && CHARPOS (startp) != BEGV)
11373 scroll_p = 1; 11377 scroll_p = 1;
11374 } 11378 }
@@ -12538,9 +12542,8 @@ try_window_reusing_current_matrix (w)
12538 position. */ 12542 position. */
12539 if (pt_row) 12543 if (pt_row)
12540 { 12544 {
12541 w->cursor.vpos -= MATRIX_ROW_VPOS (first_reusable_row, 12545 w->cursor.vpos -= nrows_scrolled;
12542 w->current_matrix); 12546 w->cursor.y -= first_reusable_row->y - start_row->y;
12543 w->cursor.y -= first_reusable_row->y;
12544 } 12547 }
12545 12548
12546 /* Scroll the display. */ 12549 /* Scroll the display. */
@@ -12585,6 +12588,29 @@ try_window_reusing_current_matrix (w)
12585 for (row -= nrows_scrolled; row < bottom_row; ++row) 12588 for (row -= nrows_scrolled; row < bottom_row; ++row)
12586 row->enabled_p = 0; 12589 row->enabled_p = 0;
12587 12590
12591 /* Point may have moved to a different line, so we cannot assume that
12592 the previous cursor position is valid; locate the correct row. */
12593 if (pt_row)
12594 {
12595 for (row = MATRIX_ROW (w->current_matrix, w->cursor.vpos);
12596 row < bottom_row && PT >= MATRIX_ROW_END_CHARPOS (row);
12597 row++)
12598 {
12599 w->cursor.vpos++;
12600 w->cursor.y = row->y;
12601 }
12602 if (row < bottom_row)
12603 {
12604 struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos;
12605 while (glyph->charpos < PT)
12606 {
12607 w->cursor.hpos++;
12608 w->cursor.x += glyph->pixel_width;
12609 glyph++;
12610 }
12611 }
12612 }
12613
12588 /* Adjust window end. A null value of last_text_row means that 12614 /* Adjust window end. A null value of last_text_row means that
12589 the window end is in reused rows which in turn means that 12615 the window end is in reused rows which in turn means that
12590 only its vpos can have changed. */ 12616 only its vpos can have changed. */
@@ -13368,9 +13394,9 @@ try_window_id (w)
13368 13394
13369 if ((w->cursor.y < this_scroll_margin 13395 if ((w->cursor.y < this_scroll_margin
13370 && CHARPOS (start) > BEGV) 13396 && CHARPOS (start) > BEGV)
13371 /* Don't take scroll margin into account at the bottom because 13397 /* Old redisplay didn't take scroll margin into account at the bottom,
13372 old redisplay didn't do it either. */ 13398 but then global-hl-line-mode doesn't scroll. KFS 2004-06-14 */
13373 || w->cursor.y + cursor_height > it.last_visible_y) 13399 || w->cursor.y + cursor_height + this_scroll_margin > it.last_visible_y)
13374 { 13400 {
13375 w->cursor.vpos = -1; 13401 w->cursor.vpos = -1;
13376 clear_glyph_matrix (w->desired_matrix); 13402 clear_glyph_matrix (w->desired_matrix);