aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-09-26 11:27:25 +0000
committerGerd Moellmann2001-09-26 11:27:25 +0000
commitcb617e7c78df353823871ad181a31e9fe2d3a98d (patch)
tree901ac22bb4fd6e2e219366ab440b868c4539563c /src
parent5d3cc43c0c7f9959dbb57d914655cd5f5ad74b71 (diff)
downloademacs-cb617e7c78df353823871ad181a31e9fe2d3a98d.tar.gz
emacs-cb617e7c78df353823871ad181a31e9fe2d3a98d.zip
(make_cursor_line_fully_visible): Return 0 and set
fonts_changed_p if need larger matrices due to vscrolling. (try_scrolling, try_cursor_movement, redisplay_window): Give up on this round of redisplay if make_cursor_line_fully_visible fails. (CURSOR_MOVEMENT_*, SCROLLING_*): New enumerators. (try_cursor_movement, try_scrolling): Use them instead of integers.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog17
-rw-r--r--src/xdisp.c159
2 files changed, 127 insertions, 49 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index db0b6e9cff6..a5179f83d27 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,22 @@
12001-09-26 Gerd Moellmann <gerd@gnu.org> 12001-09-26 Gerd Moellmann <gerd@gnu.org>
2 2
3 * xdisp.c (make_cursor_line_fully_visible): Return 0 and set
4 fonts_changed_p if need larger matrices due to vscrolling.
5 (try_scrolling, try_cursor_movement, redisplay_window): Give up on
6 this round of redisplay if make_cursor_line_fully_visible fails.
7 (CURSOR_MOVEMENT_*, SCROLLING_*): New enumerators.
8 (try_cursor_movement, try_scrolling): Use them instead of
9 integers.
10
11 * dispextern.h (required_matrix_width, required_matrix_height):
12 Add prototypes.
13
14 * dispnew.c (required_matrix_width, required_matrix_height): New
15 functions.
16 (allocate_matrices_for_window_redisplay)
17 (allocate_matrices_for_frame_redisplay: Use them. Remove
18 parameters CH_DIM.
19
3 * xdisp.c (display_mode_lines): Temporarily set selected_frame 20 * xdisp.c (display_mode_lines): Temporarily set selected_frame
4 and selected_window to the frame of the window whose mode-lines 21 and selected_window to the frame of the window whose mode-lines
5 are displayed, and to the window itself. 22 are displayed, and to the window itself.
diff --git a/src/xdisp.c b/src/xdisp.c
index 02141b7c86b..eae5e9062fb 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -708,7 +708,7 @@ static void insert_left_trunc_glyphs P_ ((struct it *));
708static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *)); 708static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *));
709static void extend_face_to_end_of_line P_ ((struct it *)); 709static void extend_face_to_end_of_line P_ ((struct it *));
710static int append_space P_ ((struct it *, int)); 710static int append_space P_ ((struct it *, int));
711static void make_cursor_line_fully_visible P_ ((struct window *)); 711static int make_cursor_line_fully_visible P_ ((struct window *));
712static int try_scrolling P_ ((Lisp_Object, int, int, int, int)); 712static int try_scrolling P_ ((Lisp_Object, int, int, int, int));
713static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); 713static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *));
714static int trailing_whitespace_p P_ ((int)); 714static int trailing_whitespace_p P_ ((int));
@@ -9284,9 +9284,11 @@ run_window_scroll_functions (window, startp)
9284 9284
9285 9285
9286/* Modify the desired matrix of window W and W->vscroll so that the 9286/* Modify the desired matrix of window W and W->vscroll so that the
9287 line containing the cursor is fully visible. */ 9287 line containing the cursor is fully visible. If this requires
9288 larger matrices than are allocated, set fonts_changed_p and return
9289 0. */
9288 9290
9289static void 9291static int
9290make_cursor_line_fully_visible (w) 9292make_cursor_line_fully_visible (w)
9291 struct window *w; 9293 struct window *w;
9292{ 9294{
@@ -9297,7 +9299,7 @@ make_cursor_line_fully_visible (w)
9297 /* It's not always possible to find the cursor, e.g, when a window 9299 /* It's not always possible to find the cursor, e.g, when a window
9298 is full of overlay strings. Don't do anything in that case. */ 9300 is full of overlay strings. Don't do anything in that case. */
9299 if (w->cursor.vpos < 0) 9301 if (w->cursor.vpos < 0)
9300 return; 9302 return 1;
9301 9303
9302 matrix = w->desired_matrix; 9304 matrix = w->desired_matrix;
9303 row = MATRIX_ROW (matrix, w->cursor.vpos); 9305 row = MATRIX_ROW (matrix, w->cursor.vpos);
@@ -9305,13 +9307,13 @@ make_cursor_line_fully_visible (w)
9305 /* If the cursor row is not partially visible, there's nothing 9307 /* If the cursor row is not partially visible, there's nothing
9306 to do. */ 9308 to do. */
9307 if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (row)) 9309 if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (row))
9308 return; 9310 return 1;
9309 9311
9310 /* If the row the cursor is in is taller than the window's height, 9312 /* If the row the cursor is in is taller than the window's height,
9311 it's not clear what to do, so do nothing. */ 9313 it's not clear what to do, so do nothing. */
9312 window_height = window_box_height (w); 9314 window_height = window_box_height (w);
9313 if (row->height >= window_height) 9315 if (row->height >= window_height)
9314 return; 9316 return 1;
9315 9317
9316 if (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row)) 9318 if (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row))
9317 { 9319 {
@@ -9334,6 +9336,16 @@ make_cursor_line_fully_visible (w)
9334 the correct y-position. */ 9336 the correct y-position. */
9335 if (w == XWINDOW (selected_window)) 9337 if (w == XWINDOW (selected_window))
9336 this_line_y = w->cursor.y; 9338 this_line_y = w->cursor.y;
9339
9340 /* If vscrolling requires a larger glyph matrix, arrange for a fresh
9341 redisplay with larger matrices. */
9342 if (matrix->nrows < required_matrix_height (w))
9343 {
9344 fonts_changed_p = 1;
9345 return 0;
9346 }
9347
9348 return 1;
9337} 9349}
9338 9350
9339 9351
@@ -9352,6 +9364,13 @@ make_cursor_line_fully_visible (w)
9352 -1 if new fonts have been loaded so that we must interrupt 9364 -1 if new fonts have been loaded so that we must interrupt
9353 redisplay, adjust glyph matrices, and try again. */ 9365 redisplay, adjust glyph matrices, and try again. */
9354 9366
9367enum
9368{
9369 SCROLLING_SUCCESS,
9370 SCROLLING_FAILED,
9371 SCROLLING_NEED_LARGER_MATRICES
9372};
9373
9355static int 9374static int
9356try_scrolling (window, just_this_one_p, scroll_conservatively, 9375try_scrolling (window, just_this_one_p, scroll_conservatively,
9357 scroll_step, temp_scroll_step) 9376 scroll_step, temp_scroll_step)
@@ -9441,7 +9460,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
9441 dy = 1 + it.current_y - y0; 9460 dy = 1 + it.current_y - y0;
9442 9461
9443 if (dy > scroll_max) 9462 if (dy > scroll_max)
9444 return 0; 9463 return SCROLLING_FAILED;
9445 9464
9446 /* Move the window start down. If scrolling conservatively, 9465 /* Move the window start down. If scrolling conservatively,
9447 move it just enough down to make point visible. If 9466 move it just enough down to make point visible. If
@@ -9464,7 +9483,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
9464 } 9483 }
9465 9484
9466 if (amount_to_scroll <= 0) 9485 if (amount_to_scroll <= 0)
9467 return 0; 9486 return SCROLLING_FAILED;
9468 9487
9469 move_it_vertically (&it, amount_to_scroll); 9488 move_it_vertically (&it, amount_to_scroll);
9470 startp = it.current.pos; 9489 startp = it.current.pos;
@@ -9498,7 +9517,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
9498 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); 9517 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
9499 dy = it.current_y - y0; 9518 dy = it.current_y - y0;
9500 if (dy > scroll_max) 9519 if (dy > scroll_max)
9501 return 0; 9520 return SCROLLING_FAILED;
9502 9521
9503 /* Compute new window start. */ 9522 /* Compute new window start. */
9504 start_display (&it, w, startp); 9523 start_display (&it, w, startp);
@@ -9518,7 +9537,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
9518 } 9537 }
9519 9538
9520 if (amount_to_scroll <= 0) 9539 if (amount_to_scroll <= 0)
9521 return 0; 9540 return SCROLLING_FAILED;
9522 9541
9523 move_it_vertically (&it, - amount_to_scroll); 9542 move_it_vertically (&it, - amount_to_scroll);
9524 startp = it.current.pos; 9543 startp = it.current.pos;
@@ -9531,11 +9550,11 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
9531 /* Display the window. Give up if new fonts are loaded, or if point 9550 /* Display the window. Give up if new fonts are loaded, or if point
9532 doesn't appear. */ 9551 doesn't appear. */
9533 if (!try_window (window, startp)) 9552 if (!try_window (window, startp))
9534 rc = -1; 9553 rc = SCROLLING_NEED_LARGER_MATRICES;
9535 else if (w->cursor.vpos < 0) 9554 else if (w->cursor.vpos < 0)
9536 { 9555 {
9537 clear_glyph_matrix (w->desired_matrix); 9556 clear_glyph_matrix (w->desired_matrix);
9538 rc = 0; 9557 rc = SCROLLING_FAILED;
9539 } 9558 }
9540 else 9559 else
9541 { 9560 {
@@ -9546,9 +9565,12 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
9546 w->base_line_number = Qnil; 9565 w->base_line_number = Qnil;
9547 9566
9548 /* If cursor ends up on a partially visible line, shift display 9567 /* If cursor ends up on a partially visible line, shift display
9549 lines up or down. */ 9568 lines up or down. If that fails because we need larger
9550 make_cursor_line_fully_visible (w); 9569 matrices, give up. */
9551 rc = 1; 9570 if (!make_cursor_line_fully_visible (w))
9571 rc = SCROLLING_NEED_LARGER_MATRICES;
9572 else
9573 rc = SCROLLING_SUCCESS;
9552 } 9574 }
9553 9575
9554 return rc; 9576 return rc;
@@ -9630,13 +9652,25 @@ compute_window_start_on_continuation_line (w)
9630/* Try cursor movement in case text has not changes in window WINDOW, 9652/* Try cursor movement in case text has not changes in window WINDOW,
9631 with window start STARTP. Value is 9653 with window start STARTP. Value is
9632 9654
9633 1 if successful 9655 CURSOR_MOVEMENT_SUCCESS if successful
9634
9635 0 if this method cannot be used
9636 9656
9637 -1 if we know we have to scroll the display. *SCROLL_STEP is 9657 CURSOR_MOVEMENT_CANNOT_BE_USED if this method cannot be used
9638 set to 1, under certain circumstances, if we want to scroll as 9658
9639 if scroll-step were set to 1. See the code. */ 9659 CURSOR_MOVEMENT_MUST_SCROLL if we know we have to scroll the
9660 display. *SCROLL_STEP is set to 1, under certain circumstances, if
9661 we want to scroll as if scroll-step were set to 1. See the code.
9662
9663 CURSOR_MOVEMENT_NEED_LARGER_MATRICES if we need larger matrices, in
9664 which case we have to abort this redisplay, and adjust matrices
9665 first. */
9666
9667enum
9668{
9669 CURSOR_MOVEMENT_SUCCESS,
9670 CURSOR_MOVEMENT_CANNOT_BE_USED,
9671 CURSOR_MOVEMENT_MUST_SCROLL,
9672 CURSOR_MOVEMENT_NEED_LARGER_MATRICES
9673};
9640 9674
9641static int 9675static int
9642try_cursor_movement (window, startp, scroll_step) 9676try_cursor_movement (window, startp, scroll_step)
@@ -9646,7 +9680,7 @@ try_cursor_movement (window, startp, scroll_step)
9646{ 9680{
9647 struct window *w = XWINDOW (window); 9681 struct window *w = XWINDOW (window);
9648 struct frame *f = XFRAME (w->frame); 9682 struct frame *f = XFRAME (w->frame);
9649 int rc = 0; 9683 int rc = CURSOR_MOVEMENT_CANNOT_BE_USED;
9650 9684
9651 /* Handle case where text has not changed, only point, and it has 9685 /* Handle case where text has not changed, only point, and it has
9652 not moved off the frame. */ 9686 not moved off the frame. */
@@ -9704,17 +9738,17 @@ try_cursor_movement (window, startp, scroll_step)
9704 not paused redisplay. Give up if that row is not valid. */ 9738 not paused redisplay. Give up if that row is not valid. */
9705 if (w->last_cursor.vpos < 0 9739 if (w->last_cursor.vpos < 0
9706 || w->last_cursor.vpos >= w->current_matrix->nrows) 9740 || w->last_cursor.vpos >= w->current_matrix->nrows)
9707 rc = -1; 9741 rc = CURSOR_MOVEMENT_MUST_SCROLL;
9708 else 9742 else
9709 { 9743 {
9710 row = MATRIX_ROW (w->current_matrix, w->last_cursor.vpos); 9744 row = MATRIX_ROW (w->current_matrix, w->last_cursor.vpos);
9711 if (row->mode_line_p) 9745 if (row->mode_line_p)
9712 ++row; 9746 ++row;
9713 if (!row->enabled_p) 9747 if (!row->enabled_p)
9714 rc = -1; 9748 rc = CURSOR_MOVEMENT_MUST_SCROLL;
9715 } 9749 }
9716 9750
9717 if (rc == 0) 9751 if (rc == CURSOR_MOVEMENT_CANNOT_BE_USED)
9718 { 9752 {
9719 int scroll_p = 0; 9753 int scroll_p = 0;
9720 int last_y = window_text_bottom_y (w) - this_scroll_margin; 9754 int last_y = window_text_bottom_y (w) - this_scroll_margin;
@@ -9797,14 +9831,14 @@ try_cursor_movement (window, startp, scroll_step)
9797 || PT > MATRIX_ROW_END_CHARPOS (row)) 9831 || PT > MATRIX_ROW_END_CHARPOS (row))
9798 { 9832 {
9799 /* if PT is not in the glyph row, give up. */ 9833 /* if PT is not in the glyph row, give up. */
9800 rc = -1; 9834 rc = CURSOR_MOVEMENT_MUST_SCROLL;
9801 } 9835 }
9802 else if (MATRIX_ROW_PARTIALLY_VISIBLE_P (row)) 9836 else if (MATRIX_ROW_PARTIALLY_VISIBLE_P (row))
9803 { 9837 {
9804 if (PT == MATRIX_ROW_END_CHARPOS (row) 9838 if (PT == MATRIX_ROW_END_CHARPOS (row)
9805 && !row->ends_at_zv_p 9839 && !row->ends_at_zv_p
9806 && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row)) 9840 && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))
9807 rc = -1; 9841 rc = CURSOR_MOVEMENT_MUST_SCROLL;
9808 else if (row->height > window_box_height (w)) 9842 else if (row->height > window_box_height (w))
9809 { 9843 {
9810 /* If we end up in a partially visible line, let's 9844 /* If we end up in a partially visible line, let's
@@ -9812,22 +9846,24 @@ try_cursor_movement (window, startp, scroll_step)
9812 than the window, in which case we can't do much 9846 than the window, in which case we can't do much
9813 about it. */ 9847 about it. */
9814 *scroll_step = 1; 9848 *scroll_step = 1;
9815 rc = -1; 9849 rc = CURSOR_MOVEMENT_MUST_SCROLL;
9816 } 9850 }
9817 else 9851 else
9818 { 9852 {
9819 set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); 9853 set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
9820 try_window (window, startp); 9854 try_window (window, startp);
9821 make_cursor_line_fully_visible (w); 9855 if (!make_cursor_line_fully_visible (w))
9822 rc = 1; 9856 rc = CURSOR_MOVEMENT_NEED_LARGER_MATRICES;
9857 else
9858 rc = CURSOR_MOVEMENT_SUCCESS;
9823 } 9859 }
9824 } 9860 }
9825 else if (scroll_p) 9861 else if (scroll_p)
9826 rc = -1; 9862 rc = CURSOR_MOVEMENT_MUST_SCROLL;
9827 else 9863 else
9828 { 9864 {
9829 set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); 9865 set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
9830 rc = 1; 9866 rc = CURSOR_MOVEMENT_SUCCESS;
9831 } 9867 }
9832 } 9868 }
9833 } 9869 }
@@ -10101,11 +10137,12 @@ redisplay_window (window, just_this_one_p)
10101 { 10137 {
10102 clear_glyph_matrix (w->desired_matrix); 10138 clear_glyph_matrix (w->desired_matrix);
10103 if (!try_window (window, startp)) 10139 if (!try_window (window, startp))
10104 goto finish_scroll_bars; 10140 goto need_larger_matrices;
10105 } 10141 }
10106 } 10142 }
10107 10143
10108 make_cursor_line_fully_visible (w); 10144 if (!make_cursor_line_fully_visible (w))
10145 goto need_larger_matrices;
10109#if GLYPH_DEBUG 10146#if GLYPH_DEBUG
10110 debug_method_add (w, "forced window start"); 10147 debug_method_add (w, "forced window start");
10111#endif 10148#endif
@@ -10116,12 +10153,22 @@ redisplay_window (window, just_this_one_p)
10116 not moved off the frame. */ 10153 not moved off the frame. */
10117 if (current_matrix_up_to_date_p 10154 if (current_matrix_up_to_date_p
10118 && (rc = try_cursor_movement (window, startp, &temp_scroll_step), 10155 && (rc = try_cursor_movement (window, startp, &temp_scroll_step),
10119 rc != 0)) 10156 rc != CURSOR_MOVEMENT_CANNOT_BE_USED))
10120 { 10157 {
10121 if (rc == -1) 10158 switch (rc)
10122 goto try_to_scroll; 10159 {
10123 else 10160 case CURSOR_MOVEMENT_SUCCESS:
10124 goto done; 10161 goto done;
10162
10163 case CURSOR_MOVEMENT_NEED_LARGER_MATRICES:
10164 goto need_larger_matrices;
10165
10166 case CURSOR_MOVEMENT_MUST_SCROLL:
10167 goto try_to_scroll;
10168
10169 default:
10170 abort ();
10171 }
10125 } 10172 }
10126 /* If current starting point was originally the beginning of a line 10173 /* If current starting point was originally the beginning of a line
10127 but no longer is, find a new starting point. */ 10174 but no longer is, find a new starting point. */
@@ -10145,7 +10192,7 @@ redisplay_window (window, just_this_one_p)
10145#endif 10192#endif
10146 10193
10147 if (fonts_changed_p) 10194 if (fonts_changed_p)
10148 goto finish_scroll_bars; 10195 goto need_larger_matrices;
10149 if (tem > 0) 10196 if (tem > 0)
10150 goto done; 10197 goto done;
10151 10198
@@ -10180,7 +10227,7 @@ redisplay_window (window, just_this_one_p)
10180 } 10227 }
10181 10228
10182 if (fonts_changed_p) 10229 if (fonts_changed_p)
10183 goto finish_scroll_bars; 10230 goto need_larger_matrices;
10184 10231
10185 if (w->cursor.vpos >= 0) 10232 if (w->cursor.vpos >= 0)
10186 { 10233 {
@@ -10190,7 +10237,8 @@ redisplay_window (window, just_this_one_p)
10190 /* Forget any recorded base line for line number display. */ 10237 /* Forget any recorded base line for line number display. */
10191 w->base_line_number = Qnil; 10238 w->base_line_number = Qnil;
10192 10239
10193 make_cursor_line_fully_visible (w); 10240 if (!make_cursor_line_fully_visible (w))
10241 goto need_larger_matrices;
10194 goto done; 10242 goto done;
10195 } 10243 }
10196 else 10244 else
@@ -10225,10 +10273,20 @@ redisplay_window (window, just_this_one_p)
10225 scroll_conservatively, 10273 scroll_conservatively,
10226 scroll_step, 10274 scroll_step,
10227 temp_scroll_step); 10275 temp_scroll_step);
10228 if (rc > 0) 10276 switch (rc)
10229 goto done; 10277 {
10230 else if (rc < 0) 10278 case SCROLLING_SUCCESS:
10231 goto finish_scroll_bars; 10279 goto done;
10280
10281 case SCROLLING_NEED_LARGER_MATRICES:
10282 goto need_larger_matrices;
10283
10284 case SCROLLING_FAILED:
10285 break;
10286
10287 default:
10288 abort ();
10289 }
10232 } 10290 }
10233 10291
10234 /* Finally, just choose place to start which centers point */ 10292 /* Finally, just choose place to start which centers point */
@@ -10289,7 +10347,7 @@ redisplay_window (window, just_this_one_p)
10289 have to start a new redisplay since we need to re-adjust glyph 10347 have to start a new redisplay since we need to re-adjust glyph
10290 matrices. */ 10348 matrices. */
10291 if (fonts_changed_p) 10349 if (fonts_changed_p)
10292 goto finish_scroll_bars; 10350 goto need_larger_matrices;
10293 10351
10294 /* If cursor did not appear assume that the middle of the window is 10352 /* If cursor did not appear assume that the middle of the window is
10295 in the first line of the window. Do it again with the next line. 10353 in the first line of the window. Do it again with the next line.
@@ -10329,7 +10387,8 @@ redisplay_window (window, just_this_one_p)
10329 set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); 10387 set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
10330 } 10388 }
10331 10389
10332 make_cursor_line_fully_visible (w); 10390 if (!make_cursor_line_fully_visible (w))
10391 goto need_larger_matrices;
10333 10392
10334 done: 10393 done:
10335 10394
@@ -10379,7 +10438,7 @@ redisplay_window (window, just_this_one_p)
10379 } 10438 }
10380 10439
10381 if (fonts_changed_p) 10440 if (fonts_changed_p)
10382 goto finish_scroll_bars; 10441 goto need_larger_matrices;
10383 } 10442 }
10384 10443
10385 if (!line_number_displayed 10444 if (!line_number_displayed
@@ -10419,6 +10478,8 @@ redisplay_window (window, just_this_one_p)
10419#endif 10478#endif
10420 } 10479 }
10421 10480
10481 need_larger_matrices:
10482 ;
10422 finish_scroll_bars: 10483 finish_scroll_bars:
10423 10484
10424 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) 10485 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))