Mercurial > emacs
comparison src/xdisp.c @ 56118:6fbabfb26a3c
(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.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 15 Jun 2004 10:35:05 +0000 |
parents | a64ca0d0e4c5 |
children | abdb38fe88c5 4c90ffeb71c5 |
comparison
equal
deleted
inserted
replaced
56117:75f76430cc6c | 56118:6fbabfb26a3c |
---|---|
11265 && INTEGERP (w->window_end_vpos) | 11265 && INTEGERP (w->window_end_vpos) |
11266 && XFASTINT (w->window_end_vpos) < w->current_matrix->nrows | 11266 && XFASTINT (w->window_end_vpos) < w->current_matrix->nrows |
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 |
11274 debug_method_add (w, "cursor movement"); | 11274 debug_method_add (w, "cursor movement"); |
11275 #endif | 11275 #endif |
11277 /* Scroll if point within this distance from the top or bottom | 11277 /* Scroll if point within this distance from the top or bottom |
11278 of the window. This is a pixel value. */ | 11278 of the window. This is a pixel value. */ |
11279 this_scroll_margin = max (0, scroll_margin); | 11279 this_scroll_margin = max (0, scroll_margin); |
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 | |
11283 top_scroll_margin = this_scroll_margin; | |
11284 if (WINDOW_WANTS_HEADER_LINE_P (w)) | |
11285 top_scroll_margin += CURRENT_HEADER_LINE_HEIGHT (w); | |
11282 | 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 |
11286 || w->last_cursor.vpos >= w->current_matrix->nrows) | 11290 || w->last_cursor.vpos >= w->current_matrix->nrows) |
11338 if-statement. */ | 11342 if-statement. */ |
11339 while (!row->mode_line_p | 11343 while (!row->mode_line_p |
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); |
11347 --row; | 11351 --row; |
11348 } | 11352 } |
11366 && MATRIX_ROW_END_CHARPOS (row) == PT | 11370 && MATRIX_ROW_END_CHARPOS (row) == PT |
11367 && !cursor_row_p (w, row)) | 11371 && !cursor_row_p (w, row)) |
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 } |
11375 | 11379 |
11376 if (PT < MATRIX_ROW_START_CHARPOS (row) | 11380 if (PT < MATRIX_ROW_START_CHARPOS (row) |
12536 | 12540 |
12537 /* If point is in a reused row, adjust y and vpos of the cursor | 12541 /* If point is in a reused row, adjust y and vpos of the cursor |
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. */ |
12547 run.current_y = first_reusable_row->y; | 12550 run.current_y = first_reusable_row->y; |
12548 run.desired_y = WINDOW_HEADER_LINE_HEIGHT (w); | 12551 run.desired_y = WINDOW_HEADER_LINE_HEIGHT (w); |
12582 -nrows_scrolled); | 12585 -nrows_scrolled); |
12583 | 12586 |
12584 /* Disable rows not reused. */ | 12587 /* Disable rows not reused. */ |
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; |
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 } | |
12587 | 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. */ |
12591 if (last_text_row) | 12617 if (last_text_row) |
13366 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f); | 13392 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f); |
13367 cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height; | 13393 cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height; |
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); |
13377 return -1; | 13403 return -1; |
13378 } | 13404 } |