diff options
| author | Vibhav Pant | 2017-02-05 23:08:53 +0530 |
|---|---|---|
| committer | Vibhav Pant | 2017-02-05 23:08:53 +0530 |
| commit | ad70ca1dad26da79f0a95cc0ec687902ef20fa9b (patch) | |
| tree | 732e8e9ace1fdd7aaf982f0fa5ac6c8e4eb5f7c7 /src/window.c | |
| parent | 2db473bda8be72cf3c1e4694d70ce48f60492b0e (diff) | |
| parent | 148100d98319499f0ac6f57b8be08cbd14884a5c (diff) | |
| download | emacs-ad70ca1dad26da79f0a95cc0ec687902ef20fa9b.tar.gz emacs-ad70ca1dad26da79f0a95cc0ec687902ef20fa9b.zip | |
Merge remote-tracking branch 'origin/master' into feature/byte-switch
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/src/window.c b/src/window.c index 71a82b522c4..95690443f8e 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -4770,7 +4770,6 @@ window_scroll (Lisp_Object window, EMACS_INT n, bool whole, bool noerror) | |||
| 4770 | { | 4770 | { |
| 4771 | ptrdiff_t count = SPECPDL_INDEX (); | 4771 | ptrdiff_t count = SPECPDL_INDEX (); |
| 4772 | 4772 | ||
| 4773 | immediate_quit = true; | ||
| 4774 | n = clip_to_bounds (INT_MIN, n, INT_MAX); | 4773 | n = clip_to_bounds (INT_MIN, n, INT_MAX); |
| 4775 | 4774 | ||
| 4776 | wset_redisplay (XWINDOW (window)); | 4775 | wset_redisplay (XWINDOW (window)); |
| @@ -4789,7 +4788,36 @@ window_scroll (Lisp_Object window, EMACS_INT n, bool whole, bool noerror) | |||
| 4789 | 4788 | ||
| 4790 | /* Bug#15957. */ | 4789 | /* Bug#15957. */ |
| 4791 | XWINDOW (window)->window_end_valid = false; | 4790 | XWINDOW (window)->window_end_valid = false; |
| 4792 | immediate_quit = false; | 4791 | } |
| 4792 | |||
| 4793 | /* Compute scroll margin for WINDOW. | ||
| 4794 | We scroll when point is within this distance from the top or bottom | ||
| 4795 | of the window. The result is measured in lines or in pixels | ||
| 4796 | depending on the second parameter. */ | ||
| 4797 | int | ||
| 4798 | window_scroll_margin (struct window *window, enum margin_unit unit) | ||
| 4799 | { | ||
| 4800 | if (scroll_margin > 0) | ||
| 4801 | { | ||
| 4802 | int frame_line_height = default_line_pixel_height (window); | ||
| 4803 | int window_lines = window_box_height (window) / frame_line_height; | ||
| 4804 | |||
| 4805 | double ratio = 0.25; | ||
| 4806 | if (FLOATP (Vmaximum_scroll_margin)) | ||
| 4807 | { | ||
| 4808 | ratio = XFLOAT_DATA (Vmaximum_scroll_margin); | ||
| 4809 | ratio = max (0.0, ratio); | ||
| 4810 | ratio = min (ratio, 0.5); | ||
| 4811 | } | ||
| 4812 | int max_margin = min ((window_lines - 1)/2, | ||
| 4813 | (int) (window_lines * ratio)); | ||
| 4814 | int margin = clip_to_bounds (0, scroll_margin, max_margin); | ||
| 4815 | return (unit == MARGIN_IN_PIXELS) | ||
| 4816 | ? margin * frame_line_height | ||
| 4817 | : margin; | ||
| 4818 | } | ||
| 4819 | else | ||
| 4820 | return 0; | ||
| 4793 | } | 4821 | } |
| 4794 | 4822 | ||
| 4795 | 4823 | ||
| @@ -4808,7 +4836,6 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 4808 | bool vscrolled = false; | 4836 | bool vscrolled = false; |
| 4809 | int x, y, rtop, rbot, rowh, vpos; | 4837 | int x, y, rtop, rbot, rowh, vpos; |
| 4810 | void *itdata = NULL; | 4838 | void *itdata = NULL; |
| 4811 | int window_total_lines; | ||
| 4812 | int frame_line_height = default_line_pixel_height (w); | 4839 | int frame_line_height = default_line_pixel_height (w); |
| 4813 | bool adjust_old_pointm = !NILP (Fequal (Fwindow_point (window), | 4840 | bool adjust_old_pointm = !NILP (Fequal (Fwindow_point (window), |
| 4814 | Fwindow_old_point (window))); | 4841 | Fwindow_old_point (window))); |
| @@ -5064,12 +5091,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 5064 | /* Move PT out of scroll margins. | 5091 | /* Move PT out of scroll margins. |
| 5065 | This code wants current_y to be zero at the window start position | 5092 | This code wants current_y to be zero at the window start position |
| 5066 | even if there is a header line. */ | 5093 | even if there is a header line. */ |
| 5067 | window_total_lines | 5094 | this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); |
| 5068 | = w->total_lines * WINDOW_FRAME_LINE_HEIGHT (w) / frame_line_height; | ||
| 5069 | this_scroll_margin = max (0, scroll_margin); | ||
| 5070 | this_scroll_margin | ||
| 5071 | = min (this_scroll_margin, window_total_lines / 4); | ||
| 5072 | this_scroll_margin *= frame_line_height; | ||
| 5073 | 5095 | ||
| 5074 | if (n > 0) | 5096 | if (n > 0) |
| 5075 | { | 5097 | { |
| @@ -5125,7 +5147,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 5125 | in the scroll margin at the bottom. */ | 5147 | in the scroll margin at the bottom. */ |
| 5126 | move_it_to (&it, PT, -1, | 5148 | move_it_to (&it, PT, -1, |
| 5127 | (it.last_visible_y - WINDOW_HEADER_LINE_HEIGHT (w) | 5149 | (it.last_visible_y - WINDOW_HEADER_LINE_HEIGHT (w) |
| 5128 | - this_scroll_margin - 1), | 5150 | - partial_line_height (&it) - this_scroll_margin - 1), |
| 5129 | -1, | 5151 | -1, |
| 5130 | MOVE_TO_POS | MOVE_TO_Y); | 5152 | MOVE_TO_POS | MOVE_TO_Y); |
| 5131 | 5153 | ||
| @@ -5292,9 +5314,7 @@ window_scroll_line_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 5292 | 5314 | ||
| 5293 | if (pos < ZV) | 5315 | if (pos < ZV) |
| 5294 | { | 5316 | { |
| 5295 | /* Don't use a scroll margin that is negative or too large. */ | 5317 | int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_LINES); |
| 5296 | int this_scroll_margin = | ||
| 5297 | max (0, min (scroll_margin, w->total_lines / 4)); | ||
| 5298 | 5318 | ||
| 5299 | set_marker_restricted_both (w->start, w->contents, pos, pos_byte); | 5319 | set_marker_restricted_both (w->start, w->contents, pos, pos_byte); |
| 5300 | w->start_at_line_beg = !NILP (bolp); | 5320 | w->start_at_line_beg = !NILP (bolp); |
| @@ -5724,8 +5744,7 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5724 | 5744 | ||
| 5725 | /* Do this after making BUF current | 5745 | /* Do this after making BUF current |
| 5726 | in case scroll_margin is buffer-local. */ | 5746 | in case scroll_margin is buffer-local. */ |
| 5727 | this_scroll_margin | 5747 | this_scroll_margin = window_scroll_margin (w, MARGIN_IN_LINES); |
| 5728 | = max (0, min (scroll_margin, w->total_lines / 4)); | ||
| 5729 | 5748 | ||
| 5730 | /* Don't use redisplay code for initial frames, as the necessary | 5749 | /* Don't use redisplay code for initial frames, as the necessary |
| 5731 | data structures might not be set up yet then. */ | 5750 | data structures might not be set up yet then. */ |
| @@ -5964,10 +5983,6 @@ from the top of the window. */) | |||
| 5964 | 5983 | ||
| 5965 | lines = displayed_window_lines (w); | 5984 | lines = displayed_window_lines (w); |
| 5966 | 5985 | ||
| 5967 | #if false | ||
| 5968 | this_scroll_margin = max (0, min (scroll_margin, lines / 4)); | ||
| 5969 | #endif | ||
| 5970 | |||
| 5971 | if (NILP (arg)) | 5986 | if (NILP (arg)) |
| 5972 | XSETFASTINT (arg, lines / 2); | 5987 | XSETFASTINT (arg, lines / 2); |
| 5973 | else | 5988 | else |
| @@ -5983,6 +5998,8 @@ from the top of the window. */) | |||
| 5983 | it is probably better not to install it. However, it is here | 5998 | it is probably better not to install it. However, it is here |
| 5984 | inside #if false so as not to lose it. -- rms. */ | 5999 | inside #if false so as not to lose it. -- rms. */ |
| 5985 | 6000 | ||
| 6001 | this_scroll_margin = window_scroll_margin (w, MARGIN_IN_LINES); | ||
| 6002 | |||
| 5986 | /* Don't let it get into the margin at either top or bottom. */ | 6003 | /* Don't let it get into the margin at either top or bottom. */ |
| 5987 | iarg = max (iarg, this_scroll_margin); | 6004 | iarg = max (iarg, this_scroll_margin); |
| 5988 | iarg = min (iarg, lines - this_scroll_margin - 1); | 6005 | iarg = min (iarg, lines - this_scroll_margin - 1); |