aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2008-08-06 18:26:47 +0000
committerChong Yidong2008-08-06 18:26:47 +0000
commit523a9735371f2045a9fb3ff290b3790386d40d22 (patch)
tree69c902751429bef76e9a8615423b460ae773addd /src
parentb2c5015c6b60c79d754918dd03543f81d6e49b17 (diff)
downloademacs-523a9735371f2045a9fb3ff290b3790386d40d22.tar.gz
emacs-523a9735371f2045a9fb3ff290b3790386d40d22.zip
(try_scrolling): Use iterator to find the scroll margin,
instead of window-end which does the wrong thing at eob. (try_cursor_movement): Minor optimization. (redisplay_window): If scroll margin is defined, don't assume window doesn't need scrolling.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c95
1 files changed, 47 insertions, 48 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 78f2dd6478c..4c099653a6d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12655,19 +12655,12 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
12655{ 12655{
12656 struct window *w = XWINDOW (window); 12656 struct window *w = XWINDOW (window);
12657 struct frame *f = XFRAME (w->frame); 12657 struct frame *f = XFRAME (w->frame);
12658 struct text_pos scroll_margin_pos; 12658 struct text_pos pos, startp;
12659 struct text_pos pos;
12660 struct text_pos startp;
12661 struct it it; 12659 struct it it;
12662 Lisp_Object window_end; 12660 int this_scroll_margin, scroll_max, rc, height;
12663 int this_scroll_margin; 12661 int dy = 0, amount_to_scroll = 0, scroll_down_p = 0;
12664 int dy = 0;
12665 int scroll_max;
12666 int rc;
12667 int amount_to_scroll = 0;
12668 Lisp_Object aggressive;
12669 int height;
12670 int extra_scroll_margin_lines = last_line_misfit ? 1 : 0; 12662 int extra_scroll_margin_lines = last_line_misfit ? 1 : 0;
12663 Lisp_Object aggressive;
12671 12664
12672#if GLYPH_DEBUG 12665#if GLYPH_DEBUG
12673 debug_method_add (w, "try_scrolling"); 12666 debug_method_add (w, "try_scrolling");
@@ -12706,48 +12699,44 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
12706 scroll_max = 0; 12699 scroll_max = 0;
12707 scroll_max *= FRAME_LINE_HEIGHT (f); 12700 scroll_max *= FRAME_LINE_HEIGHT (f);
12708 12701
12709 /* Decide whether we have to scroll down. Start at the window end
12710 and move this_scroll_margin up to find the position of the scroll
12711 margin. */
12712 window_end = Fwindow_end (window, Qt);
12713
12714 too_near_end: 12702 too_near_end:
12715 12703
12716 CHARPOS (scroll_margin_pos) = XINT (window_end); 12704 /* Decide whether we have to scroll down. */
12717 BYTEPOS (scroll_margin_pos) = CHAR_TO_BYTE (CHARPOS (scroll_margin_pos)); 12705 if (PT > CHARPOS (startp))
12718
12719 if (this_scroll_margin || extra_scroll_margin_lines)
12720 { 12706 {
12721 start_display (&it, w, scroll_margin_pos); 12707 int scroll_margin_y;
12722 if (this_scroll_margin)
12723 move_it_vertically_backward (&it, this_scroll_margin);
12724 if (extra_scroll_margin_lines)
12725 move_it_by_lines (&it, - extra_scroll_margin_lines, 0);
12726 scroll_margin_pos = it.current.pos;
12727 }
12728 12708
12729 if (PT >= CHARPOS (scroll_margin_pos)) 12709 /* Compute the pixel ypos of the scroll margin, then move it to
12730 { 12710 either that ypos or PT, whichever comes first. */
12731 int y0; 12711 start_display (&it, w, startp);
12712 scroll_margin_y = it.last_visible_y - this_scroll_margin
12713 - FRAME_LINE_HEIGHT (f) * extra_scroll_margin_lines;
12714 move_it_to (&it, PT, -1, scroll_margin_y - 1, -1,
12715 (MOVE_TO_POS | MOVE_TO_Y));
12732 12716
12733 /* Point is in the scroll margin at the bottom of the window, or 12717 if (PT > CHARPOS (it.current.pos))
12734 below. Compute a new window start that makes point visible. */ 12718 {
12719 /* Point is in the scroll margin at the bottom of the
12720 window, or below. Compute the distance from the scroll
12721 margin to PT, and give up if the distance is greater than
12722 scroll_max. */
12723 move_it_to (&it, PT, -1, it.last_visible_y - 1, -1,
12724 MOVE_TO_POS | MOVE_TO_Y);
12735 12725
12736 /* Compute the distance from the scroll margin to PT. 12726 /* To make point visible, we must move the window start down
12737 Give up if the distance is greater than scroll_max. */ 12727 so that the cursor line is visible, which means we have
12738 start_display (&it, w, scroll_margin_pos); 12728 to add in the height of the cursor line. */
12739 y0 = it.current_y; 12729 dy = line_bottom_y (&it) - scroll_margin_y;
12740 move_it_to (&it, PT, 0, it.last_visible_y, -1,
12741 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
12742 12730
12743 /* To make point visible, we have to move the window start 12731 if (dy > scroll_max)
12744 down so that the line the cursor is in is visible, which 12732 return SCROLLING_FAILED;
12745 means we have to add in the height of the cursor line. */
12746 dy = line_bottom_y (&it) - y0;
12747 12733
12748 if (dy > scroll_max) 12734 scroll_down_p = 1;
12749 return SCROLLING_FAILED; 12735 }
12736 }
12750 12737
12738 if (scroll_down_p)
12739 {
12751 /* Move the window start down. If scrolling conservatively, 12740 /* Move the window start down. If scrolling conservatively,
12752 move it just enough down to make point visible. If 12741 move it just enough down to make point visible. If
12753 scroll_step is set, move it down by scroll_step. */ 12742 scroll_step is set, move it down by scroll_step. */
@@ -12787,9 +12776,10 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
12787 } 12776 }
12788 else 12777 else
12789 { 12778 {
12779 struct text_pos scroll_margin_pos = startp;
12780
12790 /* See if point is inside the scroll margin at the top of the 12781 /* See if point is inside the scroll margin at the top of the
12791 window. */ 12782 window. */
12792 scroll_margin_pos = startp;
12793 if (this_scroll_margin) 12783 if (this_scroll_margin)
12794 { 12784 {
12795 start_display (&it, w, startp); 12785 start_display (&it, w, startp);
@@ -13038,9 +13028,13 @@ try_cursor_movement (window, startp, scroll_step)
13038 13028
13039 /* Scroll if point within this distance from the top or bottom 13029 /* Scroll if point within this distance from the top or bottom
13040 of the window. This is a pixel value. */ 13030 of the window. This is a pixel value. */
13041 this_scroll_margin = max (0, scroll_margin); 13031 if (scroll_margin > 0)
13042 this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 13032 {
13043 this_scroll_margin *= FRAME_LINE_HEIGHT (f); 13033 this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4);
13034 this_scroll_margin *= FRAME_LINE_HEIGHT (f);
13035 }
13036 else
13037 this_scroll_margin = 0;
13044 13038
13045 top_scroll_margin = this_scroll_margin; 13039 top_scroll_margin = this_scroll_margin;
13046 if (WINDOW_WANTS_HEADER_LINE_P (w)) 13040 if (WINDOW_WANTS_HEADER_LINE_P (w))
@@ -13674,6 +13668,11 @@ redisplay_window (window, just_this_one_p)
13674 debug_method_add (w, "same window start"); 13668 debug_method_add (w, "same window start");
13675#endif 13669#endif
13676 13670
13671 /* If there's a scroll margin, we must try to scroll, in case
13672 point is now in the scroll margin. */
13673 if (scroll_margin > 0)
13674 goto try_to_scroll;
13675
13677 /* Try to redisplay starting at same place as before. 13676 /* Try to redisplay starting at same place as before.
13678 If point has not moved off frame, accept the results. */ 13677 If point has not moved off frame, accept the results. */
13679 if (!current_matrix_up_to_date_p 13678 if (!current_matrix_up_to_date_p