Mercurial > vim
comparison src/move.c @ 15713:ad8b2c109b22 v8.1.0864
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
commit https://github.com/vim/vim/commit/375e3390078e740d3c83b0c118c50d9a920036c7
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 31 18:26:10 2019 +0100
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Problem: Cannot have a local value for 'scrolloff' and 'sidescrolloff'.
(Gary Holloway)
Solution: Make 'scrolloff' and 'sidescrolloff' global-local. (mostly by
Aron Widforss, closes #3539)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 31 Jan 2019 18:30:08 +0100 |
parents | b7a88676e81c |
children | 7952be788a49 |
comparison
equal
deleted
inserted
replaced
15712:bc1989f9bd37 | 15713:ad8b2c109b22 |
---|---|
190 #ifdef FEAT_FOLDING | 190 #ifdef FEAT_FOLDING |
191 linenr_T lnum; | 191 linenr_T lnum; |
192 #endif | 192 #endif |
193 int check_topline = FALSE; | 193 int check_topline = FALSE; |
194 int check_botline = FALSE; | 194 int check_botline = FALSE; |
195 long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; | |
195 #ifdef FEAT_MOUSE | 196 #ifdef FEAT_MOUSE |
196 int save_so = p_so; | 197 int save_so = *so_ptr; |
197 #endif | 198 #endif |
198 | 199 |
199 /* If there is no valid screen and when the window height is zero just use | 200 /* If there is no valid screen and when the window height is zero just use |
200 * the cursor line. */ | 201 * the cursor line. */ |
201 if (!screen_valid(TRUE) || curwin->w_height == 0) | 202 if (!screen_valid(TRUE) || curwin->w_height == 0) |
212 return; | 213 return; |
213 | 214 |
214 #ifdef FEAT_MOUSE | 215 #ifdef FEAT_MOUSE |
215 /* When dragging with the mouse, don't scroll that quickly */ | 216 /* When dragging with the mouse, don't scroll that quickly */ |
216 if (mouse_dragging > 0) | 217 if (mouse_dragging > 0) |
217 p_so = mouse_dragging - 1; | 218 *so_ptr = mouse_dragging - 1; |
218 #endif | 219 #endif |
219 | 220 |
220 old_topline = curwin->w_topline; | 221 old_topline = curwin->w_topline; |
221 #ifdef FEAT_DIFF | 222 #ifdef FEAT_DIFF |
222 old_topfill = curwin->w_topfill; | 223 old_topfill = curwin->w_topfill; |
266 | 267 |
267 #ifdef FEAT_FOLDING | 268 #ifdef FEAT_FOLDING |
268 if (hasAnyFolding(curwin)) | 269 if (hasAnyFolding(curwin)) |
269 { | 270 { |
270 /* Count the number of logical lines between the cursor and | 271 /* Count the number of logical lines between the cursor and |
271 * topline + p_so (approximation of how much will be | 272 * topline + scrolloff (approximation of how much will be |
272 * scrolled). */ | 273 * scrolled). */ |
273 n = 0; | 274 n = 0; |
274 for (lnum = curwin->w_cursor.lnum; | 275 for (lnum = curwin->w_cursor.lnum; |
275 lnum < curwin->w_topline + p_so; ++lnum) | 276 lnum < curwin->w_topline + *so_ptr; ++lnum) |
276 { | 277 { |
277 ++n; | 278 ++n; |
278 /* stop at end of file or when we know we are far off */ | 279 /* stop at end of file or when we know we are far off */ |
279 if (lnum >= curbuf->b_ml.ml_line_count || n >= halfheight) | 280 if (lnum >= curbuf->b_ml.ml_line_count || n >= halfheight) |
280 break; | 281 break; |
281 (void)hasFolding(lnum, NULL, &lnum); | 282 (void)hasFolding(lnum, NULL, &lnum); |
282 } | 283 } |
283 } | 284 } |
284 else | 285 else |
285 #endif | 286 #endif |
286 n = curwin->w_topline + p_so - curwin->w_cursor.lnum; | 287 n = curwin->w_topline + *so_ptr - curwin->w_cursor.lnum; |
287 | 288 |
288 /* If we weren't very close to begin with, we scroll to put the | 289 /* If we weren't very close to begin with, we scroll to put the |
289 * cursor in the middle of the window. Otherwise put the cursor | 290 * cursor in the middle of the window. Otherwise put the cursor |
290 * near the top of the window. */ | 291 * near the top of the window. */ |
291 if (n >= halfheight) | 292 if (n >= halfheight) |
323 if (curwin->w_botline <= curbuf->b_ml.ml_line_count) | 324 if (curwin->w_botline <= curbuf->b_ml.ml_line_count) |
324 { | 325 { |
325 if (curwin->w_cursor.lnum < curwin->w_botline) | 326 if (curwin->w_cursor.lnum < curwin->w_botline) |
326 { | 327 { |
327 if (((long)curwin->w_cursor.lnum | 328 if (((long)curwin->w_cursor.lnum |
328 >= (long)curwin->w_botline - p_so | 329 >= (long)curwin->w_botline - *so_ptr |
329 #ifdef FEAT_FOLDING | 330 #ifdef FEAT_FOLDING |
330 || hasAnyFolding(curwin) | 331 || hasAnyFolding(curwin) |
331 #endif | 332 #endif |
332 )) | 333 )) |
333 { | 334 { |
352 && (loff.lnum + 1 < curwin->w_botline || loff.fill == 0) | 353 && (loff.lnum + 1 < curwin->w_botline || loff.fill == 0) |
353 #endif | 354 #endif |
354 ) | 355 ) |
355 { | 356 { |
356 n += loff.height; | 357 n += loff.height; |
357 if (n >= p_so) | 358 if (n >= *so_ptr) |
358 break; | 359 break; |
359 botline_forw(&loff); | 360 botline_forw(&loff); |
360 } | 361 } |
361 if (n >= p_so) | 362 if (n >= *so_ptr) |
362 /* sufficient context, no need to scroll */ | 363 /* sufficient context, no need to scroll */ |
363 check_botline = FALSE; | 364 check_botline = FALSE; |
364 } | 365 } |
365 else | 366 else |
366 /* sufficient context, no need to scroll */ | 367 /* sufficient context, no need to scroll */ |
370 { | 371 { |
371 #ifdef FEAT_FOLDING | 372 #ifdef FEAT_FOLDING |
372 if (hasAnyFolding(curwin)) | 373 if (hasAnyFolding(curwin)) |
373 { | 374 { |
374 /* Count the number of logical lines between the cursor and | 375 /* Count the number of logical lines between the cursor and |
375 * botline - p_so (approximation of how much will be | 376 * botline - scrolloff (approximation of how much will be |
376 * scrolled). */ | 377 * scrolled). */ |
377 line_count = 0; | 378 line_count = 0; |
378 for (lnum = curwin->w_cursor.lnum; | 379 for (lnum = curwin->w_cursor.lnum; |
379 lnum >= curwin->w_botline - p_so; --lnum) | 380 lnum >= curwin->w_botline - *so_ptr; --lnum) |
380 { | 381 { |
381 ++line_count; | 382 ++line_count; |
382 /* stop at end of file or when we know we are far off */ | 383 /* stop at end of file or when we know we are far off */ |
383 if (lnum <= 0 || line_count > curwin->w_height + 1) | 384 if (lnum <= 0 || line_count > curwin->w_height + 1) |
384 break; | 385 break; |
386 } | 387 } |
387 } | 388 } |
388 else | 389 else |
389 #endif | 390 #endif |
390 line_count = curwin->w_cursor.lnum - curwin->w_botline | 391 line_count = curwin->w_cursor.lnum - curwin->w_botline |
391 + 1 + p_so; | 392 + 1 + *so_ptr; |
392 if (line_count <= curwin->w_height + 1) | 393 if (line_count <= curwin->w_height + 1) |
393 scroll_cursor_bot(scrolljump_value(), FALSE); | 394 scroll_cursor_bot(scrolljump_value(), FALSE); |
394 else | 395 else |
395 scroll_cursor_halfway(FALSE); | 396 scroll_cursor_halfway(FALSE); |
396 } | 397 } |
419 if (curwin->w_cursor.lnum == curwin->w_topline) | 420 if (curwin->w_cursor.lnum == curwin->w_topline) |
420 validate_cursor(); | 421 validate_cursor(); |
421 } | 422 } |
422 | 423 |
423 #ifdef FEAT_MOUSE | 424 #ifdef FEAT_MOUSE |
424 p_so = save_so; | 425 *so_ptr = save_so; |
425 #endif | 426 #endif |
426 } | 427 } |
427 | 428 |
428 /* | 429 /* |
429 * Return the scrolljump value to use for the current window. | 430 * Return the scrolljump value to use for the current window. |
445 static int | 446 static int |
446 check_top_offset(void) | 447 check_top_offset(void) |
447 { | 448 { |
448 lineoff_T loff; | 449 lineoff_T loff; |
449 int n; | 450 int n; |
450 | 451 long so = get_scrolloff_value(); |
451 if (curwin->w_cursor.lnum < curwin->w_topline + p_so | 452 |
453 if (curwin->w_cursor.lnum < curwin->w_topline + so | |
452 #ifdef FEAT_FOLDING | 454 #ifdef FEAT_FOLDING |
453 || hasAnyFolding(curwin) | 455 || hasAnyFolding(curwin) |
454 #endif | 456 #endif |
455 ) | 457 ) |
456 { | 458 { |
460 n = curwin->w_topfill; /* always have this context */ | 462 n = curwin->w_topfill; /* always have this context */ |
461 #else | 463 #else |
462 n = 0; | 464 n = 0; |
463 #endif | 465 #endif |
464 /* Count the visible screen lines above the cursor line. */ | 466 /* Count the visible screen lines above the cursor line. */ |
465 while (n < p_so) | 467 while (n < so) |
466 { | 468 { |
467 topline_back(&loff); | 469 topline_back(&loff); |
468 /* Stop when included a line above the window. */ | 470 /* Stop when included a line above the window. */ |
469 if (loff.lnum < curwin->w_topline | 471 if (loff.lnum < curwin->w_topline |
470 #ifdef FEAT_DIFF | 472 #ifdef FEAT_DIFF |
472 #endif | 474 #endif |
473 ) | 475 ) |
474 break; | 476 break; |
475 n += loff.height; | 477 n += loff.height; |
476 } | 478 } |
477 if (n < p_so) | 479 if (n < so) |
478 return TRUE; | 480 return TRUE; |
479 } | 481 } |
480 return FALSE; | 482 return FALSE; |
481 } | 483 } |
482 | 484 |
944 int textwidth; | 946 int textwidth; |
945 int new_leftcol; | 947 int new_leftcol; |
946 colnr_T startcol; | 948 colnr_T startcol; |
947 colnr_T endcol; | 949 colnr_T endcol; |
948 colnr_T prev_skipcol; | 950 colnr_T prev_skipcol; |
951 long so = get_scrolloff_value(); | |
952 long siso = get_sidescrolloff_value(); | |
949 | 953 |
950 /* | 954 /* |
951 * First make sure that w_topline is valid (after moving the cursor). | 955 * First make sure that w_topline is valid (after moving the cursor). |
952 */ | 956 */ |
953 update_topline(); | 957 update_topline(); |
1026 * If Cursor is left of the screen, scroll rightwards. | 1030 * If Cursor is left of the screen, scroll rightwards. |
1027 * If Cursor is right of the screen, scroll leftwards | 1031 * If Cursor is right of the screen, scroll leftwards |
1028 * If we get closer to the edge than 'sidescrolloff', scroll a little | 1032 * If we get closer to the edge than 'sidescrolloff', scroll a little |
1029 * extra | 1033 * extra |
1030 */ | 1034 */ |
1031 off_left = (int)startcol - (int)curwin->w_leftcol - p_siso; | 1035 off_left = (int)startcol - (int)curwin->w_leftcol - siso; |
1032 off_right = (int)endcol - (int)(curwin->w_leftcol + curwin->w_width | 1036 off_right = (int)endcol - (int)(curwin->w_leftcol + curwin->w_width |
1033 - p_siso) + 1; | 1037 - siso) + 1; |
1034 if (off_left < 0 || off_right > 0) | 1038 if (off_left < 0 || off_right > 0) |
1035 { | 1039 { |
1036 if (off_left < 0) | 1040 if (off_left < 0) |
1037 diff = -off_left; | 1041 diff = -off_left; |
1038 else | 1042 else |
1077 #endif | 1081 #endif |
1078 | 1082 |
1079 prev_skipcol = curwin->w_skipcol; | 1083 prev_skipcol = curwin->w_skipcol; |
1080 | 1084 |
1081 p_lines = 0; | 1085 p_lines = 0; |
1086 | |
1082 if ((curwin->w_wrow >= curwin->w_height | 1087 if ((curwin->w_wrow >= curwin->w_height |
1083 || ((prev_skipcol > 0 | 1088 || ((prev_skipcol > 0 |
1084 || curwin->w_wrow + p_so >= curwin->w_height) | 1089 || curwin->w_wrow + so >= curwin->w_height) |
1085 && (p_lines = | 1090 && (p_lines = |
1086 #ifdef FEAT_DIFF | 1091 #ifdef FEAT_DIFF |
1087 plines_win_nofill | 1092 plines_win_nofill |
1088 #else | 1093 #else |
1089 plines_win | 1094 plines_win |
1096 && curwin->w_width != 0) | 1101 && curwin->w_width != 0) |
1097 { | 1102 { |
1098 /* Cursor past end of screen. Happens with a single line that does | 1103 /* Cursor past end of screen. Happens with a single line that does |
1099 * not fit on screen. Find a skipcol to show the text around the | 1104 * not fit on screen. Find a skipcol to show the text around the |
1100 * cursor. Avoid scrolling all the time. compute value of "extra": | 1105 * cursor. Avoid scrolling all the time. compute value of "extra": |
1101 * 1: Less than "p_so" lines above | 1106 * 1: Less than 'scrolloff' lines above |
1102 * 2: Less than "p_so" lines below | 1107 * 2: Less than 'scrolloff' lines below |
1103 * 3: both of them */ | 1108 * 3: both of them */ |
1104 extra = 0; | 1109 extra = 0; |
1105 if (curwin->w_skipcol + p_so * width > curwin->w_virtcol) | 1110 if (curwin->w_skipcol + so * width > curwin->w_virtcol) |
1106 extra = 1; | 1111 extra = 1; |
1107 /* Compute last display line of the buffer line that we want at the | 1112 /* Compute last display line of the buffer line that we want at the |
1108 * bottom of the window. */ | 1113 * bottom of the window. */ |
1109 if (p_lines == 0) | 1114 if (p_lines == 0) |
1110 p_lines = plines_win(curwin, curwin->w_cursor.lnum, FALSE); | 1115 p_lines = plines_win(curwin, curwin->w_cursor.lnum, FALSE); |
1111 --p_lines; | 1116 --p_lines; |
1112 if (p_lines > curwin->w_wrow + p_so) | 1117 if (p_lines > curwin->w_wrow + so) |
1113 n = curwin->w_wrow + p_so; | 1118 n = curwin->w_wrow + so; |
1114 else | 1119 else |
1115 n = p_lines; | 1120 n = p_lines; |
1116 if ((colnr_T)n >= curwin->w_height + curwin->w_skipcol / width) | 1121 if ((colnr_T)n >= curwin->w_height + curwin->w_skipcol / width) |
1117 extra += 2; | 1122 extra += 2; |
1118 | 1123 |
1119 if (extra == 3 || p_lines < p_so * 2) | 1124 if (extra == 3 || p_lines < so * 2) |
1120 { | 1125 { |
1121 /* not enough room for 'scrolloff', put cursor in the middle */ | 1126 /* not enough room for 'scrolloff', put cursor in the middle */ |
1122 n = curwin->w_virtcol / width; | 1127 n = curwin->w_virtcol / width; |
1123 if (n > curwin->w_height / 2) | 1128 if (n > curwin->w_height / 2) |
1124 n -= curwin->w_height / 2; | 1129 n -= curwin->w_height / 2; |
1130 curwin->w_skipcol = n * width; | 1135 curwin->w_skipcol = n * width; |
1131 } | 1136 } |
1132 else if (extra == 1) | 1137 else if (extra == 1) |
1133 { | 1138 { |
1134 /* less then 'scrolloff' lines above, decrease skipcol */ | 1139 /* less then 'scrolloff' lines above, decrease skipcol */ |
1135 extra = (curwin->w_skipcol + p_so * width - curwin->w_virtcol | 1140 extra = (curwin->w_skipcol + so * width - curwin->w_virtcol |
1136 + width - 1) / width; | 1141 + width - 1) / width; |
1137 if (extra > 0) | 1142 if (extra > 0) |
1138 { | 1143 { |
1139 if ((colnr_T)(extra * width) > curwin->w_skipcol) | 1144 if ((colnr_T)(extra * width) > curwin->w_skipcol) |
1140 extra = curwin->w_skipcol / width; | 1145 extra = curwin->w_skipcol / width; |
1462 validate_cheight(); | 1467 validate_cheight(); |
1463 validate_virtcol(); | 1468 validate_virtcol(); |
1464 end_row += curwin->w_cline_height - 1 - | 1469 end_row += curwin->w_cline_height - 1 - |
1465 curwin->w_virtcol / curwin->w_width; | 1470 curwin->w_virtcol / curwin->w_width; |
1466 } | 1471 } |
1467 if (end_row < curwin->w_height - p_so) | 1472 if (end_row < curwin->w_height - get_scrolloff_value()) |
1468 { | 1473 { |
1469 #ifdef FEAT_DIFF | 1474 #ifdef FEAT_DIFF |
1470 if (can_fill) | 1475 if (can_fill) |
1471 { | 1476 { |
1472 ++curwin->w_topfill; | 1477 ++curwin->w_topfill; |
1520 if (curwin->w_p_wrap && curwin->w_width != 0) | 1525 if (curwin->w_p_wrap && curwin->w_width != 0) |
1521 { | 1526 { |
1522 validate_virtcol(); | 1527 validate_virtcol(); |
1523 start_row -= curwin->w_virtcol / curwin->w_width; | 1528 start_row -= curwin->w_virtcol / curwin->w_width; |
1524 } | 1529 } |
1525 if (start_row >= p_so) | 1530 if (start_row >= get_scrolloff_value()) |
1526 { | 1531 { |
1527 #ifdef FEAT_DIFF | 1532 #ifdef FEAT_DIFF |
1528 if (curwin->w_topfill > 0) | 1533 if (curwin->w_topfill > 0) |
1529 --curwin->w_topfill; | 1534 --curwin->w_topfill; |
1530 else | 1535 else |
1664 linenr_T old_topline = curwin->w_topline; | 1669 linenr_T old_topline = curwin->w_topline; |
1665 #ifdef FEAT_DIFF | 1670 #ifdef FEAT_DIFF |
1666 linenr_T old_topfill = curwin->w_topfill; | 1671 linenr_T old_topfill = curwin->w_topfill; |
1667 #endif | 1672 #endif |
1668 linenr_T new_topline; | 1673 linenr_T new_topline; |
1669 int off = p_so; | 1674 int off = get_scrolloff_value(); |
1670 | 1675 |
1671 #ifdef FEAT_MOUSE | 1676 #ifdef FEAT_MOUSE |
1672 if (mouse_dragging > 0) | 1677 if (mouse_dragging > 0) |
1673 off = mouse_dragging - 1; | 1678 off = mouse_dragging - 1; |
1674 #endif | 1679 #endif |
1840 #endif | 1845 #endif |
1841 linenr_T old_botline = curwin->w_botline; | 1846 linenr_T old_botline = curwin->w_botline; |
1842 linenr_T old_valid = curwin->w_valid; | 1847 linenr_T old_valid = curwin->w_valid; |
1843 int old_empty_rows = curwin->w_empty_rows; | 1848 int old_empty_rows = curwin->w_empty_rows; |
1844 linenr_T cln; /* Cursor Line Number */ | 1849 linenr_T cln; /* Cursor Line Number */ |
1850 long so = get_scrolloff_value(); | |
1845 | 1851 |
1846 cln = curwin->w_cursor.lnum; | 1852 cln = curwin->w_cursor.lnum; |
1847 if (set_topbot) | 1853 if (set_topbot) |
1848 { | 1854 { |
1849 used = 0; | 1855 used = 0; |
1896 | 1902 |
1897 /* | 1903 /* |
1898 * Stop counting lines to scroll when | 1904 * Stop counting lines to scroll when |
1899 * - hitting start of the file | 1905 * - hitting start of the file |
1900 * - scrolled nothing or at least 'sj' lines | 1906 * - scrolled nothing or at least 'sj' lines |
1901 * - at least 'so' lines below the cursor | 1907 * - at least 'scrolloff' lines below the cursor |
1902 * - lines between botline and cursor have been counted | 1908 * - lines between botline and cursor have been counted |
1903 */ | 1909 */ |
1904 #ifdef FEAT_FOLDING | 1910 #ifdef FEAT_FOLDING |
1905 if (!hasFolding(curwin->w_cursor.lnum, &loff.lnum, &boff.lnum)) | 1911 if (!hasFolding(curwin->w_cursor.lnum, &loff.lnum, &boff.lnum)) |
1906 #endif | 1912 #endif |
1922 if ((((scrolled <= 0 || scrolled >= min_scroll) | 1928 if ((((scrolled <= 0 || scrolled >= min_scroll) |
1923 && extra >= ( | 1929 && extra >= ( |
1924 #ifdef FEAT_MOUSE | 1930 #ifdef FEAT_MOUSE |
1925 mouse_dragging > 0 ? mouse_dragging - 1 : | 1931 mouse_dragging > 0 ? mouse_dragging - 1 : |
1926 #endif | 1932 #endif |
1927 p_so)) | 1933 so)) |
1928 || boff.lnum + 1 > curbuf->b_ml.ml_line_count) | 1934 || boff.lnum + 1 > curbuf->b_ml.ml_line_count) |
1929 && loff.lnum <= curwin->w_botline | 1935 && loff.lnum <= curwin->w_botline |
1930 #ifdef FEAT_DIFF | 1936 #ifdef FEAT_DIFF |
1931 && (loff.lnum < curwin->w_botline | 1937 && (loff.lnum < curwin->w_botline |
1932 || loff.fill >= fill_below_window) | 1938 || loff.fill >= fill_below_window) |
1968 break; | 1974 break; |
1969 if (extra < ( | 1975 if (extra < ( |
1970 #ifdef FEAT_MOUSE | 1976 #ifdef FEAT_MOUSE |
1971 mouse_dragging > 0 ? mouse_dragging - 1 : | 1977 mouse_dragging > 0 ? mouse_dragging - 1 : |
1972 #endif | 1978 #endif |
1973 p_so) || scrolled < min_scroll) | 1979 so) || scrolled < min_scroll) |
1974 { | 1980 { |
1975 extra += boff.height; | 1981 extra += boff.height; |
1976 if (boff.lnum >= curwin->w_botline | 1982 if (boff.lnum >= curwin->w_botline |
1977 #ifdef FEAT_DIFF | 1983 #ifdef FEAT_DIFF |
1978 || (boff.lnum + 1 == curwin->w_botline | 1984 || (boff.lnum + 1 == curwin->w_botline |
2122 curwin->w_valid |= VALID_TOPLINE; | 2128 curwin->w_valid |= VALID_TOPLINE; |
2123 } | 2129 } |
2124 | 2130 |
2125 /* | 2131 /* |
2126 * Correct the cursor position so that it is in a part of the screen at least | 2132 * Correct the cursor position so that it is in a part of the screen at least |
2127 * 'so' lines from the top and bottom, if possible. | 2133 * 'scrolloff' lines from the top and bottom, if possible. |
2128 * If not possible, put it at the same position as scroll_cursor_halfway(). | 2134 * If not possible, put it at the same position as scroll_cursor_halfway(). |
2129 * When called topline must be valid! | 2135 * When called topline must be valid! |
2130 */ | 2136 */ |
2131 void | 2137 void |
2132 cursor_correct(void) | 2138 cursor_correct(void) |
2136 int below = 0; /* screen lines below botline */ | 2142 int below = 0; /* screen lines below botline */ |
2137 linenr_T botline; | 2143 linenr_T botline; |
2138 int above_wanted, below_wanted; | 2144 int above_wanted, below_wanted; |
2139 linenr_T cln; /* Cursor Line Number */ | 2145 linenr_T cln; /* Cursor Line Number */ |
2140 int max_off; | 2146 int max_off; |
2147 long so = get_scrolloff_value(); | |
2141 | 2148 |
2142 /* | 2149 /* |
2143 * How many lines we would like to have above/below the cursor depends on | 2150 * How many lines we would like to have above/below the cursor depends on |
2144 * whether the first/last line of the file is on screen. | 2151 * whether the first/last line of the file is on screen. |
2145 */ | 2152 */ |
2146 above_wanted = p_so; | 2153 above_wanted = so; |
2147 below_wanted = p_so; | 2154 below_wanted = so; |
2148 #ifdef FEAT_MOUSE | 2155 #ifdef FEAT_MOUSE |
2149 if (mouse_dragging > 0) | 2156 if (mouse_dragging > 0) |
2150 { | 2157 { |
2151 above_wanted = mouse_dragging - 1; | 2158 above_wanted = mouse_dragging - 1; |
2152 below_wanted = mouse_dragging - 1; | 2159 below_wanted = mouse_dragging - 1; |
2260 { | 2267 { |
2261 long n; | 2268 long n; |
2262 int retval = OK; | 2269 int retval = OK; |
2263 lineoff_T loff; | 2270 lineoff_T loff; |
2264 linenr_T old_topline = curwin->w_topline; | 2271 linenr_T old_topline = curwin->w_topline; |
2272 long so = get_scrolloff_value(); | |
2265 | 2273 |
2266 if (curbuf->b_ml.ml_line_count == 1) /* nothing to do */ | 2274 if (curbuf->b_ml.ml_line_count == 1) /* nothing to do */ |
2267 { | 2275 { |
2268 beep_flush(); | 2276 beep_flush(); |
2269 return FAIL; | 2277 return FAIL; |
2277 * the screen. It's an error to move a page down when the last line | 2285 * the screen. It's an error to move a page down when the last line |
2278 * is on the screen and the topline is 'scrolloff' lines from the | 2286 * is on the screen and the topline is 'scrolloff' lines from the |
2279 * last line. | 2287 * last line. |
2280 */ | 2288 */ |
2281 if (dir == FORWARD | 2289 if (dir == FORWARD |
2282 ? ((curwin->w_topline >= curbuf->b_ml.ml_line_count - p_so) | 2290 ? ((curwin->w_topline >= curbuf->b_ml.ml_line_count - so) |
2283 && curwin->w_botline > curbuf->b_ml.ml_line_count) | 2291 && curwin->w_botline > curbuf->b_ml.ml_line_count) |
2284 : (curwin->w_topline == 1 | 2292 : (curwin->w_topline == 1 |
2285 #ifdef FEAT_DIFF | 2293 #ifdef FEAT_DIFF |
2286 && curwin->w_topfill == | 2294 && curwin->w_topfill == |
2287 diff_check_fill(curwin, curwin->w_topline) | 2295 diff_check_fill(curwin, curwin->w_topline) |