/[emacs]/emacs/src/window.c
ViewVC logotype

Diff of /emacs/src/window.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.489 by rms, Thu Dec 2 23:24:43 2004 UTC revision 1.490 by rms, Fri Dec 31 15:07:48 2004 UTC
# Line 4671  window_scroll_pixel_based (window, n, wh Line 4671  window_scroll_pixel_based (window, n, wh
4671       not including the height of the header line if any.  */       not including the height of the header line if any.  */
4672    it.current_y = it.vpos = 0;    it.current_y = it.vpos = 0;
4673    
4674    /* Preserve the screen position if we should.  */    /* Move PT out of scroll margins.
4675    if (preserve_y >= 0)       This code wants current_y to be zero at the window start position
4676      {       even if there is a header line.  */
4677        /* If we have a header line, take account of it.  */    this_scroll_margin = max (0, scroll_margin);
4678        if (WINDOW_WANTS_HEADER_LINE_P (w))    this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4);
4679          preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);    this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
4680    
4681        move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);    if (n > 0)
4682        SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));      {
4683      }        /* We moved the window start towards ZV, so PT may be now
4684    else           in the scroll margin at the top.  */
4685      {        move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
4686        /* Move PT out of scroll margins.        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          /* We found PT at a legitimate height.  Leave it alone.  */
4688           even if there is a header line.  */          ;
4689        this_scroll_margin = max (0, scroll_margin);        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);            /* If we have a header line, take account of it.  */
4692              if (WINDOW_WANTS_HEADER_LINE_P (w))
4693                preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
4694    
4695        if (n > 0)            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          {          {
           /* We moved the window start towards ZV, so PT may be now  
              in the scroll margin at the top.  */  
           move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);  
4700            while (it.current_y < this_scroll_margin)            while (it.current_y < this_scroll_margin)
4701              {              {
4702                int prev = it.current_y;                int prev = it.current_y;
# Line 4704  window_scroll_pixel_based (window, n, wh Line 4706  window_scroll_pixel_based (window, n, wh
4706              }              }
4707            SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));            SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
4708          }          }
4709        else if (n < 0)      }
4710          {    else if (n < 0)
4711            int charpos, bytepos;      {
4712          int charpos, bytepos;
4713    
4714            /* We moved the window start towards BEGV, so PT may be now        /* Save our position, for the preserve_y case.  */
4715               in the scroll margin at the bottom.  */        charpos = IT_CHARPOS (it);
4716            move_it_to (&it, PT, -1,        bytepos = IT_BYTEPOS (it);
4717                        it.last_visible_y - this_scroll_margin - 1, -1,  
4718                        MOVE_TO_POS | MOVE_TO_Y);        /* 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)
4728            {
4729              SET_TEXT_POS_FROM_MARKER (start, w->start);
4730              start_display (&it, w, start);
4731              /* If we have a header line, take account of it.  */
4732              if (WINDOW_WANTS_HEADER_LINE_P (w))
4733                preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
4734    
4735              move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
4736              SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
4737            }
4738          else
4739            {
4740            /* Save our position, in case it's correct.  */            /* Save our position, in case it's correct.  */
4741            charpos = IT_CHARPOS (it);            charpos = IT_CHARPOS (it);
4742            bytepos = IT_BYTEPOS (it);            bytepos = IT_BYTEPOS (it);
4743    
4744            /* See if point is on a partially visible line at the end.  */            /* See if point is on a partially visible line at the end.  */
4745            move_it_by_lines (&it, 1, 1);            move_it_by_lines (&it, 1, 1);
4746    
4747            if (it.current_y > it.last_visible_y)            if (it.current_y > it.last_visible_y)
4748              /* The last line was only partially visible, so back up two              /* The last line was only partially visible, so back up two
4749                 lines to make sure we're on a fully visible line.  */                 lines to make sure we're on a fully visible line.  */
# Line 6753  If there is only one window, it is split Line 6777  If there is only one window, it is split
6777    
6778    DEFVAR_LISP ("scroll-preserve-screen-position",    DEFVAR_LISP ("scroll-preserve-screen-position",
6779                 &Vscroll_preserve_screen_position,                 &Vscroll_preserve_screen_position,
6780                 doc: /* *Non-nil means scroll commands move point to keep its screen line unchanged.  */);                 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.  */);
6783    Vscroll_preserve_screen_position = Qnil;    Vscroll_preserve_screen_position = Qnil;
6784    
6785    DEFVAR_LISP ("window-configuration-change-hook",    DEFVAR_LISP ("window-configuration-change-hook",

Legend:
Removed from v.1.489  
changed lines
  Added in v.1.490

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26