changeset 46200:b2d574ba36c5

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.
author Richard M. Stallman <rms@gnu.org>
date Sun, 07 Jul 2002 10:50:49 +0000
parents ca604a52d267
children ec2505a6b272
files src/xdisp.c
diffstat 1 files changed, 37 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Sun Jul 07 10:17:26 2002 +0000
+++ b/src/xdisp.c	Sun Jul 07 10:50:49 2002 +0000
@@ -9470,10 +9470,12 @@
 }
 
 
-/* Modify the desired matrix of window W and W->vscroll so that the
-   line containing the cursor is fully visible.
-   A value of 1 means there is nothing to be done or we did it.
-   A value of 0 causes redisplay.  */
+/* Make sure the line containing the cursor is fully visible.
+   A value of 1 means there is nothing to be done.
+   (Either the line is fully visible, or it cannot be made so,
+   or we cannot tell.)
+   A value of 0 means the caller should do scrolling
+   as if point had gone off the screen.  */
 
 static int
 make_cursor_line_fully_visible (w)
@@ -9501,6 +9503,13 @@
   if (row->height >= window_height)
     return 1;
 
+  return 0;
+
+#if 0
+  /* This code used to try to scroll the window just enough to make
+     the line visible.  It returned 0 to say that the caller should
+     allocate larger glyph matrices.  */
+
   if (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row))
     {
       int dy = row->height - row->visible_height;
@@ -9532,6 +9541,7 @@
     }
 
   return 1;
+#endif /* 0 */
 }
 
 
@@ -9628,6 +9638,7 @@
     {
       int y0;
 
+    too_near_end:
       /* Point is in the scroll margin at the bottom of the window, or
 	 below.  Compute a new window start that makes point visible.  */
 
@@ -9748,13 +9759,11 @@
 	  || BEG_UNCHANGED < CHARPOS (startp))
 	w->base_line_number = Qnil;
 
-      /* If cursor ends up on a partially visible line, shift display
-	 lines up or down.  If that fails because we need larger
-	 matrices, give up.  */
-      if (!make_cursor_line_fully_visible (w))
-	rc = SCROLLING_NEED_LARGER_MATRICES;
-      else
-	rc = SCROLLING_SUCCESS;
+      /* If cursor ends up on a partially visible line,
+	 treat that as being off the bottom of the screen.  */
+      if (! make_cursor_line_fully_visible (w))
+	goto too_near_end;
+      rc = SCROLLING_SUCCESS;
     }
 
   return rc;
@@ -10043,7 +10052,7 @@
 		  set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
 		  try_window (window, startp);
 		  if (!make_cursor_line_fully_visible (w))
-		    rc = CURSOR_MOVEMENT_NEED_LARGER_MATRICES;
+		    rc = CURSOR_MOVEMENT_MUST_SCROLL;
 		  else
 		    rc = CURSOR_MOVEMENT_SUCCESS;
 		}
@@ -10083,6 +10092,7 @@
   int temp_scroll_step = 0;
   int count = BINDING_STACK_SIZE ();
   int rc;
+  int centering_position;
 
   SET_TEXT_POS (lpoint, PT, PT_BYTE);
   opoint = lpoint;
@@ -10333,7 +10343,7 @@
 	}
 
       if (!make_cursor_line_fully_visible (w))
-	goto need_larger_matrices;
+	goto try_to_scroll;
 #if GLYPH_DEBUG
       debug_method_add (w, "forced window start");
 #endif
@@ -10429,7 +10439,8 @@
 	    w->base_line_number = Qnil;
 
 	  if (!make_cursor_line_fully_visible (w))
-	    goto need_larger_matrices;
+	    /* Drop through and scroll.  */
+	    ;
 	  goto done;
 	}
       else
@@ -10483,6 +10494,10 @@
   /* Finally, just choose place to start which centers point */
 
  recenter:
+  centering_position = window_box_height (w) / 2;
+
+ point_at_top:
+  /* Jump here with centering_position already set to 0.  */
 
 #if GLYPH_DEBUG
   debug_method_add (w, "recenter");
@@ -10498,7 +10513,7 @@
   /* Move backward half the height of the window.  */
   init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID);
   it.current_y = it.last_visible_y;
-  move_it_vertically_backward (&it, window_box_height (w) / 2);
+  move_it_vertically_backward (&it, centering_position);
   xassert (IT_CHARPOS (it) >= BEGV);
 
   /* The function move_it_vertically_backward may move over more
@@ -10580,7 +10595,13 @@
     }
 
   if (!make_cursor_line_fully_visible (w))
-    goto need_larger_matrices;
+    {
+      /* If centering point failed to make the whole line visible,
+	 put point at the top instead.  That has to make the whole line
+	 visible, if it can be done.  */
+      centering_position = 0;
+      goto point_at_top;
+    }
 
  done: