diff options
| author | Richard M. Stallman | 1996-12-26 21:01:10 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-12-26 21:01:10 +0000 |
| commit | 101d1605856e8165700fa626005260e6f0508010 (patch) | |
| tree | 0ff34310a2509d5fe2da7292ffb749885db3440e /src | |
| parent | 8eb4d8ef14377fe13f204e0e04d91b8cda7c1ee7 (diff) | |
| download | emacs-101d1605856e8165700fa626005260e6f0508010.tar.gz emacs-101d1605856e8165700fa626005260e6f0508010.zip | |
(window_scroll): Preserve vpos of point
if we cannot preserve the actual position of it.
Make it static. New arg WHOLE; callers changed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.c | 80 |
1 files changed, 58 insertions, 22 deletions
diff --git a/src/window.c b/src/window.c index a6015ddfae9..dd5d472ed7e 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -2637,12 +2637,15 @@ window_internal_width (w) | |||
| 2637 | } | 2637 | } |
| 2638 | 2638 | ||
| 2639 | 2639 | ||
| 2640 | /* Scroll contents of window WINDOW up N lines. */ | 2640 | /* Scroll contents of window WINDOW up N lines. |
| 2641 | If WHOLE is nonzero, it means we wanted to scroll | ||
| 2642 | by entire screenfuls. */ | ||
| 2641 | 2643 | ||
| 2642 | void | 2644 | static void |
| 2643 | window_scroll (window, n, noerror) | 2645 | window_scroll (window, n, whole, noerror) |
| 2644 | Lisp_Object window; | 2646 | Lisp_Object window; |
| 2645 | int n; | 2647 | int n; |
| 2648 | int whole; | ||
| 2646 | int noerror; | 2649 | int noerror; |
| 2647 | { | 2650 | { |
| 2648 | register struct window *w = XWINDOW (window); | 2651 | register struct window *w = XWINDOW (window); |
| @@ -2653,6 +2656,16 @@ window_scroll (window, n, noerror) | |||
| 2653 | int lose; | 2656 | int lose; |
| 2654 | Lisp_Object bolp, nmoved; | 2657 | Lisp_Object bolp, nmoved; |
| 2655 | int startpos; | 2658 | int startpos; |
| 2659 | struct position posit; | ||
| 2660 | int original_vpos; | ||
| 2661 | |||
| 2662 | startpos = marker_position (w->start); | ||
| 2663 | |||
| 2664 | posit = *compute_motion (startpos, 0, 0, 0, | ||
| 2665 | PT, ht, 0, | ||
| 2666 | window_internal_width (w), XINT (w->hscroll), | ||
| 2667 | 0, w); | ||
| 2668 | original_vpos = posit.vpos; | ||
| 2656 | 2669 | ||
| 2657 | XSETFASTINT (tem, PT); | 2670 | XSETFASTINT (tem, PT); |
| 2658 | tem = Fpos_visible_in_window_p (tem, window); | 2671 | tem = Fpos_visible_in_window_p (tem, window); |
| @@ -2662,8 +2675,6 @@ window_scroll (window, n, noerror) | |||
| 2662 | Fvertical_motion (make_number (- (ht / 2)), window); | 2675 | Fvertical_motion (make_number (- (ht / 2)), window); |
| 2663 | startpos = PT; | 2676 | startpos = PT; |
| 2664 | } | 2677 | } |
| 2665 | else | ||
| 2666 | startpos = marker_position (w->start); | ||
| 2667 | 2678 | ||
| 2668 | SET_PT (startpos); | 2679 | SET_PT (startpos); |
| 2669 | lose = n < 0 && PT == BEGV; | 2680 | lose = n < 0 && PT == BEGV; |
| @@ -2702,29 +2713,54 @@ window_scroll (window, n, noerror) | |||
| 2702 | the window-scroll-functions. */ | 2713 | the window-scroll-functions. */ |
| 2703 | w->force_start = Qt; | 2714 | w->force_start = Qt; |
| 2704 | 2715 | ||
| 2705 | /* If we scrolled forward, put point enough lines down | 2716 | if (whole) |
| 2706 | that it is outside the scroll margin. */ | ||
| 2707 | if (n > 0 && this_scroll_margin > 0) | ||
| 2708 | { | 2717 | { |
| 2709 | SET_PT (pos); | 2718 | SET_PT (pos); |
| 2710 | Fvertical_motion (make_number (this_scroll_margin), window); | 2719 | Fvertical_motion (make_number (original_vpos), window); |
| 2711 | pos = PT; | ||
| 2712 | } | 2720 | } |
| 2713 | 2721 | /* If we scrolled forward, put point enough lines down | |
| 2714 | if (pos > opoint) | 2722 | that it is outside the scroll margin. */ |
| 2723 | else if (n > 0) | ||
| 2715 | { | 2724 | { |
| 2716 | SET_PT (pos); | 2725 | int top_margin; |
| 2726 | |||
| 2727 | if (this_scroll_margin > 0) | ||
| 2728 | { | ||
| 2729 | SET_PT (pos); | ||
| 2730 | Fvertical_motion (make_number (this_scroll_margin), window); | ||
| 2731 | top_margin = PT; | ||
| 2732 | } | ||
| 2733 | else | ||
| 2734 | top_margin = pos; | ||
| 2735 | |||
| 2736 | if (top_margin <= opoint) | ||
| 2737 | SET_PT (opoint); | ||
| 2738 | else | ||
| 2739 | { | ||
| 2740 | SET_PT (pos); | ||
| 2741 | Fvertical_motion (make_number (original_vpos), window); | ||
| 2742 | } | ||
| 2717 | } | 2743 | } |
| 2718 | if (n < 0) | 2744 | else if (n < 0) |
| 2719 | { | 2745 | { |
| 2746 | int bottom_margin; | ||
| 2747 | |||
| 2720 | /* If we scrolled backward, put point near the end of the window | 2748 | /* If we scrolled backward, put point near the end of the window |
| 2721 | but not within the scroll margin. */ | 2749 | but not within the scroll margin. */ |
| 2722 | SET_PT (pos); | 2750 | SET_PT (pos); |
| 2723 | tem = Fvertical_motion (make_number (ht - this_scroll_margin), window); | 2751 | tem = Fvertical_motion (make_number (ht - this_scroll_margin), window); |
| 2724 | if (PT > opoint || XFASTINT (tem) < ht - this_scroll_margin) | 2752 | if (XFASTINT (tem) == ht - this_scroll_margin) |
| 2753 | bottom_margin = PT; | ||
| 2754 | else | ||
| 2755 | bottom_margin = PT + 1; | ||
| 2756 | |||
| 2757 | if (bottom_margin > opoint) | ||
| 2725 | SET_PT (opoint); | 2758 | SET_PT (opoint); |
| 2726 | else | 2759 | else |
| 2727 | Fvertical_motion (make_number (-1), window); | 2760 | { |
| 2761 | SET_PT (pos); | ||
| 2762 | Fvertical_motion (make_number (original_vpos), window); | ||
| 2763 | } | ||
| 2728 | } | 2764 | } |
| 2729 | } | 2765 | } |
| 2730 | else | 2766 | else |
| @@ -2759,13 +2795,13 @@ scroll_command (n, direction) | |||
| 2759 | defalt = direction * (defalt < 1 ? 1 : defalt); | 2795 | defalt = direction * (defalt < 1 ? 1 : defalt); |
| 2760 | 2796 | ||
| 2761 | if (NILP (n)) | 2797 | if (NILP (n)) |
| 2762 | window_scroll (selected_window, defalt, 0); | 2798 | window_scroll (selected_window, defalt, 1, 0); |
| 2763 | else if (EQ (n, Qminus)) | 2799 | else if (EQ (n, Qminus)) |
| 2764 | window_scroll (selected_window, - defalt, 0); | 2800 | window_scroll (selected_window, - defalt, 1, 0); |
| 2765 | else | 2801 | else |
| 2766 | { | 2802 | { |
| 2767 | n = Fprefix_numeric_value (n); | 2803 | n = Fprefix_numeric_value (n); |
| 2768 | window_scroll (selected_window, XINT (n) * direction, 0); | 2804 | window_scroll (selected_window, XINT (n) * direction, 0, 0); |
| 2769 | } | 2805 | } |
| 2770 | 2806 | ||
| 2771 | unbind_to (count, Qnil); | 2807 | unbind_to (count, Qnil); |
| @@ -2869,15 +2905,15 @@ showing that buffer, popping the buffer up if necessary.") | |||
| 2869 | SET_PT (marker_position (w->pointm)); | 2905 | SET_PT (marker_position (w->pointm)); |
| 2870 | 2906 | ||
| 2871 | if (NILP (arg)) | 2907 | if (NILP (arg)) |
| 2872 | window_scroll (window, defalt, 1); | 2908 | window_scroll (window, defalt, 1, 1); |
| 2873 | else if (EQ (arg, Qminus)) | 2909 | else if (EQ (arg, Qminus)) |
| 2874 | window_scroll (window, -defalt, 1); | 2910 | window_scroll (window, -defalt, 1, 1); |
| 2875 | else | 2911 | else |
| 2876 | { | 2912 | { |
| 2877 | if (CONSP (arg)) | 2913 | if (CONSP (arg)) |
| 2878 | arg = Fcar (arg); | 2914 | arg = Fcar (arg); |
| 2879 | CHECK_NUMBER (arg, 0); | 2915 | CHECK_NUMBER (arg, 0); |
| 2880 | window_scroll (window, XINT (arg), 1); | 2916 | window_scroll (window, XINT (arg), 0, 1); |
| 2881 | } | 2917 | } |
| 2882 | 2918 | ||
| 2883 | Fset_marker (w->pointm, make_number (PT), Qnil); | 2919 | Fset_marker (w->pointm, make_number (PT), Qnil); |