aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman2005-06-25 22:35:42 +0000
committerRichard M. Stallman2005-06-25 22:35:42 +0000
commit493c1d49e5bb81a0af9fa91cb5098b80ed531547 (patch)
tree72ae44d0fcf8732650f950660f47ad261a5e0e2b /src
parent92489bddbb19494bb39bf9f9a65e43254246d389 (diff)
downloademacs-493c1d49e5bb81a0af9fa91cb5098b80ed531547.tar.gz
emacs-493c1d49e5bb81a0af9fa91cb5098b80ed531547.zip
(try_window): New arg CHECK_MARGINS. Calls changed.
(redisplay_window): Handle try_window reporting point in scroll margin.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c61
1 files changed, 49 insertions, 12 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 5bb157cae73..51ce35fedd7 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -7592,7 +7592,7 @@ display_echo_area_1 (a1, a2, a3, a4)
7592 clear_glyph_matrix (w->desired_matrix); 7592 clear_glyph_matrix (w->desired_matrix);
7593 XSETWINDOW (window, w); 7593 XSETWINDOW (window, w);
7594 SET_TEXT_POS (start, BEG, BEG_BYTE); 7594 SET_TEXT_POS (start, BEG, BEG_BYTE);
7595 try_window (window, start); 7595 try_window (window, start, 0);
7596 7596
7597 return window_height_changed_p; 7597 return window_height_changed_p;
7598} 7598}
@@ -11570,7 +11570,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
11570 11570
11571 /* Display the window. Give up if new fonts are loaded, or if point 11571 /* Display the window. Give up if new fonts are loaded, or if point
11572 doesn't appear. */ 11572 doesn't appear. */
11573 if (!try_window (window, startp)) 11573 if (!try_window (window, startp, 0))
11574 rc = SCROLLING_NEED_LARGER_MATRICES; 11574 rc = SCROLLING_NEED_LARGER_MATRICES;
11575 else if (w->cursor.vpos < 0) 11575 else if (w->cursor.vpos < 0)
11576 { 11576 {
@@ -12173,6 +12173,7 @@ redisplay_window (window, just_this_one_p)
12173 { 12173 {
12174 /* We set this later on if we have to adjust point. */ 12174 /* We set this later on if we have to adjust point. */
12175 int new_vpos = -1; 12175 int new_vpos = -1;
12176 int val;
12176 12177
12177 w->force_start = Qnil; 12178 w->force_start = Qnil;
12178 w->vscroll = 0; 12179 w->vscroll = 0;
@@ -12206,12 +12207,16 @@ redisplay_window (window, just_this_one_p)
12206 12207
12207 /* Redisplay, then check if cursor has been set during the 12208 /* Redisplay, then check if cursor has been set during the
12208 redisplay. Give up if new fonts were loaded. */ 12209 redisplay. Give up if new fonts were loaded. */
12209 if (!try_window (window, startp)) 12210 val = try_window (window, startp, 1);
12211 if (!val)
12210 { 12212 {
12211 w->force_start = Qt; 12213 w->force_start = Qt;
12212 clear_glyph_matrix (w->desired_matrix); 12214 clear_glyph_matrix (w->desired_matrix);
12213 goto need_larger_matrices; 12215 goto need_larger_matrices;
12214 } 12216 }
12217 /* Point was outside the scroll margins. */
12218 if (val < 0)
12219 new_vpos = window_box_height (w) / 2;
12215 12220
12216 if (w->cursor.vpos < 0 && !w->frozen_window_start_p) 12221 if (w->cursor.vpos < 0 && !w->frozen_window_start_p)
12217 { 12222 {
@@ -12254,7 +12259,7 @@ redisplay_window (window, just_this_one_p)
12254 && !NILP (current_buffer->mark_active)) 12259 && !NILP (current_buffer->mark_active))
12255 { 12260 {
12256 clear_glyph_matrix (w->desired_matrix); 12261 clear_glyph_matrix (w->desired_matrix);
12257 if (!try_window (window, startp)) 12262 if (!try_window (window, startp, 0))
12258 goto need_larger_matrices; 12263 goto need_larger_matrices;
12259 } 12264 }
12260 } 12265 }
@@ -12344,7 +12349,11 @@ redisplay_window (window, just_this_one_p)
12344 = try_window_reusing_current_matrix (w))) 12349 = try_window_reusing_current_matrix (w)))
12345 { 12350 {
12346 IF_DEBUG (debug_method_add (w, "1")); 12351 IF_DEBUG (debug_method_add (w, "1"));
12347 try_window (window, startp); 12352 if (try_window (window, startp, 1) < 0)
12353 /* -1 means we need to scroll.
12354 0 means we need new matrices, but fonts_changed_p
12355 is set in that case, so we will detect it below. */
12356 goto try_to_scroll;
12348 } 12357 }
12349 12358
12350 if (fonts_changed_p) 12359 if (fonts_changed_p)
@@ -12474,7 +12483,7 @@ redisplay_window (window, just_this_one_p)
12474 || MINI_WINDOW_P (w) 12483 || MINI_WINDOW_P (w)
12475 || !(used_current_matrix_p 12484 || !(used_current_matrix_p
12476 = try_window_reusing_current_matrix (w))) 12485 = try_window_reusing_current_matrix (w)))
12477 try_window (window, startp); 12486 try_window (window, startp, 0);
12478 12487
12479 /* If new fonts have been loaded (due to fontsets), give up. We 12488 /* If new fonts have been loaded (due to fontsets), give up. We
12480 have to start a new redisplay since we need to re-adjust glyph 12489 have to start a new redisplay since we need to re-adjust glyph
@@ -12494,13 +12503,13 @@ redisplay_window (window, just_this_one_p)
12494 { 12503 {
12495 clear_glyph_matrix (w->desired_matrix); 12504 clear_glyph_matrix (w->desired_matrix);
12496 move_it_by_lines (&it, 1, 0); 12505 move_it_by_lines (&it, 1, 0);
12497 try_window (window, it.current.pos); 12506 try_window (window, it.current.pos, 0);
12498 } 12507 }
12499 else if (PT < IT_CHARPOS (it)) 12508 else if (PT < IT_CHARPOS (it))
12500 { 12509 {
12501 clear_glyph_matrix (w->desired_matrix); 12510 clear_glyph_matrix (w->desired_matrix);
12502 move_it_by_lines (&it, -1, 0); 12511 move_it_by_lines (&it, -1, 0);
12503 try_window (window, it.current.pos); 12512 try_window (window, it.current.pos, 0);
12504 } 12513 }
12505 else 12514 else
12506 { 12515 {
@@ -12683,14 +12692,18 @@ redisplay_window (window, just_this_one_p)
12683 12692
12684 12693
12685/* Build the complete desired matrix of WINDOW with a window start 12694/* Build the complete desired matrix of WINDOW with a window start
12686 buffer position POS. Value is non-zero if successful. It is zero 12695 buffer position POS.
12687 if fonts were loaded during redisplay which makes re-adjusting 12696
12688 glyph matrices necessary. */ 12697 Value is 1 if successful. It is zero if fonts were loaded during
12698 redisplay which makes re-adjusting glyph matrices necessary, and -1
12699 if point would appear in the scroll margins.
12700 (We check that only if CHECK_MARGINS is nonzero. */
12689 12701
12690int 12702int
12691try_window (window, pos) 12703try_window (window, pos, check_margins)
12692 Lisp_Object window; 12704 Lisp_Object window;
12693 struct text_pos pos; 12705 struct text_pos pos;
12706 int check_margins;
12694{ 12707{
12695 struct window *w = XWINDOW (window); 12708 struct window *w = XWINDOW (window);
12696 struct it it; 12709 struct it it;
@@ -12715,6 +12728,30 @@ try_window (window, pos)
12715 return 0; 12728 return 0;
12716 } 12729 }
12717 12730
12731 /* Don't let the cursor end in the scroll margins. */
12732 if (check_margins)
12733 {
12734 int this_scroll_margin, cursor_height;
12735
12736 this_scroll_margin = max (0, scroll_margin);
12737 this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 4);
12738 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
12739 cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height;
12740
12741 if ((w->cursor.y < this_scroll_margin
12742 && CHARPOS (pos) > BEGV)
12743 /* Old redisplay didn't take scroll margin into account at the bottom,
12744 but then global-hl-line-mode doesn't scroll. KFS 2004-06-14 */
12745 || (w->cursor.y + (make_cursor_line_fully_visible_p
12746 ? cursor_height + this_scroll_margin
12747 : 1)) > it.last_visible_y)
12748 {
12749 w->cursor.vpos = -1;
12750 clear_glyph_matrix (w->desired_matrix);
12751 return -1;
12752 }
12753 }
12754
12718 /* If bottom moved off end of frame, change mode line percentage. */ 12755 /* If bottom moved off end of frame, change mode line percentage. */
12719 if (XFASTINT (w->window_end_pos) <= 0 12756 if (XFASTINT (w->window_end_pos) <= 0
12720 && Z != IT_CHARPOS (it)) 12757 && Z != IT_CHARPOS (it))