Mercurial > vim
annotate src/move.c @ 32421:603b6dcf5f9a v9.0.1542
patch 9.0.1542: line not fully displayed if it doesn't fit in the screen
Commit: https://github.com/vim/vim/commit/6c018680be0ec25d42614a93be1ea08df29a9e2a
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Thu May 11 18:38:14 2023 +0100
patch 9.0.1542: line not fully displayed if it doesn't fit in the screen
Problem: Line not fully displayed if it doesn't fit in the screen.
Solution: Do not reset s_skipcol if not needed. (Luuk van Baal,
closes #12376)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 11 May 2023 19:45:03 +0200 |
parents | f9d4988a86ef |
children | 9d072cccc8fc |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9852
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 /* | |
10 * move.c: Functions for moving the cursor and scrolling text. | |
11 * | |
12 * There are two ways to move the cursor: | |
13 * 1. Move the cursor directly, the text is scrolled to keep the cursor in the | |
14 * window. | |
15 * 2. Scroll the text, the cursor is moved into the text visible in the | |
16 * window. | |
17 * The 'scrolloff' option makes this a bit complicated. | |
18 */ | |
19 | |
20 #include "vim.h" | |
21 | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
22 static int scrolljump_value(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
23 static int check_top_offset(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
24 static void curs_rows(win_T *wp); |
7 | 25 |
26 typedef struct | |
27 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
28 linenr_T lnum; // line number |
7 | 29 #ifdef FEAT_DIFF |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
30 int fill; // filler lines |
7 | 31 #endif |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
32 int height; // height of added line |
7 | 33 } lineoff_T; |
34 | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
35 static void topline_back(lineoff_T *lp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
36 static void botline_forw(lineoff_T *lp); |
7 | 37 |
38 /* | |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
39 * Reduce "n" for the screen lines skipped with "wp->w_skipcol". |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
40 */ |
32361
9ac987a467d5
patch 9.0.1512: inserting lines when scrolling with 'smoothscroll' set
Bram Moolenaar <Bram@vim.org>
parents:
32208
diff
changeset
|
41 int |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
42 adjust_plines_for_skipcol(win_T *wp, int n) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
43 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
44 if (wp->w_skipcol == 0) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
45 return n; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
46 |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
47 int off = 0; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
48 int width = wp->w_width - win_col_off(wp); |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
49 if (wp->w_skipcol >= width) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
50 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
51 ++off; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
52 int skip = wp->w_skipcol - width; |
30635
604d7d7aa043
patch 9.0.0652: 'smoothscroll' not tested with 'number' and "n" in 'cpo'
Bram Moolenaar <Bram@vim.org>
parents:
30624
diff
changeset
|
53 width += win_col_off2(wp); |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
54 while (skip >= width) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
55 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
56 ++off; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
57 skip -= width; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
58 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
59 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
60 wp->w_valid &= ~VALID_WROW; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
61 return n - off; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
62 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
63 |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
64 /* |
30946
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
65 * Return how many lines "lnum" will take on the screen, taking into account |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
66 * whether it is the first line, whether w_skipcol is non-zero and limiting to |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
67 * the window height. |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
68 */ |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
69 static int |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
70 plines_correct_topline(win_T *wp, linenr_T lnum) |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
71 { |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
72 int n; |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
73 #ifdef FEAT_DIFF |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
74 if (lnum == wp->w_topline) |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
75 n = plines_win_nofill(wp, lnum, FALSE) + wp->w_topfill; |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
76 else |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
77 #endif |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
78 n = plines_win(wp, lnum, FALSE); |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
79 if (lnum == wp->w_topline) |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
80 n = adjust_plines_for_skipcol(wp, n); |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
81 if (n > wp->w_height) |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
82 n = wp->w_height; |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
83 return n; |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
84 } |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
85 |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
86 /* |
7 | 87 * Compute wp->w_botline for the current wp->w_topline. Can be called after |
88 * wp->w_topline changed. | |
89 */ | |
90 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
91 comp_botline(win_T *wp) |
7 | 92 { |
93 int n; | |
94 linenr_T lnum; | |
95 int done; | |
96 #ifdef FEAT_FOLDING | |
97 linenr_T last; | |
98 int folded; | |
99 #endif | |
100 | |
101 /* | |
102 * If w_cline_row is valid, start there. | |
103 * Otherwise have to start at w_topline. | |
104 */ | |
105 check_cursor_moved(wp); | |
106 if (wp->w_valid & VALID_CROW) | |
107 { | |
108 lnum = wp->w_cursor.lnum; | |
109 done = wp->w_cline_row; | |
110 } | |
111 else | |
112 { | |
113 lnum = wp->w_topline; | |
114 done = 0; | |
115 } | |
116 | |
117 for ( ; lnum <= wp->w_buffer->b_ml.ml_line_count; ++lnum) | |
118 { | |
119 #ifdef FEAT_FOLDING | |
120 last = lnum; | |
121 folded = FALSE; | |
122 if (hasFoldingWin(wp, lnum, NULL, &last, TRUE, NULL)) | |
123 { | |
124 n = 1; | |
125 folded = TRUE; | |
126 } | |
127 else | |
128 #endif | |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
129 { |
30946
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
130 n = plines_correct_topline(wp, lnum); |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
131 } |
7 | 132 if ( |
133 #ifdef FEAT_FOLDING | |
134 lnum <= wp->w_cursor.lnum && last >= wp->w_cursor.lnum | |
135 #else | |
136 lnum == wp->w_cursor.lnum | |
137 #endif | |
138 ) | |
139 { | |
140 wp->w_cline_row = done; | |
141 wp->w_cline_height = n; | |
142 #ifdef FEAT_FOLDING | |
143 wp->w_cline_folded = folded; | |
144 #endif | |
5764 | 145 redraw_for_cursorline(wp); |
7 | 146 wp->w_valid |= (VALID_CROW|VALID_CHEIGHT); |
147 } | |
148 if (done + n > wp->w_height) | |
149 break; | |
150 done += n; | |
151 #ifdef FEAT_FOLDING | |
152 lnum = last; | |
153 #endif | |
154 } | |
155 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
156 // wp->w_botline is the line that is just below the window |
7 | 157 wp->w_botline = lnum; |
158 wp->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP; | |
159 | |
160 set_empty_rows(wp, done); | |
161 } | |
162 | |
163 /* | |
5764 | 164 * Redraw when w_cline_row changes and 'relativenumber' or 'cursorline' is |
165 * set. | |
166 */ | |
15697
b7a88676e81c
patch 8.1.0856: when scrolling a window the cursorline is not always updated
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
167 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
168 redraw_for_cursorline(win_T *wp) |
5764 | 169 { |
170 if ((wp->w_p_rnu | |
171 #ifdef FEAT_SYN_HL | |
172 || wp->w_p_cul | |
173 #endif | |
174 ) | |
175 && (wp->w_valid & VALID_CROW) == 0 | |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
176 && !pum_visible()) |
14720
a9665096074b
patch 8.1.0372: screen updating slow when 'cursorline' is set
Christian Brabandt <cb@256bit.org>
parents:
14317
diff
changeset
|
177 { |
28177
f04a3ec65e2d
patch 8.2.4614: redrawing too much when 'cursorline' is set
Bram Moolenaar <Bram@vim.org>
parents:
27726
diff
changeset
|
178 // win_line() will redraw the number column and cursorline only. |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
179 redraw_win_later(wp, UPD_VALID); |
14720
a9665096074b
patch 8.1.0372: screen updating slow when 'cursorline' is set
Christian Brabandt <cb@256bit.org>
parents:
14317
diff
changeset
|
180 } |
5764 | 181 } |
182 | |
28224
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
183 #ifdef FEAT_SYN_HL |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
184 /* |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
185 * Redraw when w_virtcol changes and 'cursorcolumn' is set or 'cursorlineopt' |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
186 * contains "screenline". |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
187 */ |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
188 static void |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
189 redraw_for_cursorcolumn(win_T *wp) |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
190 { |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
191 if ((wp->w_valid & VALID_VIRTCOL) == 0 && !pum_visible()) |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
192 { |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
193 // When 'cursorcolumn' is set need to redraw with UPD_SOME_VALID. |
28224
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
194 if (wp->w_p_cuc) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
195 redraw_win_later(wp, UPD_SOME_VALID); |
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
196 // When 'cursorlineopt' contains "screenline" need to redraw with |
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
197 // UPD_VALID. |
28224
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
198 else if (wp->w_p_cul && (wp->w_p_culopt_flags & CULOPT_SCRLINE)) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
199 redraw_win_later(wp, UPD_VALID); |
28224
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
200 } |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
201 } |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
202 #endif |
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
203 |
5764 | 204 /* |
31131
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
205 * Calculates how much overlap the smoothscroll marker "<<<" overlaps with |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
206 * buffer text for curwin. |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
207 * Parameter "extra2" should be the padding on the 2nd line, not the first |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
208 * line. |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
209 * Returns the number of columns of overlap with buffer text, excluding the |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
210 * extra padding on the ledge. |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
211 */ |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
212 static int |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
213 smoothscroll_marker_overlap(int extra2) |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
214 { |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
215 #if defined(FEAT_LINEBREAK) |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
216 // We don't draw the <<< marker when in showbreak mode, thus no need to |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
217 // account for it. See wlv_screen_line(). |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
218 if (*get_showbreak_value(curwin) != NUL) |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
219 return 0; |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
220 #endif |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
221 return extra2 > 3 ? 0 : 3 - extra2; |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
222 } |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
223 |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
224 /* |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
225 * Calculates the skipcol offset for window "wp" given how many |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
226 * physical lines we want to scroll down. |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
227 */ |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
228 static int |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
229 skipcol_from_plines(win_T *wp, int plines_off) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
230 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
231 int width1 = wp->w_width - win_col_off(wp); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
232 |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
233 int skipcol = 0; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
234 if (plines_off > 0) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
235 skipcol += width1; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
236 if (plines_off > 1) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
237 skipcol += (width1 + win_col_off2(wp)) * (plines_off - 1); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
238 return skipcol; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
239 } |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
240 |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
241 /* |
32361
9ac987a467d5
patch 9.0.1512: inserting lines when scrolling with 'smoothscroll' set
Bram Moolenaar <Bram@vim.org>
parents:
32208
diff
changeset
|
242 * Set curwin->w_skipcol to zero and redraw later if needed. |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
243 */ |
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
244 static void |
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
245 reset_skipcol(void) |
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
246 { |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
247 if (curwin->w_skipcol == 0) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
248 return; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
249 |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
250 curwin->w_skipcol = 0; |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
251 |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
252 // Should use the least expensive way that displays all that changed. |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
253 // UPD_NOT_VALID is too expensive, UPD_REDRAW_TOP does not redraw |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
254 // enough when the top line gets another screen line. |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
255 redraw_later(UPD_SOME_VALID); |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
256 } |
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
257 |
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
258 /* |
7 | 259 * Update curwin->w_topline and redraw if necessary. |
260 * Used to update the screen before printing a message. | |
261 */ | |
262 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
263 update_topline_redraw(void) |
7 | 264 { |
265 update_topline(); | |
266 if (must_redraw) | |
267 update_screen(0); | |
268 } | |
269 | |
270 /* | |
271 * Update curwin->w_topline to move the cursor onto the screen. | |
272 */ | |
273 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
274 update_topline(void) |
7 | 275 { |
276 long line_count; | |
277 int halfheight; | |
278 int n; | |
279 #ifdef FEAT_FOLDING | |
280 linenr_T lnum; | |
281 #endif | |
282 int check_topline = FALSE; | |
283 int check_botline = FALSE; | |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28782
diff
changeset
|
284 long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
285 int save_so = *so_ptr; |
7 | 286 |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30622
diff
changeset
|
287 // Cursor is updated instead when this is TRUE for 'splitkeep'. |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30622
diff
changeset
|
288 if (skip_update_topline) |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30622
diff
changeset
|
289 return; |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30622
diff
changeset
|
290 |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
291 // If there is no valid screen and when the window height is zero just use |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
292 // the cursor line. |
11258
84f71a8a5f2c
patch 8.0.0515: ml_get errors in silent Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
293 if (!screen_valid(TRUE) || curwin->w_height == 0) |
6247 | 294 { |
22782
53b996eb5e76
patch 8.2.1939: invalid memory access in Ex mode with global command
Bram Moolenaar <Bram@vim.org>
parents:
22403
diff
changeset
|
295 check_cursor_lnum(); |
6247 | 296 curwin->w_topline = curwin->w_cursor.lnum; |
297 curwin->w_botline = curwin->w_topline; | |
298 curwin->w_scbind_pos = 1; | |
299 return; | |
300 } | |
301 | |
7 | 302 check_cursor_moved(curwin); |
303 if (curwin->w_valid & VALID_TOPLINE) | |
304 return; | |
305 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
306 // When dragging with the mouse, don't scroll that quickly |
1121 | 307 if (mouse_dragging > 0) |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
308 *so_ptr = mouse_dragging - 1; |
7 | 309 |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
310 linenr_T old_topline = curwin->w_topline; |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
311 colnr_T old_skipcol = curwin->w_skipcol; |
7 | 312 #ifdef FEAT_DIFF |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
313 int old_topfill = curwin->w_topfill; |
7 | 314 #endif |
315 | |
316 /* | |
317 * If the buffer is empty, always set topline to 1. | |
318 */ | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
319 if (BUFEMPTY()) // special case - file is empty |
7 | 320 { |
321 if (curwin->w_topline != 1) | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
322 redraw_later(UPD_NOT_VALID); |
7 | 323 curwin->w_topline = 1; |
324 curwin->w_botline = 2; | |
325 curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP; | |
326 curwin->w_scbind_pos = 1; | |
327 } | |
328 | |
329 /* | |
330 * If the cursor is above or near the top of the window, scroll the window | |
331 * to show the line the cursor is in, with 'scrolloff' context. | |
332 */ | |
333 else | |
334 { | |
30677
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
335 if (curwin->w_topline > 1 || curwin->w_skipcol > 0) |
7 | 336 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
337 // If the cursor is above topline, scrolling is always needed. |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
338 // If the cursor is far below topline and there is no folding, |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
339 // scrolling down is never needed. |
7 | 340 if (curwin->w_cursor.lnum < curwin->w_topline) |
341 check_topline = TRUE; | |
342 else if (check_top_offset()) | |
343 check_topline = TRUE; | |
30677
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
344 else if (curwin->w_cursor.lnum == curwin->w_topline) |
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
345 { |
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
346 colnr_T vcol; |
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
347 |
31131
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
348 // Check that the cursor position is visible. Add columns for |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
349 // the smoothscroll marker "<<<" displayed in the top-left if |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
350 // needed. |
30677
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
351 getvvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); |
31131
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
352 int smoothscroll_overlap = smoothscroll_marker_overlap( |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
353 curwin_col_off() - curwin_col_off2()); |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
354 if (curwin->w_skipcol + smoothscroll_overlap > vcol) |
30677
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
355 check_topline = TRUE; |
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
356 } |
7 | 357 } |
358 #ifdef FEAT_DIFF | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
359 // Check if there are more filler lines than allowed. |
7 | 360 if (!check_topline && curwin->w_topfill > diff_check_fill(curwin, |
361 curwin->w_topline)) | |
362 check_topline = TRUE; | |
363 #endif | |
364 | |
365 if (check_topline) | |
366 { | |
367 halfheight = curwin->w_height / 2 - 1; | |
368 if (halfheight < 2) | |
369 halfheight = 2; | |
370 | |
371 #ifdef FEAT_FOLDING | |
372 if (hasAnyFolding(curwin)) | |
373 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
374 // Count the number of logical lines between the cursor and |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
375 // topline + scrolloff (approximation of how much will be |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
376 // scrolled). |
7 | 377 n = 0; |
378 for (lnum = curwin->w_cursor.lnum; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
379 lnum < curwin->w_topline + *so_ptr; ++lnum) |
7 | 380 { |
381 ++n; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
382 // stop at end of file or when we know we are far off |
7 | 383 if (lnum >= curbuf->b_ml.ml_line_count || n >= halfheight) |
384 break; | |
385 (void)hasFolding(lnum, NULL, &lnum); | |
386 } | |
387 } | |
388 else | |
389 #endif | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
390 n = curwin->w_topline + *so_ptr - curwin->w_cursor.lnum; |
7 | 391 |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
392 // If we weren't very close to begin with, we scroll to put the |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
393 // cursor in the middle of the window. Otherwise put the cursor |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
394 // near the top of the window. |
7 | 395 if (n >= halfheight) |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
396 scroll_cursor_halfway(FALSE, FALSE); |
7 | 397 else |
398 { | |
532 | 399 scroll_cursor_top(scrolljump_value(), FALSE); |
7 | 400 check_botline = TRUE; |
401 } | |
402 } | |
403 | |
404 else | |
405 { | |
406 #ifdef FEAT_FOLDING | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
407 // Make sure topline is the first line of a fold. |
7 | 408 (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); |
409 #endif | |
410 check_botline = TRUE; | |
411 } | |
412 } | |
413 | |
414 /* | |
415 * If the cursor is below the bottom of the window, scroll the window | |
416 * to put the cursor on the window. | |
417 * When w_botline is invalid, recompute it first, to avoid a redraw later. | |
418 * If w_botline was approximated, we might need a redraw later in a few | |
419 * cases, but we don't want to spend (a lot of) time recomputing w_botline | |
420 * for every small change. | |
421 */ | |
422 if (check_botline) | |
423 { | |
424 if (!(curwin->w_valid & VALID_BOTLINE_AP)) | |
425 validate_botline(); | |
426 | |
427 if (curwin->w_botline <= curbuf->b_ml.ml_line_count) | |
428 { | |
1744 | 429 if (curwin->w_cursor.lnum < curwin->w_botline) |
430 { | |
431 if (((long)curwin->w_cursor.lnum | |
29239
da56650de132
patch 8.2.5138: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
432 >= (long)curwin->w_botline - *so_ptr |
7 | 433 #ifdef FEAT_FOLDING |
434 || hasAnyFolding(curwin) | |
435 #endif | |
436 )) | |
1744 | 437 { |
7 | 438 lineoff_T loff; |
439 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
440 // Cursor is (a few lines) above botline, check if there are |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
441 // 'scrolloff' window lines below the cursor. If not, need to |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
442 // scroll. |
7 | 443 n = curwin->w_empty_rows; |
444 loff.lnum = curwin->w_cursor.lnum; | |
445 #ifdef FEAT_FOLDING | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
446 // In a fold go to its last line. |
7 | 447 (void)hasFolding(loff.lnum, NULL, &loff.lnum); |
448 #endif | |
449 #ifdef FEAT_DIFF | |
450 loff.fill = 0; | |
451 n += curwin->w_filler_rows; | |
452 #endif | |
453 loff.height = 0; | |
454 while (loff.lnum < curwin->w_botline | |
455 #ifdef FEAT_DIFF | |
456 && (loff.lnum + 1 < curwin->w_botline || loff.fill == 0) | |
457 #endif | |
458 ) | |
459 { | |
460 n += loff.height; | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
461 if (n >= *so_ptr) |
7 | 462 break; |
463 botline_forw(&loff); | |
464 } | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
465 if (n >= *so_ptr) |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
466 // sufficient context, no need to scroll |
7 | 467 check_botline = FALSE; |
1744 | 468 } |
469 else | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
470 // sufficient context, no need to scroll |
1744 | 471 check_botline = FALSE; |
7 | 472 } |
473 if (check_botline) | |
474 { | |
475 #ifdef FEAT_FOLDING | |
476 if (hasAnyFolding(curwin)) | |
477 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
478 // Count the number of logical lines between the cursor and |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
479 // botline - scrolloff (approximation of how much will be |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
480 // scrolled). |
7 | 481 line_count = 0; |
482 for (lnum = curwin->w_cursor.lnum; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
483 lnum >= curwin->w_botline - *so_ptr; --lnum) |
7 | 484 { |
485 ++line_count; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
486 // stop at end of file or when we know we are far off |
7 | 487 if (lnum <= 0 || line_count > curwin->w_height + 1) |
488 break; | |
489 (void)hasFolding(lnum, &lnum, NULL); | |
490 } | |
491 } | |
492 else | |
493 #endif | |
494 line_count = curwin->w_cursor.lnum - curwin->w_botline | |
29239
da56650de132
patch 8.2.5138: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
495 + 1 + *so_ptr; |
7 | 496 if (line_count <= curwin->w_height + 1) |
532 | 497 scroll_cursor_bot(scrolljump_value(), FALSE); |
7 | 498 else |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
499 scroll_cursor_halfway(FALSE, FALSE); |
7 | 500 } |
501 } | |
502 } | |
503 curwin->w_valid |= VALID_TOPLINE; | |
504 | |
505 /* | |
506 * Need to redraw when topline changed. | |
507 */ | |
508 if (curwin->w_topline != old_topline | |
509 #ifdef FEAT_DIFF | |
510 || curwin->w_topfill != old_topfill | |
511 #endif | |
512 ) | |
513 { | |
3318 | 514 dollar_vcol = -1; |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
515 redraw_later(UPD_VALID); |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
516 |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
517 // Only reset w_skipcol if it was not just set to make cursor visible. |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
518 if (curwin->w_skipcol == old_skipcol) |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
519 reset_skipcol(); |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
520 |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
521 // May need to set w_skipcol when cursor in w_topline. |
7 | 522 if (curwin->w_cursor.lnum == curwin->w_topline) |
523 validate_cursor(); | |
524 } | |
525 | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
526 *so_ptr = save_so; |
7 | 527 } |
528 | |
529 /* | |
532 | 530 * Return the scrolljump value to use for the current window. |
531 * When 'scrolljump' is positive use it as-is. | |
532 * When 'scrolljump' is negative use it as a percentage of the window height. | |
533 */ | |
534 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
535 scrolljump_value(void) |
532 | 536 { |
537 if (p_sj >= 0) | |
538 return (int)p_sj; | |
539 return (curwin->w_height * -p_sj) / 100; | |
540 } | |
541 | |
542 /* | |
7 | 543 * Return TRUE when there are not 'scrolloff' lines above the cursor for the |
544 * current window. | |
545 */ | |
546 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
547 check_top_offset(void) |
7 | 548 { |
549 lineoff_T loff; | |
550 int n; | |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28782
diff
changeset
|
551 long so = get_scrolloff_value(); |
7 | 552 |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
553 if (curwin->w_cursor.lnum < curwin->w_topline + so |
7 | 554 #ifdef FEAT_FOLDING |
555 || hasAnyFolding(curwin) | |
556 #endif | |
557 ) | |
558 { | |
559 loff.lnum = curwin->w_cursor.lnum; | |
560 #ifdef FEAT_DIFF | |
561 loff.fill = 0; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
562 n = curwin->w_topfill; // always have this context |
7 | 563 #else |
564 n = 0; | |
565 #endif | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
566 // Count the visible screen lines above the cursor line. |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
567 while (n < so) |
7 | 568 { |
569 topline_back(&loff); | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
570 // Stop when included a line above the window. |
7 | 571 if (loff.lnum < curwin->w_topline |
572 #ifdef FEAT_DIFF | |
573 || (loff.lnum == curwin->w_topline && loff.fill > 0) | |
574 #endif | |
575 ) | |
576 break; | |
577 n += loff.height; | |
578 } | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
579 if (n < so) |
7 | 580 return TRUE; |
581 } | |
582 return FALSE; | |
583 } | |
584 | |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
585 /* |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
586 * Update w_curswant. |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
587 */ |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
588 void |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
589 update_curswant_force(void) |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
590 { |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
591 validate_virtcol(); |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
592 curwin->w_curswant = curwin->w_virtcol |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
593 #ifdef FEAT_PROP_POPUP |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
594 - curwin->w_virtcol_first_char |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
595 #endif |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
596 ; |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
597 curwin->w_set_curswant = FALSE; |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
598 } |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
599 |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
600 /* |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
601 * Update w_curswant if w_set_curswant is set. |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
602 */ |
7 | 603 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
604 update_curswant(void) |
7 | 605 { |
606 if (curwin->w_set_curswant) | |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30231
diff
changeset
|
607 update_curswant_force(); |
7 | 608 } |
609 | |
610 /* | |
611 * Check if the cursor has moved. Set the w_valid flag accordingly. | |
612 */ | |
613 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
614 check_cursor_moved(win_T *wp) |
7 | 615 { |
616 if (wp->w_cursor.lnum != wp->w_valid_cursor.lnum) | |
617 { | |
618 wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL | |
28782
3892e7574812
patch 8.2.4915: sometimes the cursor is in the wrong position
Bram Moolenaar <Bram@vim.org>
parents:
28542
diff
changeset
|
619 |VALID_CHEIGHT|VALID_CROW|VALID_TOPLINE |
3892e7574812
patch 8.2.4915: sometimes the cursor is in the wrong position
Bram Moolenaar <Bram@vim.org>
parents:
28542
diff
changeset
|
620 |VALID_BOTLINE|VALID_BOTLINE_AP); |
7 | 621 wp->w_valid_cursor = wp->w_cursor; |
622 wp->w_valid_leftcol = wp->w_leftcol; | |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
623 wp->w_valid_skipcol = wp->w_skipcol; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
624 } |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
625 else if (wp->w_skipcol != wp->w_valid_skipcol) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
626 { |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
627 wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
628 |VALID_CHEIGHT|VALID_CROW |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
629 |VALID_BOTLINE|VALID_BOTLINE_AP); |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
630 wp->w_valid_cursor = wp->w_cursor; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
631 wp->w_valid_leftcol = wp->w_leftcol; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
632 wp->w_valid_skipcol = wp->w_skipcol; |
7 | 633 } |
634 else if (wp->w_cursor.col != wp->w_valid_cursor.col | |
635 || wp->w_leftcol != wp->w_valid_leftcol | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
636 || wp->w_cursor.coladd != wp->w_valid_cursor.coladd) |
7 | 637 { |
638 wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL); | |
639 wp->w_valid_cursor.col = wp->w_cursor.col; | |
640 wp->w_valid_leftcol = wp->w_leftcol; | |
641 wp->w_valid_cursor.coladd = wp->w_cursor.coladd; | |
642 } | |
643 } | |
644 | |
645 /* | |
646 * Call this function when some window settings have changed, which require | |
647 * the cursor position, botline and topline to be recomputed and the window to | |
648 * be redrawn. E.g, when changing the 'wrap' option or folding. | |
649 */ | |
650 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
651 changed_window_setting(void) |
7 | 652 { |
653 changed_window_setting_win(curwin); | |
654 } | |
655 | |
656 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
657 changed_window_setting_win(win_T *wp) |
7 | 658 { |
659 wp->w_lines_valid = 0; | |
660 changed_line_abv_curs_win(wp); | |
661 wp->w_valid &= ~(VALID_BOTLINE|VALID_BOTLINE_AP|VALID_TOPLINE); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
662 redraw_win_later(wp, UPD_NOT_VALID); |
7 | 663 } |
664 | |
32144
f3987fde6dea
patch 9.0.1403: unused variables and functions
Bram Moolenaar <Bram@vim.org>
parents:
32072
diff
changeset
|
665 #if defined(FEAT_PROP_POPUP) || defined(PROTO) |
7 | 666 /* |
31319
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
667 * Call changed_window_setting_win() for every window containing "buf". |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
668 */ |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
669 void |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
670 changed_window_setting_buf(buf_T *buf) |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
671 { |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
672 tabpage_T *tp; |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
673 win_T *wp; |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
674 |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
675 FOR_ALL_TAB_WINDOWS(tp, wp) |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
676 if (wp->w_buffer == buf) |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
677 changed_window_setting_win(wp); |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
678 } |
32144
f3987fde6dea
patch 9.0.1403: unused variables and functions
Bram Moolenaar <Bram@vim.org>
parents:
32072
diff
changeset
|
679 #endif |
31319
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
680 |
243c35fad9cb
patch 9.0.0993: display errors when adding or removing text property type
Bram Moolenaar <Bram@vim.org>
parents:
31148
diff
changeset
|
681 /* |
7 | 682 * Set wp->w_topline to a certain number. |
683 */ | |
684 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
685 set_topline(win_T *wp, linenr_T lnum) |
7 | 686 { |
25717
d3f992bc6ef8
patch 8.2.3394: filler lines are wrong when changing text in diff mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
687 #ifdef FEAT_DIFF |
d3f992bc6ef8
patch 8.2.3394: filler lines are wrong when changing text in diff mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
688 linenr_T prev_topline = wp->w_topline; |
d3f992bc6ef8
patch 8.2.3394: filler lines are wrong when changing text in diff mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
689 #endif |
d3f992bc6ef8
patch 8.2.3394: filler lines are wrong when changing text in diff mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
690 |
7 | 691 #ifdef FEAT_FOLDING |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
692 // go to first of folded lines |
7 | 693 (void)hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); |
694 #endif | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
695 // Approximate the value of w_botline |
7 | 696 wp->w_botline += lnum - wp->w_topline; |
23306
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
697 if (wp->w_botline > wp->w_buffer->b_ml.ml_line_count + 1) |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
698 wp->w_botline = wp->w_buffer->b_ml.ml_line_count + 1; |
7 | 699 wp->w_topline = lnum; |
1744 | 700 wp->w_topline_was_set = TRUE; |
7 | 701 #ifdef FEAT_DIFF |
25717
d3f992bc6ef8
patch 8.2.3394: filler lines are wrong when changing text in diff mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
702 if (lnum != prev_topline) |
d3f992bc6ef8
patch 8.2.3394: filler lines are wrong when changing text in diff mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
703 // Keep the filler lines when the topline didn't change. |
d3f992bc6ef8
patch 8.2.3394: filler lines are wrong when changing text in diff mode
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
704 wp->w_topfill = 0; |
7 | 705 #endif |
706 wp->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_TOPLINE); | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
707 // Don't set VALID_TOPLINE here, 'scrolloff' needs to be checked. |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
708 redraw_later(UPD_VALID); |
7 | 709 } |
710 | |
711 /* | |
712 * Call this function when the length of the cursor line (in screen | |
713 * characters) has changed, and the change is before the cursor. | |
714 * Need to take care of w_botline separately! | |
715 */ | |
716 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
717 changed_cline_bef_curs(void) |
7 | 718 { |
719 curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL | |
720 |VALID_CHEIGHT|VALID_TOPLINE); | |
721 } | |
722 | |
723 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
724 changed_cline_bef_curs_win(win_T *wp) |
7 | 725 { |
726 wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL | |
727 |VALID_CHEIGHT|VALID_TOPLINE); | |
728 } | |
729 | |
730 /* | |
731 * Call this function when the length of a line (in screen characters) above | |
732 * the cursor have changed. | |
733 * Need to take care of w_botline separately! | |
734 */ | |
735 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
736 changed_line_abv_curs(void) |
7 | 737 { |
738 curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW | |
739 |VALID_CHEIGHT|VALID_TOPLINE); | |
740 } | |
741 | |
742 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
743 changed_line_abv_curs_win(win_T *wp) |
7 | 744 { |
745 wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW | |
746 |VALID_CHEIGHT|VALID_TOPLINE); | |
747 } | |
748 | |
32144
f3987fde6dea
patch 9.0.1403: unused variables and functions
Bram Moolenaar <Bram@vim.org>
parents:
32072
diff
changeset
|
749 #if defined(FEAT_PROP_POPUP) || defined(PROTO) |
7 | 750 /* |
29708
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
751 * Display of line has changed for "buf", invalidate cursor position and |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
752 * w_botline. |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
753 */ |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
754 void |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
755 changed_line_display_buf(buf_T *buf) |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
756 { |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
757 win_T *wp; |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
758 |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
759 FOR_ALL_WINDOWS(wp) |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
760 if (wp->w_buffer == buf) |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
761 wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
762 |VALID_CROW|VALID_CHEIGHT |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
763 |VALID_TOPLINE|VALID_BOTLINE|VALID_BOTLINE_AP); |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
764 } |
32144
f3987fde6dea
patch 9.0.1403: unused variables and functions
Bram Moolenaar <Bram@vim.org>
parents:
32072
diff
changeset
|
765 #endif |
29708
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
766 |
d97b2ce26258
patch 9.0.0194: cursor displayed in wrong position after removing text prop
Bram Moolenaar <Bram@vim.org>
parents:
29275
diff
changeset
|
767 /* |
7 | 768 * Make sure the value of curwin->w_botline is valid. |
769 */ | |
770 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
771 validate_botline(void) |
7 | 772 { |
23306
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
773 validate_botline_win(curwin); |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
774 } |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
775 |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
776 /* |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
777 * Make sure the value of wp->w_botline is valid. |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
778 */ |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
779 void |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
780 validate_botline_win(win_T *wp) |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
781 { |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
782 if (!(wp->w_valid & VALID_BOTLINE)) |
90ea5037a7e3
patch 8.2.2198: ml_get error when resizing window and using text property
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
783 comp_botline(wp); |
7 | 784 } |
785 | |
786 /* | |
787 * Mark curwin->w_botline as invalid (because of some change in the buffer). | |
788 */ | |
789 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
790 invalidate_botline(void) |
7 | 791 { |
792 curwin->w_valid &= ~(VALID_BOTLINE|VALID_BOTLINE_AP); | |
793 } | |
794 | |
795 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
796 invalidate_botline_win(win_T *wp) |
7 | 797 { |
798 wp->w_valid &= ~(VALID_BOTLINE|VALID_BOTLINE_AP); | |
799 } | |
800 | |
801 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
802 approximate_botline_win( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
803 win_T *wp) |
7 | 804 { |
805 wp->w_valid &= ~VALID_BOTLINE; | |
806 } | |
807 | |
808 /* | |
809 * Return TRUE if curwin->w_wrow and curwin->w_wcol are valid. | |
810 */ | |
811 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
812 cursor_valid(void) |
7 | 813 { |
814 check_cursor_moved(curwin); | |
815 return ((curwin->w_valid & (VALID_WROW|VALID_WCOL)) == | |
816 (VALID_WROW|VALID_WCOL)); | |
817 } | |
818 | |
819 /* | |
820 * Validate cursor position. Makes sure w_wrow and w_wcol are valid. | |
821 * w_topline must be valid, you may need to call update_topline() first! | |
822 */ | |
823 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
824 validate_cursor(void) |
7 | 825 { |
30491
729e2305f4b2
patch 9.0.0581: adding a character for incsearch fails at end of line
Bram Moolenaar <Bram@vim.org>
parents:
30487
diff
changeset
|
826 check_cursor_lnum(); |
7 | 827 check_cursor_moved(curwin); |
828 if ((curwin->w_valid & (VALID_WCOL|VALID_WROW)) != (VALID_WCOL|VALID_WROW)) | |
829 curs_columns(TRUE); | |
830 } | |
831 | |
832 #if defined(FEAT_GUI) || defined(PROTO) | |
833 /* | |
834 * validate w_cline_row. | |
835 */ | |
836 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
837 validate_cline_row(void) |
7 | 838 { |
839 /* | |
840 * First make sure that w_topline is valid (after moving the cursor). | |
841 */ | |
842 update_topline(); | |
843 check_cursor_moved(curwin); | |
844 if (!(curwin->w_valid & VALID_CROW)) | |
6441 | 845 curs_rows(curwin); |
7 | 846 } |
847 #endif | |
848 | |
849 /* | |
850 * Compute wp->w_cline_row and wp->w_cline_height, based on the current value | |
2154
7c8c7c95a865
First step in the Vim 7.3 branch. Changed version numbers.
Bram Moolenaar <bram@zimbu.org>
parents:
2082
diff
changeset
|
851 * of wp->w_topline. |
7 | 852 */ |
853 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
854 curs_rows(win_T *wp) |
7 | 855 { |
856 linenr_T lnum; | |
857 int i; | |
858 int all_invalid; | |
859 int valid; | |
860 #ifdef FEAT_FOLDING | |
861 long fold_count; | |
862 #endif | |
863 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
864 // Check if wp->w_lines[].wl_size is invalid |
7 | 865 all_invalid = (!redrawing() |
866 || wp->w_lines_valid == 0 | |
867 || wp->w_lines[0].wl_lnum > wp->w_topline); | |
868 i = 0; | |
869 wp->w_cline_row = 0; | |
870 for (lnum = wp->w_topline; lnum < wp->w_cursor.lnum; ++i) | |
871 { | |
872 valid = FALSE; | |
873 if (!all_invalid && i < wp->w_lines_valid) | |
874 { | |
875 if (wp->w_lines[i].wl_lnum < lnum || !wp->w_lines[i].wl_valid) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
876 continue; // skip changed or deleted lines |
7 | 877 if (wp->w_lines[i].wl_lnum == lnum) |
878 { | |
879 #ifdef FEAT_FOLDING | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
880 // Check for newly inserted lines below this row, in which |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
881 // case we need to check for folded lines. |
7 | 882 if (!wp->w_buffer->b_mod_set |
883 || wp->w_lines[i].wl_lastlnum < wp->w_cursor.lnum | |
884 || wp->w_buffer->b_mod_top | |
885 > wp->w_lines[i].wl_lastlnum + 1) | |
886 #endif | |
887 valid = TRUE; | |
888 } | |
889 else if (wp->w_lines[i].wl_lnum > lnum) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
890 --i; // hold at inserted lines |
7 | 891 } |
892 if (valid | |
893 #ifdef FEAT_DIFF | |
894 && (lnum != wp->w_topline || !wp->w_p_diff) | |
895 #endif | |
896 ) | |
897 { | |
898 #ifdef FEAT_FOLDING | |
899 lnum = wp->w_lines[i].wl_lastlnum + 1; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
900 // Cursor inside folded lines, don't count this row |
7 | 901 if (lnum > wp->w_cursor.lnum) |
902 break; | |
903 #else | |
904 ++lnum; | |
905 #endif | |
906 wp->w_cline_row += wp->w_lines[i].wl_size; | |
907 } | |
908 else | |
909 { | |
910 #ifdef FEAT_FOLDING | |
911 fold_count = foldedCount(wp, lnum, NULL); | |
912 if (fold_count) | |
913 { | |
914 lnum += fold_count; | |
915 if (lnum > wp->w_cursor.lnum) | |
916 break; | |
917 ++wp->w_cline_row; | |
918 } | |
919 else | |
920 #endif | |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
921 { |
30946
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
922 wp->w_cline_row += plines_correct_topline(wp, lnum); |
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
923 ++lnum; |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
924 } |
7 | 925 } |
926 } | |
927 | |
928 check_cursor_moved(wp); | |
929 if (!(wp->w_valid & VALID_CHEIGHT)) | |
930 { | |
931 if (all_invalid | |
932 || i == wp->w_lines_valid | |
933 || (i < wp->w_lines_valid | |
934 && (!wp->w_lines[i].wl_valid | |
935 || wp->w_lines[i].wl_lnum != wp->w_cursor.lnum))) | |
936 { | |
937 #ifdef FEAT_DIFF | |
938 if (wp->w_cursor.lnum == wp->w_topline) | |
939 wp->w_cline_height = plines_win_nofill(wp, wp->w_cursor.lnum, | |
940 TRUE) + wp->w_topfill; | |
941 else | |
942 #endif | |
943 wp->w_cline_height = plines_win(wp, wp->w_cursor.lnum, TRUE); | |
944 #ifdef FEAT_FOLDING | |
945 wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum, | |
946 NULL, NULL, TRUE, NULL); | |
947 #endif | |
948 } | |
949 else if (i > wp->w_lines_valid) | |
950 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
951 // a line that is too long to fit on the last screen line |
7 | 952 wp->w_cline_height = 0; |
953 #ifdef FEAT_FOLDING | |
954 wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum, | |
955 NULL, NULL, TRUE, NULL); | |
956 #endif | |
957 } | |
958 else | |
959 { | |
960 wp->w_cline_height = wp->w_lines[i].wl_size; | |
961 #ifdef FEAT_FOLDING | |
962 wp->w_cline_folded = wp->w_lines[i].wl_folded; | |
963 #endif | |
964 } | |
965 } | |
966 | |
5764 | 967 redraw_for_cursorline(curwin); |
7 | 968 wp->w_valid |= VALID_CROW|VALID_CHEIGHT; |
969 } | |
970 | |
971 /* | |
972 * Validate curwin->w_virtcol only. | |
973 */ | |
974 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
975 validate_virtcol(void) |
7 | 976 { |
977 validate_virtcol_win(curwin); | |
978 } | |
979 | |
980 /* | |
981 * Validate wp->w_virtcol only. | |
982 */ | |
983 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
984 validate_virtcol_win(win_T *wp) |
7 | 985 { |
986 check_cursor_moved(wp); | |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
987 |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
988 if (wp->w_valid & VALID_VIRTCOL) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
989 return; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
990 |
30205
ed6f3d2593df
patch 9.0.0438: cannot put virtual text above a line
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
991 #ifdef FEAT_PROP_POPUP |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
992 wp->w_virtcol_first_char = 0; |
30205
ed6f3d2593df
patch 9.0.0438: cannot put virtual text above a line
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
993 #endif |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
994 getvvcol(wp, &wp->w_cursor, NULL, &(wp->w_virtcol), NULL); |
28224
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
995 #ifdef FEAT_SYN_HL |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
996 redraw_for_cursorcolumn(wp); |
28224
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
997 #endif |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
998 wp->w_valid |= VALID_VIRTCOL; |
7 | 999 } |
1000 | |
1001 /* | |
1002 * Validate curwin->w_cline_height only. | |
1003 */ | |
18892
fb2d26bc8ca1
patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1004 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1005 validate_cheight(void) |
7 | 1006 { |
1007 check_cursor_moved(curwin); | |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1008 |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1009 if (curwin->w_valid & VALID_CHEIGHT) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1010 return; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1011 |
7 | 1012 #ifdef FEAT_DIFF |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1013 if (curwin->w_cursor.lnum == curwin->w_topline) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1014 curwin->w_cline_height = plines_nofill(curwin->w_cursor.lnum) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1015 + curwin->w_topfill; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1016 else |
7 | 1017 #endif |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1018 curwin->w_cline_height = plines(curwin->w_cursor.lnum); |
7 | 1019 #ifdef FEAT_FOLDING |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1020 curwin->w_cline_folded = hasFolding(curwin->w_cursor.lnum, NULL, NULL); |
7 | 1021 #endif |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1022 curwin->w_valid |= VALID_CHEIGHT; |
7 | 1023 } |
1024 | |
1025 /* | |
1668 | 1026 * Validate w_wcol and w_virtcol only. |
7 | 1027 */ |
1028 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1029 validate_cursor_col(void) |
7 | 1030 { |
1031 colnr_T off; | |
1032 colnr_T col; | |
2070
4483ee552619
updated for version 7.2.355
Bram Moolenaar <bram@zimbu.org>
parents:
1980
diff
changeset
|
1033 int width; |
7 | 1034 |
1035 validate_virtcol(); | |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1036 |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1037 if (curwin->w_valid & VALID_WCOL) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1038 return; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1039 |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1040 col = curwin->w_virtcol; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1041 off = curwin_col_off(); |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1042 col += off; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1043 width = curwin->w_width - off + curwin_col_off2(); |
7 | 1044 |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1045 // long line wrapping, adjust curwin->w_wrow |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1046 if (curwin->w_p_wrap |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1047 && col >= (colnr_T)curwin->w_width |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1048 && width > 0) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1049 // use same formula as what is used in curs_columns() |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1050 col -= ((col - curwin->w_width) / width + 1) * width; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1051 if (col > (int)curwin->w_leftcol) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1052 col -= curwin->w_leftcol; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1053 else |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1054 col = 0; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1055 curwin->w_wcol = col; |
1668 | 1056 |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1057 curwin->w_valid |= VALID_WCOL; |
22890
255473b88c8e
patch 8.2.1992: build fails with small features
Bram Moolenaar <Bram@vim.org>
parents:
22886
diff
changeset
|
1058 #ifdef FEAT_PROP_POPUP |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
1059 curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED; |
22890
255473b88c8e
patch 8.2.1992: build fails with small features
Bram Moolenaar <Bram@vim.org>
parents:
22886
diff
changeset
|
1060 #endif |
7 | 1061 } |
1062 | |
1063 /* | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
1064 * Compute offset of a window, occupied by absolute or relative line number, |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
1065 * fold column and sign column (these don't move when scrolling horizontally). |
7 | 1066 */ |
1067 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1068 win_col_off(win_T *wp) |
7 | 1069 { |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
1070 return (((wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) + 1 : 0) |
7 | 1071 + (cmdwin_type == 0 || wp != curwin ? 0 : 1) |
1072 #ifdef FEAT_FOLDING | |
1073 + wp->w_p_fdc | |
1074 #endif | |
1075 #ifdef FEAT_SIGNS | |
9852
4eea48b76d03
commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1076 + (signcolumn_on(wp) ? 2 : 0) |
7 | 1077 #endif |
1078 ); | |
1079 } | |
1080 | |
1081 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1082 curwin_col_off(void) |
7 | 1083 { |
1084 return win_col_off(curwin); | |
1085 } | |
1086 | |
1087 /* | |
1088 * Return the difference in column offset for the second screen line of a | |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1089 * wrapped line. It's positive if 'number' or 'relativenumber' is on and 'n' |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1090 * is in 'cpoptions'. |
7 | 1091 */ |
1092 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1093 win_col_off2(win_T *wp) |
7 | 1094 { |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
1095 if ((wp->w_p_nu || wp->w_p_rnu) && vim_strchr(p_cpo, CPO_NUMCOL) != NULL) |
13 | 1096 return number_width(wp) + 1; |
7 | 1097 return 0; |
1098 } | |
1099 | |
1100 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1101 curwin_col_off2(void) |
7 | 1102 { |
1103 return win_col_off2(curwin); | |
1104 } | |
1105 | |
1106 /* | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15414
diff
changeset
|
1107 * Compute curwin->w_wcol and curwin->w_virtcol. |
7 | 1108 * Also updates curwin->w_wrow and curwin->w_cline_row. |
1109 * Also updates curwin->w_leftcol. | |
1110 */ | |
1111 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1112 curs_columns( |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1113 int may_scroll) // when TRUE, may scroll horizontally |
7 | 1114 { |
1115 int diff; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1116 int extra; // offset for first screen line |
7 | 1117 int off_left, off_right; |
1118 int n; | |
1119 int p_lines; | |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1120 int width1; // text width for first screen line |
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1121 int width2 = 0; // text width for second and later screen line |
7 | 1122 int new_leftcol; |
1123 colnr_T startcol; | |
1124 colnr_T endcol; | |
1125 colnr_T prev_skipcol; | |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28782
diff
changeset
|
1126 long so = get_scrolloff_value(); |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28782
diff
changeset
|
1127 long siso = get_sidescrolloff_value(); |
30821
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1128 int did_sub_skipcol = FALSE; |
7 | 1129 |
1130 /* | |
1131 * First make sure that w_topline is valid (after moving the cursor). | |
1132 */ | |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30622
diff
changeset
|
1133 update_topline(); |
7 | 1134 |
1135 /* | |
1136 * Next make sure that w_cline_row is valid. | |
1137 */ | |
1138 if (!(curwin->w_valid & VALID_CROW)) | |
6441 | 1139 curs_rows(curwin); |
7 | 1140 |
30205
ed6f3d2593df
patch 9.0.0438: cannot put virtual text above a line
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1141 #ifdef FEAT_PROP_POPUP |
ed6f3d2593df
patch 9.0.0438: cannot put virtual text above a line
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1142 // will be set by getvvcol() but not reset |
ed6f3d2593df
patch 9.0.0438: cannot put virtual text above a line
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1143 curwin->w_virtcol_first_char = 0; |
ed6f3d2593df
patch 9.0.0438: cannot put virtual text above a line
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1144 #endif |
ed6f3d2593df
patch 9.0.0438: cannot put virtual text above a line
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1145 |
7 | 1146 /* |
1147 * Compute the number of virtual columns. | |
1148 */ | |
1149 #ifdef FEAT_FOLDING | |
1150 if (curwin->w_cline_folded) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1151 // In a folded line the cursor is always in the first column |
7 | 1152 startcol = curwin->w_virtcol = endcol = curwin->w_leftcol; |
1153 else | |
1154 #endif | |
1155 getvvcol(curwin, &curwin->w_cursor, | |
1156 &startcol, &(curwin->w_virtcol), &endcol); | |
1157 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1158 // remove '$' from change command when cursor moves onto it |
7 | 1159 if (startcol > dollar_vcol) |
3318 | 1160 dollar_vcol = -1; |
7 | 1161 |
1162 extra = curwin_col_off(); | |
1163 curwin->w_wcol = curwin->w_virtcol + extra; | |
1164 endcol += extra; | |
1165 | |
1166 /* | |
1167 * Now compute w_wrow, counting screen lines from w_cline_row. | |
1168 */ | |
1169 curwin->w_wrow = curwin->w_cline_row; | |
1170 | |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1171 width1 = curwin->w_width - extra; |
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1172 if (width1 <= 0) |
7 | 1173 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1174 // No room for text, put cursor in last char of window. |
25172
406ab8d0bc0f
patch 8.2.3122: with 'nowrap' cursor position is unexected in narrow window
Bram Moolenaar <Bram@vim.org>
parents:
23905
diff
changeset
|
1175 // If not wrapping, the last non-empty line. |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
1176 curwin->w_wcol = curwin->w_width - 1; |
25172
406ab8d0bc0f
patch 8.2.3122: with 'nowrap' cursor position is unexected in narrow window
Bram Moolenaar <Bram@vim.org>
parents:
23905
diff
changeset
|
1177 if (curwin->w_p_wrap) |
406ab8d0bc0f
patch 8.2.3122: with 'nowrap' cursor position is unexected in narrow window
Bram Moolenaar <Bram@vim.org>
parents:
23905
diff
changeset
|
1178 curwin->w_wrow = curwin->w_height - 1; |
406ab8d0bc0f
patch 8.2.3122: with 'nowrap' cursor position is unexected in narrow window
Bram Moolenaar <Bram@vim.org>
parents:
23905
diff
changeset
|
1179 else |
406ab8d0bc0f
patch 8.2.3122: with 'nowrap' cursor position is unexected in narrow window
Bram Moolenaar <Bram@vim.org>
parents:
23905
diff
changeset
|
1180 curwin->w_wrow = curwin->w_height - 1 - curwin->w_empty_rows; |
7 | 1181 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12152
diff
changeset
|
1182 else if (curwin->w_p_wrap && curwin->w_width != 0) |
7 | 1183 { |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1184 width2 = width1 + curwin_col_off2(); |
7 | 1185 |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1186 // skip columns that are not visible |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1187 if (curwin->w_cursor.lnum == curwin->w_topline |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1188 && curwin->w_skipcol > 0 |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1189 && curwin->w_wcol >= curwin->w_skipcol) |
30821
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1190 { |
31117
a5bf86083558
patch 9.0.0893: 'smoothscroll' cursor calculations wrong when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
31115
diff
changeset
|
1191 // Deduct by multiples of width2. This allows the long line |
a5bf86083558
patch 9.0.0893: 'smoothscroll' cursor calculations wrong when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
31115
diff
changeset
|
1192 // wrapping formula below to correctly calculate the w_wcol value |
a5bf86083558
patch 9.0.0893: 'smoothscroll' cursor calculations wrong when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
31115
diff
changeset
|
1193 // when wrapping. |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1194 if (curwin->w_skipcol <= width1) |
31117
a5bf86083558
patch 9.0.0893: 'smoothscroll' cursor calculations wrong when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
31115
diff
changeset
|
1195 curwin->w_wcol -= width2; |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1196 else |
31117
a5bf86083558
patch 9.0.0893: 'smoothscroll' cursor calculations wrong when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
31115
diff
changeset
|
1197 curwin->w_wcol -= width2 |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1198 * (((curwin->w_skipcol - width1) / width2) + 1); |
31117
a5bf86083558
patch 9.0.0893: 'smoothscroll' cursor calculations wrong when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
31115
diff
changeset
|
1199 |
30821
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1200 did_sub_skipcol = TRUE; |
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1201 } |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1202 |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1203 // long line wrapping, adjust curwin->w_wrow |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
1204 if (curwin->w_wcol >= curwin->w_width) |
7 | 1205 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1206 // this same formula is used in validate_cursor_col() |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1207 n = (curwin->w_wcol - curwin->w_width) / width2 + 1; |
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1208 curwin->w_wcol -= n * width2; |
7 | 1209 curwin->w_wrow += n; |
1210 | |
1211 #ifdef FEAT_LINEBREAK | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1212 // When cursor wraps to first char of next line in Insert |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1213 // mode, the 'showbreak' string isn't shown, backup to first |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1214 // column |
30821
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1215 char_u *sbr = get_showbreak_value(curwin); |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18469
diff
changeset
|
1216 if (*sbr && *ml_get_cursor() == NUL |
25852
336e2d9924e6
patch 8.2.3460: some type casts are not needed
Bram Moolenaar <Bram@vim.org>
parents:
25717
diff
changeset
|
1217 && curwin->w_wcol == vim_strsize(sbr)) |
7 | 1218 curwin->w_wcol = 0; |
1219 #endif | |
1220 } | |
1221 } | |
1222 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1223 // No line wrapping: compute curwin->w_leftcol if scrolling is on and line |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1224 // is not folded. |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1225 // If scrolling is off, curwin->w_leftcol is assumed to be 0 |
3263 | 1226 else if (may_scroll |
7 | 1227 #ifdef FEAT_FOLDING |
1228 && !curwin->w_cline_folded | |
1229 #endif | |
1230 ) | |
1231 { | |
30231
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1232 #ifdef FEAT_PROP_POPUP |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1233 if (curwin->w_virtcol_first_char > 0) |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1234 { |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1235 int cols = (curwin->w_width - extra); |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1236 int rows = cols > 0 ? curwin->w_virtcol_first_char / cols : 1; |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1237 |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1238 // each "above" text prop shifts the text one row down |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1239 curwin->w_wrow += rows; |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1240 curwin->w_wcol -= rows * cols; |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1241 endcol -= rows * cols; |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1242 curwin->w_cline_height = rows + 1; |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1243 } |
0d084880276a
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
1244 #endif |
7 | 1245 /* |
1246 * If Cursor is left of the screen, scroll rightwards. | |
1247 * If Cursor is right of the screen, scroll leftwards | |
1248 * If we get closer to the edge than 'sidescrolloff', scroll a little | |
1249 * extra | |
1250 */ | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
1251 off_left = (int)startcol - (int)curwin->w_leftcol - siso; |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
1252 off_right = (int)endcol - (int)(curwin->w_leftcol + curwin->w_width |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
1253 - siso) + 1; |
7 | 1254 if (off_left < 0 || off_right > 0) |
1255 { | |
1256 if (off_left < 0) | |
1257 diff = -off_left; | |
1258 else | |
1259 diff = off_right; | |
1260 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1261 // When far off or not enough room on either side, put cursor in |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1262 // middle of window. |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1263 if (p_ss == 0 || diff >= width1 / 2 || off_right >= off_left) |
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1264 new_leftcol = curwin->w_wcol - extra - width1 / 2; |
7 | 1265 else |
1266 { | |
1267 if (diff < p_ss) | |
1268 diff = p_ss; | |
1269 if (off_left < 0) | |
1270 new_leftcol = curwin->w_leftcol - diff; | |
1271 else | |
1272 new_leftcol = curwin->w_leftcol + diff; | |
1273 } | |
1274 if (new_leftcol < 0) | |
1275 new_leftcol = 0; | |
1276 if (new_leftcol != (int)curwin->w_leftcol) | |
1277 { | |
1278 curwin->w_leftcol = new_leftcol; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1279 // screen has to be redrawn with new curwin->w_leftcol |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
1280 redraw_later(UPD_NOT_VALID); |
7 | 1281 } |
1282 } | |
1283 curwin->w_wcol -= curwin->w_leftcol; | |
1284 } | |
1285 else if (curwin->w_wcol > (int)curwin->w_leftcol) | |
1286 curwin->w_wcol -= curwin->w_leftcol; | |
1287 else | |
1288 curwin->w_wcol = 0; | |
1289 | |
1290 #ifdef FEAT_DIFF | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1291 // Skip over filler lines. At the top use w_topfill, there |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1292 // may be some filler lines above the window. |
7 | 1293 if (curwin->w_cursor.lnum == curwin->w_topline) |
1294 curwin->w_wrow += curwin->w_topfill; | |
1295 else | |
1296 curwin->w_wrow += diff_check_fill(curwin, curwin->w_cursor.lnum); | |
1297 #endif | |
1298 | |
1299 prev_skipcol = curwin->w_skipcol; | |
1300 | |
1301 p_lines = 0; | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
1302 |
7 | 1303 if ((curwin->w_wrow >= curwin->w_height |
1304 || ((prev_skipcol > 0 | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
1305 || curwin->w_wrow + so >= curwin->w_height) |
7 | 1306 && (p_lines = |
1307 #ifdef FEAT_DIFF | |
1308 plines_win_nofill | |
1309 #else | |
1310 plines_win | |
1311 #endif | |
1312 (curwin, curwin->w_cursor.lnum, FALSE)) | |
1313 - 1 >= curwin->w_height)) | |
1314 && curwin->w_height != 0 | |
1315 && curwin->w_cursor.lnum == curwin->w_topline | |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1316 && width2 > 0 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12152
diff
changeset
|
1317 && curwin->w_width != 0) |
7 | 1318 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1319 // Cursor past end of screen. Happens with a single line that does |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1320 // not fit on screen. Find a skipcol to show the text around the |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1321 // cursor. Avoid scrolling all the time. compute value of "extra": |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1322 // 1: Less than 'scrolloff' lines above |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1323 // 2: Less than 'scrolloff' lines below |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1324 // 3: both of them |
7 | 1325 extra = 0; |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1326 if (curwin->w_skipcol + so * width2 > curwin->w_virtcol) |
7 | 1327 extra = 1; |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1328 // Compute last display line of the buffer line that we want at the |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1329 // bottom of the window. |
7 | 1330 if (p_lines == 0) |
1331 p_lines = plines_win(curwin, curwin->w_cursor.lnum, FALSE); | |
1332 --p_lines; | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
1333 if (p_lines > curwin->w_wrow + so) |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
1334 n = curwin->w_wrow + so; |
7 | 1335 else |
1336 n = p_lines; | |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1337 if ((colnr_T)n >= curwin->w_height + curwin->w_skipcol / width2 - so) |
7 | 1338 extra += 2; |
1339 | |
30821
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1340 if (extra == 3 || curwin->w_height <= so * 2) |
7 | 1341 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1342 // not enough room for 'scrolloff', put cursor in the middle |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1343 n = curwin->w_virtcol / width2; |
7 | 1344 if (n > curwin->w_height / 2) |
1345 n -= curwin->w_height / 2; | |
1346 else | |
1347 n = 0; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1348 // don't skip more than necessary |
7 | 1349 if (n > p_lines - curwin->w_height + 1) |
1350 n = p_lines - curwin->w_height + 1; | |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1351 curwin->w_skipcol = n * width2; |
7 | 1352 } |
1353 else if (extra == 1) | |
1354 { | |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26061
diff
changeset
|
1355 // less than 'scrolloff' lines above, decrease skipcol |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1356 extra = (curwin->w_skipcol + so * width2 - curwin->w_virtcol |
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1357 + width2 - 1) / width2; |
7 | 1358 if (extra > 0) |
1359 { | |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1360 if ((colnr_T)(extra * width2) > curwin->w_skipcol) |
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1361 extra = curwin->w_skipcol / width2; |
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1362 curwin->w_skipcol -= extra * width2; |
7 | 1363 } |
1364 } | |
1365 else if (extra == 2) | |
1366 { | |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26061
diff
changeset
|
1367 // less than 'scrolloff' lines below, increase skipcol |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1368 endcol = (n - curwin->w_height + 1) * width2; |
7 | 1369 while (endcol > curwin->w_virtcol) |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1370 endcol -= width2; |
7 | 1371 if (endcol > curwin->w_skipcol) |
1372 curwin->w_skipcol = endcol; | |
1373 } | |
1374 | |
30821
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1375 // adjust w_wrow for the changed w_skipcol |
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1376 if (did_sub_skipcol) |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1377 curwin->w_wrow -= (curwin->w_skipcol - prev_skipcol) / width2; |
30821
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1378 else |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1379 curwin->w_wrow -= curwin->w_skipcol / width2; |
30821
a57e6da5860f
patch 9.0.0745: wrong cursor position when using "gj" and "gk" in a long line
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1380 |
7 | 1381 if (curwin->w_wrow >= curwin->w_height) |
1382 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1383 // small window, make sure cursor is in it |
7 | 1384 extra = curwin->w_wrow - curwin->w_height + 1; |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1385 curwin->w_skipcol += extra * width2; |
7 | 1386 curwin->w_wrow -= extra; |
1387 } | |
1388 | |
30823
80a336303eb9
patch 9.0.0746: breakindent test cases are commented out
Bram Moolenaar <Bram@vim.org>
parents:
30821
diff
changeset
|
1389 extra = ((int)prev_skipcol - (int)curwin->w_skipcol) / width2; |
7 | 1390 if (extra > 0) |
1391 win_ins_lines(curwin, 0, extra, FALSE, FALSE); | |
1392 else if (extra < 0) | |
12152
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
11258
diff
changeset
|
1393 win_del_lines(curwin, 0, -extra, FALSE, FALSE, 0); |
7 | 1394 } |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1395 else if (!curwin->w_p_sms) |
7 | 1396 curwin->w_skipcol = 0; |
1397 if (prev_skipcol != curwin->w_skipcol) | |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
1398 redraw_later(UPD_SOME_VALID); |
7 | 1399 |
740 | 1400 #ifdef FEAT_SYN_HL |
28224
c99005ffa8c3
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents:
28177
diff
changeset
|
1401 redraw_for_cursorcolumn(curwin); |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
1402 #endif |
19542
9e428147e4ee
patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal
Bram Moolenaar <Bram@vim.org>
parents:
18931
diff
changeset
|
1403 #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL) |
9e428147e4ee
patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal
Bram Moolenaar <Bram@vim.org>
parents:
18931
diff
changeset
|
1404 if (popup_is_popup(curwin) && curbuf->b_term != NULL) |
9e428147e4ee
patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal
Bram Moolenaar <Bram@vim.org>
parents:
18931
diff
changeset
|
1405 { |
9e428147e4ee
patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal
Bram Moolenaar <Bram@vim.org>
parents:
18931
diff
changeset
|
1406 curwin->w_wrow += popup_top_extra(curwin); |
9e428147e4ee
patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal
Bram Moolenaar <Bram@vim.org>
parents:
18931
diff
changeset
|
1407 curwin->w_wcol += popup_left_extra(curwin); |
22886
38324d4f1c94
patch 8.2.1990: cursor position wrong in terminal popup with finished job
Bram Moolenaar <Bram@vim.org>
parents:
22782
diff
changeset
|
1408 curwin->w_flags |= WFLAG_WCOL_OFF_ADDED + WFLAG_WROW_OFF_ADDED; |
19542
9e428147e4ee
patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal
Bram Moolenaar <Bram@vim.org>
parents:
18931
diff
changeset
|
1409 } |
22886
38324d4f1c94
patch 8.2.1990: cursor position wrong in terminal popup with finished job
Bram Moolenaar <Bram@vim.org>
parents:
22782
diff
changeset
|
1410 else |
38324d4f1c94
patch 8.2.1990: cursor position wrong in terminal popup with finished job
Bram Moolenaar <Bram@vim.org>
parents:
22782
diff
changeset
|
1411 curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED + WFLAG_WROW_OFF_ADDED); |
19542
9e428147e4ee
patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal
Bram Moolenaar <Bram@vim.org>
parents:
18931
diff
changeset
|
1412 #endif |
740 | 1413 |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1414 // now w_leftcol and w_skipcol are valid, avoid check_cursor_moved() |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1415 // thinking otherwise |
18621
a9bfdc5ea1ec
patch 8.1.2303: cursor in wrong position after horizontal scroll
Bram Moolenaar <Bram@vim.org>
parents:
18580
diff
changeset
|
1416 curwin->w_valid_leftcol = curwin->w_leftcol; |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1417 curwin->w_valid_skipcol = curwin->w_skipcol; |
18621
a9bfdc5ea1ec
patch 8.1.2303: cursor in wrong position after horizontal scroll
Bram Moolenaar <Bram@vim.org>
parents:
18580
diff
changeset
|
1418 |
7 | 1419 curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL; |
1420 } | |
1421 | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18621
diff
changeset
|
1422 #if (defined(FEAT_EVAL) || defined(FEAT_PROP_POPUP)) || defined(PROTO) |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1423 /* |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1424 * Compute the screen position of text character at "pos" in window "wp" |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1425 * The resulting values are one-based, zero when character is not visible. |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1426 */ |
17863
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1427 void |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1428 textpos2screenpos( |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1429 win_T *wp, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1430 pos_T *pos, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1431 int *rowp, // screen row |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1432 int *scolp, // start screen column |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1433 int *ccolp, // cursor screen column |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1434 int *ecolp) // end screen column |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1435 { |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1436 colnr_T scol = 0, ccol = 0, ecol = 0; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1437 int row = 0; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1438 int rowoff = 0; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1439 colnr_T coloff = 0; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1440 |
25312
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
25172
diff
changeset
|
1441 if (pos->lnum >= wp->w_topline && pos->lnum <= wp->w_botline) |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1442 { |
27726
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1443 colnr_T col; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1444 int width; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1445 linenr_T lnum = pos->lnum; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1446 #ifdef FEAT_FOLDING |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1447 int is_folded; |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1448 |
27726
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1449 is_folded = hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1450 #endif |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1451 row = plines_m_win(wp, wp->w_topline, lnum - 1) + 1; |
31365
040b59b92dca
patch 9.0.1016: screenpos() does not count filler lines for diff mode
Bram Moolenaar <Bram@vim.org>
parents:
31355
diff
changeset
|
1452 |
040b59b92dca
patch 9.0.1016: screenpos() does not count filler lines for diff mode
Bram Moolenaar <Bram@vim.org>
parents:
31355
diff
changeset
|
1453 #ifdef FEAT_DIFF |
040b59b92dca
patch 9.0.1016: screenpos() does not count filler lines for diff mode
Bram Moolenaar <Bram@vim.org>
parents:
31355
diff
changeset
|
1454 // Add filler lines above this buffer line. |
040b59b92dca
patch 9.0.1016: screenpos() does not count filler lines for diff mode
Bram Moolenaar <Bram@vim.org>
parents:
31355
diff
changeset
|
1455 row += diff_check_fill(wp, lnum); |
040b59b92dca
patch 9.0.1016: screenpos() does not count filler lines for diff mode
Bram Moolenaar <Bram@vim.org>
parents:
31355
diff
changeset
|
1456 #endif |
040b59b92dca
patch 9.0.1016: screenpos() does not count filler lines for diff mode
Bram Moolenaar <Bram@vim.org>
parents:
31355
diff
changeset
|
1457 |
31479
0c0b78aa7ae3
patch 9.0.1072: screenpos() column result in fold may be too small
Bram Moolenaar <Bram@vim.org>
parents:
31365
diff
changeset
|
1458 colnr_T off = win_col_off(wp); |
27726
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1459 #ifdef FEAT_FOLDING |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1460 if (is_folded) |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1461 { |
27352
2bec1976362c
patch 8.2.4204: screenpos() has non-zero row for invisible text
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
1462 row += W_WINROW(wp); |
31479
0c0b78aa7ae3
patch 9.0.1072: screenpos() column result in fold may be too small
Bram Moolenaar <Bram@vim.org>
parents:
31365
diff
changeset
|
1463 coloff = wp->w_wincol + 1 + off; |
27352
2bec1976362c
patch 8.2.4204: screenpos() has non-zero row for invisible text
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
1464 } |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1465 else |
27726
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1466 #endif |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1467 { |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1468 getvcol(wp, pos, &scol, &ccol, &ecol); |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1469 |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1470 // similar to what is done in validate_cursor_col() |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1471 col = scol; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1472 col += off; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1473 width = wp->w_width - off + win_col_off2(wp); |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1474 |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1475 // long line wrapping, adjust row |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1476 if (wp->w_p_wrap |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1477 && col >= (colnr_T)wp->w_width |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1478 && width > 0) |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1479 { |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1480 // use same formula as what is used in curs_columns() |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1481 rowoff = ((col - wp->w_width) / width + 1); |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1482 col -= rowoff * width; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1483 } |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1484 col -= wp->w_leftcol; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1485 if (col >= wp->w_width) |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1486 col = -1; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1487 if (col >= 0 && row + rowoff <= wp->w_height) |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1488 { |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1489 coloff = col - scol + wp->w_wincol + 1; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1490 row += W_WINROW(wp); |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1491 } |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1492 else |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1493 // character is left, right or below of the window |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1494 row = rowoff = scol = ccol = ecol = 0; |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
1495 } |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1496 } |
27352
2bec1976362c
patch 8.2.4204: screenpos() has non-zero row for invisible text
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
1497 *rowp = row + rowoff; |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1498 *scolp = scol + coloff; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1499 *ccolp = ccol + coloff; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1500 *ecolp = ecol + coloff; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1501 } |
17863
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1502 #endif |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1503 |
17863
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1504 #if defined(FEAT_EVAL) || defined(PROTO) |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1505 /* |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1506 * "screenpos({winid}, {lnum}, {col})" function |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1507 */ |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1508 void |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1509 f_screenpos(typval_T *argvars UNUSED, typval_T *rettv) |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1510 { |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1511 dict_T *dict; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1512 win_T *wp; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1513 pos_T pos; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1514 int row = 0; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1515 int scol = 0, ccol = 0, ecol = 0; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1516 |
29175
755ab148288b
patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents:
29024
diff
changeset
|
1517 if (rettv_dict_alloc(rettv) == FAIL) |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1518 return; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1519 dict = rettv->vval.v_dict; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1520 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
1521 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
1522 && (check_for_number_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
1523 || check_for_number_arg(argvars, 1) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
1524 || check_for_number_arg(argvars, 2) == FAIL)) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
1525 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
1526 |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1527 wp = find_win_by_nr_or_id(&argvars[0]); |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1528 if (wp == NULL) |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1529 return; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1530 |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1531 pos.lnum = tv_get_number(&argvars[1]); |
31355
45a03dd92f28
patch 9.0.1011: ml_get error when using screenpos()
Bram Moolenaar <Bram@vim.org>
parents:
31333
diff
changeset
|
1532 if (pos.lnum > wp->w_buffer->b_ml.ml_line_count) |
45a03dd92f28
patch 9.0.1011: ml_get error when using screenpos()
Bram Moolenaar <Bram@vim.org>
parents:
31333
diff
changeset
|
1533 { |
45a03dd92f28
patch 9.0.1011: ml_get error when using screenpos()
Bram Moolenaar <Bram@vim.org>
parents:
31333
diff
changeset
|
1534 semsg(_(e_invalid_line_number_nr), pos.lnum); |
45a03dd92f28
patch 9.0.1011: ml_get error when using screenpos()
Bram Moolenaar <Bram@vim.org>
parents:
31333
diff
changeset
|
1535 return; |
45a03dd92f28
patch 9.0.1011: ml_get error when using screenpos()
Bram Moolenaar <Bram@vim.org>
parents:
31333
diff
changeset
|
1536 } |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1537 pos.col = tv_get_number(&argvars[2]) - 1; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1538 pos.coladd = 0; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1539 textpos2screenpos(wp, &pos, &row, &scol, &ccol, &ecol); |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1540 |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1541 dict_add_number(dict, "row", row); |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1542 dict_add_number(dict, "col", scol); |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1543 dict_add_number(dict, "curscol", ccol); |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1544 dict_add_number(dict, "endcol", ecol); |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1545 } |
29024
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1546 |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1547 /* |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1548 * "virtcol2col({winid}, {lnum}, {col})" function |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1549 */ |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1550 void |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1551 f_virtcol2col(typval_T *argvars UNUSED, typval_T *rettv) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1552 { |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1553 win_T *wp; |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1554 linenr_T lnum; |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1555 int screencol; |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1556 int error = FALSE; |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1557 |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1558 rettv->vval.v_number = -1; |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1559 |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1560 if (check_for_number_arg(argvars, 0) == FAIL |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1561 || check_for_number_arg(argvars, 1) == FAIL |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1562 || check_for_number_arg(argvars, 2) == FAIL) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1563 return; |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1564 |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1565 wp = find_win_by_nr_or_id(&argvars[0]); |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1566 if (wp == NULL) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1567 return; |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1568 |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1569 lnum = tv_get_number_chk(&argvars[1], &error); |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1570 if (error || lnum < 0 || lnum > wp->w_buffer->b_ml.ml_line_count) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1571 return; |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1572 |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1573 screencol = tv_get_number_chk(&argvars[2], &error); |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1574 if (error || screencol < 0) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1575 return; |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1576 |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1577 rettv->vval.v_number = vcol2col(wp, lnum, screencol); |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1578 } |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1579 #endif |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1580 |
7 | 1581 /* |
1582 * Scroll the current window down by "line_count" logical lines. "CTRL-Y" | |
1583 */ | |
1584 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1585 scrolldown( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1586 long line_count, |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1587 int byfold UNUSED) // TRUE: count a closed fold as one line |
7 | 1588 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1589 long done = 0; // total # of physical lines done |
7 | 1590 int wrow; |
1591 int moved = FALSE; | |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1592 int do_sms = curwin->w_p_wrap && curwin->w_p_sms; |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1593 int width1 = 0; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1594 int width2 = 0; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1595 |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1596 if (do_sms) |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1597 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1598 width1 = curwin->w_width - curwin_col_off(); |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1599 width2 = width1 + curwin_col_off2(); |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1600 } |
7 | 1601 |
1602 #ifdef FEAT_FOLDING | |
1603 linenr_T first; | |
1604 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1605 // Make sure w_topline is at the first of a sequence of folded lines. |
7 | 1606 (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); |
1607 #endif | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1608 validate_cursor(); // w_wrow needs to be valid |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1609 for (int todo = line_count; todo > 0; --todo) |
7 | 1610 { |
1611 #ifdef FEAT_DIFF | |
1980 | 1612 if (curwin->w_topfill < diff_check(curwin, curwin->w_topline) |
1613 && curwin->w_topfill < curwin->w_height - 1) | |
7 | 1614 { |
1615 ++curwin->w_topfill; | |
1616 ++done; | |
1617 } | |
1618 else | |
1619 #endif | |
1620 { | |
30620
70d6345a2976
patch 9.0.0645: CTRL-Y does not stop at line 1
Bram Moolenaar <Bram@vim.org>
parents:
30610
diff
changeset
|
1621 // break when at the very top |
70d6345a2976
patch 9.0.0645: CTRL-Y does not stop at line 1
Bram Moolenaar <Bram@vim.org>
parents:
30610
diff
changeset
|
1622 if (curwin->w_topline == 1 |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1623 && (!do_sms || curwin->w_skipcol < width1)) |
7 | 1624 break; |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1625 if (do_sms && curwin->w_skipcol >= width1) |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1626 { |
30620
70d6345a2976
patch 9.0.0645: CTRL-Y does not stop at line 1
Bram Moolenaar <Bram@vim.org>
parents:
30610
diff
changeset
|
1627 // scroll a screen line down |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1628 if (curwin->w_skipcol >= width1 + width2) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1629 curwin->w_skipcol -= width2; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1630 else |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1631 curwin->w_skipcol -= width1; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1632 redraw_later(UPD_NOT_VALID); |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1633 ++done; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1634 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1635 else |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1636 { |
30620
70d6345a2976
patch 9.0.0645: CTRL-Y does not stop at line 1
Bram Moolenaar <Bram@vim.org>
parents:
30610
diff
changeset
|
1637 // scroll a text line down |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1638 --curwin->w_topline; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1639 curwin->w_skipcol = 0; |
7 | 1640 #ifdef FEAT_DIFF |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1641 curwin->w_topfill = 0; |
7 | 1642 #endif |
1643 #ifdef FEAT_FOLDING | |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1644 // A sequence of folded lines only counts for one logical line |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1645 if (hasFolding(curwin->w_topline, &first, NULL)) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1646 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1647 ++done; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1648 if (!byfold) |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1649 todo -= curwin->w_topline - first - 1; |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1650 curwin->w_botline -= curwin->w_topline - first; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1651 curwin->w_topline = first; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1652 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1653 else |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1654 #endif |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1655 if (do_sms) |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1656 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1657 int size = win_linetabsize(curwin, curwin->w_topline, |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1658 ml_get(curwin->w_topline), (colnr_T)MAXCOL); |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1659 if (size > width1) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1660 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1661 curwin->w_skipcol = width1; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1662 size -= width1; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1663 redraw_later(UPD_NOT_VALID); |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1664 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1665 while (size > width2) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1666 { |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1667 curwin->w_skipcol += width2; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1668 size -= width2; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1669 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1670 ++done; |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1671 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1672 else |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1673 done += PLINES_NOFILL(curwin->w_topline); |
7 | 1674 } |
1675 } | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1676 --curwin->w_botline; // approximate w_botline |
7 | 1677 invalidate_botline(); |
1678 } | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1679 curwin->w_wrow += done; // keep w_wrow updated |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1680 curwin->w_cline_row += done; // keep w_cline_row updated |
7 | 1681 |
1682 #ifdef FEAT_DIFF | |
1683 if (curwin->w_cursor.lnum == curwin->w_topline) | |
1684 curwin->w_cline_row = 0; | |
1685 check_topfill(curwin, TRUE); | |
1686 #endif | |
1687 | |
1688 /* | |
1689 * Compute the row number of the last row of the cursor line | |
1690 * and move the cursor onto the displayed part of the window. | |
1691 */ | |
1692 wrow = curwin->w_wrow; | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12152
diff
changeset
|
1693 if (curwin->w_p_wrap && curwin->w_width != 0) |
7 | 1694 { |
1695 validate_virtcol(); | |
1696 validate_cheight(); | |
1697 wrow += curwin->w_cline_height - 1 - | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
1698 curwin->w_virtcol / curwin->w_width; |
7 | 1699 } |
1700 while (wrow >= curwin->w_height && curwin->w_cursor.lnum > 1) | |
1701 { | |
1702 #ifdef FEAT_FOLDING | |
1703 if (hasFolding(curwin->w_cursor.lnum, &first, NULL)) | |
1704 { | |
1705 --wrow; | |
1706 if (first == 1) | |
1707 curwin->w_cursor.lnum = 1; | |
1708 else | |
1709 curwin->w_cursor.lnum = first - 1; | |
1710 } | |
1711 else | |
1712 #endif | |
1713 wrow -= plines(curwin->w_cursor.lnum--); | |
1714 curwin->w_valid &= | |
1715 ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW|VALID_VIRTCOL); | |
1716 moved = TRUE; | |
1717 } | |
1718 if (moved) | |
1719 { | |
1720 #ifdef FEAT_FOLDING | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1721 // Move cursor to first line of closed fold. |
7 | 1722 foldAdjustCursor(); |
1723 #endif | |
1724 coladvance(curwin->w_curswant); | |
1725 } | |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1726 |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1727 if (curwin->w_cursor.lnum == curwin->w_topline && do_sms) |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1728 { |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1729 long so = get_scrolloff_value(); |
30745
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1730 int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2; |
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1731 |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1732 // make sure the cursor is in the visible text |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1733 validate_virtcol(); |
30745
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1734 int col = curwin->w_virtcol - curwin->w_skipcol + scrolloff_cols; |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1735 int row = 0; |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1736 if (col >= width1) |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1737 { |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1738 col -= width1; |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1739 ++row; |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1740 } |
32072
b232759b29c8
patch 9.0.1367: divide by zero in zero-width window
Bram Moolenaar <Bram@vim.org>
parents:
31954
diff
changeset
|
1741 if (col > width2 && width2 > 0) |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1742 { |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1743 row += col / width2; |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1744 col = col % width2; |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1745 } |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1746 if (row >= curwin->w_height) |
30745
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1747 { |
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1748 curwin->w_curswant = curwin->w_virtcol |
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1749 - (row - curwin->w_height + 1) * width2; |
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1750 coladvance(curwin->w_curswant); |
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1751 } |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1752 } |
7 | 1753 } |
1754 | |
1755 /* | |
1756 * Scroll the current window up by "line_count" logical lines. "CTRL-E" | |
1757 */ | |
1758 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1759 scrollup( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1760 long line_count, |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1761 int byfold UNUSED) // TRUE: count a closed fold as one line |
7 | 1762 { |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1763 int do_sms = curwin->w_p_wrap && curwin->w_p_sms; |
7 | 1764 |
32397
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
1765 if (do_sms |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
1766 # ifdef FEAT_FOLDING |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
1767 || (byfold && hasAnyFolding(curwin)) |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
1768 # endif |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
1769 # ifdef FEAT_DIFF |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
1770 || (curwin->w_p_diff && !curwin->w_p_wrap) |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
1771 # endif |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
1772 ) |
7 | 1773 { |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1774 int width1 = curwin->w_width - curwin_col_off(); |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1775 int width2 = width1 + curwin_col_off2(); |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1776 int size = 0; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1777 linenr_T prev_topline = curwin->w_topline; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1778 |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1779 if (do_sms) |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1780 size = linetabsize(curwin, curwin->w_topline); |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1781 |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1782 // diff mode: first consume "topfill" |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1783 // 'smoothscroll': increase "w_skipcol" until it goes over the end of |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1784 // the line, then advance to the next line. |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1785 // folding: count each sequence of folded lines as one logical line. |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1786 for (int todo = line_count; todo > 0; --todo) |
7 | 1787 { |
1788 # ifdef FEAT_DIFF | |
1789 if (curwin->w_topfill > 0) | |
1790 --curwin->w_topfill; | |
1791 else | |
1792 # endif | |
1793 { | |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1794 linenr_T lnum = curwin->w_topline; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1795 |
7 | 1796 # ifdef FEAT_FOLDING |
1797 if (byfold) | |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1798 // for a closed fold: go to the last line in the fold |
7 | 1799 (void)hasFolding(lnum, NULL, &lnum); |
1800 # endif | |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1801 if (lnum == curwin->w_topline && do_sms) |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1802 { |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1803 // 'smoothscroll': increase "w_skipcol" until it goes over |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1804 // the end of the line, then advance to the next line. |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1805 int add = curwin->w_skipcol > 0 ? width2 : width1; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1806 curwin->w_skipcol += add; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1807 if (curwin->w_skipcol >= size) |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1808 { |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1809 if (lnum == curbuf->b_ml.ml_line_count) |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1810 { |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1811 // at the last screen line, can't scroll further |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1812 curwin->w_skipcol -= add; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1813 break; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1814 } |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1815 ++lnum; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1816 } |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1817 } |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1818 else |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1819 { |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1820 if (lnum >= curbuf->b_ml.ml_line_count) |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1821 break; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1822 ++lnum; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1823 } |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1824 |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1825 if (lnum > curwin->w_topline) |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1826 { |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1827 // approximate w_botline |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1828 curwin->w_botline += lnum - curwin->w_topline; |
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1829 curwin->w_topline = lnum; |
7 | 1830 # ifdef FEAT_DIFF |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1831 curwin->w_topfill = diff_check_fill(curwin, lnum); |
7 | 1832 # endif |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1833 curwin->w_skipcol = 0; |
30673
53b826c4649f
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
1834 if (todo > 1 && do_sms) |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1835 size = linetabsize(curwin, curwin->w_topline); |
30622
ffd6e3bd65b8
patch 9.0.0646: with 'smoothscroll' CTRL-E is wrong when 'foldmethod' set
Bram Moolenaar <Bram@vim.org>
parents:
30620
diff
changeset
|
1836 } |
7 | 1837 } |
1838 } | |
30610
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1839 |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1840 if (curwin->w_topline == prev_topline) |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1841 // need to redraw even though w_topline didn't change |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1842 redraw_later(UPD_NOT_VALID); |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1843 } |
6c6ac189a05f
patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents:
30491
diff
changeset
|
1844 else |
7 | 1845 { |
1846 curwin->w_topline += line_count; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1847 curwin->w_botline += line_count; // approximate w_botline |
7 | 1848 } |
1849 | |
1850 if (curwin->w_topline > curbuf->b_ml.ml_line_count) | |
1851 curwin->w_topline = curbuf->b_ml.ml_line_count; | |
1852 if (curwin->w_botline > curbuf->b_ml.ml_line_count + 1) | |
1853 curwin->w_botline = curbuf->b_ml.ml_line_count + 1; | |
1854 | |
1855 #ifdef FEAT_DIFF | |
1856 check_topfill(curwin, FALSE); | |
1857 #endif | |
1858 | |
1859 #ifdef FEAT_FOLDING | |
1860 if (hasAnyFolding(curwin)) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1861 // Make sure w_topline is at the first of a sequence of folded lines. |
7 | 1862 (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); |
1863 #endif | |
1864 | |
1865 curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE); | |
1866 if (curwin->w_cursor.lnum < curwin->w_topline) | |
1867 { | |
1868 curwin->w_cursor.lnum = curwin->w_topline; | |
1869 curwin->w_valid &= | |
1870 ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW|VALID_VIRTCOL); | |
1871 coladvance(curwin->w_curswant); | |
1872 } | |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1873 if (curwin->w_cursor.lnum == curwin->w_topline |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1874 && do_sms && curwin->w_skipcol > 0) |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1875 { |
31131
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1876 int col_off = curwin_col_off(); |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1877 int col_off2 = curwin_col_off2(); |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1878 |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1879 int width1 = curwin->w_width - col_off; |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1880 int width2 = width1 + col_off2; |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1881 int extra2 = col_off - col_off2; |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1882 long so = get_scrolloff_value(); |
30745
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1883 int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2; |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1884 int space_cols = (curwin->w_height - 1) * width2; |
30745
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1885 |
31131
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1886 // If we have non-zero scrolloff, just ignore the <<< marker as we are |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1887 // going past it anyway. |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1888 int smoothscroll_overlap = scrolloff_cols != 0 ? 0 : |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1889 smoothscroll_marker_overlap(extra2); |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1890 |
30745
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1891 // Make sure the cursor is in a visible part of the line, taking |
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1892 // 'scrolloff' into account, but using screen lines. |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1893 // If there are not enough screen lines put the cursor in the middle. |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1894 if (scrolloff_cols > space_cols / 2) |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1895 scrolloff_cols = space_cols / 2; |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1896 validate_virtcol(); |
31131
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1897 if (curwin->w_virtcol < curwin->w_skipcol |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1898 + smoothscroll_overlap + scrolloff_cols) |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1899 { |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1900 colnr_T col = curwin->w_virtcol; |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1901 |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1902 if (col < width1) |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1903 col += width1; |
31131
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1904 while (col < curwin->w_skipcol |
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
1905 + smoothscroll_overlap + scrolloff_cols) |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1906 col += width2; |
30745
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1907 curwin->w_curswant = col; |
fdc44acc3250
patch 9.0.0707: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30733
diff
changeset
|
1908 coladvance(curwin->w_curswant); |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1909 |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1910 // validate_virtcol() marked various things as valid, but after |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1911 // moving the cursor they need to be recomputed |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1912 curwin->w_valid &= |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1913 ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW|VALID_VIRTCOL); |
30733
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1914 } |
5bea8e583d28
patch 9.0.0701: with 'smoothscroll' cursor position not adjusted in long line
Bram Moolenaar <Bram@vim.org>
parents:
30679
diff
changeset
|
1915 } |
7 | 1916 } |
1917 | |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1918 /* |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1919 * Called after changing the cursor column: make sure that curwin->w_skipcol is |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1920 * valid for 'smoothscroll'. |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1921 */ |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1922 void |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1923 adjust_skipcol(void) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1924 { |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1925 if (!curwin->w_p_wrap |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1926 || !curwin->w_p_sms |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1927 || curwin->w_cursor.lnum != curwin->w_topline) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1928 return; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1929 |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1930 int width1 = curwin->w_width - curwin_col_off(); |
31829
2a590b4a3fba
patch 9.0.1247: divide by zero with 'smoothscroll' set and a narrow window
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1931 if (width1 <= 0) |
2a590b4a3fba
patch 9.0.1247: divide by zero with 'smoothscroll' set and a narrow window
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1932 return; // no text will be displayed |
2a590b4a3fba
patch 9.0.1247: divide by zero with 'smoothscroll' set and a narrow window
Bram Moolenaar <Bram@vim.org>
parents:
31728
diff
changeset
|
1933 |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1934 int width2 = width1 + curwin_col_off2(); |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1935 long so = get_scrolloff_value(); |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1936 int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1937 int scrolled = FALSE; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1938 |
30946
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
1939 validate_cheight(); |
31333
bfbcc148da58
patch 9.0.1000: with 'smoothscroll' skipcol may be reset unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
31329
diff
changeset
|
1940 if (curwin->w_cline_height == curwin->w_height |
bfbcc148da58
patch 9.0.1000: with 'smoothscroll' skipcol may be reset unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
31329
diff
changeset
|
1941 // w_cline_height may be capped at w_height, check there aren't |
bfbcc148da58
patch 9.0.1000: with 'smoothscroll' skipcol may be reset unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
31329
diff
changeset
|
1942 // actually more lines. |
bfbcc148da58
patch 9.0.1000: with 'smoothscroll' skipcol may be reset unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
31329
diff
changeset
|
1943 && plines_win(curwin, curwin->w_cursor.lnum, FALSE) |
bfbcc148da58
patch 9.0.1000: with 'smoothscroll' skipcol may be reset unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
31329
diff
changeset
|
1944 <= curwin->w_height) |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1945 { |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1946 // the line just fits in the window, don't scroll |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
1947 reset_skipcol(); |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1948 return; |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1949 } |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
1950 |
30946
1819fe895aea
patch 9.0.0807: with 'smoothscroll' typing "0" may not go to the first column
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
1951 validate_virtcol(); |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1952 while (curwin->w_skipcol > 0 |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1953 && curwin->w_virtcol < curwin->w_skipcol + 3 + scrolloff_cols) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1954 { |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1955 // scroll a screen line down |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1956 if (curwin->w_skipcol >= width1 + width2) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1957 curwin->w_skipcol -= width2; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1958 else |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1959 curwin->w_skipcol -= width1; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1960 redraw_later(UPD_NOT_VALID); |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1961 scrolled = TRUE; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1962 validate_virtcol(); |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1963 } |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1964 if (scrolled) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1965 return; // don't scroll in the other direction now |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1966 |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1967 int col = curwin->w_virtcol - curwin->w_skipcol + scrolloff_cols; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1968 int row = 0; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1969 if (col >= width1) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1970 { |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1971 col -= width1; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1972 ++row; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1973 } |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1974 if (col > width2) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1975 { |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1976 row += col / width2; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1977 col = col % width2; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1978 } |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1979 if (row >= curwin->w_height) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1980 { |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1981 if (curwin->w_skipcol == 0) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1982 { |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1983 curwin->w_skipcol += width1; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1984 --row; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1985 } |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1986 if (row >= curwin->w_height) |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1987 curwin->w_skipcol += (row - curwin->w_height) * width2; |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1988 redraw_later(UPD_NOT_VALID); |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1989 } |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1990 } |
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30745
diff
changeset
|
1991 |
7 | 1992 #ifdef FEAT_DIFF |
1993 /* | |
1994 * Don't end up with too many filler lines in the window. | |
1995 */ | |
1996 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1997 check_topfill( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1998 win_T *wp, |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1999 int down) // when TRUE scroll down when not enough space |
7 | 2000 { |
2001 int n; | |
2002 | |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2003 if (wp->w_topfill <= 0) |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2004 return; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2005 |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2006 n = plines_win_nofill(wp, wp->w_topline, TRUE); |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2007 if (wp->w_topfill + n > wp->w_height) |
7 | 2008 { |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2009 if (down && wp->w_topline > 1) |
7 | 2010 { |
31728
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2011 --wp->w_topline; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2012 wp->w_topfill = 0; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2013 } |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2014 else |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2015 { |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2016 wp->w_topfill = wp->w_height - n; |
238ca27dbfd2
patch 9.0.1196: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
2017 if (wp->w_topfill < 0) |
7 | 2018 wp->w_topfill = 0; |
2019 } | |
2020 } | |
2021 } | |
2022 | |
2023 /* | |
2024 * Use as many filler lines as possible for w_topline. Make sure w_topline | |
2025 * is still visible. | |
2026 */ | |
2027 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2028 max_topfill(void) |
7 | 2029 { |
2030 int n; | |
2031 | |
2032 n = plines_nofill(curwin->w_topline); | |
2033 if (n >= curwin->w_height) | |
2034 curwin->w_topfill = 0; | |
2035 else | |
2036 { | |
2037 curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline); | |
2038 if (curwin->w_topfill + n > curwin->w_height) | |
2039 curwin->w_topfill = curwin->w_height - n; | |
2040 } | |
2041 } | |
2042 #endif | |
2043 | |
2044 /* | |
2045 * Scroll the screen one line down, but don't do it if it would move the | |
2046 * cursor off the screen. | |
2047 */ | |
2048 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2049 scrolldown_clamp(void) |
7 | 2050 { |
2051 int end_row; | |
2052 #ifdef FEAT_DIFF | |
2053 int can_fill = (curwin->w_topfill | |
2054 < diff_check_fill(curwin, curwin->w_topline)); | |
2055 #endif | |
2056 | |
2057 if (curwin->w_topline <= 1 | |
2058 #ifdef FEAT_DIFF | |
2059 && !can_fill | |
2060 #endif | |
2061 ) | |
2062 return; | |
2063 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2064 validate_cursor(); // w_wrow needs to be valid |
7 | 2065 |
2066 /* | |
2067 * Compute the row number of the last row of the cursor line | |
2068 * and make sure it doesn't go off the screen. Make sure the cursor | |
2069 * doesn't go past 'scrolloff' lines from the screen end. | |
2070 */ | |
2071 end_row = curwin->w_wrow; | |
2072 #ifdef FEAT_DIFF | |
2073 if (can_fill) | |
2074 ++end_row; | |
2075 else | |
2076 end_row += plines_nofill(curwin->w_topline - 1); | |
2077 #else | |
2078 end_row += plines(curwin->w_topline - 1); | |
2079 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12152
diff
changeset
|
2080 if (curwin->w_p_wrap && curwin->w_width != 0) |
7 | 2081 { |
2082 validate_cheight(); | |
2083 validate_virtcol(); | |
2084 end_row += curwin->w_cline_height - 1 - | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2085 curwin->w_virtcol / curwin->w_width; |
7 | 2086 } |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2087 if (end_row < curwin->w_height - get_scrolloff_value()) |
7 | 2088 { |
2089 #ifdef FEAT_DIFF | |
2090 if (can_fill) | |
2091 { | |
2092 ++curwin->w_topfill; | |
2093 check_topfill(curwin, TRUE); | |
2094 } | |
2095 else | |
2096 { | |
2097 --curwin->w_topline; | |
2098 curwin->w_topfill = 0; | |
2099 } | |
2100 #else | |
2101 --curwin->w_topline; | |
2102 #endif | |
2103 #ifdef FEAT_FOLDING | |
7009 | 2104 (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); |
7 | 2105 #endif |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2106 --curwin->w_botline; // approximate w_botline |
7 | 2107 curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE); |
2108 } | |
2109 } | |
2110 | |
2111 /* | |
2112 * Scroll the screen one line up, but don't do it if it would move the cursor | |
2113 * off the screen. | |
2114 */ | |
2115 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2116 scrollup_clamp(void) |
7 | 2117 { |
2118 int start_row; | |
2119 | |
2120 if (curwin->w_topline == curbuf->b_ml.ml_line_count | |
2121 #ifdef FEAT_DIFF | |
2122 && curwin->w_topfill == 0 | |
2123 #endif | |
2124 ) | |
2125 return; | |
2126 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2127 validate_cursor(); // w_wrow needs to be valid |
7 | 2128 |
2129 /* | |
2130 * Compute the row number of the first row of the cursor line | |
2131 * and make sure it doesn't go off the screen. Make sure the cursor | |
2132 * doesn't go before 'scrolloff' lines from the screen start. | |
2133 */ | |
2134 #ifdef FEAT_DIFF | |
2135 start_row = curwin->w_wrow - plines_nofill(curwin->w_topline) | |
2136 - curwin->w_topfill; | |
2137 #else | |
2138 start_row = curwin->w_wrow - plines(curwin->w_topline); | |
2139 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12152
diff
changeset
|
2140 if (curwin->w_p_wrap && curwin->w_width != 0) |
7 | 2141 { |
2142 validate_virtcol(); | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2143 start_row -= curwin->w_virtcol / curwin->w_width; |
7 | 2144 } |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2145 if (start_row >= get_scrolloff_value()) |
7 | 2146 { |
2147 #ifdef FEAT_DIFF | |
2148 if (curwin->w_topfill > 0) | |
2149 --curwin->w_topfill; | |
2150 else | |
2151 #endif | |
36 | 2152 { |
2153 #ifdef FEAT_FOLDING | |
2154 (void)hasFolding(curwin->w_topline, NULL, &curwin->w_topline); | |
2155 #endif | |
7 | 2156 ++curwin->w_topline; |
36 | 2157 } |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2158 ++curwin->w_botline; // approximate w_botline |
7 | 2159 curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE); |
2160 } | |
2161 } | |
2162 | |
2163 /* | |
2164 * Add one line above "lp->lnum". This can be a filler line, a closed fold or | |
2165 * a (wrapped) text line. Uses and sets "lp->fill". | |
2166 * Returns the height of the added line in "lp->height". | |
2082
8ca3c9ad0bee
updated for version 7.2.366
Bram Moolenaar <bram@zimbu.org>
parents:
2070
diff
changeset
|
2167 * Lines above the first one are incredibly high: MAXCOL. |
7 | 2168 */ |
2169 static void | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2170 topline_back_winheight( |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2171 lineoff_T *lp, |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2172 int winheight) // when TRUE limit to window height |
7 | 2173 { |
2174 #ifdef FEAT_DIFF | |
2175 if (lp->fill < diff_check_fill(curwin, lp->lnum)) | |
2176 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2177 // Add a filler line. |
7 | 2178 ++lp->fill; |
2179 lp->height = 1; | |
2180 } | |
2181 else | |
2182 #endif | |
2183 { | |
2184 --lp->lnum; | |
2185 #ifdef FEAT_DIFF | |
2186 lp->fill = 0; | |
2187 #endif | |
2188 if (lp->lnum < 1) | |
2189 lp->height = MAXCOL; | |
2190 else | |
2191 #ifdef FEAT_FOLDING | |
2192 if (hasFolding(lp->lnum, &lp->lnum, NULL)) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2193 // Add a closed fold |
7 | 2194 lp->height = 1; |
2195 else | |
2196 #endif | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2197 lp->height = PLINES_WIN_NOFILL(curwin, lp->lnum, winheight); |
7 | 2198 } |
2199 } | |
2200 | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2201 static void |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2202 topline_back(lineoff_T *lp) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2203 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2204 topline_back_winheight(lp, TRUE); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2205 } |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2206 |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2207 |
7 | 2208 /* |
2209 * Add one line below "lp->lnum". This can be a filler line, a closed fold or | |
2210 * a (wrapped) text line. Uses and sets "lp->fill". | |
2211 * Returns the height of the added line in "lp->height". | |
2212 * Lines below the last one are incredibly high. | |
2213 */ | |
2214 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2215 botline_forw(lineoff_T *lp) |
7 | 2216 { |
2217 #ifdef FEAT_DIFF | |
2218 if (lp->fill < diff_check_fill(curwin, lp->lnum + 1)) | |
2219 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2220 // Add a filler line. |
7 | 2221 ++lp->fill; |
2222 lp->height = 1; | |
2223 } | |
2224 else | |
2225 #endif | |
2226 { | |
2227 ++lp->lnum; | |
2228 #ifdef FEAT_DIFF | |
2229 lp->fill = 0; | |
2230 #endif | |
2231 if (lp->lnum > curbuf->b_ml.ml_line_count) | |
2232 lp->height = MAXCOL; | |
2233 else | |
2234 #ifdef FEAT_FOLDING | |
2235 if (hasFolding(lp->lnum, NULL, &lp->lnum)) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2236 // Add a closed fold |
7 | 2237 lp->height = 1; |
2238 else | |
2239 #endif | |
7103
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
7088
diff
changeset
|
2240 lp->height = PLINES_NOFILL(lp->lnum); |
7 | 2241 } |
2242 } | |
2243 | |
2244 #ifdef FEAT_DIFF | |
2245 /* | |
2246 * Switch from including filler lines below lp->lnum to including filler | |
2247 * lines above loff.lnum + 1. This keeps pointing to the same line. | |
2248 * When there are no filler lines nothing changes. | |
2249 */ | |
2250 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2251 botline_topline(lineoff_T *lp) |
7 | 2252 { |
2253 if (lp->fill > 0) | |
2254 { | |
2255 ++lp->lnum; | |
2256 lp->fill = diff_check_fill(curwin, lp->lnum) - lp->fill + 1; | |
2257 } | |
2258 } | |
2259 | |
2260 /* | |
2261 * Switch from including filler lines above lp->lnum to including filler | |
2262 * lines below loff.lnum - 1. This keeps pointing to the same line. | |
2263 * When there are no filler lines nothing changes. | |
2264 */ | |
2265 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2266 topline_botline(lineoff_T *lp) |
7 | 2267 { |
2268 if (lp->fill > 0) | |
2269 { | |
2270 lp->fill = diff_check_fill(curwin, lp->lnum) - lp->fill + 1; | |
2271 --lp->lnum; | |
2272 } | |
2273 } | |
2274 #endif | |
2275 | |
2276 /* | |
2277 * Recompute topline to put the cursor at the top of the window. | |
2278 * Scroll at least "min_scroll" lines. | |
2279 * If "always" is TRUE, always set topline (for "zt"). | |
2280 */ | |
2281 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2282 scroll_cursor_top(int min_scroll, int always) |
7 | 2283 { |
2284 int scrolled = 0; | |
2285 int extra = 0; | |
2286 int used; | |
2287 int i; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2288 linenr_T top; // just above displayed lines |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2289 linenr_T bot; // just below displayed lines |
7 | 2290 linenr_T old_topline = curwin->w_topline; |
30677
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
2291 int old_skipcol = curwin->w_skipcol; |
7 | 2292 #ifdef FEAT_DIFF |
2293 linenr_T old_topfill = curwin->w_topfill; | |
2294 #endif | |
2295 linenr_T new_topline; | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2296 int off = get_scrolloff_value(); |
7 | 2297 |
2298 if (mouse_dragging > 0) | |
2299 off = mouse_dragging - 1; | |
2300 | |
2301 /* | |
2302 * Decrease topline until: | |
2303 * - it has become 1 | |
2304 * - (part of) the cursor line is moved off the screen or | |
2305 * - moved at least 'scrolljump' lines and | |
2306 * - at least 'scrolloff' lines above and below the cursor | |
2307 */ | |
2308 validate_cheight(); | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2309 used = curwin->w_cline_height; // includes filler lines above |
7 | 2310 if (curwin->w_cursor.lnum < curwin->w_topline) |
2311 scrolled = used; | |
2312 | |
2313 #ifdef FEAT_FOLDING | |
2314 if (hasFolding(curwin->w_cursor.lnum, &top, &bot)) | |
2315 { | |
2316 --top; | |
2317 ++bot; | |
2318 } | |
2319 else | |
2320 #endif | |
2321 { | |
2322 top = curwin->w_cursor.lnum - 1; | |
2323 bot = curwin->w_cursor.lnum + 1; | |
2324 } | |
2325 new_topline = top + 1; | |
2326 | |
2327 #ifdef FEAT_DIFF | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2328 // "used" already contains the number of filler lines above, don't add it |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2329 // again. |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2330 // Hide filler lines above cursor line by adding them to "extra". |
7088
8a58dde655a8
commit https://github.com/vim/vim/commit/a09a2c5857ab854f0870573b5160da1964c905a2
Christian Brabandt <cb@256bit.org>
parents:
7082
diff
changeset
|
2331 extra += diff_check_fill(curwin, curwin->w_cursor.lnum); |
7 | 2332 #endif |
2333 | |
2334 /* | |
2335 * Check if the lines from "top" to "bot" fit in the window. If they do, | |
2336 * set new_topline and advance "top" and "bot" to include more lines. | |
2337 */ | |
2338 while (top > 0) | |
2339 { | |
2340 #ifdef FEAT_FOLDING | |
2341 if (hasFolding(top, &top, NULL)) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2342 // count one logical line for a sequence of folded lines |
7 | 2343 i = 1; |
2344 else | |
2345 #endif | |
7103
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
7088
diff
changeset
|
2346 i = PLINES_NOFILL(top); |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2347 if (top < curwin->w_topline) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2348 scrolled += i; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2349 |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2350 // If scrolling is needed, scroll at least 'sj' lines. |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2351 if ((new_topline >= curwin->w_topline || scrolled > min_scroll) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2352 && extra >= off) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2353 break; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2354 |
7 | 2355 used += i; |
2356 if (extra + i <= off && bot < curbuf->b_ml.ml_line_count) | |
2357 { | |
2358 #ifdef FEAT_FOLDING | |
2359 if (hasFolding(bot, NULL, &bot)) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2360 // count one logical line for a sequence of folded lines |
7 | 2361 ++used; |
2362 else | |
2363 #endif | |
2364 used += plines(bot); | |
2365 } | |
2366 if (used > curwin->w_height) | |
2367 break; | |
2368 | |
2369 extra += i; | |
2370 new_topline = top; | |
2371 --top; | |
2372 ++bot; | |
2373 } | |
2374 | |
2375 /* | |
2376 * If we don't have enough space, put cursor in the middle. | |
2377 * This makes sure we get the same position when using "k" and "j" | |
2378 * in a small window. | |
2379 */ | |
2380 if (used > curwin->w_height) | |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2381 scroll_cursor_halfway(FALSE, FALSE); |
7 | 2382 else |
2383 { | |
2384 /* | |
2385 * If "always" is FALSE, only adjust topline to a lower value, higher | |
31329
5c83140aafc9
patch 9.0.0998: "gk" may reset skipcol when not needed
Bram Moolenaar <Bram@vim.org>
parents:
31319
diff
changeset
|
2386 * value may happen with wrapping lines. |
7 | 2387 */ |
2388 if (new_topline < curwin->w_topline || always) | |
2389 curwin->w_topline = new_topline; | |
2390 if (curwin->w_topline > curwin->w_cursor.lnum) | |
2391 curwin->w_topline = curwin->w_cursor.lnum; | |
2392 #ifdef FEAT_DIFF | |
2393 curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline); | |
2394 if (curwin->w_topfill > 0 && extra > off) | |
2395 { | |
2396 curwin->w_topfill -= extra - off; | |
2397 if (curwin->w_topfill < 0) | |
2398 curwin->w_topfill = 0; | |
2399 } | |
2400 check_topfill(curwin, FALSE); | |
2401 #endif | |
30677
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
2402 // TODO: if the line doesn't fit may optimize w_skipcol |
31329
5c83140aafc9
patch 9.0.0998: "gk" may reset skipcol when not needed
Bram Moolenaar <Bram@vim.org>
parents:
31319
diff
changeset
|
2403 if (curwin->w_topline == curwin->w_cursor.lnum |
5c83140aafc9
patch 9.0.0998: "gk" may reset skipcol when not needed
Bram Moolenaar <Bram@vim.org>
parents:
31319
diff
changeset
|
2404 && curwin->w_skipcol >= curwin->w_cursor.col) |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
2405 reset_skipcol(); |
7 | 2406 if (curwin->w_topline != old_topline |
30677
a345ad853b08
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30675
diff
changeset
|
2407 || curwin->w_skipcol != old_skipcol |
7 | 2408 #ifdef FEAT_DIFF |
2409 || curwin->w_topfill != old_topfill | |
2410 #endif | |
2411 ) | |
2412 curwin->w_valid &= | |
2413 ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP); | |
2414 curwin->w_valid |= VALID_TOPLINE; | |
2415 } | |
2416 } | |
2417 | |
2418 /* | |
2419 * Set w_empty_rows and w_filler_rows for window "wp", having used up "used" | |
2420 * screen lines for text lines. | |
2421 */ | |
2422 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2423 set_empty_rows(win_T *wp, int used) |
7 | 2424 { |
2425 #ifdef FEAT_DIFF | |
2426 wp->w_filler_rows = 0; | |
2427 #endif | |
2428 if (used == 0) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2429 wp->w_empty_rows = 0; // single line that doesn't fit |
7 | 2430 else |
2431 { | |
2432 wp->w_empty_rows = wp->w_height - used; | |
2433 #ifdef FEAT_DIFF | |
2434 if (wp->w_botline <= wp->w_buffer->b_ml.ml_line_count) | |
2435 { | |
2436 wp->w_filler_rows = diff_check_fill(wp, wp->w_botline); | |
2437 if (wp->w_empty_rows > wp->w_filler_rows) | |
2438 wp->w_empty_rows -= wp->w_filler_rows; | |
2439 else | |
2440 { | |
2441 wp->w_filler_rows = wp->w_empty_rows; | |
2442 wp->w_empty_rows = 0; | |
2443 } | |
2444 } | |
2445 #endif | |
2446 } | |
2447 } | |
2448 | |
2449 /* | |
2450 * Recompute topline to put the cursor at the bottom of the window. | |
29239
da56650de132
patch 8.2.5138: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
2451 * When scrolling scroll at least "min_scroll" lines. |
7 | 2452 * If "set_topbot" is TRUE, set topline and botline first (for "zb"). |
2453 * This is messy stuff!!! | |
2454 */ | |
2455 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2456 scroll_cursor_bot(int min_scroll, int set_topbot) |
7 | 2457 { |
2458 int used; | |
2459 int scrolled = 0; | |
2460 int extra = 0; | |
2461 int i; | |
2462 linenr_T line_count; | |
2463 linenr_T old_topline = curwin->w_topline; | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2464 int old_skipcol = curwin->w_skipcol; |
7 | 2465 lineoff_T loff; |
2466 lineoff_T boff; | |
2467 #ifdef FEAT_DIFF | |
2468 int old_topfill = curwin->w_topfill; | |
2469 int fill_below_window; | |
2470 #endif | |
2471 linenr_T old_botline = curwin->w_botline; | |
2472 linenr_T old_valid = curwin->w_valid; | |
2473 int old_empty_rows = curwin->w_empty_rows; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2474 linenr_T cln; // Cursor Line Number |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28782
diff
changeset
|
2475 long so = get_scrolloff_value(); |
32397
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
2476 int do_sms = curwin->w_p_wrap && curwin->w_p_sms; |
7 | 2477 |
2478 cln = curwin->w_cursor.lnum; | |
2479 if (set_topbot) | |
2480 { | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2481 int set_skipcol = FALSE; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2482 |
7 | 2483 used = 0; |
2484 curwin->w_botline = cln + 1; | |
2485 #ifdef FEAT_DIFF | |
2486 loff.fill = 0; | |
2487 #endif | |
2488 for (curwin->w_topline = curwin->w_botline; | |
2489 curwin->w_topline > 1; | |
2490 curwin->w_topline = loff.lnum) | |
2491 { | |
2492 loff.lnum = curwin->w_topline; | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2493 topline_back_winheight(&loff, FALSE); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2494 if (loff.height == MAXCOL) |
7 | 2495 break; |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2496 if (used + loff.height > curwin->w_height) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2497 { |
32397
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
2498 if (do_sms) |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2499 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2500 // 'smoothscroll' and 'wrap' are set. The above line is |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2501 // too long to show in its entirety, so we show just a part |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2502 // of it. |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2503 if (used < curwin->w_height) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2504 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2505 int plines_offset = used + loff.height |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2506 - curwin->w_height; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2507 used = curwin->w_height; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2508 #ifdef FEAT_DIFF |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2509 curwin->w_topfill = loff.fill; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2510 #endif |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2511 curwin->w_topline = loff.lnum; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2512 curwin->w_skipcol = skipcol_from_plines( |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2513 curwin, plines_offset); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2514 set_skipcol = TRUE; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2515 } |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2516 } |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2517 break; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2518 } |
7 | 2519 used += loff.height; |
2520 #ifdef FEAT_DIFF | |
2521 curwin->w_topfill = loff.fill; | |
2522 #endif | |
2523 } | |
2524 set_empty_rows(curwin, used); | |
2525 curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP; | |
2526 if (curwin->w_topline != old_topline | |
2527 #ifdef FEAT_DIFF | |
2528 || curwin->w_topfill != old_topfill | |
2529 #endif | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2530 || set_skipcol |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2531 || curwin->w_skipcol != 0) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2532 { |
7 | 2533 curwin->w_valid &= ~(VALID_WROW|VALID_CROW); |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2534 if (set_skipcol) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2535 redraw_later(UPD_NOT_VALID); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2536 else |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2537 reset_skipcol(); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2538 } |
7 | 2539 } |
2540 else | |
2541 validate_botline(); | |
2542 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2543 // The lines of the cursor line itself are always used. |
7 | 2544 #ifdef FEAT_DIFF |
2545 used = plines_nofill(cln); | |
2546 #else | |
2547 validate_cheight(); | |
2548 used = curwin->w_cline_height; | |
2549 #endif | |
2550 | |
31148
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2551 // If the cursor is on or below botline, we will at least scroll by the |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2552 // height of the cursor line, which is "used". Correct for empty lines, |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2553 // which are really part of botline. |
7 | 2554 if (cln >= curwin->w_botline) |
2555 { | |
2556 scrolled = used; | |
2557 if (cln == curwin->w_botline) | |
2558 scrolled -= curwin->w_empty_rows; | |
32397
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
2559 if (do_sms) |
31148
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2560 { |
32397
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
2561 // 'smoothscroll' and 'wrap' are set. |
31148
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2562 // Calculate how many screen lines the current top line of window |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2563 // occupies. If it is occupying more than the entire window, we |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2564 // need to scroll the additional clipped lines to scroll past the |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2565 // top line before we can move on to the other lines. |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2566 int top_plines = |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2567 #ifdef FEAT_DIFF |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2568 plines_win_nofill |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2569 #else |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2570 plines_win |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2571 #endif |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2572 (curwin, curwin->w_topline, FALSE); |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2573 int skip_lines = 0; |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2574 int width1 = curwin->w_width - curwin_col_off(); |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2575 int width2 = width1 + curwin_col_off2(); |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2576 // similar formula is used in curs_columns() |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2577 if (curwin->w_skipcol > width1) |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2578 skip_lines += (curwin->w_skipcol - width1) / width2 + 1; |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2579 else if (curwin->w_skipcol > 0) |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2580 skip_lines = 1; |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2581 |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2582 top_plines -= skip_lines; |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2583 if (top_plines > curwin->w_height) |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2584 { |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2585 scrolled += (top_plines - curwin->w_height); |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2586 } |
69cea3380d9a
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong position
Bram Moolenaar <Bram@vim.org>
parents:
31140
diff
changeset
|
2587 } |
7 | 2588 } |
2589 | |
2590 /* | |
2591 * Stop counting lines to scroll when | |
2592 * - hitting start of the file | |
2593 * - scrolled nothing or at least 'sj' lines | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2594 * - at least 'scrolloff' lines below the cursor |
7 | 2595 * - lines between botline and cursor have been counted |
2596 */ | |
2597 #ifdef FEAT_FOLDING | |
2598 if (!hasFolding(curwin->w_cursor.lnum, &loff.lnum, &boff.lnum)) | |
2599 #endif | |
2600 { | |
2601 loff.lnum = cln; | |
2602 boff.lnum = cln; | |
2603 } | |
2604 #ifdef FEAT_DIFF | |
2605 loff.fill = 0; | |
2606 boff.fill = 0; | |
2607 fill_below_window = diff_check_fill(curwin, curwin->w_botline) | |
2608 - curwin->w_filler_rows; | |
2609 #endif | |
2610 | |
2611 while (loff.lnum > 1) | |
2612 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2613 // Stop when scrolled nothing or at least "min_scroll", found "extra" |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2614 // context for 'scrolloff' and counted all lines below the window. |
7 | 2615 if ((((scrolled <= 0 || scrolled >= min_scroll) |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
17863
diff
changeset
|
2616 && extra >= (mouse_dragging > 0 ? mouse_dragging - 1 : so)) |
7 | 2617 || boff.lnum + 1 > curbuf->b_ml.ml_line_count) |
2618 && loff.lnum <= curwin->w_botline | |
2619 #ifdef FEAT_DIFF | |
2620 && (loff.lnum < curwin->w_botline | |
2621 || loff.fill >= fill_below_window) | |
2622 #endif | |
2623 ) | |
2624 break; | |
2625 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2626 // Add one line above |
7 | 2627 topline_back(&loff); |
2082
8ca3c9ad0bee
updated for version 7.2.366
Bram Moolenaar <bram@zimbu.org>
parents:
2070
diff
changeset
|
2628 if (loff.height == MAXCOL) |
8ca3c9ad0bee
updated for version 7.2.366
Bram Moolenaar <bram@zimbu.org>
parents:
2070
diff
changeset
|
2629 used = MAXCOL; |
8ca3c9ad0bee
updated for version 7.2.366
Bram Moolenaar <bram@zimbu.org>
parents:
2070
diff
changeset
|
2630 else |
8ca3c9ad0bee
updated for version 7.2.366
Bram Moolenaar <bram@zimbu.org>
parents:
2070
diff
changeset
|
2631 used += loff.height; |
7 | 2632 if (used > curwin->w_height) |
2633 break; | |
2634 if (loff.lnum >= curwin->w_botline | |
2635 #ifdef FEAT_DIFF | |
2636 && (loff.lnum > curwin->w_botline | |
2637 || loff.fill <= fill_below_window) | |
2638 #endif | |
2639 ) | |
2640 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2641 // Count screen lines that are below the window. |
7 | 2642 scrolled += loff.height; |
2643 if (loff.lnum == curwin->w_botline | |
2644 #ifdef FEAT_DIFF | |
15064
7b2dcca9e0c1
patch 8.1.0543: Coverity warns for leaking memory and using wrong struct
Bram Moolenaar <Bram@vim.org>
parents:
14873
diff
changeset
|
2645 && loff.fill == 0 |
7 | 2646 #endif |
2647 ) | |
2648 scrolled -= curwin->w_empty_rows; | |
2649 } | |
2650 | |
2651 if (boff.lnum < curbuf->b_ml.ml_line_count) | |
2652 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2653 // Add one line below |
7 | 2654 botline_forw(&boff); |
2655 used += boff.height; | |
2656 if (used > curwin->w_height) | |
2657 break; | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
17863
diff
changeset
|
2658 if (extra < ( mouse_dragging > 0 ? mouse_dragging - 1 : so) |
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
17863
diff
changeset
|
2659 || scrolled < min_scroll) |
7 | 2660 { |
2661 extra += boff.height; | |
2662 if (boff.lnum >= curwin->w_botline | |
2663 #ifdef FEAT_DIFF | |
2664 || (boff.lnum + 1 == curwin->w_botline | |
2665 && boff.fill > curwin->w_filler_rows) | |
2666 #endif | |
2667 ) | |
2668 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2669 // Count screen lines that are below the window. |
7 | 2670 scrolled += boff.height; |
2671 if (boff.lnum == curwin->w_botline | |
2672 #ifdef FEAT_DIFF | |
2673 && boff.fill == 0 | |
2674 #endif | |
2675 ) | |
2676 scrolled -= curwin->w_empty_rows; | |
2677 } | |
2678 } | |
2679 } | |
2680 } | |
2681 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2682 // curwin->w_empty_rows is larger, no need to scroll |
7 | 2683 if (scrolled <= 0) |
2684 line_count = 0; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2685 // more than a screenfull, don't scroll but redraw |
7 | 2686 else if (used > curwin->w_height) |
2687 line_count = used; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2688 // scroll minimal number of lines |
7 | 2689 else |
2690 { | |
2691 line_count = 0; | |
2692 #ifdef FEAT_DIFF | |
2693 boff.fill = curwin->w_topfill; | |
2694 #endif | |
2695 boff.lnum = curwin->w_topline - 1; | |
2696 for (i = 0; i < scrolled && boff.lnum < curwin->w_botline; ) | |
2697 { | |
2698 botline_forw(&boff); | |
2699 i += boff.height; | |
2700 ++line_count; | |
2701 } | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2702 if (i < scrolled) // below curwin->w_botline, don't scroll |
7 | 2703 line_count = 9999; |
2704 } | |
2705 | |
2706 /* | |
2707 * Scroll up if the cursor is off the bottom of the screen a bit. | |
2708 * Otherwise put it at 1/2 of the screen. | |
2709 */ | |
2710 if (line_count >= curwin->w_height && line_count > min_scroll) | |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2711 scroll_cursor_halfway(FALSE, TRUE); |
32397
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
2712 else if (line_count > 0) |
30675
bc48f3752d8d
patch 9.0.0672: line partly shows with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30673
diff
changeset
|
2713 { |
32397
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
2714 if (do_sms) |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
2715 scrollup(scrolled, TRUE); // TODO |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
2716 else |
f9d4988a86ef
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Bram Moolenaar <Bram@vim.org>
parents:
32387
diff
changeset
|
2717 scrollup(line_count, TRUE); |
30675
bc48f3752d8d
patch 9.0.0672: line partly shows with 'smoothscroll' and 'scrolloff' zero
Bram Moolenaar <Bram@vim.org>
parents:
30673
diff
changeset
|
2718 } |
7 | 2719 |
2720 /* | |
2721 * If topline didn't change we need to restore w_botline and w_empty_rows | |
2722 * (we changed them). | |
2723 * If topline did change, update_screen() will set botline. | |
2724 */ | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2725 if (curwin->w_topline == old_topline |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2726 && curwin->w_skipcol == old_skipcol |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2727 && set_topbot) |
7 | 2728 { |
2729 curwin->w_botline = old_botline; | |
2730 curwin->w_empty_rows = old_empty_rows; | |
2731 curwin->w_valid = old_valid; | |
2732 } | |
2733 curwin->w_valid |= VALID_TOPLINE; | |
2734 } | |
2735 | |
2736 /* | |
2737 * Recompute topline to put the cursor halfway the window | |
2738 * If "atend" is TRUE, also put it halfway at the end of the file. | |
2739 */ | |
2740 void | |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2741 scroll_cursor_halfway(int atend, int prefer_above) |
7 | 2742 { |
2743 int above = 0; | |
2744 linenr_T topline; | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2745 colnr_T skipcol = 0; |
7 | 2746 #ifdef FEAT_DIFF |
2747 int topfill = 0; | |
2748 #endif | |
2749 int below = 0; | |
2750 int used; | |
2751 lineoff_T loff; | |
2752 lineoff_T boff; | |
5661 | 2753 #ifdef FEAT_DIFF |
5653 | 2754 linenr_T old_topline = curwin->w_topline; |
5661 | 2755 #endif |
7 | 2756 |
22403
3351d2cd3f1f
patch 8.2.1750: popup_setoptions() setting firstline fails if cursorline set
Bram Moolenaar <Bram@vim.org>
parents:
21321
diff
changeset
|
2757 #ifdef FEAT_PROP_POPUP |
3351d2cd3f1f
patch 8.2.1750: popup_setoptions() setting firstline fails if cursorline set
Bram Moolenaar <Bram@vim.org>
parents:
21321
diff
changeset
|
2758 // if the width changed this needs to be updated first |
3351d2cd3f1f
patch 8.2.1750: popup_setoptions() setting firstline fails if cursorline set
Bram Moolenaar <Bram@vim.org>
parents:
21321
diff
changeset
|
2759 may_update_popup_position(); |
3351d2cd3f1f
patch 8.2.1750: popup_setoptions() setting firstline fails if cursorline set
Bram Moolenaar <Bram@vim.org>
parents:
21321
diff
changeset
|
2760 #endif |
7 | 2761 loff.lnum = boff.lnum = curwin->w_cursor.lnum; |
2762 #ifdef FEAT_FOLDING | |
2763 (void)hasFolding(loff.lnum, &loff.lnum, &boff.lnum); | |
2764 #endif | |
2765 #ifdef FEAT_DIFF | |
2766 used = plines_nofill(loff.lnum); | |
2767 loff.fill = 0; | |
2768 boff.fill = 0; | |
2769 #else | |
2770 used = plines(loff.lnum); | |
2771 #endif | |
2772 topline = loff.lnum; | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2773 |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2774 int want_height; |
32421
603b6dcf5f9a
patch 9.0.1542: line not fully displayed if it doesn't fit in the screen
Bram Moolenaar <Bram@vim.org>
parents:
32397
diff
changeset
|
2775 int do_sms = curwin->w_p_wrap && curwin->w_p_sms; |
603b6dcf5f9a
patch 9.0.1542: line not fully displayed if it doesn't fit in the screen
Bram Moolenaar <Bram@vim.org>
parents:
32397
diff
changeset
|
2776 if (do_sms) |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2777 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2778 // 'smoothscroll' and 'wrap' are set |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2779 if (atend) |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2780 { |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2781 want_height = (curwin->w_height - used) / 2; |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2782 used = 0; |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2783 } |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2784 else |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2785 want_height = curwin->w_height; |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2786 } |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2787 |
7 | 2788 while (topline > 1) |
2789 { | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2790 // If using smoothscroll, we can precisely scroll to the |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2791 // exact point where the cursor is halfway down the screen. |
32421
603b6dcf5f9a
patch 9.0.1542: line not fully displayed if it doesn't fit in the screen
Bram Moolenaar <Bram@vim.org>
parents:
32397
diff
changeset
|
2792 if (do_sms) |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2793 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2794 topline_back_winheight(&loff, FALSE); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2795 if (loff.height == MAXCOL) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2796 break; |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2797 used += loff.height; |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2798 if (!atend && boff.lnum < curbuf->b_ml.ml_line_count) |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2799 { |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2800 botline_forw(&boff); |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2801 used += boff.height; |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2802 } |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2803 if (used > want_height) |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2804 { |
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2805 if (used - loff.height < want_height) |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2806 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2807 topline = loff.lnum; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2808 #ifdef FEAT_DIFF |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2809 topfill = loff.fill; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2810 #endif |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2811 skipcol = skipcol_from_plines(curwin, used - want_height); |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2812 } |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2813 break; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2814 } |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2815 topline = loff.lnum; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2816 #ifdef FEAT_DIFF |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2817 topfill = loff.fill; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2818 #endif |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2819 continue; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2820 } |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2821 |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2822 // If not using smoothscroll, we have to iteratively find how many |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2823 // lines to scroll down to roughly fit the cursor. |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2824 // This may not be right in the middle if the lines' |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2825 // physical height > 1 (e.g. 'wrap' is on). |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2826 |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2827 // Depending on "prefer_above" we add a line above or below first. |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2828 // Loop twice to avoid duplicating code. |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2829 int done = FALSE; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2830 for (int round = 1; round <= 2; ++round) |
7 | 2831 { |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2832 if (prefer_above ? (round == 2 && below < above) |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2833 : (round == 1 && below <= above)) |
7 | 2834 { |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2835 // add a line below the cursor |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2836 if (boff.lnum < curbuf->b_ml.ml_line_count) |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2837 { |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2838 botline_forw(&boff); |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2839 used += boff.height; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2840 if (used > curwin->w_height) |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2841 { |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2842 done = TRUE; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2843 break; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2844 } |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2845 below += boff.height; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2846 } |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2847 else |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2848 { |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2849 ++below; // count a "~" line |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2850 if (atend) |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2851 ++used; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2852 } |
7 | 2853 } |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2854 |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2855 if (prefer_above ? (round == 1 && below >= above) |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2856 : (round == 1 && below > above)) |
7 | 2857 { |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2858 // add a line above the cursor |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2859 topline_back(&loff); |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2860 if (loff.height == MAXCOL) |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2861 used = MAXCOL; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2862 else |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2863 used += loff.height; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2864 if (used > curwin->w_height) |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2865 { |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2866 done = TRUE; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2867 break; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2868 } |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2869 above += loff.height; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2870 topline = loff.lnum; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2871 #ifdef FEAT_DIFF |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2872 topfill = loff.fill; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2873 #endif |
7 | 2874 } |
2875 } | |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2876 if (done) |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2877 break; |
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31829
diff
changeset
|
2878 } |
7 | 2879 |
2880 #ifdef FEAT_FOLDING | |
2881 if (!hasFolding(topline, &curwin->w_topline, NULL)) | |
2882 #endif | |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2883 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2884 if (curwin->w_topline != topline |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2885 || skipcol != 0 |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2886 || curwin->w_skipcol != 0) |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2887 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2888 curwin->w_topline = topline; |
32387
1ddef52ea786
patch 9.0.1525: 'smoothscroll' does not always work properly
Bram Moolenaar <Bram@vim.org>
parents:
32361
diff
changeset
|
2889 if (skipcol != 0) |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2890 { |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2891 curwin->w_skipcol = skipcol; |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2892 redraw_later(UPD_NOT_VALID); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2893 } |
32421
603b6dcf5f9a
patch 9.0.1542: line not fully displayed if it doesn't fit in the screen
Bram Moolenaar <Bram@vim.org>
parents:
32397
diff
changeset
|
2894 else if (do_sms) |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2895 reset_skipcol(); |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2896 } |
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31479
diff
changeset
|
2897 } |
7 | 2898 #ifdef FEAT_DIFF |
2899 curwin->w_topfill = topfill; | |
5653 | 2900 if (old_topline > curwin->w_topline + curwin->w_height) |
2901 curwin->w_botfill = FALSE; | |
7 | 2902 check_topfill(curwin, FALSE); |
2903 #endif | |
2904 curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP); | |
2905 curwin->w_valid |= VALID_TOPLINE; | |
2906 } | |
2907 | |
2908 /* | |
2909 * Correct the cursor position so that it is in a part of the screen at least | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2910 * 'scrolloff' lines from the top and bottom, if possible. |
7 | 2911 * If not possible, put it at the same position as scroll_cursor_halfway(). |
2912 * When called topline must be valid! | |
2913 */ | |
2914 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2915 cursor_correct(void) |
7 | 2916 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2917 int above = 0; // screen lines above topline |
7 | 2918 linenr_T topline; |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2919 int below = 0; // screen lines below botline |
7 | 2920 linenr_T botline; |
2921 int above_wanted, below_wanted; | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2922 linenr_T cln; // Cursor Line Number |
7 | 2923 int max_off; |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28782
diff
changeset
|
2924 long so = get_scrolloff_value(); |
7 | 2925 |
2926 /* | |
2927 * How many lines we would like to have above/below the cursor depends on | |
2928 * whether the first/last line of the file is on screen. | |
2929 */ | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2930 above_wanted = so; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2931 below_wanted = so; |
1121 | 2932 if (mouse_dragging > 0) |
7 | 2933 { |
2934 above_wanted = mouse_dragging - 1; | |
2935 below_wanted = mouse_dragging - 1; | |
2936 } | |
2937 if (curwin->w_topline == 1) | |
2938 { | |
2939 above_wanted = 0; | |
2940 max_off = curwin->w_height / 2; | |
2941 if (below_wanted > max_off) | |
2942 below_wanted = max_off; | |
2943 } | |
2944 validate_botline(); | |
2945 if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1 | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
17863
diff
changeset
|
2946 && mouse_dragging == 0) |
7 | 2947 { |
2948 below_wanted = 0; | |
2949 max_off = (curwin->w_height - 1) / 2; | |
2950 if (above_wanted > max_off) | |
2951 above_wanted = max_off; | |
2952 } | |
2953 | |
2954 /* | |
2955 * If there are sufficient file-lines above and below the cursor, we can | |
2956 * return now. | |
2957 */ | |
2958 cln = curwin->w_cursor.lnum; | |
2959 if (cln >= curwin->w_topline + above_wanted | |
2960 && cln < curwin->w_botline - below_wanted | |
2961 #ifdef FEAT_FOLDING | |
2962 && !hasAnyFolding(curwin) | |
2963 #endif | |
2964 ) | |
2965 return; | |
2966 | |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2967 if (curwin->w_p_sms && !curwin->w_p_wrap) |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2968 { |
32361
9ac987a467d5
patch 9.0.1512: inserting lines when scrolling with 'smoothscroll' set
Bram Moolenaar <Bram@vim.org>
parents:
32208
diff
changeset
|
2969 // 'smoothscroll' is active |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2970 if (curwin->w_cline_height == curwin->w_height) |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2971 { |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2972 // The cursor line just fits in the window, don't scroll. |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
30946
diff
changeset
|
2973 reset_skipcol(); |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2974 return; |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2975 } |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2976 // TODO: If the cursor line doesn't fit in the window then only adjust |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2977 // w_skipcol. |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2978 } |
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30823
diff
changeset
|
2979 |
7 | 2980 /* |
2981 * Narrow down the area where the cursor can be put by taking lines from | |
2982 * the top and the bottom until: | |
2983 * - the desired context lines are found | |
2984 * - the lines from the top is past the lines from the bottom | |
2985 */ | |
2986 topline = curwin->w_topline; | |
2987 botline = curwin->w_botline - 1; | |
2988 #ifdef FEAT_DIFF | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
2989 // count filler lines as context |
7 | 2990 above = curwin->w_topfill; |
2991 below = curwin->w_filler_rows; | |
2992 #endif | |
2993 while ((above < above_wanted || below < below_wanted) && topline < botline) | |
2994 { | |
2995 if (below < below_wanted && (below <= above || above >= above_wanted)) | |
2996 { | |
2997 #ifdef FEAT_FOLDING | |
2998 if (hasFolding(botline, &botline, NULL)) | |
2999 ++below; | |
3000 else | |
3001 #endif | |
3002 below += plines(botline); | |
3003 --botline; | |
3004 } | |
3005 if (above < above_wanted && (above < below || below >= below_wanted)) | |
3006 { | |
3007 #ifdef FEAT_FOLDING | |
3008 if (hasFolding(topline, NULL, &topline)) | |
3009 ++above; | |
3010 else | |
3011 #endif | |
7103
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
7088
diff
changeset
|
3012 above += PLINES_NOFILL(topline); |
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
7088
diff
changeset
|
3013 #ifdef FEAT_DIFF |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3014 // Count filler lines below this line as context. |
7 | 3015 if (topline < botline) |
3016 above += diff_check_fill(curwin, topline + 1); | |
3017 #endif | |
3018 ++topline; | |
3019 } | |
3020 } | |
3021 if (topline == botline || botline == 0) | |
3022 curwin->w_cursor.lnum = topline; | |
3023 else if (topline > botline) | |
3024 curwin->w_cursor.lnum = botline; | |
3025 else | |
3026 { | |
3027 if (cln < topline && curwin->w_topline > 1) | |
3028 { | |
3029 curwin->w_cursor.lnum = topline; | |
3030 curwin->w_valid &= | |
3031 ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW); | |
3032 } | |
3033 if (cln > botline && curwin->w_botline <= curbuf->b_ml.ml_line_count) | |
3034 { | |
3035 curwin->w_cursor.lnum = botline; | |
3036 curwin->w_valid &= | |
3037 ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW); | |
3038 } | |
3039 } | |
3040 curwin->w_valid |= VALID_TOPLINE; | |
3041 } | |
3042 | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
3043 static void get_scroll_overlap(lineoff_T *lp, int dir); |
7 | 3044 |
3045 /* | |
31140
a52697bcffa6
patch 9.0.0904: various comment and indent flaws
Bram Moolenaar <Bram@vim.org>
parents:
31131
diff
changeset
|
3046 * Move screen "count" pages up ("dir" is BACKWARD) or down ("dir" is FORWARD) |
a52697bcffa6
patch 9.0.0904: various comment and indent flaws
Bram Moolenaar <Bram@vim.org>
parents:
31131
diff
changeset
|
3047 * and update the screen. |
7 | 3048 * |
31131
8de082110e2d
patch 9.0.0900: cursor moves too far with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
31117
diff
changeset
|
3049 * Return FAIL for failure, OK otherwise. |
7 | 3050 */ |
3051 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3052 onepage(int dir, long count) |
7 | 3053 { |
3054 long n; | |
3055 int retval = OK; | |
3056 lineoff_T loff; | |
3057 linenr_T old_topline = curwin->w_topline; | |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28782
diff
changeset
|
3058 long so = get_scrolloff_value(); |
7 | 3059 |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3060 if (curbuf->b_ml.ml_line_count == 1) // nothing to do |
7 | 3061 { |
3062 beep_flush(); | |
3063 return FAIL; | |
3064 } | |
3065 | |
3066 for ( ; count > 0; --count) | |
3067 { | |
3068 validate_botline(); | |
3069 /* | |
3070 * It's an error to move a page up when the first line is already on | |
3071 * the screen. It's an error to move a page down when the last line | |
3072 * is on the screen and the topline is 'scrolloff' lines from the | |
3073 * last line. | |
3074 */ | |
3075 if (dir == FORWARD | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
3076 ? ((curwin->w_topline >= curbuf->b_ml.ml_line_count - so) |
7 | 3077 && curwin->w_botline > curbuf->b_ml.ml_line_count) |
3078 : (curwin->w_topline == 1 | |
3079 #ifdef FEAT_DIFF | |
3080 && curwin->w_topfill == | |
3081 diff_check_fill(curwin, curwin->w_topline) | |
3082 #endif | |
3083 )) | |
3084 { | |
3085 beep_flush(); | |
3086 retval = FAIL; | |
3087 break; | |
3088 } | |
3089 | |
3090 #ifdef FEAT_DIFF | |
3091 loff.fill = 0; | |
3092 #endif | |
3093 if (dir == FORWARD) | |
3094 { | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10295
diff
changeset
|
3095 if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1) |
7 | 3096 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3097 // Vi compatible scrolling |
164 | 3098 if (p_window <= 2) |
3099 ++curwin->w_topline; | |
3100 else | |
3101 curwin->w_topline += p_window - 2; | |
3102 if (curwin->w_topline > curbuf->b_ml.ml_line_count) | |
3103 curwin->w_topline = curbuf->b_ml.ml_line_count; | |
3104 curwin->w_cursor.lnum = curwin->w_topline; | |
3105 } | |
3106 else if (curwin->w_botline > curbuf->b_ml.ml_line_count) | |
3107 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3108 // at end of file |
7 | 3109 curwin->w_topline = curbuf->b_ml.ml_line_count; |
3110 #ifdef FEAT_DIFF | |
3111 curwin->w_topfill = 0; | |
3112 #endif | |
3113 curwin->w_valid &= ~(VALID_WROW|VALID_CROW); | |
3114 } | |
3115 else | |
3116 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3117 // For the overlap, start with the line just below the window |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3118 // and go upwards. |
7 | 3119 loff.lnum = curwin->w_botline; |
3120 #ifdef FEAT_DIFF | |
3121 loff.fill = diff_check_fill(curwin, loff.lnum) | |
3122 - curwin->w_filler_rows; | |
3123 #endif | |
3124 get_scroll_overlap(&loff, -1); | |
3125 curwin->w_topline = loff.lnum; | |
3126 #ifdef FEAT_DIFF | |
3127 curwin->w_topfill = loff.fill; | |
3128 check_topfill(curwin, FALSE); | |
3129 #endif | |
3130 curwin->w_cursor.lnum = curwin->w_topline; | |
3131 curwin->w_valid &= ~(VALID_WCOL|VALID_CHEIGHT|VALID_WROW| | |
3132 VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP); | |
3133 } | |
3134 } | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3135 else // dir == BACKWARDS |
7 | 3136 { |
3137 #ifdef FEAT_DIFF | |
3138 if (curwin->w_topline == 1) | |
3139 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3140 // Include max number of filler lines |
7 | 3141 max_topfill(); |
3142 continue; | |
3143 } | |
3144 #endif | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10295
diff
changeset
|
3145 if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1) |
164 | 3146 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3147 // Vi compatible scrolling (sort of) |
164 | 3148 if (p_window <= 2) |
3149 --curwin->w_topline; | |
3150 else | |
3151 curwin->w_topline -= p_window - 2; | |
3152 if (curwin->w_topline < 1) | |
3153 curwin->w_topline = 1; | |
3154 curwin->w_cursor.lnum = curwin->w_topline + p_window - 1; | |
3155 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
3156 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
3157 continue; | |
3158 } | |
3159 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3160 // Find the line at the top of the window that is going to be the |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3161 // line at the bottom of the window. Make sure this results in |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3162 // the same line as before doing CTRL-F. |
7 | 3163 loff.lnum = curwin->w_topline - 1; |
3164 #ifdef FEAT_DIFF | |
3165 loff.fill = diff_check_fill(curwin, loff.lnum + 1) | |
3166 - curwin->w_topfill; | |
3167 #endif | |
3168 get_scroll_overlap(&loff, 1); | |
3169 | |
3170 if (loff.lnum >= curbuf->b_ml.ml_line_count) | |
3171 { | |
3172 loff.lnum = curbuf->b_ml.ml_line_count; | |
3173 #ifdef FEAT_DIFF | |
3174 loff.fill = 0; | |
3175 } | |
3176 else | |
3177 { | |
3178 botline_topline(&loff); | |
3179 #endif | |
3180 } | |
3181 curwin->w_cursor.lnum = loff.lnum; | |
3182 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3183 // Find the line just above the new topline to get the right line |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3184 // at the bottom of the window. |
7 | 3185 n = 0; |
3186 while (n <= curwin->w_height && loff.lnum >= 1) | |
3187 { | |
3188 topline_back(&loff); | |
2082
8ca3c9ad0bee
updated for version 7.2.366
Bram Moolenaar <bram@zimbu.org>
parents:
2070
diff
changeset
|
3189 if (loff.height == MAXCOL) |
8ca3c9ad0bee
updated for version 7.2.366
Bram Moolenaar <bram@zimbu.org>
parents:
2070
diff
changeset
|
3190 n = MAXCOL; |
8ca3c9ad0bee
updated for version 7.2.366
Bram Moolenaar <bram@zimbu.org>
parents:
2070
diff
changeset
|
3191 else |
8ca3c9ad0bee
updated for version 7.2.366
Bram Moolenaar <bram@zimbu.org>
parents:
2070
diff
changeset
|
3192 n += loff.height; |
7 | 3193 } |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3194 if (loff.lnum < 1) // at begin of file |
7 | 3195 { |
3196 curwin->w_topline = 1; | |
3197 #ifdef FEAT_DIFF | |
3198 max_topfill(); | |
3199 #endif | |
3200 curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE); | |
3201 } | |
3202 else | |
3203 { | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3204 // Go two lines forward again. |
7 | 3205 #ifdef FEAT_DIFF |
3206 topline_botline(&loff); | |
3207 #endif | |
3208 botline_forw(&loff); | |
3209 botline_forw(&loff); | |
3210 #ifdef FEAT_DIFF | |
3211 botline_topline(&loff); | |
3212 #endif | |
3213 #ifdef FEAT_FOLDING | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3214 // We're at the wrong end of a fold now. |
7 | 3215 (void)hasFolding(loff.lnum, &loff.lnum, NULL); |
3216 #endif | |
3217 | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3218 // Always scroll at least one line. Avoid getting stuck on |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3219 // very long lines. |
7 | 3220 if (loff.lnum >= curwin->w_topline |
3221 #ifdef FEAT_DIFF | |
3222 && (loff.lnum > curwin->w_topline | |
3223 || loff.fill >= curwin->w_topfill) | |
3224 #endif | |
3225 ) | |
3226 { | |
3227 #ifdef FEAT_DIFF | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3228 // First try using the maximum number of filler lines. If |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3229 // that's not enough, backup one line. |
7 | 3230 loff.fill = curwin->w_topfill; |
3231 if (curwin->w_topfill < diff_check_fill(curwin, | |
3232 curwin->w_topline)) | |
3233 max_topfill(); | |
3234 if (curwin->w_topfill == loff.fill) | |
3235 #endif | |
3236 { | |
3237 --curwin->w_topline; | |
3238 #ifdef FEAT_DIFF | |
3239 curwin->w_topfill = 0; | |
3240 #endif | |
3241 } | |
3242 comp_botline(curwin); | |
3243 curwin->w_cursor.lnum = curwin->w_botline - 1; | |
5764 | 3244 curwin->w_valid &= |
3245 ~(VALID_WCOL|VALID_CHEIGHT|VALID_WROW|VALID_CROW); | |
7 | 3246 } |
3247 else | |
3248 { | |
3249 curwin->w_topline = loff.lnum; | |
3250 #ifdef FEAT_DIFF | |
3251 curwin->w_topfill = loff.fill; | |
3252 check_topfill(curwin, FALSE); | |
3253 #endif | |
3254 curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE); | |
3255 } | |
3256 } | |
3257 } | |
3258 } | |
3259 #ifdef FEAT_FOLDING | |
3260 foldAdjustCursor(); | |
3261 #endif | |
3262 cursor_correct(); | |
10102
b80ad55d62d8
commit https://github.com/vim/vim/commit/bc54f3f3fed4dc3556df8c46cee6739d211b0eb2
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
3263 check_cursor_col(); |
161 | 3264 if (retval == OK) |
3265 beginline(BL_SOL | BL_FIX); | |
7 | 3266 curwin->w_valid &= ~(VALID_WCOL|VALID_WROW|VALID_VIRTCOL); |
3267 | |
14317
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3268 if (retval == OK && dir == FORWARD) |
7 | 3269 { |
14317
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3270 // Avoid the screen jumping up and down when 'scrolloff' is non-zero. |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3271 // But make sure we scroll at least one line (happens with mix of long |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3272 // wrapping lines and non-wrapping line). |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3273 if (check_top_offset()) |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3274 { |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3275 scroll_cursor_top(1, FALSE); |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3276 if (curwin->w_topline <= old_topline |
7 | 3277 && old_topline < curbuf->b_ml.ml_line_count) |
14317
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3278 { |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3279 curwin->w_topline = old_topline + 1; |
7 | 3280 #ifdef FEAT_FOLDING |
14317
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3281 (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3282 #endif |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3283 } |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3284 } |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3285 #ifdef FEAT_FOLDING |
1bc96dbb5498
patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
3286 else if (curwin->w_botline > curbuf->b_ml.ml_line_count) |
7 | 3287 (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); |
3288 #endif | |
3289 } | |
3290 | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
3291 redraw_later(UPD_VALID); |
7 | 3292 return retval; |
3293 } | |
3294 | |
3295 /* | |
3296 * Decide how much overlap to use for page-up or page-down scrolling. | |
3297 * This is symmetric, so that doing both keeps the same lines displayed. | |
3298 * Three lines are examined: | |
3299 * | |
3300 * before CTRL-F after CTRL-F / before CTRL-B | |
3301 * etc. l1 | |
3302 * l1 last but one line ------------ | |
3303 * l2 last text line l2 top text line | |
3304 * ------------- l3 second text line | |
3305 * l3 etc. | |
3306 */ | |
3307 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3308 get_scroll_overlap(lineoff_T *lp, int dir) |
7 | 3309 { |
3310 int h1, h2, h3, h4; | |
3311 int min_height = curwin->w_height - 2; | |
3312 lineoff_T loff0, loff1, loff2; | |
3313 | |
3314 #ifdef FEAT_DIFF | |
3315 if (lp->fill > 0) | |
3316 lp->height = 1; | |
3317 else | |
3318 lp->height = plines_nofill(lp->lnum); | |
3319 #else | |
3320 lp->height = plines(lp->lnum); | |
3321 #endif | |
3322 h1 = lp->height; | |
3323 if (h1 > min_height) | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3324 return; // no overlap |
7 | 3325 |
3326 loff0 = *lp; | |
3327 if (dir > 0) | |
3328 botline_forw(lp); | |
3329 else | |
3330 topline_back(lp); | |
3331 h2 = lp->height; | |
3968 | 3332 if (h2 == MAXCOL || h2 + h1 > min_height) |
7 | 3333 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3334 *lp = loff0; // no overlap |
7 | 3335 return; |
3336 } | |
3337 | |
3338 loff1 = *lp; | |
3339 if (dir > 0) | |
3340 botline_forw(lp); | |
3341 else | |
3342 topline_back(lp); | |
3343 h3 = lp->height; | |
3968 | 3344 if (h3 == MAXCOL || h3 + h2 > min_height) |
7 | 3345 { |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3346 *lp = loff0; // no overlap |
7 | 3347 return; |
3348 } | |
3349 | |
3350 loff2 = *lp; | |
3351 if (dir > 0) | |
3352 botline_forw(lp); | |
3353 else | |
3354 topline_back(lp); | |
3355 h4 = lp->height; | |
3968 | 3356 if (h4 == MAXCOL || h4 + h3 + h2 > min_height || h3 + h2 + h1 > min_height) |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3357 *lp = loff1; // 1 line overlap |
7 | 3358 else |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3359 *lp = loff2; // 2 lines overlap |
7 | 3360 } |
3361 | |
3362 /* | |
3363 * Scroll 'scroll' lines up or down. | |
3364 */ | |
3365 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3366 halfpage(int flag, linenr_T Prenum) |
7 | 3367 { |
3368 long scrolled = 0; | |
3369 int i; | |
3370 int n; | |
3371 int room; | |
3372 | |
3373 if (Prenum) | |
3374 curwin->w_p_scr = (Prenum > curwin->w_height) ? | |
3375 curwin->w_height : Prenum; | |
3376 n = (curwin->w_p_scr <= curwin->w_height) ? | |
3377 curwin->w_p_scr : curwin->w_height; | |
3378 | |
11258
84f71a8a5f2c
patch 8.0.0515: ml_get errors in silent Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
3379 update_topline(); |
7 | 3380 validate_botline(); |
3381 room = curwin->w_empty_rows; | |
3382 #ifdef FEAT_DIFF | |
3383 room += curwin->w_filler_rows; | |
3384 #endif | |
3385 if (flag) | |
3386 { | |
3387 /* | |
3388 * scroll the text up | |
3389 */ | |
3390 while (n > 0 && curwin->w_botline <= curbuf->b_ml.ml_line_count) | |
3391 { | |
3392 #ifdef FEAT_DIFF | |
3393 if (curwin->w_topfill > 0) | |
3394 { | |
3395 i = 1; | |
21321
1421eca61db9
patch 8.2.1211: removed more than dead code
Bram Moolenaar <Bram@vim.org>
parents:
21134
diff
changeset
|
3396 --n; |
7 | 3397 --curwin->w_topfill; |
3398 } | |
3399 else | |
3400 #endif | |
3401 { | |
7103
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
7088
diff
changeset
|
3402 i = PLINES_NOFILL(curwin->w_topline); |
7 | 3403 n -= i; |
3404 if (n < 0 && scrolled > 0) | |
3405 break; | |
3406 #ifdef FEAT_FOLDING | |
3407 (void)hasFolding(curwin->w_topline, NULL, &curwin->w_topline); | |
3408 #endif | |
3409 ++curwin->w_topline; | |
3410 #ifdef FEAT_DIFF | |
3411 curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline); | |
3412 #endif | |
3413 | |
3414 if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
3415 { | |
3416 ++curwin->w_cursor.lnum; | |
3417 curwin->w_valid &= | |
3418 ~(VALID_VIRTCOL|VALID_CHEIGHT|VALID_WCOL); | |
3419 } | |
3420 } | |
3421 curwin->w_valid &= ~(VALID_CROW|VALID_WROW); | |
3422 scrolled += i; | |
3423 | |
3424 /* | |
3425 * Correct w_botline for changed w_topline. | |
3426 * Won't work when there are filler lines. | |
3427 */ | |
3428 #ifdef FEAT_DIFF | |
3429 if (curwin->w_p_diff) | |
3430 curwin->w_valid &= ~(VALID_BOTLINE|VALID_BOTLINE_AP); | |
3431 else | |
3432 #endif | |
3433 { | |
3434 room += i; | |
3435 do | |
3436 { | |
3437 i = plines(curwin->w_botline); | |
3438 if (i > room) | |
3439 break; | |
3440 #ifdef FEAT_FOLDING | |
3441 (void)hasFolding(curwin->w_botline, NULL, | |
3442 &curwin->w_botline); | |
3443 #endif | |
3444 ++curwin->w_botline; | |
3445 room -= i; | |
3446 } while (curwin->w_botline <= curbuf->b_ml.ml_line_count); | |
3447 } | |
3448 } | |
3449 | |
3450 /* | |
3451 * When hit bottom of the file: move cursor down. | |
3452 */ | |
3453 if (n > 0) | |
3454 { | |
3455 # ifdef FEAT_FOLDING | |
3456 if (hasAnyFolding(curwin)) | |
3457 { | |
3458 while (--n >= 0 | |
3459 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
3460 { | |
3461 (void)hasFolding(curwin->w_cursor.lnum, NULL, | |
3462 &curwin->w_cursor.lnum); | |
3463 ++curwin->w_cursor.lnum; | |
3464 } | |
3465 } | |
3466 else | |
3467 # endif | |
3468 curwin->w_cursor.lnum += n; | |
3469 check_cursor_lnum(); | |
3470 } | |
3471 } | |
3472 else | |
3473 { | |
3474 /* | |
3475 * scroll the text down | |
3476 */ | |
3477 while (n > 0 && curwin->w_topline > 1) | |
3478 { | |
3479 #ifdef FEAT_DIFF | |
3480 if (curwin->w_topfill < diff_check_fill(curwin, curwin->w_topline)) | |
3481 { | |
3482 i = 1; | |
16042
7952be788a49
patch 8.1.1026: unused condition
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
3483 --n; |
7 | 3484 ++curwin->w_topfill; |
3485 } | |
3486 else | |
3487 #endif | |
3488 { | |
7103
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
7088
diff
changeset
|
3489 i = PLINES_NOFILL(curwin->w_topline - 1); |
7 | 3490 n -= i; |
3491 if (n < 0 && scrolled > 0) | |
3492 break; | |
3493 --curwin->w_topline; | |
3494 #ifdef FEAT_FOLDING | |
3495 (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); | |
3496 #endif | |
3497 #ifdef FEAT_DIFF | |
3498 curwin->w_topfill = 0; | |
3499 #endif | |
3500 } | |
3501 curwin->w_valid &= ~(VALID_CROW|VALID_WROW| | |
3502 VALID_BOTLINE|VALID_BOTLINE_AP); | |
3503 scrolled += i; | |
3504 if (curwin->w_cursor.lnum > 1) | |
3505 { | |
3506 --curwin->w_cursor.lnum; | |
3507 curwin->w_valid &= ~(VALID_VIRTCOL|VALID_CHEIGHT|VALID_WCOL); | |
3508 } | |
3509 } | |
16042
7952be788a49
patch 8.1.1026: unused condition
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
3510 |
7 | 3511 /* |
3512 * When hit top of the file: move cursor up. | |
3513 */ | |
3514 if (n > 0) | |
3515 { | |
3516 if (curwin->w_cursor.lnum <= (linenr_T)n) | |
3517 curwin->w_cursor.lnum = 1; | |
3518 else | |
3519 # ifdef FEAT_FOLDING | |
3520 if (hasAnyFolding(curwin)) | |
3521 { | |
3522 while (--n >= 0 && curwin->w_cursor.lnum > 1) | |
3523 { | |
3524 --curwin->w_cursor.lnum; | |
3525 (void)hasFolding(curwin->w_cursor.lnum, | |
3526 &curwin->w_cursor.lnum, NULL); | |
3527 } | |
3528 } | |
3529 else | |
3530 # endif | |
3531 curwin->w_cursor.lnum -= n; | |
3532 } | |
3533 } | |
3534 # ifdef FEAT_FOLDING | |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3535 // Move cursor to first line of closed fold. |
7 | 3536 foldAdjustCursor(); |
3537 # endif | |
3538 #ifdef FEAT_DIFF | |
3539 check_topfill(curwin, !flag); | |
3540 #endif | |
3541 cursor_correct(); | |
3542 beginline(BL_SOL | BL_FIX); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
3543 redraw_later(UPD_VALID); |
7 | 3544 } |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3545 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3546 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3547 do_check_cursorbind(void) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3548 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3549 linenr_T line = curwin->w_cursor.lnum; |
3415 | 3550 colnr_T col = curwin->w_cursor.col; |
3551 colnr_T coladd = curwin->w_cursor.coladd; | |
3433 | 3552 colnr_T curswant = curwin->w_curswant; |
3553 int set_curswant = curwin->w_set_curswant; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3554 win_T *old_curwin = curwin; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3555 buf_T *old_curbuf = curbuf; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3556 int old_VIsual_select = VIsual_select; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3557 int old_VIsual_active = VIsual_active; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3558 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3559 /* |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3560 * loop through the cursorbound windows |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3561 */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3562 VIsual_select = VIsual_active = 0; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3563 FOR_ALL_WINDOWS(curwin) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3564 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3565 curbuf = curwin->w_buffer; |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3566 // skip original window and windows with 'noscrollbind' |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3567 if (curwin != old_curwin && curwin->w_p_crb) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3568 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3569 # ifdef FEAT_DIFF |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3570 if (curwin->w_p_diff) |
10295
d0b74b18e4b5
commit https://github.com/vim/vim/commit/025e3e0bafbc85cc4e365145af711edf99d0a90d
Christian Brabandt <cb@256bit.org>
parents:
10102
diff
changeset
|
3571 curwin->w_cursor.lnum = |
d0b74b18e4b5
commit https://github.com/vim/vim/commit/025e3e0bafbc85cc4e365145af711edf99d0a90d
Christian Brabandt <cb@256bit.org>
parents:
10102
diff
changeset
|
3572 diff_get_corresponding_line(old_curbuf, line); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3573 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3574 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3575 curwin->w_cursor.lnum = line; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3576 curwin->w_cursor.col = col; |
3415 | 3577 curwin->w_cursor.coladd = coladd; |
3433 | 3578 curwin->w_curswant = curswant; |
3579 curwin->w_set_curswant = set_curswant; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3580 |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3581 // Make sure the cursor is in a valid position. Temporarily set |
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3582 // "restart_edit" to allow the cursor to be beyond the EOL. |
32144
f3987fde6dea
patch 9.0.1403: unused variables and functions
Bram Moolenaar <Bram@vim.org>
parents:
32072
diff
changeset
|
3583 int restart_edit_save = restart_edit; |
f3987fde6dea
patch 9.0.1403: unused variables and functions
Bram Moolenaar <Bram@vim.org>
parents:
32072
diff
changeset
|
3584 restart_edit = 'a'; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3585 check_cursor(); |
29275
281509f1417b
patch 8.2.5155: in diff mode windows may get out of sync
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
3586 |
281509f1417b
patch 8.2.5155: in diff mode windows may get out of sync
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
3587 // Avoid a scroll here for the cursor position, 'scrollbind' is |
281509f1417b
patch 8.2.5155: in diff mode windows may get out of sync
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
3588 // more important. |
281509f1417b
patch 8.2.5155: in diff mode windows may get out of sync
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
3589 if (!curwin->w_p_scb) |
281509f1417b
patch 8.2.5155: in diff mode windows may get out of sync
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
3590 validate_cursor(); |
281509f1417b
patch 8.2.5155: in diff mode windows may get out of sync
Bram Moolenaar <Bram@vim.org>
parents:
29239
diff
changeset
|
3591 |
2693 | 3592 restart_edit = restart_edit_save; |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3593 // Correct cursor for multi-byte character. |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3594 if (has_mbyte) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3595 mb_adjust_cursor(); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29708
diff
changeset
|
3596 redraw_later(UPD_VALID); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3597 |
18931
80b40bd5ec1a
patch 8.2.0026: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
3598 // Only scroll when 'scrollbind' hasn't done this. |
2688 | 3599 if (!curwin->w_p_scb) |
3600 update_topline(); | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3601 curwin->w_redr_status = TRUE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3602 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3603 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3604 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3605 /* |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3606 * reset current-window |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3607 */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3608 VIsual_select = old_VIsual_select; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3609 VIsual_active = old_VIsual_active; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3610 curwin = old_curwin; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3611 curbuf = old_curbuf; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3612 } |