}
-/* 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)
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;
}
return 1;
+#endif /* 0 */
}
{
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. */
|| 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;
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;
}
int temp_scroll_step = 0;
int count = BINDING_STACK_SIZE ();
int rc;
+ int centering_position;
SET_TEXT_POS (lpoint, PT, PT_BYTE);
opoint = lpoint;
}
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
w->base_line_number = Qnil;
if (!make_cursor_line_fully_visible (w))
- goto need_larger_matrices;
+ /* Drop through and scroll. */
+ ;
goto done;
}
else
/* 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");
/* 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
}
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: