diff options
| author | Richard M. Stallman | 2002-07-07 10:50:49 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-07-07 10:50:49 +0000 |
| commit | ddf6b9a3b7e5ee7b97b45ceef47f73491dc178a3 (patch) | |
| tree | e6ae27689ff20b1114fd742be98a424ba153b7d3 /src | |
| parent | f0bac7deee2f56ac02ff886dc5a1b7210e1fd089 (diff) | |
| download | emacs-ddf6b9a3b7e5ee7b97b45ceef47f73491dc178a3.tar.gz emacs-ddf6b9a3b7e5ee7b97b45ceef47f73491dc178a3.zip | |
Treat a partially visible line like "cursor off screen".
(make_cursor_line_fully_visible): Don't try short scrolls.
Instead just return 0 when there is something to be done.
(try_scrolling): If make_cursor_line_fully_visible returns 0,
retry scrolling as if cursor were off the bottom.
(try_cursor_movement): If make_cursor_line_fully_visible returns 0,
return CURSOR_MOVEMENT_MUST_SCROLL.
(redisplay_window): If make_cursor_line_fully_visible returns 0,
go to try_to_scroll.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 0534090211d..64d2d1bdc7e 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -9470,10 +9470,12 @@ run_window_scroll_functions (window, startp) | |||
| 9470 | } | 9470 | } |
| 9471 | 9471 | ||
| 9472 | 9472 | ||
| 9473 | /* Modify the desired matrix of window W and W->vscroll so that the | 9473 | /* Make sure the line containing the cursor is fully visible. |
| 9474 | line containing the cursor is fully visible. | 9474 | A value of 1 means there is nothing to be done. |
| 9475 | A value of 1 means there is nothing to be done or we did it. | 9475 | (Either the line is fully visible, or it cannot be made so, |
| 9476 | A value of 0 causes redisplay. */ | 9476 | or we cannot tell.) |
| 9477 | A value of 0 means the caller should do scrolling | ||
| 9478 | as if point had gone off the screen. */ | ||
| 9477 | 9479 | ||
| 9478 | static int | 9480 | static int |
| 9479 | make_cursor_line_fully_visible (w) | 9481 | make_cursor_line_fully_visible (w) |
| @@ -9501,6 +9503,13 @@ make_cursor_line_fully_visible (w) | |||
| 9501 | if (row->height >= window_height) | 9503 | if (row->height >= window_height) |
| 9502 | return 1; | 9504 | return 1; |
| 9503 | 9505 | ||
| 9506 | return 0; | ||
| 9507 | |||
| 9508 | #if 0 | ||
| 9509 | /* This code used to try to scroll the window just enough to make | ||
| 9510 | the line visible. It returned 0 to say that the caller should | ||
| 9511 | allocate larger glyph matrices. */ | ||
| 9512 | |||
| 9504 | if (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row)) | 9513 | if (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row)) |
| 9505 | { | 9514 | { |
| 9506 | int dy = row->height - row->visible_height; | 9515 | int dy = row->height - row->visible_height; |
| @@ -9532,6 +9541,7 @@ make_cursor_line_fully_visible (w) | |||
| 9532 | } | 9541 | } |
| 9533 | 9542 | ||
| 9534 | return 1; | 9543 | return 1; |
| 9544 | #endif /* 0 */ | ||
| 9535 | } | 9545 | } |
| 9536 | 9546 | ||
| 9537 | 9547 | ||
| @@ -9628,6 +9638,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively, | |||
| 9628 | { | 9638 | { |
| 9629 | int y0; | 9639 | int y0; |
| 9630 | 9640 | ||
| 9641 | too_near_end: | ||
| 9631 | /* Point is in the scroll margin at the bottom of the window, or | 9642 | /* Point is in the scroll margin at the bottom of the window, or |
| 9632 | below. Compute a new window start that makes point visible. */ | 9643 | below. Compute a new window start that makes point visible. */ |
| 9633 | 9644 | ||
| @@ -9748,13 +9759,11 @@ try_scrolling (window, just_this_one_p, scroll_conservatively, | |||
| 9748 | || BEG_UNCHANGED < CHARPOS (startp)) | 9759 | || BEG_UNCHANGED < CHARPOS (startp)) |
| 9749 | w->base_line_number = Qnil; | 9760 | w->base_line_number = Qnil; |
| 9750 | 9761 | ||
| 9751 | /* If cursor ends up on a partially visible line, shift display | 9762 | /* If cursor ends up on a partially visible line, |
| 9752 | lines up or down. If that fails because we need larger | 9763 | treat that as being off the bottom of the screen. */ |
| 9753 | matrices, give up. */ | 9764 | if (! make_cursor_line_fully_visible (w)) |
| 9754 | if (!make_cursor_line_fully_visible (w)) | 9765 | goto too_near_end; |
| 9755 | rc = SCROLLING_NEED_LARGER_MATRICES; | 9766 | rc = SCROLLING_SUCCESS; |
| 9756 | else | ||
| 9757 | rc = SCROLLING_SUCCESS; | ||
| 9758 | } | 9767 | } |
| 9759 | 9768 | ||
| 9760 | return rc; | 9769 | return rc; |
| @@ -10043,7 +10052,7 @@ try_cursor_movement (window, startp, scroll_step) | |||
| 10043 | set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); | 10052 | set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); |
| 10044 | try_window (window, startp); | 10053 | try_window (window, startp); |
| 10045 | if (!make_cursor_line_fully_visible (w)) | 10054 | if (!make_cursor_line_fully_visible (w)) |
| 10046 | rc = CURSOR_MOVEMENT_NEED_LARGER_MATRICES; | 10055 | rc = CURSOR_MOVEMENT_MUST_SCROLL; |
| 10047 | else | 10056 | else |
| 10048 | rc = CURSOR_MOVEMENT_SUCCESS; | 10057 | rc = CURSOR_MOVEMENT_SUCCESS; |
| 10049 | } | 10058 | } |
| @@ -10083,6 +10092,7 @@ redisplay_window (window, just_this_one_p) | |||
| 10083 | int temp_scroll_step = 0; | 10092 | int temp_scroll_step = 0; |
| 10084 | int count = BINDING_STACK_SIZE (); | 10093 | int count = BINDING_STACK_SIZE (); |
| 10085 | int rc; | 10094 | int rc; |
| 10095 | int centering_position; | ||
| 10086 | 10096 | ||
| 10087 | SET_TEXT_POS (lpoint, PT, PT_BYTE); | 10097 | SET_TEXT_POS (lpoint, PT, PT_BYTE); |
| 10088 | opoint = lpoint; | 10098 | opoint = lpoint; |
| @@ -10333,7 +10343,7 @@ redisplay_window (window, just_this_one_p) | |||
| 10333 | } | 10343 | } |
| 10334 | 10344 | ||
| 10335 | if (!make_cursor_line_fully_visible (w)) | 10345 | if (!make_cursor_line_fully_visible (w)) |
| 10336 | goto need_larger_matrices; | 10346 | goto try_to_scroll; |
| 10337 | #if GLYPH_DEBUG | 10347 | #if GLYPH_DEBUG |
| 10338 | debug_method_add (w, "forced window start"); | 10348 | debug_method_add (w, "forced window start"); |
| 10339 | #endif | 10349 | #endif |
| @@ -10429,7 +10439,8 @@ redisplay_window (window, just_this_one_p) | |||
| 10429 | w->base_line_number = Qnil; | 10439 | w->base_line_number = Qnil; |
| 10430 | 10440 | ||
| 10431 | if (!make_cursor_line_fully_visible (w)) | 10441 | if (!make_cursor_line_fully_visible (w)) |
| 10432 | goto need_larger_matrices; | 10442 | /* Drop through and scroll. */ |
| 10443 | ; | ||
| 10433 | goto done; | 10444 | goto done; |
| 10434 | } | 10445 | } |
| 10435 | else | 10446 | else |
| @@ -10483,6 +10494,10 @@ redisplay_window (window, just_this_one_p) | |||
| 10483 | /* Finally, just choose place to start which centers point */ | 10494 | /* Finally, just choose place to start which centers point */ |
| 10484 | 10495 | ||
| 10485 | recenter: | 10496 | recenter: |
| 10497 | centering_position = window_box_height (w) / 2; | ||
| 10498 | |||
| 10499 | point_at_top: | ||
| 10500 | /* Jump here with centering_position already set to 0. */ | ||
| 10486 | 10501 | ||
| 10487 | #if GLYPH_DEBUG | 10502 | #if GLYPH_DEBUG |
| 10488 | debug_method_add (w, "recenter"); | 10503 | debug_method_add (w, "recenter"); |
| @@ -10498,7 +10513,7 @@ redisplay_window (window, just_this_one_p) | |||
| 10498 | /* Move backward half the height of the window. */ | 10513 | /* Move backward half the height of the window. */ |
| 10499 | init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); | 10514 | init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); |
| 10500 | it.current_y = it.last_visible_y; | 10515 | it.current_y = it.last_visible_y; |
| 10501 | move_it_vertically_backward (&it, window_box_height (w) / 2); | 10516 | move_it_vertically_backward (&it, centering_position); |
| 10502 | xassert (IT_CHARPOS (it) >= BEGV); | 10517 | xassert (IT_CHARPOS (it) >= BEGV); |
| 10503 | 10518 | ||
| 10504 | /* The function move_it_vertically_backward may move over more | 10519 | /* The function move_it_vertically_backward may move over more |
| @@ -10580,7 +10595,13 @@ redisplay_window (window, just_this_one_p) | |||
| 10580 | } | 10595 | } |
| 10581 | 10596 | ||
| 10582 | if (!make_cursor_line_fully_visible (w)) | 10597 | if (!make_cursor_line_fully_visible (w)) |
| 10583 | goto need_larger_matrices; | 10598 | { |
| 10599 | /* If centering point failed to make the whole line visible, | ||
| 10600 | put point at the top instead. That has to make the whole line | ||
| 10601 | visible, if it can be done. */ | ||
| 10602 | centering_position = 0; | ||
| 10603 | goto point_at_top; | ||
| 10604 | } | ||
| 10584 | 10605 | ||
| 10585 | done: | 10606 | done: |
| 10586 | 10607 | ||