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