Changeset 3433

Show
Ignore:
Timestamp:
09/04/04 10:50:19 (4 years ago)
Author:
miyoshi
Message:

* xdisp.c (make_cursor_line_fully_visible): Sync up with Emacs CVS
HEAD.
(try_scrolling): Ditto.
(redisplay_window): Partially sync up with Emacs CVS HEAD.

* window.h (WINDOW_TOTAL_LINES): New macro.

* lisp.h (MOST_NEGATIVE_FIXNUM): New macro from Emacs CVS HEAD.
(MOST_POSITIVE_FIXNUM): Ditto.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.2/src/ChangeLog.Meadow

    r3429 r3433  
     12004-09-04  MIYOSHI Masanori  <miyoshi@meadowy.org> 
     2 
     3        * xdisp.c (make_cursor_line_fully_visible): Sync up with Emacs CVS 
     4        HEAD. 
     5        (try_scrolling): Ditto. 
     6        (redisplay_window): Partially sync up with Emacs CVS HEAD. 
     7 
     8        * window.h (WINDOW_TOTAL_LINES): New macro. 
     9 
     10        * lisp.h (MOST_NEGATIVE_FIXNUM): New macro from Emacs CVS HEAD. 
     11        (MOST_POSITIVE_FIXNUM): Ditto. 
     12 
    1132004-08-29  MIYOSHI Masanori  <miyoshi@meadowy.org> 
    214 
  • branches/2.2/src/lisp.h

    r3426 r3433  
    471471 
    472472#endif /* NO_UNION_TYPE */ 
     473 
     474/* Largest and smallest representable fixnum values.  These are the C 
     475   values.  */ 
     476 
     477#define MOST_NEGATIVE_FIXNUM    - ((EMACS_INT) 1 << (VALBITS - 1)) 
     478#define MOST_POSITIVE_FIXNUM    (((EMACS_INT) 1 << (VALBITS - 1)) - 1) 
    473479 
    474480/* Extract a value or address from a Lisp_Object.  */ 
  • branches/2.2/src/window.h

    r3421 r3433  
    282282#define MINI_WINDOW_P(W)        (!EQ ((W)->mini_p, Qnil)) 
    283283 
     284/* A handy macro.  */ 
     285 
     286/* Return the frame height in canonical line units. 
     287   This includes header and mode lines, if any.  */ 
     288 
     289#define WINDOW_TOTAL_LINES(W) \ 
     290  (XFASTINT ((W)->height)) 
     291 
    284292/* Return the window column at which the text in window W starts. 
    285293   This is different from the `left' field because it does not include 
     
    316324     (WINDOW_RIGHT_EDGE (W) == FRAME_WINDOW_WIDTH (XFRAME (WINDOW_FRAME (W)))) 
    317325 
     326/* Pixel height of window W without mode and header line.  */ 
     327 
     328#define WINDOW_BOX_TEXT_HEIGHT(W)               \ 
     329     (WINDOW_DISPLAY_PIXEL_HEIGHT ((W))         \ 
     330      - WINDOW_DISPLAY_MODE_LINE_HEIGHT ((W))   \ 
     331      - WINDOW_DISPLAY_HEADER_LINE_HEIGHT (W)); 
    318332 
    319333/* This is the window in which the terminal's cursor should 
  • branches/2.2/src/xdisp.c

    r3421 r3433  
    721721static void extend_face_to_end_of_line P_ ((struct it *)); 
    722722static int append_space P_ ((struct it *, int)); 
    723 static int make_cursor_line_fully_visible P_ ((struct window *)); 
    724 static int try_scrolling P_ ((Lisp_Object, int, int, int, int)); 
     723static int make_cursor_line_fully_visible P_ ((struct window *, int)); 
     724static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int)); 
    725725static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); 
    726726static int trailing_whitespace_p P_ ((int)); 
     
    93649364 
    93659365 
    9366 /* Modify the desired matrix of window W and W->vscroll so that the 
    9367    line containing the cursor is fully visible.  If this requires 
    9368    larger matrices than are allocated, set fonts_changed_p and return 
    9369    0.  */ 
     9366/* Make sure the line containing the cursor is fully visible. 
     9367   A value of 1 means there is nothing to be done. 
     9368   (Either the line is fully visible, or it cannot be made so, 
     9369   or we cannot tell.) 
     9370 
     9371   If FORCE_P is non-zero, return 0 even if partial visible cursor row 
     9372   is higher than window. 
     9373 
     9374   A value of 0 means the caller should do scrolling 
     9375   as if point had gone off the screen.  */ 
    93709376 
    93719377static int 
    9372 make_cursor_line_fully_visible (w
     9378make_cursor_line_fully_visible (w, force_p
    93739379     struct window *w; 
     9380     int force_p; 
    93749381{ 
    93759382  struct glyph_matrix *matrix; 
     
    93859392  row = MATRIX_ROW (matrix, w->cursor.vpos); 
    93869393 
    9387   /* If the cursor row is not partially visible, there's nothing 
    9388      to do.  */ 
     9394  /* If the cursor row is not partially visible, there's nothing to do.  */ 
    93899395  if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (row)) 
    93909396    return 1; 
     
    93949400  window_height = window_box_height (w); 
    93959401  if (row->height >= window_height) 
    9396     return 1; 
     9402    { 
     9403      if (!force_p || w->vscroll) 
     9404        return 1; 
     9405    } 
     9406  return 0; 
     9407 
     9408#if 0 
     9409  /* This code used to try to scroll the window just enough to make 
     9410     the line visible.  It returned 0 to say that the caller should 
     9411     allocate larger glyph matrices.  */ 
    93979412 
    93989413  if (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row)) 
     
    94279442 
    94289443  return 1; 
     9444#endif /* 0 */ 
    94299445} 
    94309446 
     
    94369452   the case that only the cursor has moved. 
    94379453 
     9454   LAST_LINE_MISFIT should be nonzero if we're scrolling because the 
     9455   last screen line's vertical height extends past the end of the screen. 
     9456 
    94389457   Value is 
    94399458 
     
    94549473static int 
    94559474try_scrolling (window, just_this_one_p, scroll_conservatively, 
    9456                scroll_step, temp_scroll_step
     9475               scroll_step, temp_scroll_step, last_line_misfit
    94579476     Lisp_Object window; 
    94589477     int just_this_one_p; 
    9459      int scroll_conservatively, scroll_step; 
     9478     EMACS_INT scroll_conservatively, scroll_step; 
    94609479     int temp_scroll_step; 
     9480     int last_line_misfit; 
    94619481{ 
    94629482  struct window *w = XWINDOW (window); 
     
    94749494  Lisp_Object aggressive; 
    94759495  int height; 
     9496  int extra_scroll_margin_lines = last_line_misfit ? 1 : 0; 
    94769497 
    94779498#if GLYPH_DEBUG 
     
    94859506  if (scroll_margin > 0) 
    94869507    { 
    9487       this_scroll_margin = min (scroll_margin, XINT (w->height) / 4); 
    9488       this_scroll_margin *= CANON_Y_UNIT (f); 
     9508      this_scroll_margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 
     9509      this_scroll_margin *= FRAME_LINE_HEIGHT (f); 
    94899510    } 
    94909511  else 
    94919512    this_scroll_margin = 0; 
     9513 
     9514  /* Force scroll_conservatively to have a reasonable value so it doesn't 
     9515     cause an overflow while computing how much to scroll.  */ 
     9516  if (scroll_conservatively) 
     9517    scroll_conservatively = min (scroll_conservatively, 
     9518                                 MOST_POSITIVE_FIXNUM / FRAME_LINE_HEIGHT (f)); 
    94929519 
    94939520  /* Compute how much we should try to scroll maximally to bring point 
     
    95049531  else 
    95059532    scroll_max = 0; 
    9506   scroll_max *= CANON_Y_UNIT (f); 
     9533  scroll_max *= FRAME_LINE_HEIGHT (f); 
    95079534 
    95089535  /* Decide whether we have to scroll down.  Start at the window end 
     
    95109537     margin.  */ 
    95119538  window_end = Fwindow_end (window, Qt); 
     9539 
     9540 too_near_end: 
     9541 
    95129542  CHARPOS (scroll_margin_pos) = XINT (window_end); 
    95139543  BYTEPOS (scroll_margin_pos) = CHAR_TO_BYTE (CHARPOS (scroll_margin_pos)); 
    9514   if (this_scroll_margin) 
     9544 
     9545  if (this_scroll_margin || extra_scroll_margin_lines) 
    95159546    { 
    95169547      start_display (&it, w, scroll_margin_pos); 
    9517       move_it_vertically (&it, - this_scroll_margin); 
     9548      if (this_scroll_margin) 
     9549        move_it_vertically (&it, - this_scroll_margin); 
     9550      if (extra_scroll_margin_lines) 
     9551        move_it_by_lines (&it, - extra_scroll_margin_lines, 0); 
    95189552      scroll_margin_pos = it.current.pos; 
    95199553    } 
     
    95479581 
    95489582      if (scroll_conservatively) 
     9583        /* Set AMOUNT_TO_SCROLL to at least one line, 
     9584           and at most scroll_conservatively lines.  */ 
    95499585        amount_to_scroll 
    9550           = max (max (dy, CANON_Y_UNIT (f)), 
    9551                  CANON_Y_UNIT (f) * max (scroll_step, temp_scroll_step)); 
     9586          = min (max (dy, FRAME_LINE_HEIGHT (f)), 
     9587                 FRAME_LINE_HEIGHT (f) * scroll_conservatively); 
    95529588      else if (scroll_step || temp_scroll_step) 
    95539589        amount_to_scroll = scroll_max; 
     
    95559591        { 
    95569592          aggressive = current_buffer->scroll_up_aggressively; 
    9557           height = (WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (w) 
    9558                     - WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w)); 
     9593          height = WINDOW_BOX_TEXT_HEIGHT (w); 
    95599594          if (NUMBERP (aggressive)) 
    9560             amount_to_scroll = (int) XFLOATINT (aggressive) * height; 
     9595            { 
     9596              double float_amount = XFLOATINT (aggressive) * height; 
     9597              amount_to_scroll = (int) float_amount; 
     9598              if (amount_to_scroll == 0 && float_amount > 0) 
     9599                amount_to_scroll = 1; 
     9600            } 
    95619601        } 
    95629602 
     
    95649604        return SCROLLING_FAILED; 
    95659605 
     9606      /* If moving by amount_to_scroll leaves STARTP unchanged, 
     9607         move it down one screen line.  */ 
     9608 
    95669609      move_it_vertically (&it, amount_to_scroll); 
     9610      if (CHARPOS (it.current.pos) == CHARPOS (startp)) 
     9611        move_it_by_lines (&it, 1, 1); 
    95679612      startp = it.current.pos; 
    95689613    } 
     
    96039648          if (scroll_conservatively) 
    96049649            amount_to_scroll = 
    9605               max (dy, CANON_Y_UNIT (f) * max (scroll_step, temp_scroll_step)); 
     9650              max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, temp_scroll_step)); 
    96069651          else if (scroll_step || temp_scroll_step) 
    96079652            amount_to_scroll = scroll_max; 
     
    96099654            { 
    96109655              aggressive = current_buffer->scroll_down_aggressively; 
    9611               height = (WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE (w) 
    9612                         - WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w)); 
     9656              height = WINDOW_BOX_TEXT_HEIGHT (w); 
    96139657              if (NUMBERP (aggressive)) 
    9614                 amount_to_scroll = (int) (XFLOATINT (aggressive) * height); 
     9658                { 
     9659                  double float_amount = XFLOATINT (aggressive) * height; 
     9660                  amount_to_scroll = (int) float_amount; 
     9661                  if (amount_to_scroll == 0 && float_amount > 0) 
     9662                    amount_to_scroll = 1; 
     9663                } 
    96159664            } 
    96169665 
     
    96439692        w->base_line_number = Qnil; 
    96449693 
    9645       /* If cursor ends up on a partially visible line, shift display 
    9646          lines up or down.  If that fails because we need larger 
    9647          matrices, give up.  */ 
    9648       if (!make_cursor_line_fully_visible (w)) 
    9649         rc = SCROLLING_NEED_LARGER_MATRICES; 
    9650       else 
    9651         rc = SCROLLING_SUCCESS; 
     9694      /* If cursor ends up on a partially visible line, 
     9695         treat that as being off the bottom of the screen.  */ 
     9696      if (! make_cursor_line_fully_visible (w, extra_scroll_margin_lines <= 1)) 
     9697        { 
     9698          clear_glyph_matrix (w->desired_matrix); 
     9699          ++extra_scroll_margin_lines; 
     9700          goto too_near_end; 
     9701        } 
     9702      rc = SCROLLING_SUCCESS; 
    96529703    } 
    96539704 
     
    99359986                { 
    99369987                  set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); 
    9937                   try_window (window, startp); 
    9938                   if (!make_cursor_line_fully_visible (w)) 
    9939                     rc = CURSOR_MOVEMENT_NEED_LARGER_MATRICES; 
     9988                  if (!make_cursor_line_fully_visible (w, 0)) 
     9989                    rc = CURSOR_MOVEMENT_MUST_SCROLL; 
    99409990                  else 
    99419991                    rc = CURSOR_MOVEMENT_SUCCESS; 
     
    997510025  int current_matrix_up_to_date_p = 0; 
    997610026  int temp_scroll_step = 0; 
    9977   int count = BINDING_STACK_SIZE (); 
     10027  int count = SPECPDL_INDEX (); 
    997810028  int rc; 
     10029  int centering_position; 
     10030  int last_line_misfit = 0; 
    997910031 
    998010032  SET_TEXT_POS (lpoint, PT, PT_BYTE); 
     
    1015110203      || w->frozen_window_start_p) 
    1015210204    { 
     10205      /* We set this later on if we have to adjust point.  */ 
     10206      int new_vpos = -1; 
     10207 
    1015310208      w->force_start = Qnil; 
    1015410209      w->vscroll = 0; 
     
    1018810243          w->force_start = Qt; 
    1018910244          clear_glyph_matrix (w->desired_matrix); 
    10190           goto finish_scroll_bars; 
     10245          goto need_larger_matrices; 
    1019110246        } 
    1019210247 
     
    1019610251             appear. The desired matrix has been built above, so we 
    1019710252             can use it here.  */ 
    10198           int window_height; 
     10253          new_vpos = window_box_height (w) / 2; 
     10254        } 
     10255 
     10256      if (!make_cursor_line_fully_visible (w, 0)) 
     10257        { 
     10258          /* Point does appear, but on a line partly visible at end of window. 
     10259             Move it back to a fully-visible line.  */ 
     10260          new_vpos = window_box_height (w); 
     10261        } 
     10262 
     10263      /* If we need to move point for either of the above reasons, 
     10264         now actually do it.  */ 
     10265      if (new_vpos >= 0) 
     10266        { 
    1019910267          struct glyph_row *row; 
    1020010268 
    10201           window_height = window_box_height (w) / 2; 
    1020210269          row = MATRIX_FIRST_TEXT_ROW (w->desired_matrix); 
    10203           while (MATRIX_ROW_BOTTOM_Y (row) < window_height
     10270          while (MATRIX_ROW_BOTTOM_Y (row) < new_vpos
    1020410271            ++row; 
    1020510272 
     
    1022510292        } 
    1022610293 
    10227       if (!make_cursor_line_fully_visible (w)) 
    10228         goto need_larger_matrices; 
    1022910294#if GLYPH_DEBUG 
    1023010295      debug_method_add (w, "forced window start"); 
     
    1023410299 
    1023510300  /* Handle case where text has not changed, only point, and it has 
    10236      not moved off the frame.  */ 
     10301     not moved off the frame, and we are not retrying after hscroll. 
     10302     (current_matrix_up_to_date_p is nonzero when retrying.)  */ 
    1023710303  if (current_matrix_up_to_date_p 
    1023810304      && (rc = try_cursor_movement (window, startp, &temp_scroll_step), 
     
    1032110387            w->base_line_number = Qnil; 
    1032210388 
    10323           if (!make_cursor_line_fully_visible (w)) 
    10324             goto need_larger_matrices; 
    10325           goto done; 
     10389          if (!make_cursor_line_fully_visible (w, 1)) 
     10390            { 
     10391              clear_glyph_matrix (w->desired_matrix); 
     10392              last_line_misfit = 1; 
     10393            } 
     10394            /* Drop through and scroll.  */ 
     10395          else 
     10396            goto done; 
    1032610397        } 
    1032710398      else 
     
    1035610427                              scroll_conservatively, 
    1035710428                              scroll_step, 
    10358                               temp_scroll_step); 
     10429                              temp_scroll_step, last_line_misfit); 
    1035910430      switch (rc) 
    1036010431        { 
     
    1037610447 
    1037710448 recenter: 
     10449  centering_position = window_box_height (w) / 2; 
     10450 
     10451 point_at_top: 
     10452  /* Jump here with centering_position already set to 0.  */ 
    1037810453 
    1037910454#if GLYPH_DEBUG 
     
    1039110466  init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); 
    1039210467  it.current_y = it.last_visible_y; 
    10393   move_it_vertically_backward (&it, window_box_height (w) / 2); 
     10468  move_it_vertically_backward (&it, centering_position); 
    1039410469  xassert (IT_CHARPOS (it) >= BEGV); 
    1039510470 
     
    1047110546    } 
    1047210547 
    10473   if (!make_cursor_line_fully_visible (w)) 
    10474     goto need_larger_matrices; 
     10548  if (!make_cursor_line_fully_visible (w, centering_position > 0)) 
     10549    { 
     10550      /* If vscroll is enabled, disable it and try again.  */ 
     10551      if (w->vscroll) 
     10552        { 
     10553          w->vscroll = 0; 
     10554          clear_glyph_matrix (w->desired_matrix); 
     10555          goto recenter; 
     10556        } 
     10557 
     10558      /* If centering point failed to make the whole line visible, 
     10559         put point at the top instead.  That has to make the whole line 
     10560         visible, if it can be done.  */ 
     10561      clear_glyph_matrix (w->desired_matrix); 
     10562      centering_position = 0; 
     10563      goto point_at_top; 
     10564    } 
    1047510565 
    1047610566 done: