comparison src/xdisp.c @ 47188:fc2b2a9d0188

(redisplay_window) <force-start case>: If point is on semi-visible last line, reposition it at previous line.
author Richard M. Stallman <rms@gnu.org>
date Sun, 01 Sep 2002 13:43:38 +0000
parents 68836f99f298
children 38bf43c3fb05
comparison
equal deleted inserted replaced
47187:075242ae1c42 47188:fc2b2a9d0188
8961 nuked should now go away. */ 8961 nuked should now go away. */
8962 if (judge_scroll_bars_hook) 8962 if (judge_scroll_bars_hook)
8963 judge_scroll_bars_hook (f); 8963 judge_scroll_bars_hook (f);
8964 8964
8965 /* If fonts changed, display again. */ 8965 /* If fonts changed, display again. */
8966 /* ??? rms: I suspect it is a mistake to jump all the way
8967 back to retry here. It should just retry this frame. */
8966 if (fonts_changed_p) 8968 if (fonts_changed_p)
8967 goto retry; 8969 goto retry;
8968 8970
8969 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f)) 8971 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
8970 { 8972 {
10096 return rc; 10098 return rc;
10097 } 10099 }
10098 10100
10099 10101
10100 /* Redisplay leaf window WINDOW. JUST_THIS_ONE_P non-zero means only 10102 /* Redisplay leaf window WINDOW. JUST_THIS_ONE_P non-zero means only
10101 selected_window is redisplayed. */ 10103 selected_window is redisplayed.
10104
10105 We can return without actually redisplaying the window if
10106 fonts_changed_p is nonzero. In that case, redisplay_internal will
10107 retry. */
10102 10108
10103 static void 10109 static void
10104 redisplay_window (window, just_this_one_p) 10110 redisplay_window (window, just_this_one_p)
10105 Lisp_Object window; 10111 Lisp_Object window;
10106 int just_this_one_p; 10112 int just_this_one_p;
10303 /* Handle case where place to start displaying has been specified, 10309 /* Handle case where place to start displaying has been specified,
10304 unless the specified location is outside the accessible range. */ 10310 unless the specified location is outside the accessible range. */
10305 if (!NILP (w->force_start) 10311 if (!NILP (w->force_start)
10306 || w->frozen_window_start_p) 10312 || w->frozen_window_start_p)
10307 { 10313 {
10314 /* We set this later on if we have to adjust point. */
10315 int new_vpos = -1;
10316
10308 w->force_start = Qnil; 10317 w->force_start = Qnil;
10309 w->vscroll = 0; 10318 w->vscroll = 0;
10310 w->window_end_valid = Qnil; 10319 w->window_end_valid = Qnil;
10311 10320
10312 /* Forget any recorded base line for line number display. */ 10321 /* Forget any recorded base line for line number display. */
10339 redisplay. Give up if new fonts were loaded. */ 10348 redisplay. Give up if new fonts were loaded. */
10340 if (!try_window (window, startp)) 10349 if (!try_window (window, startp))
10341 { 10350 {
10342 w->force_start = Qt; 10351 w->force_start = Qt;
10343 clear_glyph_matrix (w->desired_matrix); 10352 clear_glyph_matrix (w->desired_matrix);
10344 goto finish_scroll_bars; 10353 goto need_larger_matrices;
10345 } 10354 }
10346 10355
10347 if (w->cursor.vpos < 0 && !w->frozen_window_start_p) 10356 if (w->cursor.vpos < 0 && !w->frozen_window_start_p)
10348 { 10357 {
10349 /* If point does not appear, try to move point so it does 10358 /* If point does not appear, try to move point so it does
10350 appear. The desired matrix has been built above, so we 10359 appear. The desired matrix has been built above, so we
10351 can use it here. */ 10360 can use it here. */
10352 int window_height; 10361 new_vpos = window_box_height (w) / 2;
10362 }
10363
10364 if (!make_cursor_line_fully_visible (w))
10365 {
10366 /* Point does appear, but on a line partly visible at end of window.
10367 Move it back to a fully-visible line. */
10368 new_vpos = window_box_height (w);
10369 }
10370
10371 /* If we need to move point for either of the above reasons,
10372 now actually do it. */
10373 if (new_vpos >= 0)
10374 {
10353 struct glyph_row *row; 10375 struct glyph_row *row;
10354 10376
10355 window_height = window_box_height (w) / 2;
10356 row = MATRIX_FIRST_TEXT_ROW (w->desired_matrix); 10377 row = MATRIX_FIRST_TEXT_ROW (w->desired_matrix);
10357 while (MATRIX_ROW_BOTTOM_Y (row) < window_height) 10378 while (MATRIX_ROW_BOTTOM_Y (row) < new_vpos)
10358 ++row; 10379 ++row;
10359 10380
10360 TEMP_SET_PT_BOTH (MATRIX_ROW_START_CHARPOS (row), 10381 TEMP_SET_PT_BOTH (MATRIX_ROW_START_CHARPOS (row),
10361 MATRIX_ROW_START_BYTEPOS (row)); 10382 MATRIX_ROW_START_BYTEPOS (row));
10362 10383
10376 if (!try_window (window, startp)) 10397 if (!try_window (window, startp))
10377 goto need_larger_matrices; 10398 goto need_larger_matrices;
10378 } 10399 }
10379 } 10400 }
10380 10401
10381 if (!make_cursor_line_fully_visible (w))
10382 {
10383 /* CVS rev. 1.761 had changed this to ``goto try_to_scroll''.
10384
10385 The intention of the fix -- AFAIU -- was to ensure that
10386 the cursor didn't end up on a partially visible last (or
10387 first?) line when scrolling.
10388
10389
10390 But that change causes havoc when scrolling backwards and
10391 a partially visible first (or last?) line is present when
10392 we reach the top of the buffer. In effect, the text
10393 already in the window is repeated (each line is appended
10394 to the same or another lines in the window)...
10395
10396 I changed it back to ``goto need_larger_matrices'' which
10397 in effect mean that we don't go through `try_scrolling'
10398 when the cursor is already at the first line of the buffer,
10399 and there is really only a few pixels [rather than lines]
10400 to scroll backwards. I guess move_it_by_lines etc. really
10401 isn't the right device for doing that, ref. the code in
10402 make_cursor_line_fully_visible which was also disabled by
10403 CVS rev. 1.761.
10404
10405 But how do we know that we are already on the top line of
10406 the window showing the first line in the buffer, so that
10407 scrolling really wont help here?
10408
10409 I cannot find a simple fix for this (I tried various
10410 approaches), but I prefer to an occasional partial line
10411 rather than the visual messup, so I reverted this part of
10412 the fix.
10413
10414 Someone will need to look into this when time allows.
10415
10416 -- 2002-08-22, Kim F. Storm */
10417
10418 goto need_larger_matrices;
10419 }
10420 #if GLYPH_DEBUG 10402 #if GLYPH_DEBUG
10421 debug_method_add (w, "forced window start"); 10403 debug_method_add (w, "forced window start");
10422 #endif 10404 #endif
10423 goto done; 10405 goto done;
10424 } 10406 }
10433 switch (rc) 10415 switch (rc)
10434 { 10416 {
10435 case CURSOR_MOVEMENT_SUCCESS: 10417 case CURSOR_MOVEMENT_SUCCESS:
10436 goto done; 10418 goto done;
10437 10419
10420 #if 0 /* try_cursor_movement never returns this value. */
10438 case CURSOR_MOVEMENT_NEED_LARGER_MATRICES: 10421 case CURSOR_MOVEMENT_NEED_LARGER_MATRICES:
10439 goto need_larger_matrices; 10422 goto need_larger_matrices;
10423 #endif
10440 10424
10441 case CURSOR_MOVEMENT_MUST_SCROLL: 10425 case CURSOR_MOVEMENT_MUST_SCROLL:
10442 goto try_to_scroll; 10426 goto try_to_scroll;
10443 10427
10444 default: 10428 default:
10763 || auto_resize_tool_bars_p)) 10747 || auto_resize_tool_bars_p))
10764 redisplay_tool_bar (f); 10748 redisplay_tool_bar (f);
10765 #endif 10749 #endif
10766 } 10750 }
10767 10751
10752 /* We go to this label, with fonts_changed_p nonzero,
10753 if it is necessary to try again using larger glyph matrices.
10754 We have to redeem the scroll bar even in this case,
10755 because the loop in redisplay_internal expects that. */
10768 need_larger_matrices: 10756 need_larger_matrices:
10769 ; 10757 ;
10770 finish_scroll_bars: 10758 finish_scroll_bars:
10771 10759
10772 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) 10760 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))