Changeset 3433
- Timestamp:
- 09/04/04 10:50:19 (4 years ago)
- Files:
-
- branches/2.2/src/ChangeLog.Meadow (modified) (1 diff)
- branches/2.2/src/lisp.h (modified) (1 diff)
- branches/2.2/src/window.h (modified) (2 diffs)
- branches/2.2/src/xdisp.c (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.2/src/ChangeLog.Meadow
r3429 r3433 1 2004-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 1 13 2004-08-29 MIYOSHI Masanori <miyoshi@meadowy.org> 2 14 branches/2.2/src/lisp.h
r3426 r3433 471 471 472 472 #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) 473 479 474 480 /* Extract a value or address from a Lisp_Object. */ branches/2.2/src/window.h
r3421 r3433 282 282 #define MINI_WINDOW_P(W) (!EQ ((W)->mini_p, Qnil)) 283 283 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 284 292 /* Return the window column at which the text in window W starts. 285 293 This is different from the `left' field because it does not include … … 316 324 (WINDOW_RIGHT_EDGE (W) == FRAME_WINDOW_WIDTH (XFRAME (WINDOW_FRAME (W)))) 317 325 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)); 318 332 319 333 /* This is the window in which the terminal's cursor should branches/2.2/src/xdisp.c
r3421 r3433 721 721 static void extend_face_to_end_of_line P_ ((struct it *)); 722 722 static 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));723 static int make_cursor_line_fully_visible P_ ((struct window *, int)); 724 static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int)); 725 725 static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); 726 726 static int trailing_whitespace_p P_ ((int)); … … 9364 9364 9365 9365 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. */ 9370 9376 9371 9377 static int 9372 make_cursor_line_fully_visible (w )9378 make_cursor_line_fully_visible (w, force_p) 9373 9379 struct window *w; 9380 int force_p; 9374 9381 { 9375 9382 struct glyph_matrix *matrix; … … 9385 9392 row = MATRIX_ROW (matrix, w->cursor.vpos); 9386 9393 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. */ 9389 9395 if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (row)) 9390 9396 return 1; … … 9394 9400 window_height = window_box_height (w); 9395 9401 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. */ 9397 9412 9398 9413 if (MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row)) … … 9427 9442 9428 9443 return 1; 9444 #endif /* 0 */ 9429 9445 } 9430 9446 … … 9436 9452 the case that only the cursor has moved. 9437 9453 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 9438 9457 Value is 9439 9458 … … 9454 9473 static int 9455 9474 try_scrolling (window, just_this_one_p, scroll_conservatively, 9456 scroll_step, temp_scroll_step )9475 scroll_step, temp_scroll_step, last_line_misfit) 9457 9476 Lisp_Object window; 9458 9477 int just_this_one_p; 9459 intscroll_conservatively, scroll_step;9478 EMACS_INT scroll_conservatively, scroll_step; 9460 9479 int temp_scroll_step; 9480 int last_line_misfit; 9461 9481 { 9462 9482 struct window *w = XWINDOW (window); … … 9474 9494 Lisp_Object aggressive; 9475 9495 int height; 9496 int extra_scroll_margin_lines = last_line_misfit ? 1 : 0; 9476 9497 9477 9498 #if GLYPH_DEBUG … … 9485 9506 if (scroll_margin > 0) 9486 9507 { 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); 9489 9510 } 9490 9511 else 9491 9512 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)); 9492 9519 9493 9520 /* Compute how much we should try to scroll maximally to bring point … … 9504 9531 else 9505 9532 scroll_max = 0; 9506 scroll_max *= CANON_Y_UNIT (f);9533 scroll_max *= FRAME_LINE_HEIGHT (f); 9507 9534 9508 9535 /* Decide whether we have to scroll down. Start at the window end … … 9510 9537 margin. */ 9511 9538 window_end = Fwindow_end (window, Qt); 9539 9540 too_near_end: 9541 9512 9542 CHARPOS (scroll_margin_pos) = XINT (window_end); 9513 9543 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) 9515 9546 { 9516 9547 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); 9518 9552 scroll_margin_pos = it.current.pos; 9519 9553 } … … 9547 9581 9548 9582 if (scroll_conservatively) 9583 /* Set AMOUNT_TO_SCROLL to at least one line, 9584 and at most scroll_conservatively lines. */ 9549 9585 amount_to_scroll 9550 = m ax (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); 9552 9588 else if (scroll_step || temp_scroll_step) 9553 9589 amount_to_scroll = scroll_max; … … 9555 9591 { 9556 9592 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); 9559 9594 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 } 9561 9601 } 9562 9602 … … 9564 9604 return SCROLLING_FAILED; 9565 9605 9606 /* If moving by amount_to_scroll leaves STARTP unchanged, 9607 move it down one screen line. */ 9608 9566 9609 move_it_vertically (&it, amount_to_scroll); 9610 if (CHARPOS (it.current.pos) == CHARPOS (startp)) 9611 move_it_by_lines (&it, 1, 1); 9567 9612 startp = it.current.pos; 9568 9613 } … … 9603 9648 if (scroll_conservatively) 9604 9649 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)); 9606 9651 else if (scroll_step || temp_scroll_step) 9607 9652 amount_to_scroll = scroll_max; … … 9609 9654 { 9610 9655 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); 9613 9657 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 } 9615 9664 } 9616 9665 … … 9643 9692 w->base_line_number = Qnil; 9644 9693 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; 9652 9703 } 9653 9704 … … 9935 9986 { 9936 9987 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; 9940 9990 else 9941 9991 rc = CURSOR_MOVEMENT_SUCCESS; … … 9975 10025 int current_matrix_up_to_date_p = 0; 9976 10026 int temp_scroll_step = 0; 9977 int count = BINDING_STACK_SIZE();10027 int count = SPECPDL_INDEX (); 9978 10028 int rc; 10029 int centering_position; 10030 int last_line_misfit = 0; 9979 10031 9980 10032 SET_TEXT_POS (lpoint, PT, PT_BYTE); … … 10151 10203 || w->frozen_window_start_p) 10152 10204 { 10205 /* We set this later on if we have to adjust point. */ 10206 int new_vpos = -1; 10207 10153 10208 w->force_start = Qnil; 10154 10209 w->vscroll = 0; … … 10188 10243 w->force_start = Qt; 10189 10244 clear_glyph_matrix (w->desired_matrix); 10190 goto finish_scroll_bars;10245 goto need_larger_matrices; 10191 10246 } 10192 10247 … … 10196 10251 appear. The desired matrix has been built above, so we 10197 10252 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 { 10199 10267 struct glyph_row *row; 10200 10268 10201 window_height = window_box_height (w) / 2;10202 10269 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) 10204 10271 ++row; 10205 10272 … … 10225 10292 } 10226 10293 10227 if (!make_cursor_line_fully_visible (w))10228 goto need_larger_matrices;10229 10294 #if GLYPH_DEBUG 10230 10295 debug_method_add (w, "forced window start"); … … 10234 10299 10235 10300 /* 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.) */ 10237 10303 if (current_matrix_up_to_date_p 10238 10304 && (rc = try_cursor_movement (window, startp, &temp_scroll_step), … … 10321 10387 w->base_line_number = Qnil; 10322 10388 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; 10326 10397 } 10327 10398 else … … 10356 10427 scroll_conservatively, 10357 10428 scroll_step, 10358 temp_scroll_step );10429 temp_scroll_step, last_line_misfit); 10359 10430 switch (rc) 10360 10431 { … … 10376 10447 10377 10448 recenter: 10449 centering_position = window_box_height (w) / 2; 10450 10451 point_at_top: 10452 /* Jump here with centering_position already set to 0. */ 10378 10453 10379 10454 #if GLYPH_DEBUG … … 10391 10466 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); 10392 10467 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); 10394 10469 xassert (IT_CHARPOS (it) >= BEGV); 10395 10470 … … 10471 10546 } 10472 10547 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 } 10475 10565 10476 10566 done:
