comparison src/window.c @ 59258:e5b68c4be92b

(window_scroll_pixel_based): Only look at Vscroll_preserve_screen_position if the old PT can't be kept. (syms_of_window) <scroll-preserve-screen-position>: Doc fix.
author Richard M. Stallman <rms@gnu.org>
date Fri, 31 Dec 2004 15:07:48 +0000
parents cd5b85acf394
children 132e8f3a36a1 025da3ba778e 95879cc1ed20
comparison
equal deleted inserted replaced
59257:e828ce1ff4bb 59258:e5b68c4be92b
4669 4669
4670 /* The rest of this function uses current_y in a nonstandard way, 4670 /* The rest of this function uses current_y in a nonstandard way,
4671 not including the height of the header line if any. */ 4671 not including the height of the header line if any. */
4672 it.current_y = it.vpos = 0; 4672 it.current_y = it.vpos = 0;
4673 4673
4674 /* Preserve the screen position if we should. */ 4674 /* Move PT out of scroll margins.
4675 if (preserve_y >= 0) 4675 This code wants current_y to be zero at the window start position
4676 { 4676 even if there is a header line. */
4677 /* If we have a header line, take account of it. */ 4677 this_scroll_margin = max (0, scroll_margin);
4678 if (WINDOW_WANTS_HEADER_LINE_P (w)) 4678 this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4);
4679 preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w); 4679 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
4680 4680
4681 move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y); 4681 if (n > 0)
4682 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); 4682 {
4683 } 4683 /* We moved the window start towards ZV, so PT may be now
4684 else 4684 in the scroll margin at the top. */
4685 { 4685 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
4686 /* Move PT out of scroll margins. 4686 if (IT_CHARPOS (it) == PT && it.current_y >= this_scroll_margin)
4687 This code wants current_y to be zero at the window start position 4687 /* We found PT at a legitimate height. Leave it alone. */
4688 even if there is a header line. */ 4688 ;
4689 this_scroll_margin = max (0, scroll_margin); 4689 else if (preserve_y >= 0)
4690 this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4);
4691 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
4692
4693 if (n > 0)
4694 { 4690 {
4695 /* We moved the window start towards ZV, so PT may be now 4691 /* If we have a header line, take account of it. */
4696 in the scroll margin at the top. */ 4692 if (WINDOW_WANTS_HEADER_LINE_P (w))
4697 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); 4693 preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
4694
4695 move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
4696 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
4697 }
4698 else
4699 {
4698 while (it.current_y < this_scroll_margin) 4700 while (it.current_y < this_scroll_margin)
4699 { 4701 {
4700 int prev = it.current_y; 4702 int prev = it.current_y;
4701 move_it_by_lines (&it, 1, 1); 4703 move_it_by_lines (&it, 1, 1);
4702 if (prev == it.current_y) 4704 if (prev == it.current_y)
4703 break; 4705 break;
4704 } 4706 }
4705 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); 4707 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
4706 } 4708 }
4707 else if (n < 0) 4709 }
4710 else if (n < 0)
4711 {
4712 int charpos, bytepos;
4713
4714 /* Save our position, for the preserve_y case. */
4715 charpos = IT_CHARPOS (it);
4716 bytepos = IT_BYTEPOS (it);
4717
4718 /* We moved the window start towards BEGV, so PT may be now
4719 in the scroll margin at the bottom. */
4720 move_it_to (&it, PT, -1,
4721 it.last_visible_y - this_scroll_margin - 1, -1,
4722 MOVE_TO_POS | MOVE_TO_Y);
4723
4724 if (IT_CHARPOS (it) == PT)
4725 /* We found PT before we found the display margin, so PT is ok. */
4726 ;
4727 else if (preserve_y >= 0)
4708 { 4728 {
4709 int charpos, bytepos; 4729 SET_TEXT_POS_FROM_MARKER (start, w->start);
4710 4730 start_display (&it, w, start);
4711 /* We moved the window start towards BEGV, so PT may be now 4731 /* If we have a header line, take account of it. */
4712 in the scroll margin at the bottom. */ 4732 if (WINDOW_WANTS_HEADER_LINE_P (w))
4713 move_it_to (&it, PT, -1, 4733 preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
4714 it.last_visible_y - this_scroll_margin - 1, -1, 4734
4715 MOVE_TO_POS | MOVE_TO_Y); 4735 move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
4716 4736 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
4737 }
4738 else
4739 {
4717 /* Save our position, in case it's correct. */ 4740 /* Save our position, in case it's correct. */
4718 charpos = IT_CHARPOS (it); 4741 charpos = IT_CHARPOS (it);
4719 bytepos = IT_BYTEPOS (it); 4742 bytepos = IT_BYTEPOS (it);
4720 4743
4721 /* See if point is on a partially visible line at the end. */ 4744 /* See if point is on a partially visible line at the end. */
4722 move_it_by_lines (&it, 1, 1); 4745 move_it_by_lines (&it, 1, 1);
4746
4723 if (it.current_y > it.last_visible_y) 4747 if (it.current_y > it.last_visible_y)
4724 /* The last line was only partially visible, so back up two 4748 /* The last line was only partially visible, so back up two
4725 lines to make sure we're on a fully visible line. */ 4749 lines to make sure we're on a fully visible line. */
4726 { 4750 {
4727 move_it_by_lines (&it, -2, 0); 4751 move_it_by_lines (&it, -2, 0);
6751 doc: /* *Delete any window less than this wide. */); 6775 doc: /* *Delete any window less than this wide. */);
6752 window_min_width = 10; 6776 window_min_width = 10;
6753 6777
6754 DEFVAR_LISP ("scroll-preserve-screen-position", 6778 DEFVAR_LISP ("scroll-preserve-screen-position",
6755 &Vscroll_preserve_screen_position, 6779 &Vscroll_preserve_screen_position,
6756 doc: /* *Non-nil means scroll commands move point to keep its screen line unchanged. */); 6780 doc: /* *Non-nil means scroll commands move point to keep its screen line unchanged.
6781 This is only when it is impossible to keep point fixed and still
6782 scroll as specified. */);
6757 Vscroll_preserve_screen_position = Qnil; 6783 Vscroll_preserve_screen_position = Qnil;
6758 6784
6759 DEFVAR_LISP ("window-configuration-change-hook", 6785 DEFVAR_LISP ("window-configuration-change-hook",
6760 &Vwindow_configuration_change_hook, 6786 &Vwindow_configuration_change_hook,
6761 doc: /* Functions to call when window configuration changes. 6787 doc: /* Functions to call when window configuration changes.