Mercurial > vim
annotate src/screen.c @ 5539:62c720661f81 v7.4.118
updated for version 7.4.118
Problem: It's possible that redrawing the status lines causes
win_redr_custom() to be called recursively.
Solution: Protect against recursiveness. (Yasuhiro Matsumoto)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 11 Dec 2013 15:52:01 +0100 |
parents | 6ae816249627 |
children | 50dbef5e774a |
rev | line source |
---|---|
7 | 1 /* vi:set ts=8 sts=4 sw=4: |
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 /* | |
11 * screen.c: code for displaying on the screen | |
12 * | |
13 * Output to the screen (console, terminal emulator or GUI window) is minimized | |
14 * by remembering what is already on the screen, and only updating the parts | |
15 * that changed. | |
16 * | |
17 * ScreenLines[off] Contains a copy of the whole screen, as it is currently | |
18 * displayed (excluding text written by external commands). | |
19 * ScreenAttrs[off] Contains the associated attributes. | |
20 * LineOffset[row] Contains the offset into ScreenLines*[] and ScreenAttrs[] | |
21 * for each line. | |
22 * LineWraps[row] Flag for each line whether it wraps to the next line. | |
23 * | |
24 * For double-byte characters, two consecutive bytes in ScreenLines[] can form | |
25 * one character which occupies two display cells. | |
26 * For UTF-8 a multi-byte character is converted to Unicode and stored in | |
27 * ScreenLinesUC[]. ScreenLines[] contains the first byte only. For an ASCII | |
2124
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
28 * character without composing chars ScreenLinesUC[] will be 0 and |
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
29 * ScreenLinesC[][] is not used. When the character occupies two display |
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
30 * cells the next byte in ScreenLines[] is 0. |
714 | 31 * ScreenLinesC[][] contain up to 'maxcombine' composing characters |
2124
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
32 * (drawn on top of the first character). There is 0 after the last one used. |
7 | 33 * ScreenLines2[] is only used for euc-jp to store the second byte if the |
34 * first byte is 0x8e (single-width character). | |
35 * | |
36 * The screen_*() functions write to the screen and handle updating | |
37 * ScreenLines[]. | |
38 * | |
39 * update_screen() is the function that updates all windows and status lines. | |
40 * It is called form the main loop when must_redraw is non-zero. It may be | |
1213 | 41 * called from other places when an immediate screen update is needed. |
7 | 42 * |
43 * The part of the buffer that is displayed in a window is set with: | |
44 * - w_topline (first buffer line in window) | |
45 * - w_topfill (filler line above the first line) | |
46 * - w_leftcol (leftmost window cell in window), | |
47 * - w_skipcol (skipped window cells of first line) | |
48 * | |
49 * Commands that only move the cursor around in a window, do not need to take | |
50 * action to update the display. The main loop will check if w_topline is | |
51 * valid and update it (scroll the window) when needed. | |
52 * | |
53 * Commands that scroll a window change w_topline and must call | |
54 * check_cursor() to move the cursor into the visible part of the window, and | |
55 * call redraw_later(VALID) to have the window displayed by update_screen() | |
56 * later. | |
57 * | |
58 * Commands that change text in the buffer must call changed_bytes() or | |
59 * changed_lines() to mark the area that changed and will require updating | |
60 * later. The main loop will call update_screen(), which will update each | |
61 * window that shows the changed buffer. This assumes text above the change | |
62 * can remain displayed as it is. Text after the change may need updating for | |
63 * scrolling, folding and syntax highlighting. | |
64 * | |
65 * Commands that change how a window is displayed (e.g., setting 'list') or | |
66 * invalidate the contents of a window in another way (e.g., change fold | |
67 * settings), must call redraw_later(NOT_VALID) to have the whole window | |
68 * redisplayed by update_screen() later. | |
69 * | |
70 * Commands that change how a buffer is displayed (e.g., setting 'tabstop') | |
71 * must call redraw_curbuf_later(NOT_VALID) to have all the windows for the | |
72 * buffer redisplayed by update_screen() later. | |
73 * | |
743 | 74 * Commands that change highlighting and possibly cause a scroll too must call |
75 * redraw_later(SOME_VALID) to update the whole window but still use scrolling | |
76 * to avoid redrawing everything. But the length of displayed lines must not | |
77 * change, use NOT_VALID then. | |
78 * | |
7 | 79 * Commands that move the window position must call redraw_later(NOT_VALID). |
80 * TODO: should minimize redrawing by scrolling when possible. | |
81 * | |
82 * Commands that change everything (e.g., resizing the screen) must call | |
83 * redraw_all_later(NOT_VALID) or redraw_all_later(CLEAR). | |
84 * | |
85 * Things that are handled indirectly: | |
86 * - When messages scroll the screen up, msg_scrolled will be set and | |
87 * update_screen() called to redraw. | |
88 */ | |
89 | |
90 #include "vim.h" | |
91 | |
3586 | 92 #define MB_FILLER_CHAR '<' /* character used when a double-width character |
93 * doesn't fit. */ | |
94 | |
7 | 95 /* |
96 * The attributes that are actually active for writing to the screen. | |
97 */ | |
98 static int screen_attr = 0; | |
99 | |
100 /* | |
101 * Positioning the cursor is reduced by remembering the last position. | |
102 * Mostly used by windgoto() and screen_char(). | |
103 */ | |
104 static int screen_cur_row, screen_cur_col; /* last known cursor position */ | |
105 | |
106 #ifdef FEAT_SEARCH_EXTRA | |
107 static match_T search_hl; /* used for 'hlsearch' highlight matching */ | |
108 #endif | |
109 | |
110 #ifdef FEAT_FOLDING | |
111 static foldinfo_T win_foldinfo; /* info for 'foldcolumn' */ | |
112 #endif | |
113 | |
114 /* | |
115 * Buffer for one screen line (characters and attributes). | |
116 */ | |
117 static schar_T *current_ScreenLine; | |
118 | |
119 static void win_update __ARGS((win_T *wp)); | |
534 | 120 static void win_draw_end __ARGS((win_T *wp, int c1, int c2, int row, int endrow, hlf_T hl)); |
7 | 121 #ifdef FEAT_FOLDING |
122 static void fold_line __ARGS((win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T lnum, int row)); | |
123 static void fill_foldcolumn __ARGS((char_u *p, win_T *wp, int closed, linenr_T lnum)); | |
124 static void copy_text_attr __ARGS((int off, char_u *buf, int len, int attr)); | |
125 #endif | |
625 | 126 static int win_line __ARGS((win_T *, linenr_T, int, int, int nochange)); |
7 | 127 static int char_needs_redraw __ARGS((int off_from, int off_to, int cols)); |
128 #ifdef FEAT_RIGHTLEFT | |
129 static void screen_line __ARGS((int row, int coloff, int endcol, int clear_width, int rlflag)); | |
130 # define SCREEN_LINE(r, o, e, c, rl) screen_line((r), (o), (e), (c), (rl)) | |
131 #else | |
132 static void screen_line __ARGS((int row, int coloff, int endcol, int clear_width)); | |
133 # define SCREEN_LINE(r, o, e, c, rl) screen_line((r), (o), (e), (c)) | |
134 #endif | |
135 #ifdef FEAT_VERTSPLIT | |
136 static void draw_vsep_win __ARGS((win_T *wp, int row)); | |
137 #endif | |
680 | 138 #ifdef FEAT_STL_OPT |
1983 | 139 static void redraw_custom_statusline __ARGS((win_T *wp)); |
680 | 140 #endif |
7 | 141 #ifdef FEAT_SEARCH_EXTRA |
1326 | 142 #define SEARCH_HL_PRIORITY 0 |
7 | 143 static void start_search_hl __ARGS((void)); |
144 static void end_search_hl __ARGS((void)); | |
2284
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
145 static void init_search_hl __ARGS((win_T *wp)); |
7 | 146 static void prepare_search_hl __ARGS((win_T *wp, linenr_T lnum)); |
147 static void next_search_hl __ARGS((win_T *win, match_T *shl, linenr_T lnum, colnr_T mincol)); | |
148 #endif | |
149 static void screen_start_highlight __ARGS((int attr)); | |
150 static void screen_char __ARGS((unsigned off, int row, int col)); | |
151 #ifdef FEAT_MBYTE | |
152 static void screen_char_2 __ARGS((unsigned off, int row, int col)); | |
153 #endif | |
154 static void screenclear2 __ARGS((void)); | |
155 static void lineclear __ARGS((unsigned off, int width)); | |
156 static void lineinvalid __ARGS((unsigned off, int width)); | |
157 #ifdef FEAT_VERTSPLIT | |
158 static void linecopy __ARGS((int to, int from, win_T *wp)); | |
159 static void redraw_block __ARGS((int row, int end, win_T *wp)); | |
160 #endif | |
161 static int win_do_lines __ARGS((win_T *wp, int row, int line_count, int mayclear, int del)); | |
162 static void win_rest_invalid __ARGS((win_T *wp)); | |
163 static void msg_pos_mode __ARGS((void)); | |
667 | 164 #if defined(FEAT_WINDOWS) |
677 | 165 static void draw_tabline __ARGS((void)); |
667 | 166 #endif |
7 | 167 #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT) |
168 static int fillchar_status __ARGS((int *attr, int is_curwin)); | |
169 #endif | |
170 #ifdef FEAT_VERTSPLIT | |
171 static int fillchar_vsep __ARGS((int *attr)); | |
172 #endif | |
173 #ifdef FEAT_STL_OPT | |
574 | 174 static void win_redr_custom __ARGS((win_T *wp, int draw_ruler)); |
7 | 175 #endif |
176 #ifdef FEAT_CMDL_INFO | |
177 static void win_redr_ruler __ARGS((win_T *wp, int always)); | |
178 #endif | |
179 | |
180 #if defined(FEAT_CLIPBOARD) || defined(FEAT_VERTSPLIT) | |
181 /* Ugly global: overrule attribute used by screen_char() */ | |
182 static int screen_char_attr = 0; | |
183 #endif | |
184 | |
185 /* | |
186 * Redraw the current window later, with update_screen(type). | |
187 * Set must_redraw only if not already set to a higher value. | |
188 * e.g. if must_redraw is CLEAR, type NOT_VALID will do nothing. | |
189 */ | |
190 void | |
191 redraw_later(type) | |
192 int type; | |
193 { | |
194 redraw_win_later(curwin, type); | |
195 } | |
196 | |
197 void | |
198 redraw_win_later(wp, type) | |
199 win_T *wp; | |
200 int type; | |
201 { | |
202 if (wp->w_redr_type < type) | |
203 { | |
204 wp->w_redr_type = type; | |
205 if (type >= NOT_VALID) | |
206 wp->w_lines_valid = 0; | |
207 if (must_redraw < type) /* must_redraw is the maximum of all windows */ | |
208 must_redraw = type; | |
209 } | |
210 } | |
211 | |
212 /* | |
213 * Force a complete redraw later. Also resets the highlighting. To be used | |
214 * after executing a shell command that messes up the screen. | |
215 */ | |
216 void | |
217 redraw_later_clear() | |
218 { | |
219 redraw_all_later(CLEAR); | |
826 | 220 #ifdef FEAT_GUI |
221 if (gui.in_use) | |
222 /* Use a code that will reset gui.highlight_mask in | |
223 * gui_stop_highlight(). */ | |
224 screen_attr = HL_ALL + 1; | |
225 else | |
226 #endif | |
227 /* Use attributes that is very unlikely to appear in text. */ | |
228 screen_attr = HL_BOLD | HL_UNDERLINE | HL_INVERSE; | |
7 | 229 } |
230 | |
231 /* | |
232 * Mark all windows to be redrawn later. | |
233 */ | |
234 void | |
235 redraw_all_later(type) | |
236 int type; | |
237 { | |
238 win_T *wp; | |
239 | |
240 FOR_ALL_WINDOWS(wp) | |
241 { | |
242 redraw_win_later(wp, type); | |
243 } | |
244 } | |
245 | |
246 /* | |
301 | 247 * Mark all windows that are editing the current buffer to be updated later. |
7 | 248 */ |
249 void | |
250 redraw_curbuf_later(type) | |
251 int type; | |
252 { | |
253 redraw_buf_later(curbuf, type); | |
254 } | |
255 | |
256 void | |
257 redraw_buf_later(buf, type) | |
258 buf_T *buf; | |
259 int type; | |
260 { | |
261 win_T *wp; | |
262 | |
263 FOR_ALL_WINDOWS(wp) | |
264 { | |
265 if (wp->w_buffer == buf) | |
266 redraw_win_later(wp, type); | |
267 } | |
268 } | |
269 | |
270 /* | |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
271 * Redraw as soon as possible. When the command line is not scrolled redraw |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
272 * right away and restore what was on the command line. |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
273 * Return a code indicating what happened. |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
274 */ |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
275 int |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
276 redraw_asap(type) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
277 int type; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
278 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
279 int rows; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
280 int r; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
281 int ret = 0; |
5096
a6ddcab6a240
updated for version 7.3.1291
Bram Moolenaar <bram@vim.org>
parents:
5090
diff
changeset
|
282 schar_T *screenline; /* copy from ScreenLines[] */ |
a6ddcab6a240
updated for version 7.3.1291
Bram Moolenaar <bram@vim.org>
parents:
5090
diff
changeset
|
283 sattr_T *screenattr; /* copy from ScreenAttrs[] */ |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
284 #ifdef FEAT_MBYTE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
285 int i; |
5096
a6ddcab6a240
updated for version 7.3.1291
Bram Moolenaar <bram@vim.org>
parents:
5090
diff
changeset
|
286 u8char_T *screenlineUC = NULL; /* copy from ScreenLinesUC[] */ |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
287 u8char_T *screenlineC[MAX_MCO]; /* copy from ScreenLinesC[][] */ |
5096
a6ddcab6a240
updated for version 7.3.1291
Bram Moolenaar <bram@vim.org>
parents:
5090
diff
changeset
|
288 schar_T *screenline2 = NULL; /* copy from ScreenLines2[] */ |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
289 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
290 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
291 redraw_later(type); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
292 if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY)) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
293 return ret; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
294 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
295 /* Allocate space to save the text displayed in the command line area. */ |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
296 rows = Rows - cmdline_row; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
297 screenline = (schar_T *)lalloc( |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
298 (long_u)(rows * Columns * sizeof(schar_T)), FALSE); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
299 screenattr = (sattr_T *)lalloc( |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
300 (long_u)(rows * Columns * sizeof(sattr_T)), FALSE); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
301 if (screenline == NULL || screenattr == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
302 ret = 2; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
303 #ifdef FEAT_MBYTE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
304 if (enc_utf8) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
305 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
306 screenlineUC = (u8char_T *)lalloc( |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
307 (long_u)(rows * Columns * sizeof(u8char_T)), FALSE); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
308 if (screenlineUC == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
309 ret = 2; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
310 for (i = 0; i < p_mco; ++i) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
311 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
312 screenlineC[i] = (u8char_T *)lalloc( |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
313 (long_u)(rows * Columns * sizeof(u8char_T)), FALSE); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
314 if (screenlineC[i] == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
315 ret = 2; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
316 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
317 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
318 if (enc_dbcs == DBCS_JPNU) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
319 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
320 screenline2 = (schar_T *)lalloc( |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
321 (long_u)(rows * Columns * sizeof(schar_T)), FALSE); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
322 if (screenline2 == NULL) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
323 ret = 2; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
324 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
325 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
326 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
327 if (ret != 2) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
328 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
329 /* Save the text displayed in the command line area. */ |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
330 for (r = 0; r < rows; ++r) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
331 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
332 mch_memmove(screenline + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
333 ScreenLines + LineOffset[cmdline_row + r], |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
334 (size_t)Columns * sizeof(schar_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
335 mch_memmove(screenattr + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
336 ScreenAttrs + LineOffset[cmdline_row + r], |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
337 (size_t)Columns * sizeof(sattr_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
338 #ifdef FEAT_MBYTE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
339 if (enc_utf8) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
340 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
341 mch_memmove(screenlineUC + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
342 ScreenLinesUC + LineOffset[cmdline_row + r], |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
343 (size_t)Columns * sizeof(u8char_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
344 for (i = 0; i < p_mco; ++i) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
345 mch_memmove(screenlineC[i] + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
346 ScreenLinesC[r] + LineOffset[cmdline_row + r], |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
347 (size_t)Columns * sizeof(u8char_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
348 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
349 if (enc_dbcs == DBCS_JPNU) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
350 mch_memmove(screenline2 + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
351 ScreenLines2 + LineOffset[cmdline_row + r], |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
352 (size_t)Columns * sizeof(schar_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
353 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
354 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
355 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
356 update_screen(0); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
357 ret = 3; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
358 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
359 if (must_redraw == 0) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
360 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
361 int off = (int)(current_ScreenLine - ScreenLines); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
362 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
363 /* Restore the text displayed in the command line area. */ |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
364 for (r = 0; r < rows; ++r) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
365 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
366 mch_memmove(current_ScreenLine, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
367 screenline + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
368 (size_t)Columns * sizeof(schar_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
369 mch_memmove(ScreenAttrs + off, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
370 screenattr + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
371 (size_t)Columns * sizeof(sattr_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
372 #ifdef FEAT_MBYTE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
373 if (enc_utf8) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
374 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
375 mch_memmove(ScreenLinesUC + off, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
376 screenlineUC + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
377 (size_t)Columns * sizeof(u8char_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
378 for (i = 0; i < p_mco; ++i) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
379 mch_memmove(ScreenLinesC[i] + off, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
380 screenlineC[i] + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
381 (size_t)Columns * sizeof(u8char_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
382 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
383 if (enc_dbcs == DBCS_JPNU) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
384 mch_memmove(ScreenLines2 + off, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
385 screenline2 + r * Columns, |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
386 (size_t)Columns * sizeof(schar_T)); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
387 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
388 SCREEN_LINE(cmdline_row + r, 0, Columns, Columns, FALSE); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
389 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
390 ret = 4; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
391 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
392 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
393 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
394 vim_free(screenline); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
395 vim_free(screenattr); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
396 #ifdef FEAT_MBYTE |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
397 if (enc_utf8) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
398 { |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
399 vim_free(screenlineUC); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
400 for (i = 0; i < p_mco; ++i) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
401 vim_free(screenlineC[i]); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
402 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
403 if (enc_dbcs == DBCS_JPNU) |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
404 vim_free(screenline2); |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
405 #endif |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
406 |
5126
71859e71b1f9
updated for version 7.3.1306
Bram Moolenaar <bram@vim.org>
parents:
5096
diff
changeset
|
407 /* Show the intro message when appropriate. */ |
71859e71b1f9
updated for version 7.3.1306
Bram Moolenaar <bram@vim.org>
parents:
5096
diff
changeset
|
408 maybe_intro_message(); |
71859e71b1f9
updated for version 7.3.1306
Bram Moolenaar <bram@vim.org>
parents:
5096
diff
changeset
|
409 |
71859e71b1f9
updated for version 7.3.1306
Bram Moolenaar <bram@vim.org>
parents:
5096
diff
changeset
|
410 setcursor(); |
71859e71b1f9
updated for version 7.3.1306
Bram Moolenaar <bram@vim.org>
parents:
5096
diff
changeset
|
411 |
5090
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
412 return ret; |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
413 } |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
414 |
8b7baf39a345
updated for version 7.3.1288
Bram Moolenaar <bram@vim.org>
parents:
5078
diff
changeset
|
415 /* |
7 | 416 * Changed something in the current window, at buffer line "lnum", that |
417 * requires that line and possibly other lines to be redrawn. | |
418 * Used when entering/leaving Insert mode with the cursor on a folded line. | |
419 * Used to remove the "$" from a change command. | |
420 * Note that when also inserting/deleting lines w_redraw_top and w_redraw_bot | |
421 * may become invalid and the whole window will have to be redrawn. | |
422 */ | |
423 void | |
424 redrawWinline(lnum, invalid) | |
425 linenr_T lnum; | |
1883 | 426 int invalid UNUSED; /* window line height is invalid now */ |
7 | 427 { |
428 #ifdef FEAT_FOLDING | |
429 int i; | |
430 #endif | |
431 | |
432 if (curwin->w_redraw_top == 0 || curwin->w_redraw_top > lnum) | |
433 curwin->w_redraw_top = lnum; | |
434 if (curwin->w_redraw_bot == 0 || curwin->w_redraw_bot < lnum) | |
435 curwin->w_redraw_bot = lnum; | |
436 redraw_later(VALID); | |
437 | |
438 #ifdef FEAT_FOLDING | |
439 if (invalid) | |
440 { | |
441 /* A w_lines[] entry for this lnum has become invalid. */ | |
442 i = find_wl_entry(curwin, lnum); | |
443 if (i >= 0) | |
444 curwin->w_lines[i].wl_valid = FALSE; | |
445 } | |
446 #endif | |
447 } | |
448 | |
2255 | 449 #if defined(FEAT_RUBY) || defined(FEAT_PERL) || defined(FEAT_VISUAL) || \ |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
450 (defined(FEAT_CLIPBOARD) && defined(FEAT_X11)) || defined(PROTO) |
7 | 451 /* |
452 * update all windows that are editing the current buffer | |
453 */ | |
454 void | |
455 update_curbuf(type) | |
456 int type; | |
457 { | |
458 redraw_curbuf_later(type); | |
459 update_screen(type); | |
460 } | |
2237
770485470e59
Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
461 #endif |
7 | 462 |
463 /* | |
464 * update_screen() | |
465 * | |
466 * Based on the current value of curwin->w_topline, transfer a screenfull | |
467 * of stuff from Filemem to ScreenLines[], and update curwin->w_botline. | |
468 */ | |
469 void | |
470 update_screen(type) | |
471 int type; | |
472 { | |
473 win_T *wp; | |
474 static int did_intro = FALSE; | |
475 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD) | |
476 int did_one; | |
477 #endif | |
478 | |
2008 | 479 /* Don't do anything if the screen structures are (not yet) valid. */ |
7 | 480 if (!screen_valid(TRUE)) |
481 return; | |
482 | |
483 if (must_redraw) | |
484 { | |
485 if (type < must_redraw) /* use maximal type */ | |
486 type = must_redraw; | |
1331 | 487 |
488 /* must_redraw is reset here, so that when we run into some weird | |
489 * reason to redraw while busy redrawing (e.g., asynchronous | |
490 * scrolling), or update_topline() in win_update() will cause a | |
491 * scroll, the screen will be redrawn later or in win_update(). */ | |
7 | 492 must_redraw = 0; |
493 } | |
494 | |
495 /* Need to update w_lines[]. */ | |
496 if (curwin->w_lines_valid == 0 && type < NOT_VALID) | |
497 type = NOT_VALID; | |
498 | |
2008 | 499 /* Postpone the redrawing when it's not needed and when being called |
500 * recursively. */ | |
501 if (!redrawing() || updating_screen) | |
7 | 502 { |
503 redraw_later(type); /* remember type for next time */ | |
504 must_redraw = type; | |
505 if (type > INVERTED_ALL) | |
506 curwin->w_lines_valid = 0; /* don't use w_lines[].wl_size now */ | |
507 return; | |
508 } | |
509 | |
510 updating_screen = TRUE; | |
511 #ifdef FEAT_SYN_HL | |
512 ++display_tick; /* let syntax code know we're in a next round of | |
513 * display updating */ | |
514 #endif | |
515 | |
516 /* | |
517 * if the screen was scrolled up when displaying a message, scroll it down | |
518 */ | |
519 if (msg_scrolled) | |
520 { | |
521 clear_cmdline = TRUE; | |
522 if (msg_scrolled > Rows - 5) /* clearing is faster */ | |
523 type = CLEAR; | |
524 else if (type != CLEAR) | |
525 { | |
526 check_for_delay(FALSE); | |
527 if (screen_ins_lines(0, 0, msg_scrolled, (int)Rows, NULL) == FAIL) | |
528 type = CLEAR; | |
529 FOR_ALL_WINDOWS(wp) | |
530 { | |
531 if (W_WINROW(wp) < msg_scrolled) | |
532 { | |
533 if (W_WINROW(wp) + wp->w_height > msg_scrolled | |
534 && wp->w_redr_type < REDRAW_TOP | |
535 && wp->w_lines_valid > 0 | |
536 && wp->w_topline == wp->w_lines[0].wl_lnum) | |
537 { | |
538 wp->w_upd_rows = msg_scrolled - W_WINROW(wp); | |
539 wp->w_redr_type = REDRAW_TOP; | |
540 } | |
541 else | |
542 { | |
543 wp->w_redr_type = NOT_VALID; | |
544 #ifdef FEAT_WINDOWS | |
545 if (W_WINROW(wp) + wp->w_height + W_STATUS_HEIGHT(wp) | |
546 <= msg_scrolled) | |
547 wp->w_redr_status = TRUE; | |
548 #endif | |
549 } | |
550 } | |
551 } | |
552 redraw_cmdline = TRUE; | |
667 | 553 #ifdef FEAT_WINDOWS |
673 | 554 redraw_tabline = TRUE; |
667 | 555 #endif |
7 | 556 } |
557 msg_scrolled = 0; | |
558 need_wait_return = FALSE; | |
559 } | |
560 | |
561 /* reset cmdline_row now (may have been changed temporarily) */ | |
562 compute_cmdrow(); | |
563 | |
564 /* Check for changed highlighting */ | |
565 if (need_highlight_changed) | |
566 highlight_changed(); | |
567 | |
568 if (type == CLEAR) /* first clear screen */ | |
569 { | |
570 screenclear(); /* will reset clear_cmdline */ | |
571 type = NOT_VALID; | |
572 } | |
573 | |
574 if (clear_cmdline) /* going to clear cmdline (done below) */ | |
575 check_for_delay(FALSE); | |
576 | |
13 | 577 #ifdef FEAT_LINEBREAK |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
578 /* Force redraw when width of 'number' or 'relativenumber' column |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
579 * changes. */ |
13 | 580 if (curwin->w_redr_type < NOT_VALID |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
581 && curwin->w_nrwidth != ((curwin->w_p_nu || curwin->w_p_rnu) |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
582 ? number_width(curwin) : 0)) |
13 | 583 curwin->w_redr_type = NOT_VALID; |
584 #endif | |
585 | |
7 | 586 /* |
587 * Only start redrawing if there is really something to do. | |
588 */ | |
589 if (type == INVERTED) | |
590 update_curswant(); | |
591 if (curwin->w_redr_type < type | |
592 && !((type == VALID | |
593 && curwin->w_lines[0].wl_valid | |
594 #ifdef FEAT_DIFF | |
595 && curwin->w_topfill == curwin->w_old_topfill | |
596 && curwin->w_botfill == curwin->w_old_botfill | |
597 #endif | |
598 && curwin->w_topline == curwin->w_lines[0].wl_lnum) | |
599 #ifdef FEAT_VISUAL | |
600 || (type == INVERTED | |
1043 | 601 && VIsual_active |
7 | 602 && curwin->w_old_cursor_lnum == curwin->w_cursor.lnum |
603 && curwin->w_old_visual_mode == VIsual_mode | |
604 && (curwin->w_valid & VALID_VIRTCOL) | |
605 && curwin->w_old_curswant == curwin->w_curswant) | |
606 #endif | |
607 )) | |
608 curwin->w_redr_type = type; | |
609 | |
849 | 610 #ifdef FEAT_WINDOWS |
611 /* Redraw the tab pages line if needed. */ | |
612 if (redraw_tabline || type >= NOT_VALID) | |
613 draw_tabline(); | |
614 #endif | |
615 | |
7 | 616 #ifdef FEAT_SYN_HL |
617 /* | |
618 * Correct stored syntax highlighting info for changes in each displayed | |
619 * buffer. Each buffer must only be done once. | |
620 */ | |
621 FOR_ALL_WINDOWS(wp) | |
622 { | |
623 if (wp->w_buffer->b_mod_set) | |
624 { | |
625 # ifdef FEAT_WINDOWS | |
626 win_T *wwp; | |
627 | |
628 /* Check if we already did this buffer. */ | |
629 for (wwp = firstwin; wwp != wp; wwp = wwp->w_next) | |
630 if (wwp->w_buffer == wp->w_buffer) | |
631 break; | |
632 # endif | |
633 if ( | |
634 # ifdef FEAT_WINDOWS | |
635 wwp == wp && | |
636 # endif | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
637 syntax_present(wp)) |
7 | 638 syn_stack_apply_changes(wp->w_buffer); |
639 } | |
640 } | |
641 #endif | |
642 | |
643 /* | |
644 * Go from top to bottom through the windows, redrawing the ones that need | |
645 * it. | |
646 */ | |
647 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD) | |
648 did_one = FALSE; | |
649 #endif | |
650 #ifdef FEAT_SEARCH_EXTRA | |
651 search_hl.rm.regprog = NULL; | |
652 #endif | |
653 FOR_ALL_WINDOWS(wp) | |
654 { | |
655 if (wp->w_redr_type != 0) | |
656 { | |
657 cursor_off(); | |
658 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD) | |
659 if (!did_one) | |
660 { | |
661 did_one = TRUE; | |
662 # ifdef FEAT_SEARCH_EXTRA | |
663 start_search_hl(); | |
664 # endif | |
665 # ifdef FEAT_CLIPBOARD | |
666 /* When Visual area changed, may have to update selection. */ | |
3674 | 667 if (clip_star.available && clip_isautosel_star()) |
668 clip_update_selection(&clip_star); | |
669 if (clip_plus.available && clip_isautosel_plus()) | |
670 clip_update_selection(&clip_plus); | |
7 | 671 # endif |
672 #ifdef FEAT_GUI | |
673 /* Remove the cursor before starting to do anything, because | |
674 * scrolling may make it difficult to redraw the text under | |
675 * it. */ | |
676 if (gui.in_use) | |
677 gui_undraw_cursor(); | |
678 #endif | |
679 } | |
680 #endif | |
681 win_update(wp); | |
682 } | |
683 | |
684 #ifdef FEAT_WINDOWS | |
685 /* redraw status line after the window to minimize cursor movement */ | |
686 if (wp->w_redr_status) | |
687 { | |
688 cursor_off(); | |
689 win_redr_status(wp); | |
690 } | |
691 #endif | |
692 } | |
693 #if defined(FEAT_SEARCH_EXTRA) | |
694 end_search_hl(); | |
695 #endif | |
4107 | 696 #ifdef FEAT_INS_EXPAND |
697 /* May need to redraw the popup menu. */ | |
698 if (pum_visible()) | |
699 pum_redraw(); | |
700 #endif | |
7 | 701 |
702 #ifdef FEAT_WINDOWS | |
703 /* Reset b_mod_set flags. Going through all windows is probably faster | |
704 * than going through all buffers (there could be many buffers). */ | |
705 for (wp = firstwin; wp != NULL; wp = wp->w_next) | |
706 wp->w_buffer->b_mod_set = FALSE; | |
707 #else | |
708 curbuf->b_mod_set = FALSE; | |
709 #endif | |
710 | |
711 updating_screen = FALSE; | |
712 #ifdef FEAT_GUI | |
713 gui_may_resize_shell(); | |
714 #endif | |
715 | |
716 /* Clear or redraw the command line. Done last, because scrolling may | |
717 * mess up the command line. */ | |
718 if (clear_cmdline || redraw_cmdline) | |
719 showmode(); | |
720 | |
721 /* May put up an introductory message when not editing a file */ | |
5126
71859e71b1f9
updated for version 7.3.1306
Bram Moolenaar <bram@vim.org>
parents:
5096
diff
changeset
|
722 if (!did_intro) |
71859e71b1f9
updated for version 7.3.1306
Bram Moolenaar <bram@vim.org>
parents:
5096
diff
changeset
|
723 maybe_intro_message(); |
7 | 724 did_intro = TRUE; |
725 | |
726 #ifdef FEAT_GUI | |
727 /* Redraw the cursor and update the scrollbars when all screen updating is | |
728 * done. */ | |
729 if (gui.in_use) | |
730 { | |
731 out_flush(); /* required before updating the cursor */ | |
732 if (did_one) | |
733 gui_update_cursor(FALSE, FALSE); | |
734 gui_update_scrollbars(FALSE); | |
735 } | |
736 #endif | |
737 } | |
738 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
739 #if defined(FEAT_CONCEAL) || defined(PROTO) |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
740 /* |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
741 * Return TRUE if the cursor line in window "wp" may be concealed, according |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
742 * to the 'concealcursor' option. |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
743 */ |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
744 int |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
745 conceal_cursor_line(wp) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
746 win_T *wp; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
747 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
748 int c; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
749 |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
750 if (*wp->w_p_cocu == NUL) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
751 return FALSE; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
752 if (get_real_state() & VISUAL) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
753 c = 'v'; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
754 else if (State & INSERT) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
755 c = 'i'; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
756 else if (State & NORMAL) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
757 c = 'n'; |
2382
3a5ededa240a
Add the 'c' flag to 'concealcursor'.
Bram Moolenaar <bram@vim.org>
parents:
2381
diff
changeset
|
758 else if (State & CMDLINE) |
3a5ededa240a
Add the 'c' flag to 'concealcursor'.
Bram Moolenaar <bram@vim.org>
parents:
2381
diff
changeset
|
759 c = 'c'; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
760 else |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
761 return FALSE; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
762 return vim_strchr(wp->w_p_cocu, c) != NULL; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
763 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
764 |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
765 /* |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
766 * Check if the cursor line needs to be redrawn because of 'concealcursor'. |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
767 */ |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
768 void |
2428
33148c37f3c9
Changes for VMS. Mostly by Zoltan Arpadffy.
Bram Moolenaar <bram@vim.org>
parents:
2409
diff
changeset
|
769 conceal_check_cursur_line() |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
770 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
771 if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin)) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
772 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
773 need_cursor_line_redraw = TRUE; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
774 /* Need to recompute cursor column, e.g., when starting Visual mode |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
775 * without concealing. */ |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
776 curs_columns(TRUE); |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
777 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
778 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
779 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
780 void |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
781 update_single_line(wp, lnum) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
782 win_T *wp; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
783 linenr_T lnum; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
784 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
785 int row; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
786 int j; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
787 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
788 if (lnum >= wp->w_topline && lnum < wp->w_botline |
2269
fb627e94e6c6
Couple of small fixes for conceal feature. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
789 && foldedCount(wp, lnum, &win_foldinfo) == 0) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
790 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
791 # ifdef FEAT_GUI |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
792 /* Remove the cursor before starting to do anything, because scrolling |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
793 * may make it difficult to redraw the text under it. */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
794 if (gui.in_use) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
795 gui_undraw_cursor(); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
796 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
797 row = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
798 for (j = 0; j < wp->w_lines_valid; ++j) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
799 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
800 if (lnum == wp->w_lines[j].wl_lnum) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
801 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
802 screen_start(); /* not sure of screen cursor */ |
2284
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
803 # ifdef FEAT_SEARCH_EXTRA |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
804 init_search_hl(wp); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
805 start_search_hl(); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
806 prepare_search_hl(wp, lnum); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
807 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
808 win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
809 # if defined(FEAT_SEARCH_EXTRA) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
810 end_search_hl(); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
811 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
812 break; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
813 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
814 row += wp->w_lines[j].wl_size; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
815 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
816 # ifdef FEAT_GUI |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
817 /* Redraw the cursor */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
818 if (gui.in_use) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
819 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
820 out_flush(); /* required before updating the cursor */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
821 gui_update_cursor(FALSE, FALSE); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
822 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
823 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
824 } |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
825 need_cursor_line_redraw = FALSE; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
826 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
827 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
828 |
7 | 829 #if defined(FEAT_SIGNS) || defined(FEAT_GUI) |
830 static void update_prepare __ARGS((void)); | |
831 static void update_finish __ARGS((void)); | |
832 | |
833 /* | |
834 * Prepare for updating one or more windows. | |
2008 | 835 * Caller must check for "updating_screen" already set to avoid recursiveness. |
7 | 836 */ |
837 static void | |
838 update_prepare() | |
839 { | |
840 cursor_off(); | |
841 updating_screen = TRUE; | |
842 #ifdef FEAT_GUI | |
843 /* Remove the cursor before starting to do anything, because scrolling may | |
844 * make it difficult to redraw the text under it. */ | |
845 if (gui.in_use) | |
846 gui_undraw_cursor(); | |
847 #endif | |
848 #ifdef FEAT_SEARCH_EXTRA | |
849 start_search_hl(); | |
850 #endif | |
851 } | |
852 | |
853 /* | |
854 * Finish updating one or more windows. | |
855 */ | |
856 static void | |
857 update_finish() | |
858 { | |
859 if (redraw_cmdline) | |
860 showmode(); | |
861 | |
862 # ifdef FEAT_SEARCH_EXTRA | |
863 end_search_hl(); | |
864 # endif | |
865 | |
866 updating_screen = FALSE; | |
867 | |
868 # ifdef FEAT_GUI | |
869 gui_may_resize_shell(); | |
870 | |
871 /* Redraw the cursor and update the scrollbars when all screen updating is | |
872 * done. */ | |
873 if (gui.in_use) | |
874 { | |
875 out_flush(); /* required before updating the cursor */ | |
876 gui_update_cursor(FALSE, FALSE); | |
877 gui_update_scrollbars(FALSE); | |
878 } | |
879 # endif | |
880 } | |
881 #endif | |
882 | |
883 #if defined(FEAT_SIGNS) || defined(PROTO) | |
884 void | |
885 update_debug_sign(buf, lnum) | |
886 buf_T *buf; | |
887 linenr_T lnum; | |
888 { | |
889 win_T *wp; | |
890 int doit = FALSE; | |
891 | |
892 # ifdef FEAT_FOLDING | |
893 win_foldinfo.fi_level = 0; | |
894 # endif | |
895 | |
896 /* update/delete a specific mark */ | |
897 FOR_ALL_WINDOWS(wp) | |
898 { | |
899 if (buf != NULL && lnum > 0) | |
900 { | |
901 if (wp->w_buffer == buf && lnum >= wp->w_topline | |
902 && lnum < wp->w_botline) | |
903 { | |
904 if (wp->w_redraw_top == 0 || wp->w_redraw_top > lnum) | |
905 wp->w_redraw_top = lnum; | |
906 if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < lnum) | |
907 wp->w_redraw_bot = lnum; | |
908 redraw_win_later(wp, VALID); | |
909 } | |
910 } | |
911 else | |
912 redraw_win_later(wp, VALID); | |
913 if (wp->w_redr_type != 0) | |
914 doit = TRUE; | |
915 } | |
916 | |
3250 | 917 /* Return when there is nothing to do, screen updating is already |
918 * happening (recursive call) or still starting up. */ | |
919 if (!doit || updating_screen | |
920 #ifdef FEAT_GUI | |
921 || gui.starting | |
922 #endif | |
923 || starting) | |
7 | 924 return; |
925 | |
926 /* update all windows that need updating */ | |
927 update_prepare(); | |
928 | |
929 # ifdef FEAT_WINDOWS | |
930 for (wp = firstwin; wp; wp = wp->w_next) | |
931 { | |
932 if (wp->w_redr_type != 0) | |
933 win_update(wp); | |
934 if (wp->w_redr_status) | |
935 win_redr_status(wp); | |
936 } | |
937 # else | |
938 if (curwin->w_redr_type != 0) | |
939 win_update(curwin); | |
940 # endif | |
941 | |
942 update_finish(); | |
943 } | |
944 #endif | |
945 | |
946 | |
947 #if defined(FEAT_GUI) || defined(PROTO) | |
948 /* | |
949 * Update a single window, its status line and maybe the command line msg. | |
950 * Used for the GUI scrollbar. | |
951 */ | |
952 void | |
953 updateWindow(wp) | |
954 win_T *wp; | |
955 { | |
2008 | 956 /* return if already busy updating */ |
957 if (updating_screen) | |
958 return; | |
959 | |
7 | 960 update_prepare(); |
961 | |
962 #ifdef FEAT_CLIPBOARD | |
963 /* When Visual area changed, may have to update selection. */ | |
3674 | 964 if (clip_star.available && clip_isautosel_star()) |
965 clip_update_selection(&clip_star); | |
966 if (clip_plus.available && clip_isautosel_plus()) | |
967 clip_update_selection(&clip_plus); | |
7 | 968 #endif |
670 | 969 |
7 | 970 win_update(wp); |
670 | 971 |
7 | 972 #ifdef FEAT_WINDOWS |
670 | 973 /* When the screen was cleared redraw the tab pages line. */ |
673 | 974 if (redraw_tabline) |
677 | 975 draw_tabline(); |
670 | 976 |
7 | 977 if (wp->w_redr_status |
978 # ifdef FEAT_CMDL_INFO | |
979 || p_ru | |
980 # endif | |
981 # ifdef FEAT_STL_OPT | |
40 | 982 || *p_stl != NUL || *wp->w_p_stl != NUL |
7 | 983 # endif |
984 ) | |
985 win_redr_status(wp); | |
986 #endif | |
987 | |
988 update_finish(); | |
989 } | |
990 #endif | |
991 | |
992 /* | |
993 * Update a single window. | |
994 * | |
995 * This may cause the windows below it also to be redrawn (when clearing the | |
996 * screen or scrolling lines). | |
997 * | |
998 * How the window is redrawn depends on wp->w_redr_type. Each type also | |
999 * implies the one below it. | |
1000 * NOT_VALID redraw the whole window | |
743 | 1001 * SOME_VALID redraw the whole window but do scroll when possible |
7 | 1002 * REDRAW_TOP redraw the top w_upd_rows window lines, otherwise like VALID |
1003 * INVERTED redraw the changed part of the Visual area | |
1004 * INVERTED_ALL redraw the whole Visual area | |
1005 * VALID 1. scroll up/down to adjust for a changed w_topline | |
1006 * 2. update lines at the top when scrolled down | |
1007 * 3. redraw changed text: | |
301 | 1008 * - if wp->w_buffer->b_mod_set set, update lines between |
7 | 1009 * b_mod_top and b_mod_bot. |
1010 * - if wp->w_redraw_top non-zero, redraw lines between | |
1011 * wp->w_redraw_top and wp->w_redr_bot. | |
1012 * - continue redrawing when syntax status is invalid. | |
1013 * 4. if scrolled up, update lines at the bottom. | |
1014 * This results in three areas that may need updating: | |
1015 * top: from first row to top_end (when scrolled down) | |
1016 * mid: from mid_start to mid_end (update inversion or changed text) | |
1017 * bot: from bot_start to last row (when scrolled up) | |
1018 */ | |
1019 static void | |
1020 win_update(wp) | |
1021 win_T *wp; | |
1022 { | |
1023 buf_T *buf = wp->w_buffer; | |
1024 int type; | |
1025 int top_end = 0; /* Below last row of the top area that needs | |
1026 updating. 0 when no top area updating. */ | |
1027 int mid_start = 999;/* first row of the mid area that needs | |
1028 updating. 999 when no mid area updating. */ | |
1029 int mid_end = 0; /* Below last row of the mid area that needs | |
1030 updating. 0 when no mid area updating. */ | |
1031 int bot_start = 999;/* first row of the bot area that needs | |
1032 updating. 999 when no bot area updating */ | |
1033 #ifdef FEAT_VISUAL | |
1034 int scrolled_down = FALSE; /* TRUE when scrolled down when | |
1035 w_topline got smaller a bit */ | |
1036 #endif | |
1037 #ifdef FEAT_SEARCH_EXTRA | |
1326 | 1038 matchitem_T *cur; /* points to the match list */ |
7 | 1039 int top_to_mod = FALSE; /* redraw above mod_top */ |
1040 #endif | |
1041 | |
1042 int row; /* current window row to display */ | |
1043 linenr_T lnum; /* current buffer lnum to display */ | |
1044 int idx; /* current index in w_lines[] */ | |
1045 int srow; /* starting row of the current line */ | |
1046 | |
1047 int eof = FALSE; /* if TRUE, we hit the end of the file */ | |
1048 int didline = FALSE; /* if TRUE, we finished the last line */ | |
1049 int i; | |
1050 long j; | |
1051 static int recursive = FALSE; /* being called recursively */ | |
1052 int old_botline = wp->w_botline; | |
1053 #ifdef FEAT_FOLDING | |
1054 long fold_count; | |
1055 #endif | |
1056 #ifdef FEAT_SYN_HL | |
1057 /* remember what happened to the previous line, to know if | |
1058 * check_visual_highlight() can be used */ | |
1059 #define DID_NONE 1 /* didn't update a line */ | |
1060 #define DID_LINE 2 /* updated a normal line */ | |
1061 #define DID_FOLD 3 /* updated a folded line */ | |
1062 int did_update = DID_NONE; | |
1063 linenr_T syntax_last_parsed = 0; /* last parsed text line */ | |
1064 #endif | |
1065 linenr_T mod_top = 0; | |
1066 linenr_T mod_bot = 0; | |
1067 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) | |
1068 int save_got_int; | |
1069 #endif | |
1070 | |
1071 type = wp->w_redr_type; | |
1072 | |
1073 if (type == NOT_VALID) | |
1074 { | |
1075 #ifdef FEAT_WINDOWS | |
1076 wp->w_redr_status = TRUE; | |
1077 #endif | |
1078 wp->w_lines_valid = 0; | |
1079 } | |
1080 | |
1081 /* Window is zero-height: nothing to draw. */ | |
1082 if (wp->w_height == 0) | |
1083 { | |
1084 wp->w_redr_type = 0; | |
1085 return; | |
1086 } | |
1087 | |
1088 #ifdef FEAT_VERTSPLIT | |
1089 /* Window is zero-width: Only need to draw the separator. */ | |
1090 if (wp->w_width == 0) | |
1091 { | |
1092 /* draw the vertical separator right of this window */ | |
1093 draw_vsep_win(wp, 0); | |
1094 wp->w_redr_type = 0; | |
1095 return; | |
1096 } | |
1097 #endif | |
1098 | |
1099 #ifdef FEAT_SEARCH_EXTRA | |
2284
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
1100 init_search_hl(wp); |
7 | 1101 #endif |
1102 | |
13 | 1103 #ifdef FEAT_LINEBREAK |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
1104 /* Force redraw when width of 'number' or 'relativenumber' column |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
1105 * changes. */ |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
1106 i = (wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) : 0; |
677 | 1107 if (wp->w_nrwidth != i) |
13 | 1108 { |
1109 type = NOT_VALID; | |
677 | 1110 wp->w_nrwidth = i; |
13 | 1111 } |
1112 else | |
1113 #endif | |
1114 | |
7 | 1115 if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0) |
1116 { | |
1117 /* | |
1118 * When there are both inserted/deleted lines and specific lines to be | |
1119 * redrawn, w_redraw_top and w_redraw_bot may be invalid, just redraw | |
1120 * everything (only happens when redrawing is off for while). | |
1121 */ | |
1122 type = NOT_VALID; | |
1123 } | |
1124 else | |
1125 { | |
1126 /* | |
1127 * Set mod_top to the first line that needs displaying because of | |
1128 * changes. Set mod_bot to the first line after the changes. | |
1129 */ | |
1130 mod_top = wp->w_redraw_top; | |
1131 if (wp->w_redraw_bot != 0) | |
1132 mod_bot = wp->w_redraw_bot + 1; | |
1133 else | |
1134 mod_bot = 0; | |
1135 wp->w_redraw_top = 0; /* reset for next time */ | |
1136 wp->w_redraw_bot = 0; | |
1137 if (buf->b_mod_set) | |
1138 { | |
1139 if (mod_top == 0 || mod_top > buf->b_mod_top) | |
1140 { | |
1141 mod_top = buf->b_mod_top; | |
1142 #ifdef FEAT_SYN_HL | |
1143 /* Need to redraw lines above the change that may be included | |
1144 * in a pattern match. */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
1145 if (syntax_present(wp)) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
1146 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
1147 mod_top -= buf->b_s.b_syn_sync_linebreaks; |
7 | 1148 if (mod_top < 1) |
1149 mod_top = 1; | |
1150 } | |
1151 #endif | |
1152 } | |
1153 if (mod_bot == 0 || mod_bot < buf->b_mod_bot) | |
1154 mod_bot = buf->b_mod_bot; | |
1155 | |
1156 #ifdef FEAT_SEARCH_EXTRA | |
1157 /* When 'hlsearch' is on and using a multi-line search pattern, a | |
1158 * change in one line may make the Search highlighting in a | |
1159 * previous line invalid. Simple solution: redraw all visible | |
1160 * lines above the change. | |
1326 | 1161 * Same for a match pattern. |
7 | 1162 */ |
699 | 1163 if (search_hl.rm.regprog != NULL |
1164 && re_multiline(search_hl.rm.regprog)) | |
7 | 1165 top_to_mod = TRUE; |
699 | 1166 else |
1326 | 1167 { |
1168 cur = wp->w_match_head; | |
1169 while (cur != NULL) | |
1170 { | |
1171 if (cur->match.regprog != NULL | |
1172 && re_multiline(cur->match.regprog)) | |
699 | 1173 { |
1174 top_to_mod = TRUE; | |
1175 break; | |
1176 } | |
1326 | 1177 cur = cur->next; |
1178 } | |
1179 } | |
7 | 1180 #endif |
1181 } | |
1182 #ifdef FEAT_FOLDING | |
1183 if (mod_top != 0 && hasAnyFolding(wp)) | |
1184 { | |
1185 linenr_T lnumt, lnumb; | |
1186 | |
1187 /* | |
1188 * A change in a line can cause lines above it to become folded or | |
1189 * unfolded. Find the top most buffer line that may be affected. | |
1190 * If the line was previously folded and displayed, get the first | |
1191 * line of that fold. If the line is folded now, get the first | |
1192 * folded line. Use the minimum of these two. | |
1193 */ | |
1194 | |
1195 /* Find last valid w_lines[] entry above mod_top. Set lnumt to | |
1196 * the line below it. If there is no valid entry, use w_topline. | |
1197 * Find the first valid w_lines[] entry below mod_bot. Set lnumb | |
1198 * to this line. If there is no valid entry, use MAXLNUM. */ | |
1199 lnumt = wp->w_topline; | |
1200 lnumb = MAXLNUM; | |
1201 for (i = 0; i < wp->w_lines_valid; ++i) | |
1202 if (wp->w_lines[i].wl_valid) | |
1203 { | |
1204 if (wp->w_lines[i].wl_lastlnum < mod_top) | |
1205 lnumt = wp->w_lines[i].wl_lastlnum + 1; | |
1206 if (lnumb == MAXLNUM && wp->w_lines[i].wl_lnum >= mod_bot) | |
1207 { | |
1208 lnumb = wp->w_lines[i].wl_lnum; | |
1209 /* When there is a fold column it might need updating | |
1210 * in the next line ("J" just above an open fold). */ | |
1211 if (wp->w_p_fdc > 0) | |
1212 ++lnumb; | |
1213 } | |
1214 } | |
1215 | |
1216 (void)hasFoldingWin(wp, mod_top, &mod_top, NULL, TRUE, NULL); | |
1217 if (mod_top > lnumt) | |
1218 mod_top = lnumt; | |
1219 | |
1220 /* Now do the same for the bottom line (one above mod_bot). */ | |
1221 --mod_bot; | |
1222 (void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, TRUE, NULL); | |
1223 ++mod_bot; | |
1224 if (mod_bot < lnumb) | |
1225 mod_bot = lnumb; | |
1226 } | |
1227 #endif | |
1228 | |
1229 /* When a change starts above w_topline and the end is below | |
1230 * w_topline, start redrawing at w_topline. | |
36 | 1231 * If the end of the change is above w_topline: do like no change was |
1232 * made, but redraw the first line to find changes in syntax. */ | |
7 | 1233 if (mod_top != 0 && mod_top < wp->w_topline) |
1234 { | |
1235 if (mod_bot > wp->w_topline) | |
1236 mod_top = wp->w_topline; | |
1237 #ifdef FEAT_SYN_HL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
1238 else if (syntax_present(wp)) |
7 | 1239 top_end = 1; |
1240 #endif | |
1241 } | |
36 | 1242 |
1243 /* When line numbers are displayed need to redraw all lines below | |
1244 * inserted/deleted lines. */ | |
1245 if (mod_top != 0 && buf->b_mod_xlines != 0 && wp->w_p_nu) | |
1246 mod_bot = MAXLNUM; | |
7 | 1247 } |
1248 | |
1249 /* | |
1250 * When only displaying the lines at the top, set top_end. Used when | |
1251 * window has scrolled down for msg_scrolled. | |
1252 */ | |
1253 if (type == REDRAW_TOP) | |
1254 { | |
1255 j = 0; | |
1256 for (i = 0; i < wp->w_lines_valid; ++i) | |
1257 { | |
1258 j += wp->w_lines[i].wl_size; | |
1259 if (j >= wp->w_upd_rows) | |
1260 { | |
1261 top_end = j; | |
1262 break; | |
1263 } | |
1264 } | |
1265 if (top_end == 0) | |
1266 /* not found (cannot happen?): redraw everything */ | |
1267 type = NOT_VALID; | |
1268 else | |
1269 /* top area defined, the rest is VALID */ | |
1270 type = VALID; | |
1271 } | |
1272 | |
1378 | 1273 /* Trick: we want to avoid clearing the screen twice. screenclear() will |
1331 | 1274 * set "screen_cleared" to TRUE. The special value MAYBE (which is still |
1275 * non-zero and thus not FALSE) will indicate that screenclear() was not | |
1276 * called. */ | |
1277 if (screen_cleared) | |
1278 screen_cleared = MAYBE; | |
1279 | |
7 | 1280 /* |
1281 * If there are no changes on the screen that require a complete redraw, | |
1282 * handle three cases: | |
1283 * 1: we are off the top of the screen by a few lines: scroll down | |
1284 * 2: wp->w_topline is below wp->w_lines[0].wl_lnum: may scroll up | |
1285 * 3: wp->w_topline is wp->w_lines[0].wl_lnum: find first entry in | |
1286 * w_lines[] that needs updating. | |
1287 */ | |
743 | 1288 if ((type == VALID || type == SOME_VALID |
1289 || type == INVERTED || type == INVERTED_ALL) | |
7 | 1290 #ifdef FEAT_DIFF |
1291 && !wp->w_botfill && !wp->w_old_botfill | |
1292 #endif | |
1293 ) | |
1294 { | |
1295 if (mod_top != 0 && wp->w_topline == mod_top) | |
1296 { | |
1297 /* | |
1298 * w_topline is the first changed line, the scrolling will be done | |
1299 * further down. | |
1300 */ | |
1301 } | |
1302 else if (wp->w_lines[0].wl_valid | |
1303 && (wp->w_topline < wp->w_lines[0].wl_lnum | |
1304 #ifdef FEAT_DIFF | |
1305 || (wp->w_topline == wp->w_lines[0].wl_lnum | |
1306 && wp->w_topfill > wp->w_old_topfill) | |
1307 #endif | |
1308 )) | |
1309 { | |
1310 /* | |
1311 * New topline is above old topline: May scroll down. | |
1312 */ | |
1313 #ifdef FEAT_FOLDING | |
1314 if (hasAnyFolding(wp)) | |
1315 { | |
1316 linenr_T ln; | |
1317 | |
1318 /* count the number of lines we are off, counting a sequence | |
1319 * of folded lines as one */ | |
1320 j = 0; | |
1321 for (ln = wp->w_topline; ln < wp->w_lines[0].wl_lnum; ++ln) | |
1322 { | |
1323 ++j; | |
1324 if (j >= wp->w_height - 2) | |
1325 break; | |
1326 (void)hasFoldingWin(wp, ln, NULL, &ln, TRUE, NULL); | |
1327 } | |
1328 } | |
1329 else | |
1330 #endif | |
1331 j = wp->w_lines[0].wl_lnum - wp->w_topline; | |
1332 if (j < wp->w_height - 2) /* not too far off */ | |
1333 { | |
1334 i = plines_m_win(wp, wp->w_topline, wp->w_lines[0].wl_lnum - 1); | |
1335 #ifdef FEAT_DIFF | |
1336 /* insert extra lines for previously invisible filler lines */ | |
1337 if (wp->w_lines[0].wl_lnum != wp->w_topline) | |
1338 i += diff_check_fill(wp, wp->w_lines[0].wl_lnum) | |
1339 - wp->w_old_topfill; | |
1340 #endif | |
1341 if (i < wp->w_height - 2) /* less than a screen off */ | |
1342 { | |
1343 /* | |
1344 * Try to insert the correct number of lines. | |
1345 * If not the last window, delete the lines at the bottom. | |
1346 * win_ins_lines may fail when the terminal can't do it. | |
1347 */ | |
1348 if (i > 0) | |
1349 check_for_delay(FALSE); | |
1350 if (win_ins_lines(wp, 0, i, FALSE, wp == firstwin) == OK) | |
1351 { | |
1352 if (wp->w_lines_valid != 0) | |
1353 { | |
1354 /* Need to update rows that are new, stop at the | |
1355 * first one that scrolled down. */ | |
1356 top_end = i; | |
1357 #ifdef FEAT_VISUAL | |
1358 scrolled_down = TRUE; | |
1359 #endif | |
1360 | |
1361 /* Move the entries that were scrolled, disable | |
1362 * the entries for the lines to be redrawn. */ | |
1363 if ((wp->w_lines_valid += j) > wp->w_height) | |
1364 wp->w_lines_valid = wp->w_height; | |
1365 for (idx = wp->w_lines_valid; idx - j >= 0; idx--) | |
1366 wp->w_lines[idx] = wp->w_lines[idx - j]; | |
1367 while (idx >= 0) | |
1368 wp->w_lines[idx--].wl_valid = FALSE; | |
1369 } | |
1370 } | |
1371 else | |
1372 mid_start = 0; /* redraw all lines */ | |
1373 } | |
1374 else | |
1375 mid_start = 0; /* redraw all lines */ | |
1376 } | |
1377 else | |
1378 mid_start = 0; /* redraw all lines */ | |
1379 } | |
1380 else | |
1381 { | |
1382 /* | |
1383 * New topline is at or below old topline: May scroll up. | |
1384 * When topline didn't change, find first entry in w_lines[] that | |
1385 * needs updating. | |
1386 */ | |
1387 | |
1388 /* try to find wp->w_topline in wp->w_lines[].wl_lnum */ | |
1389 j = -1; | |
1390 row = 0; | |
1391 for (i = 0; i < wp->w_lines_valid; i++) | |
1392 { | |
1393 if (wp->w_lines[i].wl_valid | |
1394 && wp->w_lines[i].wl_lnum == wp->w_topline) | |
1395 { | |
1396 j = i; | |
1397 break; | |
1398 } | |
1399 row += wp->w_lines[i].wl_size; | |
1400 } | |
1401 if (j == -1) | |
1402 { | |
1403 /* if wp->w_topline is not in wp->w_lines[].wl_lnum redraw all | |
1404 * lines */ | |
1405 mid_start = 0; | |
1406 } | |
1407 else | |
1408 { | |
1409 /* | |
1410 * Try to delete the correct number of lines. | |
1411 * wp->w_topline is at wp->w_lines[i].wl_lnum. | |
1412 */ | |
1413 #ifdef FEAT_DIFF | |
1414 /* If the topline didn't change, delete old filler lines, | |
1415 * otherwise delete filler lines of the new topline... */ | |
1416 if (wp->w_lines[0].wl_lnum == wp->w_topline) | |
1417 row += wp->w_old_topfill; | |
1418 else | |
1419 row += diff_check_fill(wp, wp->w_topline); | |
1420 /* ... but don't delete new filler lines. */ | |
1421 row -= wp->w_topfill; | |
1422 #endif | |
1423 if (row > 0) | |
1424 { | |
1425 check_for_delay(FALSE); | |
1426 if (win_del_lines(wp, 0, row, FALSE, wp == firstwin) == OK) | |
1427 bot_start = wp->w_height - row; | |
1428 else | |
1429 mid_start = 0; /* redraw all lines */ | |
1430 } | |
1431 if ((row == 0 || bot_start < 999) && wp->w_lines_valid != 0) | |
1432 { | |
1433 /* | |
1434 * Skip the lines (below the deleted lines) that are still | |
1435 * valid and don't need redrawing. Copy their info | |
1436 * upwards, to compensate for the deleted lines. Set | |
1437 * bot_start to the first row that needs redrawing. | |
1438 */ | |
1439 bot_start = 0; | |
1440 idx = 0; | |
1441 for (;;) | |
1442 { | |
1443 wp->w_lines[idx] = wp->w_lines[j]; | |
1444 /* stop at line that didn't fit, unless it is still | |
1445 * valid (no lines deleted) */ | |
1446 if (row > 0 && bot_start + row | |
1447 + (int)wp->w_lines[j].wl_size > wp->w_height) | |
1448 { | |
1449 wp->w_lines_valid = idx + 1; | |
1450 break; | |
1451 } | |
1452 bot_start += wp->w_lines[idx++].wl_size; | |
1453 | |
1454 /* stop at the last valid entry in w_lines[].wl_size */ | |
1455 if (++j >= wp->w_lines_valid) | |
1456 { | |
1457 wp->w_lines_valid = idx; | |
1458 break; | |
1459 } | |
1460 } | |
1461 #ifdef FEAT_DIFF | |
1462 /* Correct the first entry for filler lines at the top | |
1463 * when it won't get updated below. */ | |
1464 if (wp->w_p_diff && bot_start > 0) | |
1465 wp->w_lines[0].wl_size = | |
1466 plines_win_nofill(wp, wp->w_topline, TRUE) | |
1467 + wp->w_topfill; | |
1468 #endif | |
1469 } | |
1470 } | |
1471 } | |
1472 | |
1473 /* When starting redraw in the first line, redraw all lines. When | |
1474 * there is only one window it's probably faster to clear the screen | |
1475 * first. */ | |
1476 if (mid_start == 0) | |
1477 { | |
1478 mid_end = wp->w_height; | |
1479 if (lastwin == firstwin) | |
981 | 1480 { |
1331 | 1481 /* Clear the screen when it was not done by win_del_lines() or |
1482 * win_ins_lines() above, "screen_cleared" is FALSE or MAYBE | |
1483 * then. */ | |
1484 if (screen_cleared != TRUE) | |
1485 screenclear(); | |
981 | 1486 #ifdef FEAT_WINDOWS |
1487 /* The screen was cleared, redraw the tab pages line. */ | |
1488 if (redraw_tabline) | |
1489 draw_tabline(); | |
1490 #endif | |
1491 } | |
7 | 1492 } |
1331 | 1493 |
1494 /* When win_del_lines() or win_ins_lines() caused the screen to be | |
1495 * cleared (only happens for the first window) or when screenclear() | |
1496 * was called directly above, "must_redraw" will have been set to | |
1497 * NOT_VALID, need to reset it here to avoid redrawing twice. */ | |
1498 if (screen_cleared == TRUE) | |
1499 must_redraw = 0; | |
7 | 1500 } |
1501 else | |
1502 { | |
1503 /* Not VALID or INVERTED: redraw all lines. */ | |
1504 mid_start = 0; | |
1505 mid_end = wp->w_height; | |
1506 } | |
1507 | |
743 | 1508 if (type == SOME_VALID) |
1509 { | |
1510 /* SOME_VALID: redraw all lines. */ | |
1511 mid_start = 0; | |
1512 mid_end = wp->w_height; | |
1513 type = NOT_VALID; | |
1514 } | |
1515 | |
7 | 1516 #ifdef FEAT_VISUAL |
1517 /* check if we are updating or removing the inverted part */ | |
1518 if ((VIsual_active && buf == curwin->w_buffer) | |
1519 || (wp->w_old_cursor_lnum != 0 && type != NOT_VALID)) | |
1520 { | |
1521 linenr_T from, to; | |
1522 | |
1523 if (VIsual_active) | |
1524 { | |
1525 if (VIsual_active | |
1526 && (VIsual_mode != wp->w_old_visual_mode | |
1527 || type == INVERTED_ALL)) | |
1528 { | |
1529 /* | |
1530 * If the type of Visual selection changed, redraw the whole | |
1531 * selection. Also when the ownership of the X selection is | |
1532 * gained or lost. | |
1533 */ | |
1534 if (curwin->w_cursor.lnum < VIsual.lnum) | |
1535 { | |
1536 from = curwin->w_cursor.lnum; | |
1537 to = VIsual.lnum; | |
1538 } | |
1539 else | |
1540 { | |
1541 from = VIsual.lnum; | |
1542 to = curwin->w_cursor.lnum; | |
1543 } | |
1544 /* redraw more when the cursor moved as well */ | |
1545 if (wp->w_old_cursor_lnum < from) | |
1546 from = wp->w_old_cursor_lnum; | |
1547 if (wp->w_old_cursor_lnum > to) | |
1548 to = wp->w_old_cursor_lnum; | |
1549 if (wp->w_old_visual_lnum < from) | |
1550 from = wp->w_old_visual_lnum; | |
1551 if (wp->w_old_visual_lnum > to) | |
1552 to = wp->w_old_visual_lnum; | |
1553 } | |
1554 else | |
1555 { | |
1556 /* | |
1557 * Find the line numbers that need to be updated: The lines | |
1558 * between the old cursor position and the current cursor | |
1559 * position. Also check if the Visual position changed. | |
1560 */ | |
1561 if (curwin->w_cursor.lnum < wp->w_old_cursor_lnum) | |
1562 { | |
1563 from = curwin->w_cursor.lnum; | |
1564 to = wp->w_old_cursor_lnum; | |
1565 } | |
1566 else | |
1567 { | |
1568 from = wp->w_old_cursor_lnum; | |
1569 to = curwin->w_cursor.lnum; | |
1570 if (from == 0) /* Visual mode just started */ | |
1571 from = to; | |
1572 } | |
1573 | |
422 | 1574 if (VIsual.lnum != wp->w_old_visual_lnum |
1575 || VIsual.col != wp->w_old_visual_col) | |
7 | 1576 { |
1577 if (wp->w_old_visual_lnum < from | |
1578 && wp->w_old_visual_lnum != 0) | |
1579 from = wp->w_old_visual_lnum; | |
1580 if (wp->w_old_visual_lnum > to) | |
1581 to = wp->w_old_visual_lnum; | |
1582 if (VIsual.lnum < from) | |
1583 from = VIsual.lnum; | |
1584 if (VIsual.lnum > to) | |
1585 to = VIsual.lnum; | |
1586 } | |
1587 } | |
1588 | |
1589 /* | |
1590 * If in block mode and changed column or curwin->w_curswant: | |
1591 * update all lines. | |
1592 * First compute the actual start and end column. | |
1593 */ | |
1594 if (VIsual_mode == Ctrl_V) | |
1595 { | |
1596 colnr_T fromc, toc; | |
1597 | |
1598 getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc); | |
1599 ++toc; | |
1600 if (curwin->w_curswant == MAXCOL) | |
1601 toc = MAXCOL; | |
1602 | |
1603 if (fromc != wp->w_old_cursor_fcol | |
1604 || toc != wp->w_old_cursor_lcol) | |
1605 { | |
1606 if (from > VIsual.lnum) | |
1607 from = VIsual.lnum; | |
1608 if (to < VIsual.lnum) | |
1609 to = VIsual.lnum; | |
1610 } | |
1611 wp->w_old_cursor_fcol = fromc; | |
1612 wp->w_old_cursor_lcol = toc; | |
1613 } | |
1614 } | |
1615 else | |
1616 { | |
1617 /* Use the line numbers of the old Visual area. */ | |
1618 if (wp->w_old_cursor_lnum < wp->w_old_visual_lnum) | |
1619 { | |
1620 from = wp->w_old_cursor_lnum; | |
1621 to = wp->w_old_visual_lnum; | |
1622 } | |
1623 else | |
1624 { | |
1625 from = wp->w_old_visual_lnum; | |
1626 to = wp->w_old_cursor_lnum; | |
1627 } | |
1628 } | |
1629 | |
1630 /* | |
1631 * There is no need to update lines above the top of the window. | |
1632 */ | |
1633 if (from < wp->w_topline) | |
1634 from = wp->w_topline; | |
1635 | |
1636 /* | |
1637 * If we know the value of w_botline, use it to restrict the update to | |
1638 * the lines that are visible in the window. | |
1639 */ | |
1640 if (wp->w_valid & VALID_BOTLINE) | |
1641 { | |
1642 if (from >= wp->w_botline) | |
1643 from = wp->w_botline - 1; | |
1644 if (to >= wp->w_botline) | |
1645 to = wp->w_botline - 1; | |
1646 } | |
1647 | |
1648 /* | |
1649 * Find the minimal part to be updated. | |
1650 * Watch out for scrolling that made entries in w_lines[] invalid. | |
1651 * E.g., CTRL-U makes the first half of w_lines[] invalid and sets | |
1652 * top_end; need to redraw from top_end to the "to" line. | |
1653 * A middle mouse click with a Visual selection may change the text | |
1654 * above the Visual area and reset wl_valid, do count these for | |
1655 * mid_end (in srow). | |
1656 */ | |
1657 if (mid_start > 0) | |
1658 { | |
1659 lnum = wp->w_topline; | |
1660 idx = 0; | |
1661 srow = 0; | |
1662 if (scrolled_down) | |
1663 mid_start = top_end; | |
1664 else | |
1665 mid_start = 0; | |
1666 while (lnum < from && idx < wp->w_lines_valid) /* find start */ | |
1667 { | |
1668 if (wp->w_lines[idx].wl_valid) | |
1669 mid_start += wp->w_lines[idx].wl_size; | |
1670 else if (!scrolled_down) | |
1671 srow += wp->w_lines[idx].wl_size; | |
1672 ++idx; | |
1673 # ifdef FEAT_FOLDING | |
1674 if (idx < wp->w_lines_valid && wp->w_lines[idx].wl_valid) | |
1675 lnum = wp->w_lines[idx].wl_lnum; | |
1676 else | |
1677 # endif | |
1678 ++lnum; | |
1679 } | |
1680 srow += mid_start; | |
1681 mid_end = wp->w_height; | |
1682 for ( ; idx < wp->w_lines_valid; ++idx) /* find end */ | |
1683 { | |
1684 if (wp->w_lines[idx].wl_valid | |
1685 && wp->w_lines[idx].wl_lnum >= to + 1) | |
1686 { | |
1687 /* Only update until first row of this line */ | |
1688 mid_end = srow; | |
1689 break; | |
1690 } | |
1691 srow += wp->w_lines[idx].wl_size; | |
1692 } | |
1693 } | |
1694 } | |
1695 | |
1696 if (VIsual_active && buf == curwin->w_buffer) | |
1697 { | |
1698 wp->w_old_visual_mode = VIsual_mode; | |
1699 wp->w_old_cursor_lnum = curwin->w_cursor.lnum; | |
1700 wp->w_old_visual_lnum = VIsual.lnum; | |
422 | 1701 wp->w_old_visual_col = VIsual.col; |
7 | 1702 wp->w_old_curswant = curwin->w_curswant; |
1703 } | |
1704 else | |
1705 { | |
1706 wp->w_old_visual_mode = 0; | |
1707 wp->w_old_cursor_lnum = 0; | |
1708 wp->w_old_visual_lnum = 0; | |
422 | 1709 wp->w_old_visual_col = 0; |
7 | 1710 } |
1711 #endif /* FEAT_VISUAL */ | |
1712 | |
1713 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) | |
1714 /* reset got_int, otherwise regexp won't work */ | |
1715 save_got_int = got_int; | |
1716 got_int = 0; | |
1717 #endif | |
1718 #ifdef FEAT_FOLDING | |
1719 win_foldinfo.fi_level = 0; | |
1720 #endif | |
1721 | |
1722 /* | |
1723 * Update all the window rows. | |
1724 */ | |
1725 idx = 0; /* first entry in w_lines[].wl_size */ | |
1726 row = 0; | |
1727 srow = 0; | |
1728 lnum = wp->w_topline; /* first line shown in window */ | |
1729 for (;;) | |
1730 { | |
1731 /* stop updating when reached the end of the window (check for _past_ | |
1732 * the end of the window is at the end of the loop) */ | |
1733 if (row == wp->w_height) | |
1734 { | |
1735 didline = TRUE; | |
1736 break; | |
1737 } | |
1738 | |
1739 /* stop updating when hit the end of the file */ | |
1740 if (lnum > buf->b_ml.ml_line_count) | |
1741 { | |
1742 eof = TRUE; | |
1743 break; | |
1744 } | |
1745 | |
1746 /* Remember the starting row of the line that is going to be dealt | |
1747 * with. It is used further down when the line doesn't fit. */ | |
1748 srow = row; | |
1749 | |
1750 /* | |
1751 * Update a line when it is in an area that needs updating, when it | |
1752 * has changes or w_lines[idx] is invalid. | |
1753 * bot_start may be halfway a wrapped line after using | |
1754 * win_del_lines(), check if the current line includes it. | |
1755 * When syntax folding is being used, the saved syntax states will | |
1756 * already have been updated, we can't see where the syntax state is | |
1757 * the same again, just update until the end of the window. | |
1758 */ | |
1759 if (row < top_end | |
1760 || (row >= mid_start && row < mid_end) | |
1761 #ifdef FEAT_SEARCH_EXTRA | |
1762 || top_to_mod | |
1763 #endif | |
1764 || idx >= wp->w_lines_valid | |
1765 || (row + wp->w_lines[idx].wl_size > bot_start) | |
1766 || (mod_top != 0 | |
1767 && (lnum == mod_top | |
1768 || (lnum >= mod_top | |
1769 && (lnum < mod_bot | |
1770 #ifdef FEAT_SYN_HL | |
1771 || did_update == DID_FOLD | |
1772 || (did_update == DID_LINE | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
1773 && syntax_present(wp) |
7 | 1774 && ( |
1775 # ifdef FEAT_FOLDING | |
1776 (foldmethodIsSyntax(wp) | |
1777 && hasAnyFolding(wp)) || | |
1778 # endif | |
1779 syntax_check_changed(lnum))) | |
1780 #endif | |
4916
ba328b4a990e
updated for version 7.3.1203
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1781 #ifdef FEAT_SEARCH_EXTRA |
ba328b4a990e
updated for version 7.3.1203
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1782 /* match in fixed position might need redraw */ |
ba328b4a990e
updated for version 7.3.1203
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1783 || wp->w_match_head != NULL |
ba328b4a990e
updated for version 7.3.1203
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1784 #endif |
7 | 1785 ))))) |
1786 { | |
1787 #ifdef FEAT_SEARCH_EXTRA | |
1788 if (lnum == mod_top) | |
1789 top_to_mod = FALSE; | |
1790 #endif | |
1791 | |
1792 /* | |
1793 * When at start of changed lines: May scroll following lines | |
1794 * up or down to minimize redrawing. | |
1795 * Don't do this when the change continues until the end. | |
3318 | 1796 * Don't scroll when dollar_vcol >= 0, keep the "$". |
7 | 1797 */ |
1798 if (lnum == mod_top | |
1799 && mod_bot != MAXLNUM | |
3318 | 1800 && !(dollar_vcol >= 0 && mod_bot == mod_top + 1)) |
7 | 1801 { |
1802 int old_rows = 0; | |
1803 int new_rows = 0; | |
1804 int xtra_rows; | |
1805 linenr_T l; | |
1806 | |
1807 /* Count the old number of window rows, using w_lines[], which | |
1808 * should still contain the sizes for the lines as they are | |
1809 * currently displayed. */ | |
1810 for (i = idx; i < wp->w_lines_valid; ++i) | |
1811 { | |
1812 /* Only valid lines have a meaningful wl_lnum. Invalid | |
1813 * lines are part of the changed area. */ | |
1814 if (wp->w_lines[i].wl_valid | |
1815 && wp->w_lines[i].wl_lnum == mod_bot) | |
1816 break; | |
1817 old_rows += wp->w_lines[i].wl_size; | |
1818 #ifdef FEAT_FOLDING | |
1819 if (wp->w_lines[i].wl_valid | |
1820 && wp->w_lines[i].wl_lastlnum + 1 == mod_bot) | |
1821 { | |
1822 /* Must have found the last valid entry above mod_bot. | |
1823 * Add following invalid entries. */ | |
1824 ++i; | |
1825 while (i < wp->w_lines_valid | |
1826 && !wp->w_lines[i].wl_valid) | |
1827 old_rows += wp->w_lines[i++].wl_size; | |
1828 break; | |
1829 } | |
1830 #endif | |
1831 } | |
1832 | |
1833 if (i >= wp->w_lines_valid) | |
1834 { | |
1835 /* We can't find a valid line below the changed lines, | |
1836 * need to redraw until the end of the window. | |
1837 * Inserting/deleting lines has no use. */ | |
1838 bot_start = 0; | |
1839 } | |
1840 else | |
1841 { | |
1842 /* Able to count old number of rows: Count new window | |
1843 * rows, and may insert/delete lines */ | |
1844 j = idx; | |
1845 for (l = lnum; l < mod_bot; ++l) | |
1846 { | |
1847 #ifdef FEAT_FOLDING | |
1848 if (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL)) | |
1849 ++new_rows; | |
1850 else | |
1851 #endif | |
1852 #ifdef FEAT_DIFF | |
1853 if (l == wp->w_topline) | |
1854 new_rows += plines_win_nofill(wp, l, TRUE) | |
1855 + wp->w_topfill; | |
1856 else | |
1857 #endif | |
1858 new_rows += plines_win(wp, l, TRUE); | |
1859 ++j; | |
1860 if (new_rows > wp->w_height - row - 2) | |
1861 { | |
1862 /* it's getting too much, must redraw the rest */ | |
1863 new_rows = 9999; | |
1864 break; | |
1865 } | |
1866 } | |
1867 xtra_rows = new_rows - old_rows; | |
1868 if (xtra_rows < 0) | |
1869 { | |
1870 /* May scroll text up. If there is not enough | |
1871 * remaining text or scrolling fails, must redraw the | |
1872 * rest. If scrolling works, must redraw the text | |
1873 * below the scrolled text. */ | |
1874 if (row - xtra_rows >= wp->w_height - 2) | |
1875 mod_bot = MAXLNUM; | |
1876 else | |
1877 { | |
1878 check_for_delay(FALSE); | |
1879 if (win_del_lines(wp, row, | |
1880 -xtra_rows, FALSE, FALSE) == FAIL) | |
1881 mod_bot = MAXLNUM; | |
1882 else | |
1883 bot_start = wp->w_height + xtra_rows; | |
1884 } | |
1885 } | |
1886 else if (xtra_rows > 0) | |
1887 { | |
1888 /* May scroll text down. If there is not enough | |
1889 * remaining text of scrolling fails, must redraw the | |
1890 * rest. */ | |
1891 if (row + xtra_rows >= wp->w_height - 2) | |
1892 mod_bot = MAXLNUM; | |
1893 else | |
1894 { | |
1895 check_for_delay(FALSE); | |
1896 if (win_ins_lines(wp, row + old_rows, | |
1897 xtra_rows, FALSE, FALSE) == FAIL) | |
1898 mod_bot = MAXLNUM; | |
1899 else if (top_end > row + old_rows) | |
1900 /* Scrolled the part at the top that requires | |
1901 * updating down. */ | |
1902 top_end += xtra_rows; | |
1903 } | |
1904 } | |
1905 | |
1906 /* When not updating the rest, may need to move w_lines[] | |
1907 * entries. */ | |
1908 if (mod_bot != MAXLNUM && i != j) | |
1909 { | |
1910 if (j < i) | |
1911 { | |
1912 int x = row + new_rows; | |
1913 | |
1914 /* move entries in w_lines[] upwards */ | |
1915 for (;;) | |
1916 { | |
1917 /* stop at last valid entry in w_lines[] */ | |
1918 if (i >= wp->w_lines_valid) | |
1919 { | |
1920 wp->w_lines_valid = j; | |
1921 break; | |
1922 } | |
1923 wp->w_lines[j] = wp->w_lines[i]; | |
1924 /* stop at a line that won't fit */ | |
1925 if (x + (int)wp->w_lines[j].wl_size | |
1926 > wp->w_height) | |
1927 { | |
1928 wp->w_lines_valid = j + 1; | |
1929 break; | |
1930 } | |
1931 x += wp->w_lines[j++].wl_size; | |
1932 ++i; | |
1933 } | |
1934 if (bot_start > x) | |
1935 bot_start = x; | |
1936 } | |
1937 else /* j > i */ | |
1938 { | |
1939 /* move entries in w_lines[] downwards */ | |
1940 j -= i; | |
1941 wp->w_lines_valid += j; | |
1942 if (wp->w_lines_valid > wp->w_height) | |
1943 wp->w_lines_valid = wp->w_height; | |
1944 for (i = wp->w_lines_valid; i - j >= idx; --i) | |
1945 wp->w_lines[i] = wp->w_lines[i - j]; | |
1946 | |
1947 /* The w_lines[] entries for inserted lines are | |
1948 * now invalid, but wl_size may be used above. | |
1949 * Reset to zero. */ | |
1950 while (i >= idx) | |
1951 { | |
1952 wp->w_lines[i].wl_size = 0; | |
1953 wp->w_lines[i--].wl_valid = FALSE; | |
1954 } | |
1955 } | |
1956 } | |
1957 } | |
1958 } | |
1959 | |
1960 #ifdef FEAT_FOLDING | |
1961 /* | |
1962 * When lines are folded, display one line for all of them. | |
1963 * Otherwise, display normally (can be several display lines when | |
1964 * 'wrap' is on). | |
1965 */ | |
1966 fold_count = foldedCount(wp, lnum, &win_foldinfo); | |
1967 if (fold_count != 0) | |
1968 { | |
1969 fold_line(wp, fold_count, &win_foldinfo, lnum, row); | |
1970 ++row; | |
1971 --fold_count; | |
1972 wp->w_lines[idx].wl_folded = TRUE; | |
1973 wp->w_lines[idx].wl_lastlnum = lnum + fold_count; | |
1974 # ifdef FEAT_SYN_HL | |
1975 did_update = DID_FOLD; | |
1976 # endif | |
1977 } | |
1978 else | |
1979 #endif | |
1980 if (idx < wp->w_lines_valid | |
1981 && wp->w_lines[idx].wl_valid | |
1982 && wp->w_lines[idx].wl_lnum == lnum | |
1983 && lnum > wp->w_topline | |
1984 && !(dy_flags & DY_LASTLINE) | |
1985 && srow + wp->w_lines[idx].wl_size > wp->w_height | |
1986 #ifdef FEAT_DIFF | |
1987 && diff_check_fill(wp, lnum) == 0 | |
1988 #endif | |
1989 ) | |
1990 { | |
1991 /* This line is not going to fit. Don't draw anything here, | |
1992 * will draw "@ " lines below. */ | |
1993 row = wp->w_height + 1; | |
1994 } | |
1995 else | |
1996 { | |
1997 #ifdef FEAT_SEARCH_EXTRA | |
1998 prepare_search_hl(wp, lnum); | |
1999 #endif | |
2000 #ifdef FEAT_SYN_HL | |
2001 /* Let the syntax stuff know we skipped a few lines. */ | |
2002 if (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2003 && syntax_present(wp)) |
7 | 2004 syntax_end_parsing(syntax_last_parsed + 1); |
2005 #endif | |
2006 | |
2007 /* | |
2008 * Display one line. | |
2009 */ | |
625 | 2010 row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0); |
7 | 2011 |
2012 #ifdef FEAT_FOLDING | |
2013 wp->w_lines[idx].wl_folded = FALSE; | |
2014 wp->w_lines[idx].wl_lastlnum = lnum; | |
2015 #endif | |
2016 #ifdef FEAT_SYN_HL | |
2017 did_update = DID_LINE; | |
2018 syntax_last_parsed = lnum; | |
2019 #endif | |
2020 } | |
2021 | |
2022 wp->w_lines[idx].wl_lnum = lnum; | |
2023 wp->w_lines[idx].wl_valid = TRUE; | |
2024 if (row > wp->w_height) /* past end of screen */ | |
2025 { | |
2026 /* we may need the size of that too long line later on */ | |
3318 | 2027 if (dollar_vcol == -1) |
7 | 2028 wp->w_lines[idx].wl_size = plines_win(wp, lnum, TRUE); |
2029 ++idx; | |
2030 break; | |
2031 } | |
3318 | 2032 if (dollar_vcol == -1) |
7 | 2033 wp->w_lines[idx].wl_size = row - srow; |
2034 ++idx; | |
2035 #ifdef FEAT_FOLDING | |
2036 lnum += fold_count + 1; | |
2037 #else | |
2038 ++lnum; | |
2039 #endif | |
2040 } | |
2041 else | |
2042 { | |
2043 /* This line does not need updating, advance to the next one */ | |
2044 row += wp->w_lines[idx++].wl_size; | |
2045 if (row > wp->w_height) /* past end of screen */ | |
2046 break; | |
2047 #ifdef FEAT_FOLDING | |
2048 lnum = wp->w_lines[idx - 1].wl_lastlnum + 1; | |
2049 #else | |
2050 ++lnum; | |
2051 #endif | |
2052 #ifdef FEAT_SYN_HL | |
2053 did_update = DID_NONE; | |
2054 #endif | |
2055 } | |
2056 | |
2057 if (lnum > buf->b_ml.ml_line_count) | |
2058 { | |
2059 eof = TRUE; | |
2060 break; | |
2061 } | |
2062 } | |
2063 /* | |
2064 * End of loop over all window lines. | |
2065 */ | |
2066 | |
2067 | |
2068 if (idx > wp->w_lines_valid) | |
2069 wp->w_lines_valid = idx; | |
2070 | |
2071 #ifdef FEAT_SYN_HL | |
2072 /* | |
2073 * Let the syntax stuff know we stop parsing here. | |
2074 */ | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2075 if (syntax_last_parsed != 0 && syntax_present(wp)) |
7 | 2076 syntax_end_parsing(syntax_last_parsed + 1); |
2077 #endif | |
2078 | |
2079 /* | |
2080 * If we didn't hit the end of the file, and we didn't finish the last | |
2081 * line we were working on, then the line didn't fit. | |
2082 */ | |
2083 wp->w_empty_rows = 0; | |
2084 #ifdef FEAT_DIFF | |
2085 wp->w_filler_rows = 0; | |
2086 #endif | |
2087 if (!eof && !didline) | |
2088 { | |
2089 if (lnum == wp->w_topline) | |
2090 { | |
2091 /* | |
2092 * Single line that does not fit! | |
2093 * Don't overwrite it, it can be edited. | |
2094 */ | |
2095 wp->w_botline = lnum + 1; | |
2096 } | |
2097 #ifdef FEAT_DIFF | |
2098 else if (diff_check_fill(wp, lnum) >= wp->w_height - srow) | |
2099 { | |
2100 /* Window ends in filler lines. */ | |
2101 wp->w_botline = lnum; | |
2102 wp->w_filler_rows = wp->w_height - srow; | |
2103 } | |
2104 #endif | |
2105 else if (dy_flags & DY_LASTLINE) /* 'display' has "lastline" */ | |
2106 { | |
2107 /* | |
2108 * Last line isn't finished: Display "@@@" at the end. | |
2109 */ | |
2110 screen_fill(W_WINROW(wp) + wp->w_height - 1, | |
2111 W_WINROW(wp) + wp->w_height, | |
2112 (int)W_ENDCOL(wp) - 3, (int)W_ENDCOL(wp), | |
2113 '@', '@', hl_attr(HLF_AT)); | |
2114 set_empty_rows(wp, srow); | |
2115 wp->w_botline = lnum; | |
2116 } | |
2117 else | |
2118 { | |
2119 win_draw_end(wp, '@', ' ', srow, wp->w_height, HLF_AT); | |
2120 wp->w_botline = lnum; | |
2121 } | |
2122 } | |
2123 else | |
2124 { | |
2125 #ifdef FEAT_VERTSPLIT | |
2126 draw_vsep_win(wp, row); | |
2127 #endif | |
2128 if (eof) /* we hit the end of the file */ | |
2129 { | |
2130 wp->w_botline = buf->b_ml.ml_line_count + 1; | |
2131 #ifdef FEAT_DIFF | |
2132 j = diff_check_fill(wp, wp->w_botline); | |
2133 if (j > 0 && !wp->w_botfill) | |
2134 { | |
2135 /* | |
2136 * Display filler lines at the end of the file | |
2137 */ | |
2138 if (char2cells(fill_diff) > 1) | |
2139 i = '-'; | |
2140 else | |
2141 i = fill_diff; | |
2142 if (row + j > wp->w_height) | |
2143 j = wp->w_height - row; | |
2144 win_draw_end(wp, i, i, row, row + (int)j, HLF_DED); | |
2145 row += j; | |
2146 } | |
2147 #endif | |
2148 } | |
3318 | 2149 else if (dollar_vcol == -1) |
7 | 2150 wp->w_botline = lnum; |
2151 | |
2152 /* make sure the rest of the screen is blank */ | |
2153 /* put '~'s on rows that aren't part of the file. */ | |
2154 win_draw_end(wp, '~', ' ', row, wp->w_height, HLF_AT); | |
2155 } | |
2156 | |
2157 /* Reset the type of redrawing required, the window has been updated. */ | |
2158 wp->w_redr_type = 0; | |
2159 #ifdef FEAT_DIFF | |
2160 wp->w_old_topfill = wp->w_topfill; | |
2161 wp->w_old_botfill = wp->w_botfill; | |
2162 #endif | |
2163 | |
3318 | 2164 if (dollar_vcol == -1) |
7 | 2165 { |
2166 /* | |
2167 * There is a trick with w_botline. If we invalidate it on each | |
2168 * change that might modify it, this will cause a lot of expensive | |
2169 * calls to plines() in update_topline() each time. Therefore the | |
2170 * value of w_botline is often approximated, and this value is used to | |
2171 * compute the value of w_topline. If the value of w_botline was | |
2172 * wrong, check that the value of w_topline is correct (cursor is on | |
2173 * the visible part of the text). If it's not, we need to redraw | |
2174 * again. Mostly this just means scrolling up a few lines, so it | |
2175 * doesn't look too bad. Only do this for the current window (where | |
2176 * changes are relevant). | |
2177 */ | |
2178 wp->w_valid |= VALID_BOTLINE; | |
2179 if (wp == curwin && wp->w_botline != old_botline && !recursive) | |
2180 { | |
2181 recursive = TRUE; | |
2182 curwin->w_valid &= ~VALID_TOPLINE; | |
2183 update_topline(); /* may invalidate w_botline again */ | |
2184 if (must_redraw != 0) | |
2185 { | |
2186 /* Don't update for changes in buffer again. */ | |
2187 i = curbuf->b_mod_set; | |
2188 curbuf->b_mod_set = FALSE; | |
2189 win_update(curwin); | |
2190 must_redraw = 0; | |
2191 curbuf->b_mod_set = i; | |
2192 } | |
2193 recursive = FALSE; | |
2194 } | |
2195 } | |
2196 | |
2197 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) | |
2198 /* restore got_int, unless CTRL-C was hit while redrawing */ | |
2199 if (!got_int) | |
2200 got_int = save_got_int; | |
2201 #endif | |
2202 } | |
2203 | |
2204 #ifdef FEAT_SIGNS | |
2205 static int draw_signcolumn __ARGS((win_T *wp)); | |
2206 | |
2207 /* | |
2208 * Return TRUE when window "wp" has a column to draw signs in. | |
2209 */ | |
2210 static int | |
2211 draw_signcolumn(wp) | |
2212 win_T *wp; | |
2213 { | |
2214 return (wp->w_buffer->b_signlist != NULL | |
2215 # ifdef FEAT_NETBEANS_INTG | |
2210 | 2216 || netbeans_active() |
7 | 2217 # endif |
2218 ); | |
2219 } | |
2220 #endif | |
2221 | |
2222 /* | |
2223 * Clear the rest of the window and mark the unused lines with "c1". use "c2" | |
2224 * as the filler character. | |
2225 */ | |
2226 static void | |
2227 win_draw_end(wp, c1, c2, row, endrow, hl) | |
2228 win_T *wp; | |
2229 int c1; | |
2230 int c2; | |
2231 int row; | |
2232 int endrow; | |
534 | 2233 hlf_T hl; |
7 | 2234 { |
2235 #if defined(FEAT_FOLDING) || defined(FEAT_SIGNS) || defined(FEAT_CMDWIN) | |
2236 int n = 0; | |
2237 # define FDC_OFF n | |
2238 #else | |
2239 # define FDC_OFF 0 | |
2240 #endif | |
2241 | |
2242 #ifdef FEAT_RIGHTLEFT | |
2243 if (wp->w_p_rl) | |
2244 { | |
2245 /* No check for cmdline window: should never be right-left. */ | |
2246 # ifdef FEAT_FOLDING | |
2247 n = wp->w_p_fdc; | |
2248 | |
2249 if (n > 0) | |
2250 { | |
2251 /* draw the fold column at the right */ | |
119 | 2252 if (n > W_WIDTH(wp)) |
2253 n = W_WIDTH(wp); | |
7 | 2254 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow, |
2255 W_ENDCOL(wp) - n, (int)W_ENDCOL(wp), | |
2256 ' ', ' ', hl_attr(HLF_FC)); | |
2257 } | |
2258 # endif | |
2259 # ifdef FEAT_SIGNS | |
2260 if (draw_signcolumn(wp)) | |
2261 { | |
2262 int nn = n + 2; | |
2263 | |
2264 /* draw the sign column left of the fold column */ | |
119 | 2265 if (nn > W_WIDTH(wp)) |
2266 nn = W_WIDTH(wp); | |
7 | 2267 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow, |
2268 W_ENDCOL(wp) - nn, (int)W_ENDCOL(wp) - n, | |
2269 ' ', ' ', hl_attr(HLF_SC)); | |
2270 n = nn; | |
2271 } | |
2272 # endif | |
2273 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow, | |
2274 W_WINCOL(wp), W_ENDCOL(wp) - 1 - FDC_OFF, | |
2275 c2, c2, hl_attr(hl)); | |
2276 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow, | |
2277 W_ENDCOL(wp) - 1 - FDC_OFF, W_ENDCOL(wp) - FDC_OFF, | |
2278 c1, c2, hl_attr(hl)); | |
2279 } | |
2280 else | |
2281 #endif | |
2282 { | |
2283 #ifdef FEAT_CMDWIN | |
2284 if (cmdwin_type != 0 && wp == curwin) | |
2285 { | |
2286 /* draw the cmdline character in the leftmost column */ | |
2287 n = 1; | |
2288 if (n > wp->w_width) | |
2289 n = wp->w_width; | |
2290 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow, | |
2291 W_WINCOL(wp), (int)W_WINCOL(wp) + n, | |
2292 cmdwin_type, ' ', hl_attr(HLF_AT)); | |
2293 } | |
2294 #endif | |
2295 #ifdef FEAT_FOLDING | |
2296 if (wp->w_p_fdc > 0) | |
2297 { | |
2298 int nn = n + wp->w_p_fdc; | |
2299 | |
2300 /* draw the fold column at the left */ | |
2301 if (nn > W_WIDTH(wp)) | |
2302 nn = W_WIDTH(wp); | |
2303 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow, | |
2304 W_WINCOL(wp) + n, (int)W_WINCOL(wp) + nn, | |
2305 ' ', ' ', hl_attr(HLF_FC)); | |
2306 n = nn; | |
2307 } | |
2308 #endif | |
2309 #ifdef FEAT_SIGNS | |
2310 if (draw_signcolumn(wp)) | |
2311 { | |
2312 int nn = n + 2; | |
2313 | |
2314 /* draw the sign column after the fold column */ | |
2315 if (nn > W_WIDTH(wp)) | |
2316 nn = W_WIDTH(wp); | |
2317 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow, | |
2318 W_WINCOL(wp) + n, (int)W_WINCOL(wp) + nn, | |
2319 ' ', ' ', hl_attr(HLF_SC)); | |
2320 n = nn; | |
2321 } | |
2322 #endif | |
2323 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow, | |
2324 W_WINCOL(wp) + FDC_OFF, (int)W_ENDCOL(wp), | |
2325 c1, c2, hl_attr(hl)); | |
2326 } | |
2327 set_empty_rows(wp, row); | |
2328 } | |
2329 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2330 #ifdef FEAT_SYN_HL |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2331 static int advance_color_col __ARGS((int vcol, int **color_cols)); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2332 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2333 /* |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2334 * Advance **color_cols and return TRUE when there are columns to draw. |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2335 */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2336 static int |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2337 advance_color_col(vcol, color_cols) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2338 int vcol; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2339 int **color_cols; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2340 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2341 while (**color_cols >= 0 && vcol > **color_cols) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2342 ++*color_cols; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2343 return (**color_cols >= 0); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2344 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2345 #endif |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2346 |
7 | 2347 #ifdef FEAT_FOLDING |
2348 /* | |
2349 * Display one folded line. | |
2350 */ | |
2351 static void | |
2352 fold_line(wp, fold_count, foldinfo, lnum, row) | |
2353 win_T *wp; | |
2354 long fold_count; | |
2355 foldinfo_T *foldinfo; | |
2356 linenr_T lnum; | |
2357 int row; | |
2358 { | |
2359 char_u buf[51]; | |
2360 pos_T *top, *bot; | |
2361 linenr_T lnume = lnum + fold_count - 1; | |
2362 int len; | |
29 | 2363 char_u *text; |
7 | 2364 int fdc; |
2365 int col; | |
2366 int txtcol; | |
2367 int off = (int)(current_ScreenLine - ScreenLines); | |
216 | 2368 int ri; |
7 | 2369 |
2370 /* Build the fold line: | |
2371 * 1. Add the cmdwin_type for the command-line window | |
2372 * 2. Add the 'foldcolumn' | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2373 * 3. Add the 'number' or 'relativenumber' column |
7 | 2374 * 4. Compose the text |
2375 * 5. Add the text | |
2376 * 6. set highlighting for the Visual area an other text | |
2377 */ | |
2378 col = 0; | |
2379 | |
2380 /* | |
2381 * 1. Add the cmdwin_type for the command-line window | |
2382 * Ignores 'rightleft', this window is never right-left. | |
2383 */ | |
2384 #ifdef FEAT_CMDWIN | |
2385 if (cmdwin_type != 0 && wp == curwin) | |
2386 { | |
2387 ScreenLines[off] = cmdwin_type; | |
2388 ScreenAttrs[off] = hl_attr(HLF_AT); | |
2389 #ifdef FEAT_MBYTE | |
2390 if (enc_utf8) | |
2391 ScreenLinesUC[off] = 0; | |
2392 #endif | |
2393 ++col; | |
2394 } | |
2395 #endif | |
2396 | |
2397 /* | |
2398 * 2. Add the 'foldcolumn' | |
2399 */ | |
2400 fdc = wp->w_p_fdc; | |
2401 if (fdc > W_WIDTH(wp) - col) | |
2402 fdc = W_WIDTH(wp) - col; | |
2403 if (fdc > 0) | |
2404 { | |
2405 fill_foldcolumn(buf, wp, TRUE, lnum); | |
2406 #ifdef FEAT_RIGHTLEFT | |
2407 if (wp->w_p_rl) | |
2408 { | |
2409 int i; | |
2410 | |
2411 copy_text_attr(off + W_WIDTH(wp) - fdc - col, buf, fdc, | |
2412 hl_attr(HLF_FC)); | |
2413 /* reverse the fold column */ | |
2414 for (i = 0; i < fdc; ++i) | |
2415 ScreenLines[off + W_WIDTH(wp) - i - 1 - col] = buf[i]; | |
2416 } | |
2417 else | |
2418 #endif | |
2419 copy_text_attr(off + col, buf, fdc, hl_attr(HLF_FC)); | |
2420 col += fdc; | |
2421 } | |
2422 | |
2423 #ifdef FEAT_RIGHTLEFT | |
216 | 2424 # define RL_MEMSET(p, v, l) if (wp->w_p_rl) \ |
2425 for (ri = 0; ri < l; ++ri) \ | |
2426 ScreenAttrs[off + (W_WIDTH(wp) - (p) - (l)) + ri] = v; \ | |
2427 else \ | |
2428 for (ri = 0; ri < l; ++ri) \ | |
2429 ScreenAttrs[off + (p) + ri] = v | |
7 | 2430 #else |
216 | 2431 # define RL_MEMSET(p, v, l) for (ri = 0; ri < l; ++ri) \ |
2432 ScreenAttrs[off + (p) + ri] = v | |
7 | 2433 #endif |
2434 | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2435 /* Set all attributes of the 'number' or 'relativenumber' column and the |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2436 * text */ |
216 | 2437 RL_MEMSET(col, hl_attr(HLF_FL), W_WIDTH(wp) - col); |
7 | 2438 |
2439 #ifdef FEAT_SIGNS | |
2440 /* If signs are being displayed, add two spaces. */ | |
2441 if (draw_signcolumn(wp)) | |
2442 { | |
2443 len = W_WIDTH(wp) - col; | |
2444 if (len > 0) | |
2445 { | |
2446 if (len > 2) | |
2447 len = 2; | |
2448 # ifdef FEAT_RIGHTLEFT | |
2449 if (wp->w_p_rl) | |
2450 /* the line number isn't reversed */ | |
2451 copy_text_attr(off + W_WIDTH(wp) - len - col, | |
2452 (char_u *)" ", len, hl_attr(HLF_FL)); | |
2453 else | |
2454 # endif | |
2455 copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_FL)); | |
2456 col += len; | |
2457 } | |
2458 } | |
2459 #endif | |
2460 | |
2461 /* | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2462 * 3. Add the 'number' or 'relativenumber' column |
7 | 2463 */ |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2464 if (wp->w_p_nu || wp->w_p_rnu) |
7 | 2465 { |
2466 len = W_WIDTH(wp) - col; | |
2467 if (len > 0) | |
2468 { | |
13 | 2469 int w = number_width(wp); |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2470 long num; |
4065 | 2471 char *fmt = "%*ld "; |
13 | 2472 |
2473 if (len > w + 1) | |
2474 len = w + 1; | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2475 |
4736
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2476 if (wp->w_p_nu && !wp->w_p_rnu) |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2477 /* 'number' + 'norelativenumber' */ |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2478 num = (long)lnum; |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2479 else |
4065 | 2480 { |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
2481 /* 'relativenumber', don't use negative numbers */ |
2675 | 2482 num = labs((long)get_cursor_rel_lnum(wp, lnum)); |
4736
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2483 if (num == 0 && wp->w_p_nu && wp->w_p_rnu) |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2484 { |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2485 /* 'number' + 'relativenumber': cursor line shows absolute |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2486 * line number */ |
4065 | 2487 num = lnum; |
2488 fmt = "%-*ld "; | |
2489 } | |
2490 } | |
2491 | |
2492 sprintf((char *)buf, fmt, w, num); | |
7 | 2493 #ifdef FEAT_RIGHTLEFT |
2494 if (wp->w_p_rl) | |
2495 /* the line number isn't reversed */ | |
2496 copy_text_attr(off + W_WIDTH(wp) - len - col, buf, len, | |
2497 hl_attr(HLF_FL)); | |
2498 else | |
2499 #endif | |
2500 copy_text_attr(off + col, buf, len, hl_attr(HLF_FL)); | |
2501 col += len; | |
2502 } | |
2503 } | |
2504 | |
2505 /* | |
2506 * 4. Compose the folded-line string with 'foldtext', if set. | |
2507 */ | |
29 | 2508 text = get_foldtext(wp, lnum, lnume, foldinfo, buf); |
7 | 2509 |
2510 txtcol = col; /* remember where text starts */ | |
2511 | |
2512 /* | |
2513 * 5. move the text to current_ScreenLine. Fill up with "fill_fold". | |
2514 * Right-left text is put in columns 0 - number-col, normal text is put | |
2515 * in columns number-col - window-width. | |
2516 */ | |
2517 #ifdef FEAT_MBYTE | |
2518 if (has_mbyte) | |
2519 { | |
2520 int cells; | |
714 | 2521 int u8c, u8cc[MAX_MCO]; |
2522 int i; | |
7 | 2523 int idx; |
2524 int c_len; | |
33 | 2525 char_u *p; |
7 | 2526 # ifdef FEAT_ARABIC |
2527 int prev_c = 0; /* previous Arabic character */ | |
2528 int prev_c1 = 0; /* first composing char for prev_c */ | |
2529 # endif | |
2530 | |
2531 # ifdef FEAT_RIGHTLEFT | |
2532 if (wp->w_p_rl) | |
2533 idx = off; | |
2534 else | |
2535 # endif | |
2536 idx = off + col; | |
2537 | |
2538 /* Store multibyte characters in ScreenLines[] et al. correctly. */ | |
2539 for (p = text; *p != NUL; ) | |
2540 { | |
2541 cells = (*mb_ptr2cells)(p); | |
474 | 2542 c_len = (*mb_ptr2len)(p); |
7 | 2543 if (col + cells > W_WIDTH(wp) |
2544 # ifdef FEAT_RIGHTLEFT | |
2545 - (wp->w_p_rl ? col : 0) | |
2546 # endif | |
2547 ) | |
2548 break; | |
2549 ScreenLines[idx] = *p; | |
2550 if (enc_utf8) | |
2551 { | |
714 | 2552 u8c = utfc_ptr2char(p, u8cc); |
2553 if (*p < 0x80 && u8cc[0] == 0) | |
7 | 2554 { |
2555 ScreenLinesUC[idx] = 0; | |
2556 #ifdef FEAT_ARABIC | |
2557 prev_c = u8c; | |
2558 #endif | |
2559 } | |
2560 else | |
2561 { | |
2562 #ifdef FEAT_ARABIC | |
2563 if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c)) | |
2564 { | |
2565 /* Do Arabic shaping. */ | |
714 | 2566 int pc, pc1, nc; |
2567 int pcc[MAX_MCO]; | |
7 | 2568 int firstbyte = *p; |
2569 | |
2570 /* The idea of what is the previous and next | |
2571 * character depends on 'rightleft'. */ | |
2572 if (wp->w_p_rl) | |
2573 { | |
2574 pc = prev_c; | |
2575 pc1 = prev_c1; | |
2576 nc = utf_ptr2char(p + c_len); | |
714 | 2577 prev_c1 = u8cc[0]; |
7 | 2578 } |
2579 else | |
2580 { | |
714 | 2581 pc = utfc_ptr2char(p + c_len, pcc); |
7 | 2582 nc = prev_c; |
714 | 2583 pc1 = pcc[0]; |
7 | 2584 } |
2585 prev_c = u8c; | |
2586 | |
714 | 2587 u8c = arabic_shape(u8c, &firstbyte, &u8cc[0], |
7 | 2588 pc, pc1, nc); |
2589 ScreenLines[idx] = firstbyte; | |
2590 } | |
2591 else | |
2592 prev_c = u8c; | |
2593 #endif | |
2594 /* Non-BMP character: display as ? or fullwidth ?. */ | |
1401 | 2595 #ifdef UNICODE16 |
7 | 2596 if (u8c >= 0x10000) |
2597 ScreenLinesUC[idx] = (cells == 2) ? 0xff1f : (int)'?'; | |
2598 else | |
1401 | 2599 #endif |
7 | 2600 ScreenLinesUC[idx] = u8c; |
714 | 2601 for (i = 0; i < Screen_mco; ++i) |
2602 { | |
2603 ScreenLinesC[i][idx] = u8cc[i]; | |
2604 if (u8cc[i] == 0) | |
2605 break; | |
2606 } | |
7 | 2607 } |
2608 if (cells > 1) | |
2609 ScreenLines[idx + 1] = 0; | |
2610 } | |
2069
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
2611 else if (enc_dbcs == DBCS_JPNU && *p == 0x8e) |
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
2612 /* double-byte single width character */ |
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
2613 ScreenLines2[idx] = p[1]; |
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
2614 else if (cells > 1) |
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
2615 /* double-width character */ |
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
2616 ScreenLines[idx + 1] = p[1]; |
7 | 2617 col += cells; |
2618 idx += cells; | |
2619 p += c_len; | |
2620 } | |
2621 } | |
2622 else | |
2623 #endif | |
2624 { | |
2625 len = (int)STRLEN(text); | |
2626 if (len > W_WIDTH(wp) - col) | |
2627 len = W_WIDTH(wp) - col; | |
2628 if (len > 0) | |
2629 { | |
2630 #ifdef FEAT_RIGHTLEFT | |
2631 if (wp->w_p_rl) | |
2632 STRNCPY(current_ScreenLine, text, len); | |
2633 else | |
2634 #endif | |
2635 STRNCPY(current_ScreenLine + col, text, len); | |
2636 col += len; | |
2637 } | |
2638 } | |
2639 | |
2640 /* Fill the rest of the line with the fold filler */ | |
2641 #ifdef FEAT_RIGHTLEFT | |
2642 if (wp->w_p_rl) | |
2643 col -= txtcol; | |
2644 #endif | |
2645 while (col < W_WIDTH(wp) | |
2646 #ifdef FEAT_RIGHTLEFT | |
2647 - (wp->w_p_rl ? txtcol : 0) | |
2648 #endif | |
2649 ) | |
2650 { | |
2651 #ifdef FEAT_MBYTE | |
2652 if (enc_utf8) | |
2653 { | |
2654 if (fill_fold >= 0x80) | |
2655 { | |
2656 ScreenLinesUC[off + col] = fill_fold; | |
714 | 2657 ScreenLinesC[0][off + col] = 0; |
7 | 2658 } |
2659 else | |
2660 ScreenLinesUC[off + col] = 0; | |
2661 } | |
2662 #endif | |
2663 ScreenLines[off + col++] = fill_fold; | |
2664 } | |
2665 | |
2666 if (text != buf) | |
2667 vim_free(text); | |
2668 | |
2669 /* | |
2670 * 6. set highlighting for the Visual area an other text. | |
2671 * If all folded lines are in the Visual area, highlight the line. | |
2672 */ | |
2673 #ifdef FEAT_VISUAL | |
2674 if (VIsual_active && wp->w_buffer == curwin->w_buffer) | |
2675 { | |
2676 if (ltoreq(curwin->w_cursor, VIsual)) | |
2677 { | |
2678 /* Visual is after curwin->w_cursor */ | |
2679 top = &curwin->w_cursor; | |
2680 bot = &VIsual; | |
2681 } | |
2682 else | |
2683 { | |
2684 /* Visual is before curwin->w_cursor */ | |
2685 top = &VIsual; | |
2686 bot = &curwin->w_cursor; | |
2687 } | |
2688 if (lnum >= top->lnum | |
2689 && lnume <= bot->lnum | |
2690 && (VIsual_mode != 'v' | |
2691 || ((lnum > top->lnum | |
2692 || (lnum == top->lnum | |
2693 && top->col == 0)) | |
2694 && (lnume < bot->lnum | |
2695 || (lnume == bot->lnum | |
2696 && (bot->col - (*p_sel == 'e')) | |
1883 | 2697 >= (colnr_T)STRLEN(ml_get_buf(wp->w_buffer, lnume, FALSE))))))) |
7 | 2698 { |
2699 if (VIsual_mode == Ctrl_V) | |
2700 { | |
2701 /* Visual block mode: highlight the chars part of the block */ | |
2702 if (wp->w_old_cursor_fcol + txtcol < (colnr_T)W_WIDTH(wp)) | |
2703 { | |
3040 | 2704 if (wp->w_old_cursor_lcol != MAXCOL |
2705 && wp->w_old_cursor_lcol + txtcol | |
2706 < (colnr_T)W_WIDTH(wp)) | |
7 | 2707 len = wp->w_old_cursor_lcol; |
2708 else | |
2709 len = W_WIDTH(wp) - txtcol; | |
2710 RL_MEMSET(wp->w_old_cursor_fcol + txtcol, hl_attr(HLF_V), | |
230 | 2711 len - (int)wp->w_old_cursor_fcol); |
7 | 2712 } |
2713 } | |
2714 else | |
216 | 2715 { |
7 | 2716 /* Set all attributes of the text */ |
216 | 2717 RL_MEMSET(txtcol, hl_attr(HLF_V), W_WIDTH(wp) - txtcol); |
2718 } | |
7 | 2719 } |
2720 } | |
2721 #endif | |
2722 | |
743 | 2723 #ifdef FEAT_SYN_HL |
2724 /* Show 'cursorcolumn' in the fold line. */ | |
1725 | 2725 if (wp->w_p_cuc) |
2726 { | |
2727 txtcol += wp->w_virtcol; | |
2728 if (wp->w_p_wrap) | |
2729 txtcol -= wp->w_skipcol; | |
2730 else | |
2731 txtcol -= wp->w_leftcol; | |
2732 if (txtcol >= 0 && txtcol < W_WIDTH(wp)) | |
2733 ScreenAttrs[off + txtcol] = hl_combine_attr( | |
2734 ScreenAttrs[off + txtcol], hl_attr(HLF_CUC)); | |
2735 } | |
743 | 2736 #endif |
7 | 2737 |
2738 SCREEN_LINE(row + W_WINROW(wp), W_WINCOL(wp), (int)W_WIDTH(wp), | |
2739 (int)W_WIDTH(wp), FALSE); | |
2740 | |
2741 /* | |
2742 * Update w_cline_height and w_cline_folded if the cursor line was | |
2743 * updated (saves a call to plines() later). | |
2744 */ | |
2745 if (wp == curwin | |
2746 && lnum <= curwin->w_cursor.lnum | |
2747 && lnume >= curwin->w_cursor.lnum) | |
2748 { | |
2749 curwin->w_cline_row = row; | |
2750 curwin->w_cline_height = 1; | |
2751 curwin->w_cline_folded = TRUE; | |
2752 curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW); | |
2753 } | |
2754 } | |
2755 | |
2756 /* | |
2757 * Copy "buf[len]" to ScreenLines["off"] and set attributes to "attr". | |
2758 */ | |
2759 static void | |
2760 copy_text_attr(off, buf, len, attr) | |
2761 int off; | |
2762 char_u *buf; | |
2763 int len; | |
2764 int attr; | |
2765 { | |
216 | 2766 int i; |
2767 | |
7 | 2768 mch_memmove(ScreenLines + off, buf, (size_t)len); |
2769 # ifdef FEAT_MBYTE | |
2770 if (enc_utf8) | |
2771 vim_memset(ScreenLinesUC + off, 0, sizeof(u8char_T) * (size_t)len); | |
2772 # endif | |
216 | 2773 for (i = 0; i < len; ++i) |
2774 ScreenAttrs[off + i] = attr; | |
7 | 2775 } |
2776 | |
2777 /* | |
2778 * Fill the foldcolumn at "p" for window "wp". | |
548 | 2779 * Only to be called when 'foldcolumn' > 0. |
7 | 2780 */ |
2781 static void | |
2782 fill_foldcolumn(p, wp, closed, lnum) | |
2783 char_u *p; | |
2784 win_T *wp; | |
2785 int closed; /* TRUE of FALSE */ | |
2786 linenr_T lnum; /* current line number */ | |
2787 { | |
2788 int i = 0; | |
2789 int level; | |
2790 int first_level; | |
519 | 2791 int empty; |
7 | 2792 |
2793 /* Init to all spaces. */ | |
2794 copy_spaces(p, (size_t)wp->w_p_fdc); | |
2795 | |
2796 level = win_foldinfo.fi_level; | |
2797 if (level > 0) | |
2798 { | |
519 | 2799 /* If there is only one column put more info in it. */ |
2800 empty = (wp->w_p_fdc == 1) ? 0 : 1; | |
2801 | |
7 | 2802 /* If the column is too narrow, we start at the lowest level that |
2803 * fits and use numbers to indicated the depth. */ | |
519 | 2804 first_level = level - wp->w_p_fdc - closed + 1 + empty; |
7 | 2805 if (first_level < 1) |
2806 first_level = 1; | |
2807 | |
519 | 2808 for (i = 0; i + empty < wp->w_p_fdc; ++i) |
7 | 2809 { |
2810 if (win_foldinfo.fi_lnum == lnum | |
2811 && first_level + i >= win_foldinfo.fi_low_level) | |
2812 p[i] = '-'; | |
2813 else if (first_level == 1) | |
2814 p[i] = '|'; | |
2815 else if (first_level + i <= 9) | |
2816 p[i] = '0' + first_level + i; | |
2817 else | |
2818 p[i] = '>'; | |
2819 if (first_level + i == level) | |
2820 break; | |
2821 } | |
2822 } | |
2823 if (closed) | |
548 | 2824 p[i >= wp->w_p_fdc ? i - 1 : i] = '+'; |
7 | 2825 } |
2826 #endif /* FEAT_FOLDING */ | |
2827 | |
2828 /* | |
2829 * Display line "lnum" of window 'wp' on the screen. | |
2830 * Start at row "startrow", stop when "endrow" is reached. | |
2831 * wp->w_virtcol needs to be valid. | |
2832 * | |
2833 * Return the number of last row the line occupies. | |
2834 */ | |
2835 static int | |
625 | 2836 win_line(wp, lnum, startrow, endrow, nochange) |
7 | 2837 win_T *wp; |
2838 linenr_T lnum; | |
2839 int startrow; | |
2840 int endrow; | |
1883 | 2841 int nochange UNUSED; /* not updating for changed text */ |
7 | 2842 { |
2843 int col; /* visual column on screen */ | |
2844 unsigned off; /* offset in ScreenLines/ScreenAttrs */ | |
2845 int c = 0; /* init for GCC */ | |
2846 long vcol = 0; /* virtual column (for tabs) */ | |
2847 long vcol_prev = -1; /* "vcol" of previous character */ | |
2848 char_u *line; /* current line */ | |
2849 char_u *ptr; /* current position in "line" */ | |
2850 int row; /* row in the window, excl w_winrow */ | |
2851 int screen_row; /* row on the screen, incl w_winrow */ | |
2852 | |
2853 char_u extra[18]; /* "%ld" and 'fdc' must fit in here */ | |
2854 int n_extra = 0; /* number of extra chars */ | |
1340 | 2855 char_u *p_extra = NULL; /* string of extra chars, plus NUL */ |
7 | 2856 int c_extra = NUL; /* extra chars, all the same */ |
2857 int extra_attr = 0; /* attributes when n_extra != 0 */ | |
2858 static char_u *at_end_str = (char_u *)""; /* used for p_extra when | |
2859 displaying lcs_eol at end-of-line */ | |
2860 int lcs_eol_one = lcs_eol; /* lcs_eol until it's been used */ | |
2861 int lcs_prec_todo = lcs_prec; /* lcs_prec until it's been used */ | |
2862 | |
2863 /* saved "extra" items for when draw_state becomes WL_LINE (again) */ | |
2864 int saved_n_extra = 0; | |
2865 char_u *saved_p_extra = NULL; | |
2866 int saved_c_extra = 0; | |
2867 int saved_char_attr = 0; | |
2868 | |
2869 int n_attr = 0; /* chars with special attr */ | |
2870 int saved_attr2 = 0; /* char_attr saved for n_attr */ | |
2871 int n_attr3 = 0; /* chars with overruling special attr */ | |
2872 int saved_attr3 = 0; /* char_attr saved for n_attr3 */ | |
2873 | |
2874 int n_skip = 0; /* nr of chars to skip for 'nowrap' */ | |
2875 | |
2876 int fromcol, tocol; /* start/end of inverting */ | |
2877 int fromcol_prev = -2; /* start of inverting after cursor */ | |
2878 int noinvcur = FALSE; /* don't invert the cursor */ | |
2879 #ifdef FEAT_VISUAL | |
2880 pos_T *top, *bot; | |
1813 | 2881 int lnum_in_visual_area = FALSE; |
7 | 2882 #endif |
2883 pos_T pos; | |
2884 long v; | |
2885 | |
2886 int char_attr = 0; /* attributes for next character */ | |
674 | 2887 int attr_pri = FALSE; /* char_attr has priority */ |
7 | 2888 int area_highlighting = FALSE; /* Visual or incsearch highlighting |
2889 in this line */ | |
2890 int attr = 0; /* attributes for area highlighting */ | |
2891 int area_attr = 0; /* attributes desired by highlighting */ | |
2892 int search_attr = 0; /* attributes desired by 'hlsearch' */ | |
2893 #ifdef FEAT_SYN_HL | |
743 | 2894 int vcol_save_attr = 0; /* saved attr for 'cursorcolumn' */ |
7 | 2895 int syntax_attr = 0; /* attributes desired by syntax */ |
2896 int has_syntax = FALSE; /* this buffer has syntax highl. */ | |
2897 int save_did_emsg; | |
1437 | 2898 int eol_hl_off = 0; /* 1 if highlighted char after EOL */ |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2899 int draw_color_col = FALSE; /* highlight colorcolumn */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
2900 int *color_cols = NULL; /* pointer to according columns array */ |
743 | 2901 #endif |
2902 #ifdef FEAT_SPELL | |
221 | 2903 int has_spell = FALSE; /* this buffer has spell checking */ |
348 | 2904 # define SPWORDLEN 150 |
2905 char_u nextline[SPWORDLEN * 2];/* text with start of the next line */ | |
353 | 2906 int nextlinecol = 0; /* column where nextline[] starts */ |
2907 int nextline_idx = 0; /* index in nextline[] where next line | |
348 | 2908 starts */ |
221 | 2909 int spell_attr = 0; /* attributes desired by spelling */ |
2910 int word_end = 0; /* last byte with same spell_attr */ | |
378 | 2911 static linenr_T checked_lnum = 0; /* line number for "checked_col" */ |
2912 static int checked_col = 0; /* column in "checked_lnum" up to which | |
348 | 2913 * there are no spell errors */ |
386 | 2914 static int cap_col = -1; /* column to check for Cap word */ |
2915 static linenr_T capcol_lnum = 0; /* line number where "cap_col" used */ | |
348 | 2916 int cur_checked_col = 0; /* checked column for current line */ |
7 | 2917 #endif |
2918 int extra_check; /* has syntax or linebreak */ | |
2919 #ifdef FEAT_MBYTE | |
2920 int multi_attr = 0; /* attributes desired by multibyte */ | |
2921 int mb_l = 1; /* multi-byte byte length */ | |
2922 int mb_c = 0; /* decoded multi-byte character */ | |
2923 int mb_utf8 = FALSE; /* screen char is UTF-8 char */ | |
714 | 2924 int u8cc[MAX_MCO]; /* composing UTF-8 chars */ |
7 | 2925 #endif |
2926 #ifdef FEAT_DIFF | |
2927 int filler_lines; /* nr of filler lines to be drawn */ | |
2928 int filler_todo; /* nr of filler lines still to do + 1 */ | |
534 | 2929 hlf_T diff_hlf = (hlf_T)0; /* type of diff highlighting */ |
7 | 2930 int change_start = MAXCOL; /* first col of changed area */ |
2931 int change_end = -1; /* last col of changed area */ | |
2932 #endif | |
2933 colnr_T trailcol = MAXCOL; /* start of trailing spaces */ | |
2934 #ifdef FEAT_LINEBREAK | |
2935 int need_showbreak = FALSE; | |
2936 #endif | |
910 | 2937 #if defined(FEAT_SIGNS) || (defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS)) \ |
2938 || defined(FEAT_SYN_HL) || defined(FEAT_DIFF) | |
7 | 2939 # define LINE_ATTR |
1536 | 2940 int line_attr = 0; /* attribute for the whole line */ |
7 | 2941 #endif |
2942 #ifdef FEAT_SEARCH_EXTRA | |
1326 | 2943 matchitem_T *cur; /* points to the match list */ |
2944 match_T *shl; /* points to search_hl or a match */ | |
2945 int shl_flag; /* flag to indicate whether search_hl | |
2946 has been processed or not */ | |
2947 int prevcol_hl_flag; /* flag to indicate whether prevcol | |
2948 equals startcol of search_hl or one | |
2949 of the matches */ | |
7 | 2950 #endif |
2951 #ifdef FEAT_ARABIC | |
2952 int prev_c = 0; /* previous Arabic character */ | |
2953 int prev_c1 = 0; /* first composing char for prev_c */ | |
2954 #endif | |
910 | 2955 #if defined(LINE_ATTR) |
867 | 2956 int did_line_attr = 0; |
2957 #endif | |
7 | 2958 |
2959 /* draw_state: items that are drawn in sequence: */ | |
2960 #define WL_START 0 /* nothing done yet */ | |
2961 #ifdef FEAT_CMDWIN | |
2962 # define WL_CMDLINE WL_START + 1 /* cmdline window column */ | |
2963 #else | |
2964 # define WL_CMDLINE WL_START | |
2965 #endif | |
2966 #ifdef FEAT_FOLDING | |
2967 # define WL_FOLD WL_CMDLINE + 1 /* 'foldcolumn' */ | |
2968 #else | |
2969 # define WL_FOLD WL_CMDLINE | |
2970 #endif | |
2971 #ifdef FEAT_SIGNS | |
2972 # define WL_SIGN WL_FOLD + 1 /* column for signs */ | |
2973 #else | |
2974 # define WL_SIGN WL_FOLD /* column for signs */ | |
2975 #endif | |
2976 #define WL_NR WL_SIGN + 1 /* line number */ | |
2977 #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF) | |
2978 # define WL_SBR WL_NR + 1 /* 'showbreak' or 'diff' */ | |
2979 #else | |
2980 # define WL_SBR WL_NR | |
2981 #endif | |
2982 #define WL_LINE WL_SBR + 1 /* text in the line */ | |
2983 int draw_state = WL_START; /* what to draw next */ | |
574 | 2984 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
7 | 2985 int feedback_col = 0; |
2986 int feedback_old_attr = -1; | |
2987 #endif | |
2988 | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2989 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2990 int syntax_flags = 0; |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2382
diff
changeset
|
2991 int syntax_seqnr = 0; |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2364
diff
changeset
|
2992 int prev_syntax_id = 0; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2993 int conceal_attr = hl_attr(HLF_CONCEAL); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2994 int is_concealing = FALSE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2995 int boguscols = 0; /* nonexistent columns added to force |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2996 wrapping */ |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2400
diff
changeset
|
2997 int vcol_off = 0; /* offset for concealed characters */ |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
2998 int did_wcol = FALSE; |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
2999 # define VCOL_HLC (vcol - vcol_off) |
5174
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
3000 # define FIX_FOR_BOGUSCOLS \ |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
3001 { \ |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
3002 n_extra += vcol_off; \ |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
3003 vcol -= vcol_off; \ |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
3004 vcol_off = 0; \ |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
3005 col -= boguscols; \ |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
3006 boguscols = 0; \ |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
3007 } |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
3008 #else |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
3009 # define VCOL_HLC (vcol) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
3010 #endif |
7 | 3011 |
3012 if (startrow > endrow) /* past the end already! */ | |
3013 return startrow; | |
3014 | |
3015 row = startrow; | |
3016 screen_row = row + W_WINROW(wp); | |
3017 | |
3018 /* | |
3019 * To speed up the loop below, set extra_check when there is linebreak, | |
3020 * trailing white space and/or syntax processing to be done. | |
3021 */ | |
3022 #ifdef FEAT_LINEBREAK | |
3023 extra_check = wp->w_p_lbr; | |
3024 #else | |
3025 extra_check = 0; | |
3026 #endif | |
3027 #ifdef FEAT_SYN_HL | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
3028 if (syntax_present(wp) && !wp->w_s->b_syn_error) |
7 | 3029 { |
3030 /* Prepare for syntax highlighting in this line. When there is an | |
3031 * error, stop syntax highlighting. */ | |
3032 save_did_emsg = did_emsg; | |
3033 did_emsg = FALSE; | |
3034 syntax_start(wp, lnum); | |
3035 if (did_emsg) | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
3036 wp->w_s->b_syn_error = TRUE; |
7 | 3037 else |
3038 { | |
3039 did_emsg = save_did_emsg; | |
3040 has_syntax = TRUE; | |
3041 extra_check = TRUE; | |
3042 } | |
3043 } | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
3044 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
3045 /* Check for columns to display for 'colorcolumn'. */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
3046 color_cols = wp->w_p_cc_cols; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
3047 if (color_cols != NULL) |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
3048 draw_color_col = advance_color_col(VCOL_HLC, &color_cols); |
743 | 3049 #endif |
3050 | |
3051 #ifdef FEAT_SPELL | |
258 | 3052 if (wp->w_p_spell |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
3053 && *wp->w_s->b_p_spl != NUL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
3054 && wp->w_s->b_langp.ga_len > 0 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
3055 && *(char **)(wp->w_s->b_langp.ga_data) != NULL) |
221 | 3056 { |
3057 /* Prepare for spell checking. */ | |
3058 has_spell = TRUE; | |
3059 extra_check = TRUE; | |
348 | 3060 |
3061 /* Get the start of the next line, so that words that wrap to the next | |
3062 * line are found too: "et<line-break>al.". | |
3063 * Trick: skip a few chars for C/shell/Vim comments */ | |
3064 nextline[SPWORDLEN] = NUL; | |
3065 if (lnum < wp->w_buffer->b_ml.ml_line_count) | |
3066 { | |
3067 line = ml_get_buf(wp->w_buffer, lnum + 1, FALSE); | |
3068 spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN); | |
3069 } | |
3070 | |
3071 /* When a word wrapped from the previous line the start of the current | |
3072 * line is valid. */ | |
3073 if (lnum == checked_lnum) | |
3074 cur_checked_col = checked_col; | |
3075 checked_lnum = 0; | |
386 | 3076 |
3077 /* When there was a sentence end in the previous line may require a | |
3078 * word starting with capital in this line. In line 1 always check | |
3079 * the first word. */ | |
3080 if (lnum != capcol_lnum) | |
3081 cap_col = -1; | |
3082 if (lnum == 1) | |
3083 cap_col = 0; | |
3084 capcol_lnum = 0; | |
221 | 3085 } |
7 | 3086 #endif |
3087 | |
3088 /* | |
3089 * handle visual active in this window | |
3090 */ | |
3091 fromcol = -10; | |
3092 tocol = MAXCOL; | |
3093 #ifdef FEAT_VISUAL | |
3094 if (VIsual_active && wp->w_buffer == curwin->w_buffer) | |
3095 { | |
3096 /* Visual is after curwin->w_cursor */ | |
3097 if (ltoreq(curwin->w_cursor, VIsual)) | |
3098 { | |
3099 top = &curwin->w_cursor; | |
3100 bot = &VIsual; | |
3101 } | |
3102 else /* Visual is before curwin->w_cursor */ | |
3103 { | |
3104 top = &VIsual; | |
3105 bot = &curwin->w_cursor; | |
3106 } | |
1813 | 3107 lnum_in_visual_area = (lnum >= top->lnum && lnum <= bot->lnum); |
7 | 3108 if (VIsual_mode == Ctrl_V) /* block mode */ |
3109 { | |
1813 | 3110 if (lnum_in_visual_area) |
7 | 3111 { |
3112 fromcol = wp->w_old_cursor_fcol; | |
3113 tocol = wp->w_old_cursor_lcol; | |
3114 } | |
3115 } | |
3116 else /* non-block mode */ | |
3117 { | |
3118 if (lnum > top->lnum && lnum <= bot->lnum) | |
3119 fromcol = 0; | |
3120 else if (lnum == top->lnum) | |
3121 { | |
3122 if (VIsual_mode == 'V') /* linewise */ | |
3123 fromcol = 0; | |
3124 else | |
3125 { | |
3126 getvvcol(wp, top, (colnr_T *)&fromcol, NULL, NULL); | |
3127 if (gchar_pos(top) == NUL) | |
3128 tocol = fromcol + 1; | |
3129 } | |
3130 } | |
3131 if (VIsual_mode != 'V' && lnum == bot->lnum) | |
3132 { | |
3133 if (*p_sel == 'e' && bot->col == 0 | |
3134 #ifdef FEAT_VIRTUALEDIT | |
3135 && bot->coladd == 0 | |
3136 #endif | |
3137 ) | |
3138 { | |
3139 fromcol = -10; | |
3140 tocol = MAXCOL; | |
3141 } | |
36 | 3142 else if (bot->col == MAXCOL) |
3143 tocol = MAXCOL; | |
7 | 3144 else |
3145 { | |
3146 pos = *bot; | |
3147 if (*p_sel == 'e') | |
3148 getvvcol(wp, &pos, (colnr_T *)&tocol, NULL, NULL); | |
3149 else | |
3150 { | |
3151 getvvcol(wp, &pos, NULL, NULL, (colnr_T *)&tocol); | |
3152 ++tocol; | |
3153 } | |
3154 } | |
3155 } | |
3156 } | |
3157 | |
3158 #ifndef MSDOS | |
3159 /* Check if the character under the cursor should not be inverted */ | |
3160 if (!highlight_match && lnum == curwin->w_cursor.lnum && wp == curwin | |
3161 # ifdef FEAT_GUI | |
3162 && !gui.in_use | |
3163 # endif | |
3164 ) | |
3165 noinvcur = TRUE; | |
3166 #endif | |
3167 | |
3168 /* if inverting in this line set area_highlighting */ | |
3169 if (fromcol >= 0) | |
3170 { | |
3171 area_highlighting = TRUE; | |
3172 attr = hl_attr(HLF_V); | |
3173 #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11) | |
3674 | 3174 if ((clip_star.available && !clip_star.owned |
3175 && clip_isautosel_star()) | |
3176 || (clip_plus.available && !clip_plus.owned | |
3177 && clip_isautosel_plus())) | |
7 | 3178 attr = hl_attr(HLF_VNC); |
3179 #endif | |
3180 } | |
3181 } | |
3182 | |
3183 /* | |
674 | 3184 * handle 'incsearch' and ":s///c" highlighting |
7 | 3185 */ |
3186 else | |
3187 #endif /* FEAT_VISUAL */ | |
3188 if (highlight_match | |
3189 && wp == curwin | |
3190 && lnum >= curwin->w_cursor.lnum | |
3191 && lnum <= curwin->w_cursor.lnum + search_match_lines) | |
3192 { | |
3193 if (lnum == curwin->w_cursor.lnum) | |
3194 getvcol(curwin, &(curwin->w_cursor), | |
3195 (colnr_T *)&fromcol, NULL, NULL); | |
3196 else | |
3197 fromcol = 0; | |
3198 if (lnum == curwin->w_cursor.lnum + search_match_lines) | |
3199 { | |
3200 pos.lnum = lnum; | |
3201 pos.col = search_match_endcol; | |
3202 getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL); | |
3203 } | |
3204 else | |
3205 tocol = MAXCOL; | |
1850 | 3206 /* do at least one character; happens when past end of line */ |
3207 if (fromcol == tocol) | |
3208 tocol = fromcol + 1; | |
7 | 3209 area_highlighting = TRUE; |
3210 attr = hl_attr(HLF_I); | |
3211 } | |
3212 | |
3213 #ifdef FEAT_DIFF | |
3214 filler_lines = diff_check(wp, lnum); | |
3215 if (filler_lines < 0) | |
3216 { | |
3217 if (filler_lines == -1) | |
3218 { | |
3219 if (diff_find_change(wp, lnum, &change_start, &change_end)) | |
3220 diff_hlf = HLF_ADD; /* added line */ | |
3221 else if (change_start == 0) | |
3222 diff_hlf = HLF_TXD; /* changed text */ | |
3223 else | |
3224 diff_hlf = HLF_CHD; /* changed line */ | |
3225 } | |
3226 else | |
3227 diff_hlf = HLF_ADD; /* added line */ | |
3228 filler_lines = 0; | |
3229 area_highlighting = TRUE; | |
3230 } | |
3231 if (lnum == wp->w_topline) | |
3232 filler_lines = wp->w_topfill; | |
3233 filler_todo = filler_lines; | |
3234 #endif | |
3235 | |
3236 #ifdef LINE_ATTR | |
3237 # ifdef FEAT_SIGNS | |
3238 /* If this line has a sign with line highlighting set line_attr. */ | |
3239 v = buf_getsigntype(wp->w_buffer, lnum, SIGN_LINEHL); | |
3240 if (v != 0) | |
3241 line_attr = sign_get_attr((int)v, TRUE); | |
3242 # endif | |
3243 # if defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS) | |
3244 /* Highlight the current line in the quickfix window. */ | |
644 | 3245 if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum) |
7 | 3246 line_attr = hl_attr(HLF_L); |
3247 # endif | |
3248 if (line_attr != 0) | |
3249 area_highlighting = TRUE; | |
3250 #endif | |
3251 | |
3252 line = ml_get_buf(wp->w_buffer, lnum, FALSE); | |
3253 ptr = line; | |
3254 | |
743 | 3255 #ifdef FEAT_SPELL |
348 | 3256 if (has_spell) |
3257 { | |
386 | 3258 /* For checking first word with a capital skip white space. */ |
3259 if (cap_col == 0) | |
835 | 3260 cap_col = (int)(skipwhite(line) - line); |
386 | 3261 |
348 | 3262 /* To be able to spell-check over line boundaries copy the end of the |
3263 * current line into nextline[]. Above the start of the next line was | |
3264 * copied to nextline[SPWORDLEN]. */ | |
3265 if (nextline[SPWORDLEN] == NUL) | |
3266 { | |
3267 /* No next line or it is empty. */ | |
3268 nextlinecol = MAXCOL; | |
3269 nextline_idx = 0; | |
3270 } | |
3271 else | |
3272 { | |
835 | 3273 v = (long)STRLEN(line); |
348 | 3274 if (v < SPWORDLEN) |
3275 { | |
3276 /* Short line, use it completely and append the start of the | |
3277 * next line. */ | |
3278 nextlinecol = 0; | |
3279 mch_memmove(nextline, line, (size_t)v); | |
1621 | 3280 STRMOVE(nextline + v, nextline + SPWORDLEN); |
348 | 3281 nextline_idx = v + 1; |
3282 } | |
3283 else | |
3284 { | |
3285 /* Long line, use only the last SPWORDLEN bytes. */ | |
3286 nextlinecol = v - SPWORDLEN; | |
3287 mch_memmove(nextline, line + nextlinecol, SPWORDLEN); | |
3288 nextline_idx = SPWORDLEN + 1; | |
3289 } | |
3290 } | |
3291 } | |
3292 #endif | |
3293 | |
7 | 3294 /* find start of trailing whitespace */ |
3295 if (wp->w_p_list && lcs_trail) | |
3296 { | |
3297 trailcol = (colnr_T)STRLEN(ptr); | |
3298 while (trailcol > (colnr_T)0 && vim_iswhite(ptr[trailcol - 1])) | |
3299 --trailcol; | |
3300 trailcol += (colnr_T) (ptr - line); | |
3301 extra_check = TRUE; | |
3302 } | |
3303 | |
3304 /* | |
3305 * 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the | |
3306 * first character to be displayed. | |
3307 */ | |
3308 if (wp->w_p_wrap) | |
3309 v = wp->w_skipcol; | |
3310 else | |
3311 v = wp->w_leftcol; | |
3312 if (v > 0) | |
3313 { | |
3314 #ifdef FEAT_MBYTE | |
3315 char_u *prev_ptr = ptr; | |
3316 #endif | |
3317 while (vcol < v && *ptr != NUL) | |
3318 { | |
3319 c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL); | |
3320 vcol += c; | |
3321 #ifdef FEAT_MBYTE | |
3322 prev_ptr = ptr; | |
39 | 3323 #endif |
3324 mb_ptr_adv(ptr); | |
7 | 3325 } |
3326 | |
1984 | 3327 #if defined(FEAT_SYN_HL) || defined(FEAT_VIRTUALEDIT) || defined(FEAT_VISUAL) |
3328 /* When: | |
3329 * - 'cuc' is set, or | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
3330 * - 'colorcolumn' is set, or |
1984 | 3331 * - 'virtualedit' is set, or |
3332 * - the visual mode is active, | |
3333 * the end of the line may be before the start of the displayed part. | |
3334 */ | |
3335 if (vcol < v && ( | |
3336 # ifdef FEAT_SYN_HL | |
3337 wp->w_p_cuc | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
3338 || draw_color_col |
1984 | 3339 # if defined(FEAT_VIRTUALEDIT) || defined(FEAT_VISUAL) |
3340 || | |
3341 # endif | |
3342 # endif | |
3343 # ifdef FEAT_VIRTUALEDIT | |
3344 virtual_active() | |
3345 # ifdef FEAT_VISUAL | |
3346 || | |
3347 # endif | |
3348 # endif | |
3349 # ifdef FEAT_VISUAL | |
3350 (VIsual_active && wp->w_buffer == curwin->w_buffer) | |
3351 # endif | |
3352 )) | |
3353 { | |
7 | 3354 vcol = v; |
1984 | 3355 } |
7 | 3356 #endif |
3357 | |
3358 /* Handle a character that's not completely on the screen: Put ptr at | |
3359 * that character but skip the first few screen characters. */ | |
3360 if (vcol > v) | |
3361 { | |
3362 vcol -= c; | |
3363 #ifdef FEAT_MBYTE | |
3364 ptr = prev_ptr; | |
3365 #else | |
3366 --ptr; | |
3367 #endif | |
3368 n_skip = v - vcol; | |
3369 } | |
3370 | |
3371 /* | |
3372 * Adjust for when the inverted text is before the screen, | |
3373 * and when the start of the inverted text is before the screen. | |
3374 */ | |
3375 if (tocol <= vcol) | |
3376 fromcol = 0; | |
3377 else if (fromcol >= 0 && fromcol < vcol) | |
3378 fromcol = vcol; | |
3379 | |
3380 #ifdef FEAT_LINEBREAK | |
3381 /* When w_skipcol is non-zero, first line needs 'showbreak' */ | |
3382 if (wp->w_p_wrap) | |
3383 need_showbreak = TRUE; | |
3384 #endif | |
743 | 3385 #ifdef FEAT_SPELL |
499 | 3386 /* When spell checking a word we need to figure out the start of the |
3387 * word and if it's badly spelled or not. */ | |
3388 if (has_spell) | |
3389 { | |
3390 int len; | |
1536 | 3391 colnr_T linecol = (colnr_T)(ptr - line); |
534 | 3392 hlf_T spell_hlf = HLF_COUNT; |
499 | 3393 |
3394 pos = wp->w_cursor; | |
3395 wp->w_cursor.lnum = lnum; | |
1536 | 3396 wp->w_cursor.col = linecol; |
534 | 3397 len = spell_move_to(wp, FORWARD, TRUE, TRUE, &spell_hlf); |
1536 | 3398 |
3399 /* spell_move_to() may call ml_get() and make "line" invalid */ | |
3400 line = ml_get_buf(wp->w_buffer, lnum, FALSE); | |
3401 ptr = line + linecol; | |
3402 | |
530 | 3403 if (len == 0 || (int)wp->w_cursor.col > ptr - line) |
499 | 3404 { |
3405 /* no bad word found at line start, don't check until end of a | |
3406 * word */ | |
534 | 3407 spell_hlf = HLF_COUNT; |
3572 | 3408 word_end = (int)(spell_to_word_end(ptr, wp) - line + 1); |
499 | 3409 } |
3410 else | |
534 | 3411 { |
499 | 3412 /* bad word found, use attributes until end of word */ |
3413 word_end = wp->w_cursor.col + len + 1; | |
3414 | |
534 | 3415 /* Turn index into actual attributes. */ |
3416 if (spell_hlf != HLF_COUNT) | |
3417 spell_attr = highlight_attr[spell_hlf]; | |
3418 } | |
499 | 3419 wp->w_cursor = pos; |
501 | 3420 |
743 | 3421 # ifdef FEAT_SYN_HL |
501 | 3422 /* Need to restart syntax highlighting for this line. */ |
3423 if (has_syntax) | |
3424 syntax_start(wp, lnum); | |
743 | 3425 # endif |
499 | 3426 } |
3427 #endif | |
7 | 3428 } |
3429 | |
3430 /* | |
3431 * Correct highlighting for cursor that can't be disabled. | |
3432 * Avoids having to check this for each character. | |
3433 */ | |
3434 if (fromcol >= 0) | |
3435 { | |
3436 if (noinvcur) | |
3437 { | |
3438 if ((colnr_T)fromcol == wp->w_virtcol) | |
3439 { | |
3440 /* highlighting starts at cursor, let it start just after the | |
3441 * cursor */ | |
3442 fromcol_prev = fromcol; | |
3443 fromcol = -1; | |
3444 } | |
3445 else if ((colnr_T)fromcol < wp->w_virtcol) | |
3446 /* restart highlighting after the cursor */ | |
3447 fromcol_prev = wp->w_virtcol; | |
3448 } | |
3449 if (fromcol >= tocol) | |
3450 fromcol = -1; | |
3451 } | |
3452 | |
3453 #ifdef FEAT_SEARCH_EXTRA | |
3454 /* | |
1326 | 3455 * Handle highlighting the last used search pattern and matches. |
3456 * Do this for both search_hl and the match list. | |
7 | 3457 */ |
1326 | 3458 cur = wp->w_match_head; |
3459 shl_flag = FALSE; | |
3460 while (cur != NULL || shl_flag == FALSE) | |
3461 { | |
3462 if (shl_flag == FALSE) | |
3463 { | |
3464 shl = &search_hl; | |
3465 shl_flag = TRUE; | |
3466 } | |
3467 else | |
3468 shl = &cur->hl; | |
36 | 3469 shl->startcol = MAXCOL; |
3470 shl->endcol = MAXCOL; | |
7 | 3471 shl->attr_cur = 0; |
3472 if (shl->rm.regprog != NULL) | |
3473 { | |
3474 v = (long)(ptr - line); | |
3475 next_search_hl(wp, shl, lnum, (colnr_T)v); | |
3476 | |
3477 /* Need to get the line again, a multi-line regexp may have made it | |
3478 * invalid. */ | |
3479 line = ml_get_buf(wp->w_buffer, lnum, FALSE); | |
3480 ptr = line + v; | |
3481 | |
3482 if (shl->lnum != 0 && shl->lnum <= lnum) | |
3483 { | |
3484 if (shl->lnum == lnum) | |
36 | 3485 shl->startcol = shl->rm.startpos[0].col; |
7 | 3486 else |
36 | 3487 shl->startcol = 0; |
7 | 3488 if (lnum == shl->lnum + shl->rm.endpos[0].lnum |
3489 - shl->rm.startpos[0].lnum) | |
36 | 3490 shl->endcol = shl->rm.endpos[0].col; |
7 | 3491 else |
36 | 3492 shl->endcol = MAXCOL; |
7 | 3493 /* Highlight one character for an empty match. */ |
36 | 3494 if (shl->startcol == shl->endcol) |
7 | 3495 { |
3496 #ifdef FEAT_MBYTE | |
36 | 3497 if (has_mbyte && line[shl->endcol] != NUL) |
474 | 3498 shl->endcol += (*mb_ptr2len)(line + shl->endcol); |
7 | 3499 else |
3500 #endif | |
36 | 3501 ++shl->endcol; |
7 | 3502 } |
36 | 3503 if ((long)shl->startcol < v) /* match at leftcol */ |
7 | 3504 { |
3505 shl->attr_cur = shl->attr; | |
3506 search_attr = shl->attr; | |
3507 } | |
3508 area_highlighting = TRUE; | |
3509 } | |
3510 } | |
1326 | 3511 if (shl != &search_hl && cur != NULL) |
3512 cur = cur->next; | |
7 | 3513 } |
3514 #endif | |
3515 | |
743 | 3516 #ifdef FEAT_SYN_HL |
5068
6a7ae677d6a1
updated for version 7.3.1277
Bram Moolenaar <bram@vim.org>
parents:
4916
diff
changeset
|
3517 /* Cursor line highlighting for 'cursorline' in the current window. Not |
6a7ae677d6a1
updated for version 7.3.1277
Bram Moolenaar <bram@vim.org>
parents:
4916
diff
changeset
|
3518 * when Visual mode is active, because it's not clear what is selected |
6a7ae677d6a1
updated for version 7.3.1277
Bram Moolenaar <bram@vim.org>
parents:
4916
diff
changeset
|
3519 * then. */ |
5078
22ac43fb6d30
updated for version 7.3.1282
Bram Moolenaar <bram@vim.org>
parents:
5068
diff
changeset
|
3520 if (wp->w_p_cul && lnum == wp->w_cursor.lnum |
22ac43fb6d30
updated for version 7.3.1282
Bram Moolenaar <bram@vim.org>
parents:
5068
diff
changeset
|
3521 && !(wp == curwin && VIsual_active)) |
743 | 3522 { |
3523 line_attr = hl_attr(HLF_CUL); | |
3524 area_highlighting = TRUE; | |
3525 } | |
3526 #endif | |
3527 | |
504 | 3528 off = (unsigned)(current_ScreenLine - ScreenLines); |
7 | 3529 col = 0; |
3530 #ifdef FEAT_RIGHTLEFT | |
3531 if (wp->w_p_rl) | |
3532 { | |
3533 /* Rightleft window: process the text in the normal direction, but put | |
3534 * it in current_ScreenLine[] from right to left. Start at the | |
3535 * rightmost column of the window. */ | |
3536 col = W_WIDTH(wp) - 1; | |
3537 off += col; | |
3538 } | |
3539 #endif | |
3540 | |
3541 /* | |
3542 * Repeat for the whole displayed line. | |
3543 */ | |
3544 for (;;) | |
3545 { | |
3546 /* Skip this quickly when working on the text. */ | |
3547 if (draw_state != WL_LINE) | |
3548 { | |
3549 #ifdef FEAT_CMDWIN | |
3550 if (draw_state == WL_CMDLINE - 1 && n_extra == 0) | |
3551 { | |
3552 draw_state = WL_CMDLINE; | |
3553 if (cmdwin_type != 0 && wp == curwin) | |
3554 { | |
3555 /* Draw the cmdline character. */ | |
3556 n_extra = 1; | |
1340 | 3557 c_extra = cmdwin_type; |
7 | 3558 char_attr = hl_attr(HLF_AT); |
3559 } | |
3560 } | |
3561 #endif | |
3562 | |
3563 #ifdef FEAT_FOLDING | |
3564 if (draw_state == WL_FOLD - 1 && n_extra == 0) | |
3565 { | |
3566 draw_state = WL_FOLD; | |
3567 if (wp->w_p_fdc > 0) | |
3568 { | |
3569 /* Draw the 'foldcolumn'. */ | |
3570 fill_foldcolumn(extra, wp, FALSE, lnum); | |
3571 n_extra = wp->w_p_fdc; | |
3572 p_extra = extra; | |
1340 | 3573 p_extra[n_extra] = NUL; |
7 | 3574 c_extra = NUL; |
3575 char_attr = hl_attr(HLF_FC); | |
3576 } | |
3577 } | |
3578 #endif | |
3579 | |
3580 #ifdef FEAT_SIGNS | |
3581 if (draw_state == WL_SIGN - 1 && n_extra == 0) | |
3582 { | |
3583 draw_state = WL_SIGN; | |
3584 /* Show the sign column when there are any signs in this | |
3585 * buffer or when using Netbeans. */ | |
3586 if (draw_signcolumn(wp) | |
3587 # ifdef FEAT_DIFF | |
3588 && filler_todo <= 0 | |
3589 # endif | |
3590 ) | |
3591 { | |
2661 | 3592 int text_sign; |
7 | 3593 # ifdef FEAT_SIGN_ICONS |
2661 | 3594 int icon_sign; |
7 | 3595 # endif |
3596 | |
3597 /* Draw two cells with the sign value or blank. */ | |
3598 c_extra = ' '; | |
3599 char_attr = hl_attr(HLF_SC); | |
3600 n_extra = 2; | |
3601 | |
3602 if (row == startrow) | |
3603 { | |
3604 text_sign = buf_getsigntype(wp->w_buffer, lnum, | |
3605 SIGN_TEXT); | |
3606 # ifdef FEAT_SIGN_ICONS | |
3607 icon_sign = buf_getsigntype(wp->w_buffer, lnum, | |
3608 SIGN_ICON); | |
3609 if (gui.in_use && icon_sign != 0) | |
3610 { | |
3611 /* Use the image in this position. */ | |
3612 c_extra = SIGN_BYTE; | |
3613 # ifdef FEAT_NETBEANS_INTG | |
3614 if (buf_signcount(wp->w_buffer, lnum) > 1) | |
3615 c_extra = MULTISIGN_BYTE; | |
3616 # endif | |
3617 char_attr = icon_sign; | |
3618 } | |
3619 else | |
3620 # endif | |
3621 if (text_sign != 0) | |
3622 { | |
3623 p_extra = sign_get_text(text_sign); | |
3624 if (p_extra != NULL) | |
3625 { | |
3626 c_extra = NUL; | |
835 | 3627 n_extra = (int)STRLEN(p_extra); |
7 | 3628 } |
3629 char_attr = sign_get_attr(text_sign, FALSE); | |
3630 } | |
3631 } | |
3632 } | |
3633 } | |
3634 #endif | |
3635 | |
3636 if (draw_state == WL_NR - 1 && n_extra == 0) | |
3637 { | |
3638 draw_state = WL_NR; | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
3639 /* Display the absolute or relative line number. After the |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
3640 * first fill with blanks when the 'n' flag isn't in 'cpo' */ |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
3641 if ((wp->w_p_nu || wp->w_p_rnu) |
7 | 3642 && (row == startrow |
3643 #ifdef FEAT_DIFF | |
3644 + filler_lines | |
3645 #endif | |
3646 || vim_strchr(p_cpo, CPO_NUMCOL) == NULL)) | |
3647 { | |
3648 /* Draw the line number (empty space after wrapping). */ | |
3649 if (row == startrow | |
3650 #ifdef FEAT_DIFF | |
3651 + filler_lines | |
3652 #endif | |
3653 ) | |
3654 { | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
3655 long num; |
4065 | 3656 char *fmt = "%*ld "; |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
3657 |
4736
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3658 if (wp->w_p_nu && !wp->w_p_rnu) |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3659 /* 'number' + 'norelativenumber' */ |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
3660 num = (long)lnum; |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
3661 else |
4065 | 3662 { |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
3663 /* 'relativenumber', don't use negative numbers */ |
2675 | 3664 num = labs((long)get_cursor_rel_lnum(wp, lnum)); |
4736
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3665 if (num == 0 && wp->w_p_nu && wp->w_p_rnu) |
4065 | 3666 { |
4736
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
3667 /* 'number' + 'relativenumber' */ |
4065 | 3668 num = lnum; |
3669 fmt = "%-*ld "; | |
3670 } | |
3671 } | |
3672 | |
3673 sprintf((char *)extra, fmt, | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
3674 number_width(wp), num); |
7 | 3675 if (wp->w_skipcol > 0) |
3676 for (p_extra = extra; *p_extra == ' '; ++p_extra) | |
3677 *p_extra = '-'; | |
3678 #ifdef FEAT_RIGHTLEFT | |
3679 if (wp->w_p_rl) /* reverse line numbers */ | |
3680 rl_mirror(extra); | |
3681 #endif | |
3682 p_extra = extra; | |
3683 c_extra = NUL; | |
3684 } | |
3685 else | |
3686 c_extra = ' '; | |
13 | 3687 n_extra = number_width(wp) + 1; |
7 | 3688 char_attr = hl_attr(HLF_N); |
743 | 3689 #ifdef FEAT_SYN_HL |
3690 /* When 'cursorline' is set highlight the line number of | |
3427 | 3691 * the current line differently. |
3692 * TODO: Can we use CursorLine instead of CursorLineNr | |
3693 * when CursorLineNr isn't set? */ | |
5078
22ac43fb6d30
updated for version 7.3.1282
Bram Moolenaar <bram@vim.org>
parents:
5068
diff
changeset
|
3694 if ((wp->w_p_cul || wp->w_p_rnu) |
4065 | 3695 && lnum == wp->w_cursor.lnum) |
3427 | 3696 char_attr = hl_attr(HLF_CLN); |
743 | 3697 #endif |
7 | 3698 } |
3699 } | |
3700 | |
3701 #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF) | |
3702 if (draw_state == WL_SBR - 1 && n_extra == 0) | |
3703 { | |
3704 draw_state = WL_SBR; | |
3705 # ifdef FEAT_DIFF | |
3706 if (filler_todo > 0) | |
3707 { | |
3708 /* Draw "deleted" diff line(s). */ | |
3709 if (char2cells(fill_diff) > 1) | |
3710 c_extra = '-'; | |
3711 else | |
3712 c_extra = fill_diff; | |
3713 # ifdef FEAT_RIGHTLEFT | |
3714 if (wp->w_p_rl) | |
3715 n_extra = col + 1; | |
3716 else | |
3717 # endif | |
3718 n_extra = W_WIDTH(wp) - col; | |
3719 char_attr = hl_attr(HLF_DED); | |
3720 } | |
3721 # endif | |
3722 # ifdef FEAT_LINEBREAK | |
3723 if (*p_sbr != NUL && need_showbreak) | |
3724 { | |
3725 /* Draw 'showbreak' at the start of each broken line. */ | |
3726 p_extra = p_sbr; | |
3727 c_extra = NUL; | |
3728 n_extra = (int)STRLEN(p_sbr); | |
3729 char_attr = hl_attr(HLF_AT); | |
3730 need_showbreak = FALSE; | |
3731 /* Correct end of highlighted area for 'showbreak', | |
3732 * required when 'linebreak' is also set. */ | |
3733 if (tocol == vcol) | |
3734 tocol += n_extra; | |
5068
6a7ae677d6a1
updated for version 7.3.1277
Bram Moolenaar <bram@vim.org>
parents:
4916
diff
changeset
|
3735 #ifdef FEAT_SYN_HL |
6a7ae677d6a1
updated for version 7.3.1277
Bram Moolenaar <bram@vim.org>
parents:
4916
diff
changeset
|
3736 /* combine 'showbreak' with 'cursorline' */ |
5078
22ac43fb6d30
updated for version 7.3.1282
Bram Moolenaar <bram@vim.org>
parents:
5068
diff
changeset
|
3737 if (wp->w_p_cul && lnum == wp->w_cursor.lnum) |
5068
6a7ae677d6a1
updated for version 7.3.1277
Bram Moolenaar <bram@vim.org>
parents:
4916
diff
changeset
|
3738 char_attr = hl_combine_attr(char_attr, HLF_CLN); |
6a7ae677d6a1
updated for version 7.3.1277
Bram Moolenaar <bram@vim.org>
parents:
4916
diff
changeset
|
3739 #endif |
7 | 3740 } |
3741 # endif | |
3742 } | |
3743 #endif | |
3744 | |
3745 if (draw_state == WL_LINE - 1 && n_extra == 0) | |
3746 { | |
3747 draw_state = WL_LINE; | |
3748 if (saved_n_extra) | |
3749 { | |
3750 /* Continue item from end of wrapped line. */ | |
3751 n_extra = saved_n_extra; | |
3752 c_extra = saved_c_extra; | |
3753 p_extra = saved_p_extra; | |
3754 char_attr = saved_char_attr; | |
3755 } | |
3756 else | |
3757 char_attr = 0; | |
3758 } | |
3759 } | |
3760 | |
3761 /* When still displaying '$' of change command, stop at cursor */ | |
3318 | 3762 if (dollar_vcol >= 0 && wp == curwin |
819 | 3763 && lnum == wp->w_cursor.lnum && vcol >= (long)wp->w_virtcol |
7 | 3764 #ifdef FEAT_DIFF |
3765 && filler_todo <= 0 | |
3766 #endif | |
3767 ) | |
3768 { | |
3769 SCREEN_LINE(screen_row, W_WINCOL(wp), col, -(int)W_WIDTH(wp), | |
3770 wp->w_p_rl); | |
819 | 3771 /* Pretend we have finished updating the window. Except when |
3772 * 'cursorcolumn' is set. */ | |
3773 #ifdef FEAT_SYN_HL | |
3774 if (wp->w_p_cuc) | |
3775 row = wp->w_cline_row + wp->w_cline_height; | |
3776 else | |
3777 #endif | |
3778 row = wp->w_height; | |
7 | 3779 break; |
3780 } | |
3781 | |
3782 if (draw_state == WL_LINE && area_highlighting) | |
3783 { | |
3784 /* handle Visual or match highlighting in this line */ | |
3785 if (vcol == fromcol | |
3786 #ifdef FEAT_MBYTE | |
3787 || (has_mbyte && vcol + 1 == fromcol && n_extra == 0 | |
3788 && (*mb_ptr2cells)(ptr) > 1) | |
3789 #endif | |
3790 || ((int)vcol_prev == fromcol_prev | |
1814 | 3791 && vcol_prev < vcol /* not at margin */ |
7 | 3792 && vcol < tocol)) |
3793 area_attr = attr; /* start highlighting */ | |
3794 else if (area_attr != 0 | |
3795 && (vcol == tocol | |
3796 || (noinvcur && (colnr_T)vcol == wp->w_virtcol))) | |
3797 area_attr = 0; /* stop highlighting */ | |
3798 | |
3799 #ifdef FEAT_SEARCH_EXTRA | |
3800 if (!n_extra) | |
3801 { | |
3802 /* | |
3803 * Check for start/end of search pattern match. | |
3804 * After end, check for start/end of next match. | |
3805 * When another match, have to check for start again. | |
3806 * Watch out for matching an empty string! | |
1326 | 3807 * Do this for 'search_hl' and the match list (ordered by |
3808 * priority). | |
7 | 3809 */ |
36 | 3810 v = (long)(ptr - line); |
1326 | 3811 cur = wp->w_match_head; |
3812 shl_flag = FALSE; | |
3813 while (cur != NULL || shl_flag == FALSE) | |
3814 { | |
3815 if (shl_flag == FALSE | |
3816 && ((cur != NULL | |
3817 && cur->priority > SEARCH_HL_PRIORITY) | |
3818 || cur == NULL)) | |
3819 { | |
3820 shl = &search_hl; | |
3821 shl_flag = TRUE; | |
3822 } | |
3823 else | |
3824 shl = &cur->hl; | |
7 | 3825 while (shl->rm.regprog != NULL) |
3826 { | |
36 | 3827 if (shl->startcol != MAXCOL |
3828 && v >= (long)shl->startcol | |
3829 && v < (long)shl->endcol) | |
7 | 3830 { |
3831 shl->attr_cur = shl->attr; | |
3832 } | |
36 | 3833 else if (v == (long)shl->endcol) |
7 | 3834 { |
3835 shl->attr_cur = 0; | |
3836 | |
3837 next_search_hl(wp, shl, lnum, (colnr_T)v); | |
3838 | |
3839 /* Need to get the line again, a multi-line regexp | |
3840 * may have made it invalid. */ | |
3841 line = ml_get_buf(wp->w_buffer, lnum, FALSE); | |
3842 ptr = line + v; | |
3843 | |
3844 if (shl->lnum == lnum) | |
3845 { | |
36 | 3846 shl->startcol = shl->rm.startpos[0].col; |
7 | 3847 if (shl->rm.endpos[0].lnum == 0) |
36 | 3848 shl->endcol = shl->rm.endpos[0].col; |
7 | 3849 else |
36 | 3850 shl->endcol = MAXCOL; |
3851 | |
3852 if (shl->startcol == shl->endcol) | |
7 | 3853 { |
3854 /* highlight empty match, try again after | |
3855 * it */ | |
3856 #ifdef FEAT_MBYTE | |
3857 if (has_mbyte) | |
474 | 3858 shl->endcol += (*mb_ptr2len)(line |
36 | 3859 + shl->endcol); |
7 | 3860 else |
3861 #endif | |
36 | 3862 ++shl->endcol; |
7 | 3863 } |
3864 | |
3865 /* Loop to check if the match starts at the | |
3866 * current position */ | |
3867 continue; | |
3868 } | |
3869 } | |
3870 break; | |
3871 } | |
1326 | 3872 if (shl != &search_hl && cur != NULL) |
3873 cur = cur->next; | |
3874 } | |
3875 | |
3876 /* Use attributes from match with highest priority among | |
3877 * 'search_hl' and the match list. */ | |
3878 search_attr = search_hl.attr_cur; | |
3879 cur = wp->w_match_head; | |
3880 shl_flag = FALSE; | |
3881 while (cur != NULL || shl_flag == FALSE) | |
3882 { | |
3883 if (shl_flag == FALSE | |
3884 && ((cur != NULL | |
3885 && cur->priority > SEARCH_HL_PRIORITY) | |
3886 || cur == NULL)) | |
699 | 3887 { |
1326 | 3888 shl = &search_hl; |
3889 shl_flag = TRUE; | |
699 | 3890 } |
1326 | 3891 else |
3892 shl = &cur->hl; | |
3893 if (shl->attr_cur != 0) | |
3894 search_attr = shl->attr_cur; | |
3895 if (shl != &search_hl && cur != NULL) | |
3896 cur = cur->next; | |
3897 } | |
7 | 3898 } |
3899 #endif | |
3900 | |
3901 #ifdef FEAT_DIFF | |
674 | 3902 if (diff_hlf != (hlf_T)0) |
7 | 3903 { |
1295 | 3904 if (diff_hlf == HLF_CHD && ptr - line >= change_start |
3905 && n_extra == 0) | |
7 | 3906 diff_hlf = HLF_TXD; /* changed text */ |
1295 | 3907 if (diff_hlf == HLF_TXD && ptr - line > change_end |
3908 && n_extra == 0) | |
7 | 3909 diff_hlf = HLF_CHD; /* changed line */ |
674 | 3910 line_attr = hl_attr(diff_hlf); |
3911 } | |
3912 #endif | |
3913 | |
3914 /* Decide which of the highlight attributes to use. */ | |
3915 attr_pri = TRUE; | |
3916 if (area_attr != 0) | |
3917 char_attr = area_attr; | |
3918 else if (search_attr != 0) | |
3919 char_attr = search_attr; | |
3920 #ifdef LINE_ATTR | |
3921 /* Use line_attr when not in the Visual or 'incsearch' area | |
3922 * (area_attr may be 0 when "noinvcur" is set). */ | |
3923 else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL) | |
1842 | 3924 || vcol < fromcol || vcol_prev < fromcol_prev |
3925 || vcol >= tocol)) | |
674 | 3926 char_attr = line_attr; |
3927 #endif | |
3928 else | |
3929 { | |
3930 attr_pri = FALSE; | |
3931 #ifdef FEAT_SYN_HL | |
3932 if (has_syntax) | |
3933 char_attr = syntax_attr; | |
3934 else | |
3935 #endif | |
3936 char_attr = 0; | |
3937 } | |
7 | 3938 } |
3939 | |
3940 /* | |
3941 * Get the next character to put on the screen. | |
3942 */ | |
3943 /* | |
1340 | 3944 * The "p_extra" points to the extra stuff that is inserted to |
3945 * represent special characters (non-printable stuff) and other | |
3946 * things. When all characters are the same, c_extra is used. | |
3947 * "p_extra" must end in a NUL to avoid mb_ptr2len() reads past | |
3948 * "p_extra[n_extra]". | |
7 | 3949 * For the '$' of the 'list' option, n_extra == 1, p_extra == "". |
3950 */ | |
3951 if (n_extra > 0) | |
3952 { | |
3953 if (c_extra != NUL) | |
3954 { | |
3955 c = c_extra; | |
3956 #ifdef FEAT_MBYTE | |
3957 mb_c = c; /* doesn't handle non-utf-8 multi-byte! */ | |
3958 if (enc_utf8 && (*mb_char2len)(c) > 1) | |
3959 { | |
3960 mb_utf8 = TRUE; | |
714 | 3961 u8cc[0] = 0; |
819 | 3962 c = 0xc0; |
7 | 3963 } |
3964 else | |
3965 mb_utf8 = FALSE; | |
3966 #endif | |
3967 } | |
3968 else | |
3969 { | |
3970 c = *p_extra; | |
3971 #ifdef FEAT_MBYTE | |
3972 if (has_mbyte) | |
3973 { | |
3974 mb_c = c; | |
3975 if (enc_utf8) | |
3976 { | |
3977 /* If the UTF-8 character is more than one byte: | |
3978 * Decode it into "mb_c". */ | |
474 | 3979 mb_l = (*mb_ptr2len)(p_extra); |
7 | 3980 mb_utf8 = FALSE; |
3981 if (mb_l > n_extra) | |
3982 mb_l = 1; | |
3983 else if (mb_l > 1) | |
3984 { | |
714 | 3985 mb_c = utfc_ptr2char(p_extra, u8cc); |
7 | 3986 mb_utf8 = TRUE; |
819 | 3987 c = 0xc0; |
7 | 3988 } |
3989 } | |
3990 else | |
3991 { | |
3992 /* if this is a DBCS character, put it in "mb_c" */ | |
3993 mb_l = MB_BYTE2LEN(c); | |
3994 if (mb_l >= n_extra) | |
3995 mb_l = 1; | |
3996 else if (mb_l > 1) | |
3997 mb_c = (c << 8) + p_extra[1]; | |
3998 } | |
504 | 3999 if (mb_l == 0) /* at the NUL at end-of-line */ |
4000 mb_l = 1; | |
4001 | |
7 | 4002 /* If a double-width char doesn't fit display a '>' in the |
4003 * last column. */ | |
504 | 4004 if (( |
7 | 4005 # ifdef FEAT_RIGHTLEFT |
4006 wp->w_p_rl ? (col <= 0) : | |
4007 # endif | |
504 | 4008 (col >= W_WIDTH(wp) - 1)) |
7 | 4009 && (*mb_char2cells)(mb_c) == 2) |
4010 { | |
4011 c = '>'; | |
4012 mb_c = c; | |
4013 mb_l = 1; | |
4014 mb_utf8 = FALSE; | |
4015 multi_attr = hl_attr(HLF_AT); | |
4016 /* put the pointer back to output the double-width | |
4017 * character at the start of the next line. */ | |
4018 ++n_extra; | |
4019 --p_extra; | |
4020 } | |
4021 else | |
4022 { | |
4023 n_extra -= mb_l - 1; | |
4024 p_extra += mb_l - 1; | |
4025 } | |
4026 } | |
4027 #endif | |
4028 ++p_extra; | |
4029 } | |
4030 --n_extra; | |
4031 } | |
4032 else | |
4033 { | |
4034 /* | |
4035 * Get a character from the line itself. | |
4036 */ | |
4037 c = *ptr; | |
4038 #ifdef FEAT_MBYTE | |
4039 if (has_mbyte) | |
4040 { | |
4041 mb_c = c; | |
4042 if (enc_utf8) | |
4043 { | |
4044 /* If the UTF-8 character is more than one byte: Decode it | |
4045 * into "mb_c". */ | |
474 | 4046 mb_l = (*mb_ptr2len)(ptr); |
7 | 4047 mb_utf8 = FALSE; |
4048 if (mb_l > 1) | |
4049 { | |
714 | 4050 mb_c = utfc_ptr2char(ptr, u8cc); |
7 | 4051 /* Overlong encoded ASCII or ASCII with composing char |
4052 * is displayed normally, except a NUL. */ | |
4053 if (mb_c < 0x80) | |
4054 c = mb_c; | |
4055 mb_utf8 = TRUE; | |
507 | 4056 |
4057 /* At start of the line we can have a composing char. | |
4058 * Draw it as a space with a composing char. */ | |
4059 if (utf_iscomposing(mb_c)) | |
4060 { | |
1326 | 4061 int i; |
4062 | |
714 | 4063 for (i = Screen_mco - 1; i > 0; --i) |
4064 u8cc[i] = u8cc[i - 1]; | |
4065 u8cc[0] = mb_c; | |
507 | 4066 mb_c = ' '; |
4067 } | |
7 | 4068 } |
4069 | |
4070 if ((mb_l == 1 && c >= 0x80) | |
4071 || (mb_l >= 1 && mb_c == 0) | |
4072 || (mb_l > 1 && (!vim_isprintc(mb_c) | |
1401 | 4073 # ifdef UNICODE16 |
4074 || mb_c >= 0x10000 | |
4075 # endif | |
4076 ))) | |
7 | 4077 { |
4078 /* | |
4079 * Illegal UTF-8 byte: display as <xx>. | |
4080 * Non-BMP character : display as ? or fullwidth ?. | |
4081 */ | |
1401 | 4082 # ifdef UNICODE16 |
7 | 4083 if (mb_c < 0x10000) |
1401 | 4084 # endif |
7 | 4085 { |
4086 transchar_hex(extra, mb_c); | |
714 | 4087 # ifdef FEAT_RIGHTLEFT |
7 | 4088 if (wp->w_p_rl) /* reverse */ |
4089 rl_mirror(extra); | |
714 | 4090 # endif |
7 | 4091 } |
1401 | 4092 # ifdef UNICODE16 |
7 | 4093 else if (utf_char2cells(mb_c) != 2) |
4094 STRCPY(extra, "?"); | |
4095 else | |
4096 /* 0xff1f in UTF-8: full-width '?' */ | |
4097 STRCPY(extra, "\357\274\237"); | |
1401 | 4098 # endif |
7 | 4099 |
4100 p_extra = extra; | |
4101 c = *p_extra; | |
4102 mb_c = mb_ptr2char_adv(&p_extra); | |
4103 mb_utf8 = (c >= 0x80); | |
4104 n_extra = (int)STRLEN(p_extra); | |
4105 c_extra = NUL; | |
4106 if (area_attr == 0 && search_attr == 0) | |
4107 { | |
4108 n_attr = n_extra + 1; | |
4109 extra_attr = hl_attr(HLF_8); | |
4110 saved_attr2 = char_attr; /* save current attr */ | |
4111 } | |
4112 } | |
4113 else if (mb_l == 0) /* at the NUL at end-of-line */ | |
4114 mb_l = 1; | |
4115 #ifdef FEAT_ARABIC | |
4116 else if (p_arshape && !p_tbidi && ARABIC_CHAR(mb_c)) | |
4117 { | |
4118 /* Do Arabic shaping. */ | |
714 | 4119 int pc, pc1, nc; |
4120 int pcc[MAX_MCO]; | |
7 | 4121 |
4122 /* The idea of what is the previous and next | |
4123 * character depends on 'rightleft'. */ | |
4124 if (wp->w_p_rl) | |
4125 { | |
4126 pc = prev_c; | |
4127 pc1 = prev_c1; | |
4128 nc = utf_ptr2char(ptr + mb_l); | |
714 | 4129 prev_c1 = u8cc[0]; |
7 | 4130 } |
4131 else | |
4132 { | |
714 | 4133 pc = utfc_ptr2char(ptr + mb_l, pcc); |
7 | 4134 nc = prev_c; |
714 | 4135 pc1 = pcc[0]; |
7 | 4136 } |
4137 prev_c = mb_c; | |
4138 | |
714 | 4139 mb_c = arabic_shape(mb_c, &c, &u8cc[0], pc, pc1, nc); |
7 | 4140 } |
4141 else | |
4142 prev_c = mb_c; | |
4143 #endif | |
4144 } | |
4145 else /* enc_dbcs */ | |
4146 { | |
4147 mb_l = MB_BYTE2LEN(c); | |
4148 if (mb_l == 0) /* at the NUL at end-of-line */ | |
4149 mb_l = 1; | |
4150 else if (mb_l > 1) | |
4151 { | |
4152 /* We assume a second byte below 32 is illegal. | |
4153 * Hopefully this is OK for all double-byte encodings! | |
4154 */ | |
4155 if (ptr[1] >= 32) | |
4156 mb_c = (c << 8) + ptr[1]; | |
4157 else | |
4158 { | |
4159 if (ptr[1] == NUL) | |
4160 { | |
4161 /* head byte at end of line */ | |
4162 mb_l = 1; | |
4163 transchar_nonprint(extra, c); | |
4164 } | |
4165 else | |
4166 { | |
4167 /* illegal tail byte */ | |
4168 mb_l = 2; | |
4169 STRCPY(extra, "XX"); | |
4170 } | |
4171 p_extra = extra; | |
4172 n_extra = (int)STRLEN(extra) - 1; | |
4173 c_extra = NUL; | |
4174 c = *p_extra++; | |
4175 if (area_attr == 0 && search_attr == 0) | |
4176 { | |
4177 n_attr = n_extra + 1; | |
4178 extra_attr = hl_attr(HLF_8); | |
4179 saved_attr2 = char_attr; /* save current attr */ | |
4180 } | |
4181 mb_c = c; | |
4182 } | |
4183 } | |
4184 } | |
4185 /* If a double-width char doesn't fit display a '>' in the | |
4186 * last column; the character is displayed at the start of the | |
4187 * next line. */ | |
4188 if (( | |
4189 # ifdef FEAT_RIGHTLEFT | |
4190 wp->w_p_rl ? (col <= 0) : | |
4191 # endif | |
4192 (col >= W_WIDTH(wp) - 1)) | |
4193 && (*mb_char2cells)(mb_c) == 2) | |
4194 { | |
4195 c = '>'; | |
4196 mb_c = c; | |
4197 mb_utf8 = FALSE; | |
4198 mb_l = 1; | |
4199 multi_attr = hl_attr(HLF_AT); | |
4200 /* Put pointer back so that the character will be | |
4201 * displayed at the start of the next line. */ | |
4202 --ptr; | |
4203 } | |
4204 else if (*ptr != NUL) | |
4205 ptr += mb_l - 1; | |
4206 | |
4207 /* If a double-width char doesn't fit at the left side display | |
2509
6d6378ba18cb
Fix: An unprintable multi-byte character at the start of the screen line
Bram Moolenaar <bram@vim.org>
parents:
2428
diff
changeset
|
4208 * a '<' in the first column. Don't do this for unprintable |
4352 | 4209 * characters. */ |
2509
6d6378ba18cb
Fix: An unprintable multi-byte character at the start of the screen line
Bram Moolenaar <bram@vim.org>
parents:
2428
diff
changeset
|
4210 if (n_skip > 0 && mb_l > 1 && n_extra == 0) |
7 | 4211 { |
4212 n_extra = 1; | |
3586 | 4213 c_extra = MB_FILLER_CHAR; |
7 | 4214 c = ' '; |
4215 if (area_attr == 0 && search_attr == 0) | |
4216 { | |
4217 n_attr = n_extra + 1; | |
4218 extra_attr = hl_attr(HLF_AT); | |
4219 saved_attr2 = char_attr; /* save current attr */ | |
4220 } | |
4221 mb_c = c; | |
4222 mb_utf8 = FALSE; | |
4223 mb_l = 1; | |
4224 } | |
4225 | |
4226 } | |
4227 #endif | |
4228 ++ptr; | |
4229 | |
12 | 4230 /* 'list' : change char 160 to lcs_nbsp. */ |
819 | 4231 if (wp->w_p_list && (c == 160 |
4232 #ifdef FEAT_MBYTE | |
4233 || (mb_utf8 && mb_c == 160) | |
4234 #endif | |
4235 ) && lcs_nbsp) | |
12 | 4236 { |
4237 c = lcs_nbsp; | |
4238 if (area_attr == 0 && search_attr == 0) | |
4239 { | |
4240 n_attr = 1; | |
4241 extra_attr = hl_attr(HLF_8); | |
4242 saved_attr2 = char_attr; /* save current attr */ | |
4243 } | |
4244 #ifdef FEAT_MBYTE | |
4245 mb_c = c; | |
4246 if (enc_utf8 && (*mb_char2len)(c) > 1) | |
4247 { | |
4248 mb_utf8 = TRUE; | |
714 | 4249 u8cc[0] = 0; |
819 | 4250 c = 0xc0; |
12 | 4251 } |
4252 else | |
4253 mb_utf8 = FALSE; | |
4254 #endif | |
4255 } | |
4256 | |
7 | 4257 if (extra_check) |
4258 { | |
743 | 4259 #ifdef FEAT_SPELL |
221 | 4260 int can_spell = TRUE; |
743 | 4261 #endif |
4262 | |
4263 #ifdef FEAT_SYN_HL | |
7 | 4264 /* Get syntax attribute, unless still at the start of the line |
4265 * (double-wide char that doesn't fit). */ | |
221 | 4266 v = (long)(ptr - line); |
4267 if (has_syntax && v > 0) | |
7 | 4268 { |
4269 /* Get the syntax attribute for the character. If there | |
4270 * is an error, disable syntax highlighting. */ | |
4271 save_did_emsg = did_emsg; | |
4272 did_emsg = FALSE; | |
4273 | |
221 | 4274 syntax_attr = get_syntax_attr((colnr_T)v - 1, |
743 | 4275 # ifdef FEAT_SPELL |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4276 has_spell ? &can_spell : |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4277 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4278 NULL, FALSE); |
7 | 4279 |
4280 if (did_emsg) | |
482 | 4281 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4282 wp->w_s->b_syn_error = TRUE; |
482 | 4283 has_syntax = FALSE; |
4284 } | |
7 | 4285 else |
4286 did_emsg = save_did_emsg; | |
4287 | |
4288 /* Need to get the line again, a multi-line regexp may | |
4289 * have made it invalid. */ | |
4290 line = ml_get_buf(wp->w_buffer, lnum, FALSE); | |
4291 ptr = line + v; | |
4292 | |
674 | 4293 if (!attr_pri) |
7 | 4294 char_attr = syntax_attr; |
301 | 4295 else |
303 | 4296 char_attr = hl_combine_attr(syntax_attr, char_attr); |
2364
151b037b7e74
Fix hang when resizing in diff mode and there are concealed items.
Bram Moolenaar <bram@vim.org>
parents:
2359
diff
changeset
|
4297 # ifdef FEAT_CONCEAL |
151b037b7e74
Fix hang when resizing in diff mode and there are concealed items.
Bram Moolenaar <bram@vim.org>
parents:
2359
diff
changeset
|
4298 /* no concealing past the end of the line, it interferes |
151b037b7e74
Fix hang when resizing in diff mode and there are concealed items.
Bram Moolenaar <bram@vim.org>
parents:
2359
diff
changeset
|
4299 * with line highlighting */ |
151b037b7e74
Fix hang when resizing in diff mode and there are concealed items.
Bram Moolenaar <bram@vim.org>
parents:
2359
diff
changeset
|
4300 if (c == NUL) |
151b037b7e74
Fix hang when resizing in diff mode and there are concealed items.
Bram Moolenaar <bram@vim.org>
parents:
2359
diff
changeset
|
4301 syntax_flags = 0; |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2364
diff
changeset
|
4302 else |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2382
diff
changeset
|
4303 syntax_flags = get_syntax_info(&syntax_seqnr); |
2364
151b037b7e74
Fix hang when resizing in diff mode and there are concealed items.
Bram Moolenaar <bram@vim.org>
parents:
2359
diff
changeset
|
4304 # endif |
7 | 4305 } |
743 | 4306 #endif |
4307 | |
4308 #ifdef FEAT_SPELL | |
301 | 4309 /* Check spelling (unless at the end of the line). |
319 | 4310 * Only do this when there is no syntax highlighting, the |
4311 * @Spell cluster is not used or the current syntax item | |
4312 * contains the @Spell cluster. */ | |
348 | 4313 if (has_spell && v >= word_end && v > cur_checked_col) |
221 | 4314 { |
230 | 4315 spell_attr = 0; |
743 | 4316 # ifdef FEAT_SYN_HL |
674 | 4317 if (!attr_pri) |
230 | 4318 char_attr = syntax_attr; |
743 | 4319 # endif |
4320 if (c != 0 && ( | |
4321 # ifdef FEAT_SYN_HL | |
4322 !has_syntax || | |
4323 # endif | |
4324 can_spell)) | |
221 | 4325 { |
348 | 4326 char_u *prev_ptr, *p; |
4327 int len; | |
534 | 4328 hlf_T spell_hlf = HLF_COUNT; |
221 | 4329 # ifdef FEAT_MBYTE |
336 | 4330 if (has_mbyte) |
4331 { | |
4332 prev_ptr = ptr - mb_l; | |
4333 v -= mb_l - 1; | |
4334 } | |
4335 else | |
221 | 4336 # endif |
336 | 4337 prev_ptr = ptr - 1; |
348 | 4338 |
4339 /* Use nextline[] if possible, it has the start of the | |
4340 * next line concatenated. */ | |
4341 if ((prev_ptr - line) - nextlinecol >= 0) | |
4342 p = nextline + (prev_ptr - line) - nextlinecol; | |
4343 else | |
4344 p = prev_ptr; | |
835 | 4345 cap_col -= (int)(prev_ptr - line); |
625 | 4346 len = spell_check(wp, p, &spell_hlf, &cap_col, |
4347 nochange); | |
348 | 4348 word_end = v + len; |
301 | 4349 |
4350 /* In Insert mode only highlight a word that | |
4351 * doesn't touch the cursor. */ | |
534 | 4352 if (spell_hlf != HLF_COUNT |
301 | 4353 && (State & INSERT) != 0 |
4354 && wp->w_cursor.lnum == lnum | |
4355 && wp->w_cursor.col >= | |
4356 (colnr_T)(prev_ptr - line) | |
4357 && wp->w_cursor.col < (colnr_T)word_end) | |
221 | 4358 { |
534 | 4359 spell_hlf = HLF_COUNT; |
301 | 4360 spell_redraw_lnum = lnum; |
221 | 4361 } |
348 | 4362 |
534 | 4363 if (spell_hlf == HLF_COUNT && p != prev_ptr |
348 | 4364 && (p - nextline) + len > nextline_idx) |
4365 { | |
4366 /* Remember that the good word continues at the | |
4367 * start of the next line. */ | |
4368 checked_lnum = lnum + 1; | |
835 | 4369 checked_col = (int)((p - nextline) + len - nextline_idx); |
348 | 4370 } |
386 | 4371 |
534 | 4372 /* Turn index into actual attributes. */ |
4373 if (spell_hlf != HLF_COUNT) | |
4374 spell_attr = highlight_attr[spell_hlf]; | |
4375 | |
386 | 4376 if (cap_col > 0) |
4377 { | |
4378 if (p != prev_ptr | |
4379 && (p - nextline) + cap_col >= nextline_idx) | |
4380 { | |
4381 /* Remember that the word in the next line | |
4382 * must start with a capital. */ | |
4383 capcol_lnum = lnum + 1; | |
835 | 4384 cap_col = (int)((p - nextline) + cap_col |
4385 - nextline_idx); | |
386 | 4386 } |
4387 else | |
4388 /* Compute the actual column. */ | |
835 | 4389 cap_col += (int)(prev_ptr - line); |
386 | 4390 } |
221 | 4391 } |
4392 } | |
4393 if (spell_attr != 0) | |
348 | 4394 { |
674 | 4395 if (!attr_pri) |
348 | 4396 char_attr = hl_combine_attr(char_attr, spell_attr); |
4397 else | |
4398 char_attr = hl_combine_attr(spell_attr, char_attr); | |
4399 } | |
7 | 4400 #endif |
4401 #ifdef FEAT_LINEBREAK | |
4402 /* | |
221 | 4403 * Found last space before word: check for line break. |
7 | 4404 */ |
4405 if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr) | |
819 | 4406 && !wp->w_p_list) |
7 | 4407 { |
4408 n_extra = win_lbr_chartabsize(wp, ptr - ( | |
4409 # ifdef FEAT_MBYTE | |
4410 has_mbyte ? mb_l : | |
4411 # endif | |
4412 1), (colnr_T)vcol, NULL) - 1; | |
4413 c_extra = ' '; | |
4414 if (vim_iswhite(c)) | |
5174
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
4415 { |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
4416 #ifdef FEAT_CONCEAL |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
4417 if (c == TAB) |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
4418 /* See "Tab alignment" below. */ |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
4419 FIX_FOR_BOGUSCOLS; |
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
4420 #endif |
7 | 4421 c = ' '; |
5174
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
4422 } |
7 | 4423 } |
4424 #endif | |
4425 | |
4426 if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ') | |
4427 { | |
4428 c = lcs_trail; | |
674 | 4429 if (!attr_pri) |
7 | 4430 { |
4431 n_attr = 1; | |
4432 extra_attr = hl_attr(HLF_8); | |
4433 saved_attr2 = char_attr; /* save current attr */ | |
4434 } | |
4435 #ifdef FEAT_MBYTE | |
4436 mb_c = c; | |
4437 if (enc_utf8 && (*mb_char2len)(c) > 1) | |
4438 { | |
4439 mb_utf8 = TRUE; | |
714 | 4440 u8cc[0] = 0; |
819 | 4441 c = 0xc0; |
7 | 4442 } |
4443 else | |
4444 mb_utf8 = FALSE; | |
4445 #endif | |
4446 } | |
4447 } | |
4448 | |
4449 /* | |
4450 * Handling of non-printable characters. | |
4451 */ | |
819 | 4452 if (!(chartab[c & 0xff] & CT_PRINT_CHAR)) |
7 | 4453 { |
4454 /* | |
4455 * when getting a character from the file, we may have to | |
4456 * turn it into something else on the way to putting it | |
4457 * into "ScreenLines". | |
4458 */ | |
4459 if (c == TAB && (!wp->w_p_list || lcs_tab1)) | |
4460 { | |
4461 /* tab amount depends on current column */ | |
4462 n_extra = (int)wp->w_buffer->b_p_ts | |
3984 | 4463 - vcol % (int)wp->w_buffer->b_p_ts - 1; |
4464 #ifdef FEAT_CONCEAL | |
4465 /* Tab alignment should be identical regardless of | |
4466 * 'conceallevel' value. So tab compensates of all | |
4467 * previous concealed characters, and thus resets vcol_off | |
4468 * and boguscols accumulated so far in the line. Note that | |
4469 * the tab can be longer than 'tabstop' when there | |
4470 * are concealed characters. */ | |
5174
42d592dbbec3
updated for version 7.4a.013
Bram Moolenaar <bram@vim.org>
parents:
5126
diff
changeset
|
4471 FIX_FOR_BOGUSCOLS; |
3984 | 4472 #endif |
7 | 4473 #ifdef FEAT_MBYTE |
4474 mb_utf8 = FALSE; /* don't draw as UTF-8 */ | |
4475 #endif | |
4476 if (wp->w_p_list) | |
4477 { | |
4478 c = lcs_tab1; | |
4479 c_extra = lcs_tab2; | |
4480 n_attr = n_extra + 1; | |
4481 extra_attr = hl_attr(HLF_8); | |
4482 saved_attr2 = char_attr; /* save current attr */ | |
4483 #ifdef FEAT_MBYTE | |
4484 mb_c = c; | |
4485 if (enc_utf8 && (*mb_char2len)(c) > 1) | |
4486 { | |
4487 mb_utf8 = TRUE; | |
714 | 4488 u8cc[0] = 0; |
819 | 4489 c = 0xc0; |
7 | 4490 } |
4491 #endif | |
4492 } | |
4493 else | |
4494 { | |
4495 c_extra = ' '; | |
4496 c = ' '; | |
4497 } | |
4498 } | |
36 | 4499 else if (c == NUL |
4500 && ((wp->w_p_list && lcs_eol > 0) | |
4501 || ((fromcol >= 0 || fromcol_prev >= 0) | |
4502 && tocol > vcol | |
39 | 4503 #ifdef FEAT_VISUAL |
36 | 4504 && VIsual_mode != Ctrl_V |
39 | 4505 #endif |
36 | 4506 && ( |
4507 # ifdef FEAT_RIGHTLEFT | |
4508 wp->w_p_rl ? (col >= 0) : | |
4509 # endif | |
4510 (col < W_WIDTH(wp))) | |
4511 && !(noinvcur | |
1850 | 4512 && lnum == wp->w_cursor.lnum |
36 | 4513 && (colnr_T)vcol == wp->w_virtcol))) |
4514 && lcs_eol_one >= 0) | |
7 | 4515 { |
36 | 4516 /* Display a '$' after the line or highlight an extra |
4517 * character if the line break is included. */ | |
7 | 4518 #if defined(FEAT_DIFF) || defined(LINE_ATTR) |
4519 /* For a diff line the highlighting continues after the | |
4520 * "$". */ | |
4521 if ( | |
4522 # ifdef FEAT_DIFF | |
534 | 4523 diff_hlf == (hlf_T)0 |
7 | 4524 # ifdef LINE_ATTR |
4525 && | |
4526 # endif | |
4527 # endif | |
4528 # ifdef LINE_ATTR | |
4529 line_attr == 0 | |
4530 # endif | |
4531 ) | |
4532 #endif | |
4533 { | |
4534 #ifdef FEAT_VIRTUALEDIT | |
4535 /* In virtualedit, visual selections may extend | |
4536 * beyond end of line. */ | |
4537 if (area_highlighting && virtual_active() | |
4538 && tocol != MAXCOL && vcol < tocol) | |
4539 n_extra = 0; | |
4540 else | |
4541 #endif | |
4542 { | |
4543 p_extra = at_end_str; | |
4544 n_extra = 1; | |
4545 c_extra = NUL; | |
4546 } | |
4547 } | |
36 | 4548 if (wp->w_p_list) |
4549 c = lcs_eol; | |
4550 else | |
4551 c = ' '; | |
7 | 4552 lcs_eol_one = -1; |
4553 --ptr; /* put it back at the NUL */ | |
674 | 4554 if (!attr_pri) |
7 | 4555 { |
4556 extra_attr = hl_attr(HLF_AT); | |
4557 n_attr = 1; | |
4558 } | |
4559 #ifdef FEAT_MBYTE | |
4560 mb_c = c; | |
4561 if (enc_utf8 && (*mb_char2len)(c) > 1) | |
4562 { | |
4563 mb_utf8 = TRUE; | |
714 | 4564 u8cc[0] = 0; |
819 | 4565 c = 0xc0; |
7 | 4566 } |
4567 else | |
4568 mb_utf8 = FALSE; /* don't draw as UTF-8 */ | |
4569 #endif | |
4570 } | |
4571 else if (c != NUL) | |
4572 { | |
4573 p_extra = transchar(c); | |
4574 #ifdef FEAT_RIGHTLEFT | |
4575 if ((dy_flags & DY_UHEX) && wp->w_p_rl) | |
4576 rl_mirror(p_extra); /* reverse "<12>" */ | |
4577 #endif | |
4578 n_extra = byte2cells(c) - 1; | |
4579 c_extra = NUL; | |
4580 c = *p_extra++; | |
674 | 4581 if (!attr_pri) |
7 | 4582 { |
4583 n_attr = n_extra + 1; | |
4584 extra_attr = hl_attr(HLF_8); | |
4585 saved_attr2 = char_attr; /* save current attr */ | |
4586 } | |
4587 #ifdef FEAT_MBYTE | |
4588 mb_utf8 = FALSE; /* don't draw as UTF-8 */ | |
4589 #endif | |
4590 } | |
4591 #ifdef FEAT_VIRTUALEDIT | |
4592 else if (VIsual_active | |
4593 && (VIsual_mode == Ctrl_V | |
4594 || VIsual_mode == 'v') | |
4595 && virtual_active() | |
4596 && tocol != MAXCOL | |
4597 && vcol < tocol | |
4598 && ( | |
4599 # ifdef FEAT_RIGHTLEFT | |
4600 wp->w_p_rl ? (col >= 0) : | |
4601 # endif | |
4602 (col < W_WIDTH(wp)))) | |
4603 { | |
4604 c = ' '; | |
4605 --ptr; /* put it back at the NUL */ | |
4606 } | |
4607 #endif | |
910 | 4608 #if defined(LINE_ATTR) |
7 | 4609 else if (( |
4610 # ifdef FEAT_DIFF | |
910 | 4611 diff_hlf != (hlf_T)0 || |
7 | 4612 # endif |
4613 line_attr != 0 | |
4614 ) && ( | |
4615 # ifdef FEAT_RIGHTLEFT | |
4616 wp->w_p_rl ? (col >= 0) : | |
4617 # endif | |
2553
37d3f90f5203
Conceal feature caused the 'cursorline' highlighting to stop early.
Bram Moolenaar <bram@vim.org>
parents:
2520
diff
changeset
|
4618 (col |
37d3f90f5203
Conceal feature caused the 'cursorline' highlighting to stop early.
Bram Moolenaar <bram@vim.org>
parents:
2520
diff
changeset
|
4619 # ifdef FEAT_CONCEAL |
37d3f90f5203
Conceal feature caused the 'cursorline' highlighting to stop early.
Bram Moolenaar <bram@vim.org>
parents:
2520
diff
changeset
|
4620 - boguscols |
37d3f90f5203
Conceal feature caused the 'cursorline' highlighting to stop early.
Bram Moolenaar <bram@vim.org>
parents:
2520
diff
changeset
|
4621 # endif |
37d3f90f5203
Conceal feature caused the 'cursorline' highlighting to stop early.
Bram Moolenaar <bram@vim.org>
parents:
2520
diff
changeset
|
4622 < W_WIDTH(wp)))) |
7 | 4623 { |
4624 /* Highlight until the right side of the window */ | |
4625 c = ' '; | |
4626 --ptr; /* put it back at the NUL */ | |
867 | 4627 |
4628 /* Remember we do the char for line highlighting. */ | |
4629 ++did_line_attr; | |
4630 | |
4631 /* don't do search HL for the rest of the line */ | |
4632 if (line_attr != 0 && char_attr == search_attr && col > 0) | |
4633 char_attr = line_attr; | |
7 | 4634 # ifdef FEAT_DIFF |
4635 if (diff_hlf == HLF_TXD) | |
4636 { | |
4637 diff_hlf = HLF_CHD; | |
4638 if (attr == 0 || char_attr != attr) | |
4639 char_attr = hl_attr(diff_hlf); | |
4640 } | |
4641 # endif | |
4642 } | |
4643 #endif | |
4644 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4645 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4646 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4647 if ( wp->w_p_cole > 0 |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4648 && (wp != curwin || lnum != wp->w_cursor.lnum || |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4649 conceal_cursor_line(wp)) |
2380
b47748aa3236
Don't conceal text in lines inside the Visual area.
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4650 && (syntax_flags & HL_CONCEAL) != 0 |
2400
e6f1424dd66a
Let 'v' flag in 'concealcursor' apply to all lines in the Visual area.
Bram Moolenaar <bram@vim.org>
parents:
2393
diff
changeset
|
4651 && !(lnum_in_visual_area |
e6f1424dd66a
Let 'v' flag in 'concealcursor' apply to all lines in the Visual area.
Bram Moolenaar <bram@vim.org>
parents:
2393
diff
changeset
|
4652 && vim_strchr(wp->w_p_cocu, 'v') == NULL)) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4653 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4654 char_attr = conceal_attr; |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2382
diff
changeset
|
4655 if (prev_syntax_id != syntax_seqnr |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4656 && (syn_get_sub_char() != NUL || wp->w_p_cole == 1) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4657 && wp->w_p_cole != 3) |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2364
diff
changeset
|
4658 { |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2364
diff
changeset
|
4659 /* First time at this concealed item: display one |
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2364
diff
changeset
|
4660 * character. */ |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4661 if (syn_get_sub_char() != NUL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4662 c = syn_get_sub_char(); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4663 else if (lcs_conceal != NUL) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4664 c = lcs_conceal; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4665 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4666 c = ' '; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4667 |
2392
0371401d9d33
Give each syntax item a sequence number, so that we know when it starts and
Bram Moolenaar <bram@vim.org>
parents:
2382
diff
changeset
|
4668 prev_syntax_id = syntax_seqnr; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4669 |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4670 if (n_extra > 0) |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4671 vcol_off += n_extra; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4672 vcol += n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4673 if (wp->w_p_wrap && n_extra > 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4674 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4675 # ifdef FEAT_RIGHTLEFT |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4676 if (wp->w_p_rl) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4677 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4678 col -= n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4679 boguscols -= n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4680 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4681 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4682 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4683 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4684 boguscols += n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4685 col += n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4686 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4687 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4688 n_extra = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4689 n_attr = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4690 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4691 else if (n_skip == 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4692 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4693 is_concealing = TRUE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4694 n_skip = 1; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4695 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4696 # ifdef FEAT_MBYTE |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4697 mb_c = c; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4698 if (enc_utf8 && (*mb_char2len)(c) > 1) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4699 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4700 mb_utf8 = TRUE; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4701 u8cc[0] = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4702 c = 0xc0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4703 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4704 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4705 mb_utf8 = FALSE; /* don't draw as UTF-8 */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4706 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4707 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4708 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4709 { |
2375
a96dd77ce213
For conceal mode: when two different syntax items follow each other, show the
Bram Moolenaar <bram@vim.org>
parents:
2364
diff
changeset
|
4710 prev_syntax_id = 0; |
2348
8878a9f8db87
Rename w_p_conceal to w_p_conc for consistency.
Bram Moolenaar <bram@vim.org>
parents:
2346
diff
changeset
|
4711 is_concealing = FALSE; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4712 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
4713 #endif /* FEAT_CONCEAL */ |
7 | 4714 } |
4715 | |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4716 #ifdef FEAT_CONCEAL |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4717 /* In the cursor line and we may be concealing characters: correct |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4718 * the cursor column when we reach its position. */ |
2381
17bbb52ae218
Another conceal fix: cursor in wrong column when 'number' set.
Bram Moolenaar <bram@vim.org>
parents:
2380
diff
changeset
|
4719 if (!did_wcol && draw_state == WL_LINE |
17bbb52ae218
Another conceal fix: cursor in wrong column when 'number' set.
Bram Moolenaar <bram@vim.org>
parents:
2380
diff
changeset
|
4720 && wp == curwin && lnum == wp->w_cursor.lnum |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4721 && conceal_cursor_line(wp) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4722 && (int)wp->w_virtcol <= vcol + n_skip) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4723 { |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4724 wp->w_wcol = col - boguscols; |
2393
210a5605e126
Fix for cursor position in wrapped line with concealed text.
Bram Moolenaar <bram@vim.org>
parents:
2392
diff
changeset
|
4725 wp->w_wrow = row; |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4726 did_wcol = TRUE; |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4727 } |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4728 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
4729 |
7 | 4730 /* Don't override visual selection highlighting. */ |
4731 if (n_attr > 0 | |
4732 && draw_state == WL_LINE | |
674 | 4733 && !attr_pri) |
7 | 4734 char_attr = extra_attr; |
4735 | |
42 | 4736 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
7 | 4737 /* XIM don't send preedit_start and preedit_end, but they send |
4738 * preedit_changed and commit. Thus Vim can't set "im_is_active", use | |
4739 * im_is_preediting() here. */ | |
4740 if (xic != NULL | |
1850 | 4741 && lnum == wp->w_cursor.lnum |
7 | 4742 && (State & INSERT) |
4743 && !p_imdisable | |
4744 && im_is_preediting() | |
4745 && draw_state == WL_LINE) | |
4746 { | |
4747 colnr_T tcol; | |
4748 | |
4749 if (preedit_end_col == MAXCOL) | |
1850 | 4750 getvcol(curwin, &(wp->w_cursor), &tcol, NULL, NULL); |
7 | 4751 else |
4752 tcol = preedit_end_col; | |
4753 if ((long)preedit_start_col <= vcol && vcol < (long)tcol) | |
4754 { | |
4755 if (feedback_old_attr < 0) | |
4756 { | |
4757 feedback_col = 0; | |
4758 feedback_old_attr = char_attr; | |
4759 } | |
4760 char_attr = im_get_feedback_attr(feedback_col); | |
4761 if (char_attr < 0) | |
4762 char_attr = feedback_old_attr; | |
4763 feedback_col++; | |
4764 } | |
4765 else if (feedback_old_attr >= 0) | |
4766 { | |
4767 char_attr = feedback_old_attr; | |
4768 feedback_old_attr = -1; | |
4769 feedback_col = 0; | |
4770 } | |
4771 } | |
4772 #endif | |
4773 /* | |
4774 * Handle the case where we are in column 0 but not on the first | |
4775 * character of the line and the user wants us to show us a | |
4776 * special character (via 'listchars' option "precedes:<char>". | |
4777 */ | |
4778 if (lcs_prec_todo != NUL | |
4779 && (wp->w_p_wrap ? wp->w_skipcol > 0 : wp->w_leftcol > 0) | |
4780 #ifdef FEAT_DIFF | |
4781 && filler_todo <= 0 | |
4782 #endif | |
4783 && draw_state > WL_NR | |
4784 && c != NUL) | |
4785 { | |
4786 c = lcs_prec; | |
4787 lcs_prec_todo = NUL; | |
4788 #ifdef FEAT_MBYTE | |
3586 | 4789 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) |
4790 { | |
4791 /* Double-width character being overwritten by the "precedes" | |
4792 * character, need to fill up half the character. */ | |
4793 c_extra = MB_FILLER_CHAR; | |
4794 n_extra = 1; | |
4795 n_attr = 2; | |
4796 extra_attr = hl_attr(HLF_AT); | |
4797 } | |
7 | 4798 mb_c = c; |
4799 if (enc_utf8 && (*mb_char2len)(c) > 1) | |
4800 { | |
4801 mb_utf8 = TRUE; | |
714 | 4802 u8cc[0] = 0; |
819 | 4803 c = 0xc0; |
7 | 4804 } |
4805 else | |
4806 mb_utf8 = FALSE; /* don't draw as UTF-8 */ | |
4807 #endif | |
674 | 4808 if (!attr_pri) |
7 | 4809 { |
4810 saved_attr3 = char_attr; /* save current attr */ | |
4811 char_attr = hl_attr(HLF_AT); /* later copied to char_attr */ | |
4812 n_attr3 = 1; | |
4813 } | |
4814 } | |
4815 | |
4816 /* | |
867 | 4817 * At end of the text line or just after the last character. |
7 | 4818 */ |
867 | 4819 if (c == NUL |
910 | 4820 #if defined(LINE_ATTR) |
867 | 4821 || did_line_attr == 1 |
4822 #endif | |
4823 ) | |
4824 { | |
4825 #ifdef FEAT_SEARCH_EXTRA | |
4826 long prevcol = (long)(ptr - line) - (c == NUL); | |
1437 | 4827 |
4828 /* we're not really at that column when skipping some text */ | |
1439 | 4829 if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol) |
1437 | 4830 ++prevcol; |
867 | 4831 #endif |
4832 | |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4833 /* Invert at least one char, used for Visual and empty line or |
7 | 4834 * highlight match at end of line. If it's beyond the last |
4835 * char on the screen, just overwrite that one (tricky!) Not | |
4836 * needed when a '$' was displayed for 'list'. */ | |
1326 | 4837 #ifdef FEAT_SEARCH_EXTRA |
4838 prevcol_hl_flag = FALSE; | |
4839 if (prevcol == (long)search_hl.startcol) | |
4840 prevcol_hl_flag = TRUE; | |
4841 else | |
4842 { | |
4843 cur = wp->w_match_head; | |
4844 while (cur != NULL) | |
4845 { | |
4846 if (prevcol == (long)cur->hl.startcol) | |
4847 { | |
4848 prevcol_hl_flag = TRUE; | |
4849 break; | |
4850 } | |
4851 cur = cur->next; | |
4852 } | |
4853 } | |
4854 #endif | |
7 | 4855 if (lcs_eol == lcs_eol_one |
1850 | 4856 && ((area_attr != 0 && vcol == fromcol |
4857 #ifdef FEAT_VISUAL | |
4858 && (VIsual_mode != Ctrl_V | |
4859 || lnum == VIsual.lnum | |
4860 || lnum == curwin->w_cursor.lnum) | |
4861 #endif | |
4862 && c == NUL) | |
7 | 4863 #ifdef FEAT_SEARCH_EXTRA |
4864 /* highlight 'hlsearch' match at end of line */ | |
1326 | 4865 || (prevcol_hl_flag == TRUE |
910 | 4866 # if defined(LINE_ATTR) |
867 | 4867 && did_line_attr <= 1 |
4868 # endif | |
4869 ) | |
7 | 4870 #endif |
4871 )) | |
4872 { | |
4873 int n = 0; | |
4874 | |
4875 #ifdef FEAT_RIGHTLEFT | |
4876 if (wp->w_p_rl) | |
4877 { | |
4878 if (col < 0) | |
4879 n = 1; | |
4880 } | |
4881 else | |
4882 #endif | |
4883 { | |
4884 if (col >= W_WIDTH(wp)) | |
4885 n = -1; | |
4886 } | |
4887 if (n != 0) | |
4888 { | |
4889 /* At the window boundary, highlight the last character | |
4890 * instead (better than nothing). */ | |
4891 off += n; | |
4892 col += n; | |
4893 } | |
4894 else | |
4895 { | |
4896 /* Add a blank character to highlight. */ | |
4897 ScreenLines[off] = ' '; | |
4898 #ifdef FEAT_MBYTE | |
4899 if (enc_utf8) | |
4900 ScreenLinesUC[off] = 0; | |
4901 #endif | |
4902 } | |
4903 #ifdef FEAT_SEARCH_EXTRA | |
4904 if (area_attr == 0) | |
4905 { | |
1326 | 4906 /* Use attributes from match with highest priority among |
4907 * 'search_hl' and the match list. */ | |
4908 char_attr = search_hl.attr; | |
4909 cur = wp->w_match_head; | |
4910 shl_flag = FALSE; | |
4911 while (cur != NULL || shl_flag == FALSE) | |
699 | 4912 { |
1326 | 4913 if (shl_flag == FALSE |
4914 && ((cur != NULL | |
4915 && cur->priority > SEARCH_HL_PRIORITY) | |
4916 || cur == NULL)) | |
699 | 4917 { |
1326 | 4918 shl = &search_hl; |
4919 shl_flag = TRUE; | |
699 | 4920 } |
1326 | 4921 else |
4922 shl = &cur->hl; | |
4923 if ((ptr - line) - 1 == (long)shl->startcol) | |
4924 char_attr = shl->attr; | |
4925 if (shl != &search_hl && cur != NULL) | |
4926 cur = cur->next; | |
699 | 4927 } |
7 | 4928 } |
4929 #endif | |
4930 ScreenAttrs[off] = char_attr; | |
4931 #ifdef FEAT_RIGHTLEFT | |
4932 if (wp->w_p_rl) | |
1437 | 4933 { |
7 | 4934 --col; |
1437 | 4935 --off; |
4936 } | |
7 | 4937 else |
4938 #endif | |
1437 | 4939 { |
7 | 4940 ++col; |
1437 | 4941 ++off; |
4942 } | |
743 | 4943 ++vcol; |
1437 | 4944 #ifdef FEAT_SYN_HL |
4945 eol_hl_off = 1; | |
4946 #endif | |
743 | 4947 } |
867 | 4948 } |
4949 | |
4950 /* | |
4951 * At end of the text line. | |
4952 */ | |
4953 if (c == NUL) | |
4954 { | |
743 | 4955 #ifdef FEAT_SYN_HL |
1850 | 4956 if (eol_hl_off > 0 && vcol - eol_hl_off == (long)wp->w_virtcol |
4957 && lnum == wp->w_cursor.lnum) | |
1437 | 4958 { |
4959 /* highlight last char after line */ | |
4960 --col; | |
4961 --off; | |
4962 --vcol; | |
4963 } | |
4964 | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4965 /* Highlight 'cursorcolumn' & 'colorcolumn' past end of the line. */ |
758 | 4966 if (wp->w_p_wrap) |
4967 v = wp->w_skipcol; | |
4968 else | |
4969 v = wp->w_leftcol; | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4970 |
820 | 4971 /* check if line ends before left margin */ |
4972 if (vcol < v + col - win_col_off(wp)) | |
4973 vcol = v + col - win_col_off(wp); | |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4974 #ifdef FEAT_CONCEAL |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4975 /* Get rid of the boguscols now, we want to draw until the right |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4976 * edge for 'cursorcolumn'. */ |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4977 col -= boguscols; |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4978 boguscols = 0; |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4979 #endif |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4980 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4981 if (draw_color_col) |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4982 draw_color_col = advance_color_col(VCOL_HLC, &color_cols); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4983 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4984 if (((wp->w_p_cuc |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4985 && (int)wp->w_virtcol >= VCOL_HLC - eol_hl_off |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4986 && (int)wp->w_virtcol < |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4987 W_WIDTH(wp) * (row - startrow + 1) + v |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4988 && lnum != wp->w_cursor.lnum) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4989 || draw_color_col) |
743 | 4990 # ifdef FEAT_RIGHTLEFT |
4991 && !wp->w_p_rl | |
4992 # endif | |
4993 ) | |
4994 { | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4995 int rightmost_vcol = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4996 int i; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4997 |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4998 if (wp->w_p_cuc) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
4999 rightmost_vcol = wp->w_virtcol; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5000 if (draw_color_col) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5001 /* determine rightmost colorcolumn to possibly draw */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5002 for (i = 0; color_cols[i] >= 0; ++i) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5003 if (rightmost_vcol < color_cols[i]) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5004 rightmost_vcol = color_cols[i]; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5005 |
743 | 5006 while (col < W_WIDTH(wp)) |
5007 { | |
5008 ScreenLines[off] = ' '; | |
5009 #ifdef FEAT_MBYTE | |
5010 if (enc_utf8) | |
5011 ScreenLinesUC[off] = 0; | |
5012 #endif | |
5013 ++col; | |
2356
eb1f2554cac5
Fix 'colorcolumn' adjecent columns not highlighted after end of line.
Bram Moolenaar <bram@vim.org>
parents:
2349
diff
changeset
|
5014 if (draw_color_col) |
eb1f2554cac5
Fix 'colorcolumn' adjecent columns not highlighted after end of line.
Bram Moolenaar <bram@vim.org>
parents:
2349
diff
changeset
|
5015 draw_color_col = advance_color_col(VCOL_HLC, |
eb1f2554cac5
Fix 'colorcolumn' adjecent columns not highlighted after end of line.
Bram Moolenaar <bram@vim.org>
parents:
2349
diff
changeset
|
5016 &color_cols); |
eb1f2554cac5
Fix 'colorcolumn' adjecent columns not highlighted after end of line.
Bram Moolenaar <bram@vim.org>
parents:
2349
diff
changeset
|
5017 |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
5018 if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol) |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5019 ScreenAttrs[off++] = hl_attr(HLF_CUC); |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
5020 else if (draw_color_col && VCOL_HLC == *color_cols) |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5021 ScreenAttrs[off++] = hl_attr(HLF_MC); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5022 else |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5023 ScreenAttrs[off++] = 0; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5024 |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
5025 if (VCOL_HLC >= rightmost_vcol) |
743 | 5026 break; |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5027 |
743 | 5028 ++vcol; |
5029 } | |
5030 } | |
5031 #endif | |
7 | 5032 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5033 SCREEN_LINE(screen_row, W_WINCOL(wp), col, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5034 (int)W_WIDTH(wp), wp->w_p_rl); |
7 | 5035 row++; |
5036 | |
5037 /* | |
5038 * Update w_cline_height and w_cline_folded if the cursor line was | |
5039 * updated (saves a call to plines() later). | |
5040 */ | |
5041 if (wp == curwin && lnum == curwin->w_cursor.lnum) | |
5042 { | |
5043 curwin->w_cline_row = startrow; | |
5044 curwin->w_cline_height = row - startrow; | |
5045 #ifdef FEAT_FOLDING | |
5046 curwin->w_cline_folded = FALSE; | |
5047 #endif | |
5048 curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW); | |
5049 } | |
5050 | |
5051 break; | |
5052 } | |
5053 | |
5054 /* line continues beyond line end */ | |
5055 if (lcs_ext | |
5056 && !wp->w_p_wrap | |
5057 #ifdef FEAT_DIFF | |
5058 && filler_todo <= 0 | |
5059 #endif | |
5060 && ( | |
5061 #ifdef FEAT_RIGHTLEFT | |
5062 wp->w_p_rl ? col == 0 : | |
5063 #endif | |
5064 col == W_WIDTH(wp) - 1) | |
5065 && (*ptr != NUL | |
1555 | 5066 || (wp->w_p_list && lcs_eol_one > 0) |
7 | 5067 || (n_extra && (c_extra != NUL || *p_extra != NUL)))) |
5068 { | |
5069 c = lcs_ext; | |
5070 char_attr = hl_attr(HLF_AT); | |
5071 #ifdef FEAT_MBYTE | |
5072 mb_c = c; | |
5073 if (enc_utf8 && (*mb_char2len)(c) > 1) | |
5074 { | |
5075 mb_utf8 = TRUE; | |
714 | 5076 u8cc[0] = 0; |
819 | 5077 c = 0xc0; |
7 | 5078 } |
5079 else | |
5080 mb_utf8 = FALSE; | |
5081 #endif | |
5082 } | |
5083 | |
743 | 5084 #ifdef FEAT_SYN_HL |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5085 /* advance to the next 'colorcolumn' */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5086 if (draw_color_col) |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
5087 draw_color_col = advance_color_col(VCOL_HLC, &color_cols); |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5088 |
743 | 5089 /* Highlight the cursor column if 'cursorcolumn' is set. But don't |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5090 * highlight the cursor position itself. |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5091 * Also highlight the 'colorcolumn' if it is different than |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5092 * 'cursorcolumn' */ |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5093 vcol_save_attr = -1; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5094 if (draw_state == WL_LINE && !lnum_in_visual_area) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5095 { |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
5096 if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5097 && lnum != wp->w_cursor.lnum) |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5098 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5099 vcol_save_attr = char_attr; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5100 char_attr = hl_combine_attr(char_attr, hl_attr(HLF_CUC)); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5101 } |
2346
b38c324bdc36
Fix: 'colorcolumn' interfered with concealed text.
Bram Moolenaar <bram@vim.org>
parents:
2338
diff
changeset
|
5102 else if (draw_color_col && VCOL_HLC == *color_cols) |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5103 { |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5104 vcol_save_attr = char_attr; |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5105 char_attr = hl_combine_attr(char_attr, hl_attr(HLF_MC)); |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5106 } |
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2285
diff
changeset
|
5107 } |
743 | 5108 #endif |
5109 | |
7 | 5110 /* |
5111 * Store character to be displayed. | |
5112 * Skip characters that are left of the screen for 'nowrap'. | |
5113 */ | |
5114 vcol_prev = vcol; | |
5115 if (draw_state < WL_LINE || n_skip <= 0) | |
5116 { | |
5117 /* | |
5118 * Store the character. | |
5119 */ | |
5120 #if defined(FEAT_RIGHTLEFT) && defined(FEAT_MBYTE) | |
5121 if (has_mbyte && wp->w_p_rl && (*mb_char2cells)(mb_c) > 1) | |
5122 { | |
5123 /* A double-wide character is: put first halve in left cell. */ | |
5124 --off; | |
5125 --col; | |
5126 } | |
5127 #endif | |
5128 ScreenLines[off] = c; | |
5129 #ifdef FEAT_MBYTE | |
5130 if (enc_dbcs == DBCS_JPNU) | |
2069
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
5131 { |
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
5132 if ((mb_c & 0xff00) == 0x8e00) |
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
5133 ScreenLines[off] = 0x8e; |
7 | 5134 ScreenLines2[off] = mb_c & 0xff; |
2069
63613d8d7e4d
updated for version 7.2.354
Bram Moolenaar <bram@zimbu.org>
parents:
2055
diff
changeset
|
5135 } |
7 | 5136 else if (enc_utf8) |
5137 { | |
5138 if (mb_utf8) | |
5139 { | |
1326 | 5140 int i; |
5141 | |
7 | 5142 ScreenLinesUC[off] = mb_c; |
819 | 5143 if ((c & 0xff) == 0) |
5144 ScreenLines[off] = 0x80; /* avoid storing zero */ | |
714 | 5145 for (i = 0; i < Screen_mco; ++i) |
5146 { | |
5147 ScreenLinesC[i][off] = u8cc[i]; | |
5148 if (u8cc[i] == 0) | |
5149 break; | |
5150 } | |
7 | 5151 } |
5152 else | |
5153 ScreenLinesUC[off] = 0; | |
5154 } | |
5155 if (multi_attr) | |
5156 { | |
5157 ScreenAttrs[off] = multi_attr; | |
5158 multi_attr = 0; | |
5159 } | |
5160 else | |
5161 #endif | |
5162 ScreenAttrs[off] = char_attr; | |
5163 | |
5164 #ifdef FEAT_MBYTE | |
5165 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) | |
5166 { | |
5167 /* Need to fill two screen columns. */ | |
5168 ++off; | |
5169 ++col; | |
5170 if (enc_utf8) | |
5171 /* UTF-8: Put a 0 in the second screen char. */ | |
5172 ScreenLines[off] = 0; | |
5173 else | |
5174 /* DBCS: Put second byte in the second screen char. */ | |
5175 ScreenLines[off] = mb_c & 0xff; | |
5176 ++vcol; | |
5177 /* When "tocol" is halfway a character, set it to the end of | |
5178 * the character, otherwise highlighting won't stop. */ | |
5179 if (tocol == vcol) | |
5180 ++tocol; | |
5181 #ifdef FEAT_RIGHTLEFT | |
5182 if (wp->w_p_rl) | |
5183 { | |
5184 /* now it's time to backup one cell */ | |
5185 --off; | |
5186 --col; | |
5187 } | |
5188 #endif | |
5189 } | |
5190 #endif | |
5191 #ifdef FEAT_RIGHTLEFT | |
5192 if (wp->w_p_rl) | |
5193 { | |
5194 --off; | |
5195 --col; | |
5196 } | |
5197 else | |
5198 #endif | |
5199 { | |
5200 ++off; | |
5201 ++col; | |
5202 } | |
5203 } | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5204 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2375
diff
changeset
|
5205 else if (wp->w_p_cole > 0 && is_concealing) |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5206 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5207 --n_skip; |
2332
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
5208 ++vcol_off; |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
5209 if (n_extra > 0) |
b13079093ae1
Make 'cursorcolumn' work together with the conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
5210 vcol_off += n_extra; |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5211 if (wp->w_p_wrap) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5212 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5213 /* |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5214 * Special voodoo required if 'wrap' is on. |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5215 * |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5216 * Advance the column indicator to force the line |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5217 * drawing to wrap early. This will make the line |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5218 * take up the same screen space when parts are concealed, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5219 * so that cursor line computations aren't messed up. |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5220 * |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5221 * To avoid the fictitious advance of 'col' causing |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5222 * trailing junk to be written out of the screen line |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5223 * we are building, 'boguscols' keeps track of the number |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5224 * of bad columns we have advanced. |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5225 */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5226 if (n_extra > 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5227 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5228 vcol += n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5229 # ifdef FEAT_RIGHTLEFT |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5230 if (wp->w_p_rl) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5231 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5232 col -= n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5233 boguscols -= n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5234 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5235 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5236 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5237 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5238 col += n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5239 boguscols += n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5240 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5241 n_extra = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5242 n_attr = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5243 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5244 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5245 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5246 # ifdef FEAT_MBYTE |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5247 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5248 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5249 /* Need to fill two screen columns. */ |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5250 # ifdef FEAT_RIGHTLEFT |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5251 if (wp->w_p_rl) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5252 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5253 --boguscols; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5254 --col; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5255 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5256 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5257 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5258 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5259 ++boguscols; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5260 ++col; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5261 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5262 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5263 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5264 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5265 # ifdef FEAT_RIGHTLEFT |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5266 if (wp->w_p_rl) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5267 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5268 --boguscols; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5269 --col; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5270 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5271 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5272 # endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5273 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5274 ++boguscols; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5275 ++col; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5276 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5277 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5278 else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5279 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5280 if (n_extra > 0) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5281 { |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5282 vcol += n_extra; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5283 n_extra = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5284 n_attr = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5285 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5286 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5287 |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5288 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5289 #endif /* FEAT_CONCEAL */ |
7 | 5290 else |
5291 --n_skip; | |
5292 | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
5293 /* Only advance the "vcol" when after the 'number' or 'relativenumber' |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
5294 * column. */ |
1849 | 5295 if (draw_state > WL_NR |
7 | 5296 #ifdef FEAT_DIFF |
5297 && filler_todo <= 0 | |
5298 #endif | |
5299 ) | |
5300 ++vcol; | |
5301 | |
743 | 5302 #ifdef FEAT_SYN_HL |
5303 if (vcol_save_attr >= 0) | |
5304 char_attr = vcol_save_attr; | |
5305 #endif | |
5306 | |
7 | 5307 /* restore attributes after "predeces" in 'listchars' */ |
5308 if (draw_state > WL_NR && n_attr3 > 0 && --n_attr3 == 0) | |
5309 char_attr = saved_attr3; | |
5310 | |
5311 /* restore attributes after last 'listchars' or 'number' char */ | |
5312 if (n_attr > 0 && draw_state == WL_LINE && --n_attr == 0) | |
5313 char_attr = saved_attr2; | |
5314 | |
5315 /* | |
5316 * At end of screen line and there is more to come: Display the line | |
1378 | 5317 * so far. If there is no more to display it is caught above. |
7 | 5318 */ |
5319 if (( | |
5320 #ifdef FEAT_RIGHTLEFT | |
5321 wp->w_p_rl ? (col < 0) : | |
5322 #endif | |
5323 (col >= W_WIDTH(wp))) | |
5324 && (*ptr != NUL | |
5325 #ifdef FEAT_DIFF | |
5326 || filler_todo > 0 | |
5327 #endif | |
2724 | 5328 || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str) |
7 | 5329 || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL))) |
5330 ) | |
5331 { | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5332 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5333 SCREEN_LINE(screen_row, W_WINCOL(wp), col - boguscols, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5334 (int)W_WIDTH(wp), wp->w_p_rl); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5335 boguscols = 0; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5336 #else |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5337 SCREEN_LINE(screen_row, W_WINCOL(wp), col, |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5338 (int)W_WIDTH(wp), wp->w_p_rl); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
5339 #endif |
7 | 5340 ++row; |
5341 ++screen_row; | |
5342 | |
5343 /* When not wrapping and finished diff lines, or when displayed | |
5344 * '$' and highlighting until last column, break here. */ | |
5345 if ((!wp->w_p_wrap | |
5346 #ifdef FEAT_DIFF | |
5347 && filler_todo <= 0 | |
5348 #endif | |
5349 ) || lcs_eol_one == -1) | |
5350 break; | |
5351 | |
5352 /* When the window is too narrow draw all "@" lines. */ | |
5353 if (draw_state != WL_LINE | |
5354 #ifdef FEAT_DIFF | |
5355 && filler_todo <= 0 | |
5356 #endif | |
5357 ) | |
5358 { | |
5359 win_draw_end(wp, '@', ' ', row, wp->w_height, HLF_AT); | |
5360 #ifdef FEAT_VERTSPLIT | |
5361 draw_vsep_win(wp, row); | |
5362 #endif | |
5363 row = endrow; | |
5364 } | |
5365 | |
5366 /* When line got too long for screen break here. */ | |
5367 if (row == endrow) | |
5368 { | |
5369 ++row; | |
5370 break; | |
5371 } | |
5372 | |
5373 if (screen_cur_row == screen_row - 1 | |
5374 #ifdef FEAT_DIFF | |
5375 && filler_todo <= 0 | |
5376 #endif | |
5377 && W_WIDTH(wp) == Columns) | |
5378 { | |
5379 /* Remember that the line wraps, used for modeless copy. */ | |
5380 LineWraps[screen_row - 1] = TRUE; | |
5381 | |
5382 /* | |
5383 * Special trick to make copy/paste of wrapped lines work with | |
5384 * xterm/screen: write an extra character beyond the end of | |
5385 * the line. This will work with all terminal types | |
5386 * (regardless of the xn,am settings). | |
5387 * Only do this on a fast tty. | |
5388 * Only do this if the cursor is on the current line | |
5389 * (something has been written in it). | |
5390 * Don't do this for the GUI. | |
5391 * Don't do this for double-width characters. | |
5392 * Don't do this for a window not at the right screen border. | |
5393 */ | |
5394 if (p_tf | |
5395 #ifdef FEAT_GUI | |
5396 && !gui.in_use | |
5397 #endif | |
5398 #ifdef FEAT_MBYTE | |
5399 && !(has_mbyte | |
1378 | 5400 && ((*mb_off2cells)(LineOffset[screen_row], |
5401 LineOffset[screen_row] + screen_Columns) | |
5402 == 2 | |
7 | 5403 || (*mb_off2cells)(LineOffset[screen_row - 1] |
1378 | 5404 + (int)Columns - 2, |
5405 LineOffset[screen_row] + screen_Columns) | |
5406 == 2)) | |
7 | 5407 #endif |
5408 ) | |
5409 { | |
5410 /* First make sure we are at the end of the screen line, | |
5411 * then output the same character again to let the | |
5412 * terminal know about the wrap. If the terminal doesn't | |
5413 * auto-wrap, we overwrite the character. */ | |
5414 if (screen_cur_col != W_WIDTH(wp)) | |
5415 screen_char(LineOffset[screen_row - 1] | |
5416 + (unsigned)Columns - 1, | |
5417 screen_row - 1, (int)(Columns - 1)); | |
5418 | |
5419 #ifdef FEAT_MBYTE | |
5420 /* When there is a multi-byte character, just output a | |
5421 * space to keep it simple. */ | |
148 | 5422 if (has_mbyte && MB_BYTE2LEN(ScreenLines[LineOffset[ |
5423 screen_row - 1] + (Columns - 1)]) > 1) | |
7 | 5424 out_char(' '); |
5425 else | |
5426 #endif | |
5427 out_char(ScreenLines[LineOffset[screen_row - 1] | |
5428 + (Columns - 1)]); | |
5429 /* force a redraw of the first char on the next line */ | |
5430 ScreenAttrs[LineOffset[screen_row]] = (sattr_T)-1; | |
5431 screen_start(); /* don't know where cursor is now */ | |
5432 } | |
5433 } | |
5434 | |
5435 col = 0; | |
5436 off = (unsigned)(current_ScreenLine - ScreenLines); | |
5437 #ifdef FEAT_RIGHTLEFT | |
5438 if (wp->w_p_rl) | |
5439 { | |
5440 col = W_WIDTH(wp) - 1; /* col is not used if breaking! */ | |
5441 off += col; | |
5442 } | |
5443 #endif | |
5444 | |
5445 /* reset the drawing state for the start of a wrapped line */ | |
5446 draw_state = WL_START; | |
5447 saved_n_extra = n_extra; | |
5448 saved_p_extra = p_extra; | |
5449 saved_c_extra = c_extra; | |
5450 saved_char_attr = char_attr; | |
5451 n_extra = 0; | |
5452 lcs_prec_todo = lcs_prec; | |
5453 #ifdef FEAT_LINEBREAK | |
5454 # ifdef FEAT_DIFF | |
5455 if (filler_todo <= 0) | |
5456 # endif | |
5457 need_showbreak = TRUE; | |
5458 #endif | |
5459 #ifdef FEAT_DIFF | |
5460 --filler_todo; | |
5461 /* When the filler lines are actually below the last line of the | |
5462 * file, don't draw the line itself, break here. */ | |
5463 if (filler_todo == 0 && wp->w_botfill) | |
5464 break; | |
5465 #endif | |
5466 } | |
5467 | |
5468 } /* for every character in the line */ | |
5469 | |
743 | 5470 #ifdef FEAT_SPELL |
386 | 5471 /* After an empty line check first word for capital. */ |
5472 if (*skipwhite(line) == NUL) | |
5473 { | |
5474 capcol_lnum = lnum + 1; | |
5475 cap_col = 0; | |
5476 } | |
5477 #endif | |
5478 | |
7 | 5479 return row; |
5480 } | |
5481 | |
714 | 5482 #ifdef FEAT_MBYTE |
5483 static int comp_char_differs __ARGS((int, int)); | |
5484 | |
5485 /* | |
5486 * Return if the composing characters at "off_from" and "off_to" differ. | |
2124
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
5487 * Only to be used when ScreenLinesUC[off_from] != 0. |
714 | 5488 */ |
5489 static int | |
5490 comp_char_differs(off_from, off_to) | |
5491 int off_from; | |
5492 int off_to; | |
5493 { | |
5494 int i; | |
5495 | |
5496 for (i = 0; i < Screen_mco; ++i) | |
5497 { | |
5498 if (ScreenLinesC[i][off_from] != ScreenLinesC[i][off_to]) | |
5499 return TRUE; | |
5500 if (ScreenLinesC[i][off_from] == 0) | |
5501 break; | |
5502 } | |
5503 return FALSE; | |
5504 } | |
5505 #endif | |
5506 | |
7 | 5507 /* |
5508 * Check whether the given character needs redrawing: | |
5509 * - the (first byte of the) character is different | |
5510 * - the attributes are different | |
5511 * - the character is multi-byte and the next byte is different | |
1616 | 5512 * - the character is two cells wide and the second cell differs. |
7 | 5513 */ |
5514 static int | |
5515 char_needs_redraw(off_from, off_to, cols) | |
5516 int off_from; | |
5517 int off_to; | |
5518 int cols; | |
5519 { | |
5520 if (cols > 0 | |
5521 && ((ScreenLines[off_from] != ScreenLines[off_to] | |
5522 || ScreenAttrs[off_from] != ScreenAttrs[off_to]) | |
5523 | |
5524 #ifdef FEAT_MBYTE | |
5525 || (enc_dbcs != 0 | |
5526 && MB_BYTE2LEN(ScreenLines[off_from]) > 1 | |
5527 && (enc_dbcs == DBCS_JPNU && ScreenLines[off_from] == 0x8e | |
5528 ? ScreenLines2[off_from] != ScreenLines2[off_to] | |
5529 : (cols > 1 && ScreenLines[off_from + 1] | |
5530 != ScreenLines[off_to + 1]))) | |
5531 || (enc_utf8 | |
5532 && (ScreenLinesUC[off_from] != ScreenLinesUC[off_to] | |
5533 || (ScreenLinesUC[off_from] != 0 | |
1616 | 5534 && comp_char_differs(off_from, off_to)) |
3759 | 5535 || ((*mb_off2cells)(off_from, off_from + cols) > 1 |
5536 && ScreenLines[off_from + 1] | |
5537 != ScreenLines[off_to + 1]))) | |
7 | 5538 #endif |
5539 )) | |
5540 return TRUE; | |
5541 return FALSE; | |
5542 } | |
5543 | |
5544 /* | |
5545 * Move one "cooked" screen line to the screen, but only the characters that | |
5546 * have actually changed. Handle insert/delete character. | |
5547 * "coloff" gives the first column on the screen for this line. | |
5548 * "endcol" gives the columns where valid characters are. | |
5549 * "clear_width" is the width of the window. It's > 0 if the rest of the line | |
5550 * needs to be cleared, negative otherwise. | |
5551 * "rlflag" is TRUE in a rightleft window: | |
5552 * When TRUE and "clear_width" > 0, clear columns 0 to "endcol" | |
5553 * When FALSE and "clear_width" > 0, clear columns "endcol" to "clear_width" | |
5554 */ | |
5555 static void | |
5556 screen_line(row, coloff, endcol, clear_width | |
5557 #ifdef FEAT_RIGHTLEFT | |
5558 , rlflag | |
5559 #endif | |
5560 ) | |
5561 int row; | |
5562 int coloff; | |
5563 int endcol; | |
5564 int clear_width; | |
5565 #ifdef FEAT_RIGHTLEFT | |
5566 int rlflag; | |
5567 #endif | |
5568 { | |
5569 unsigned off_from; | |
5570 unsigned off_to; | |
1378 | 5571 #ifdef FEAT_MBYTE |
5572 unsigned max_off_from; | |
5573 unsigned max_off_to; | |
5574 #endif | |
7 | 5575 int col = 0; |
5576 #if defined(FEAT_GUI) || defined(UNIX) || defined(FEAT_VERTSPLIT) | |
5577 int hl; | |
5578 #endif | |
5579 int force = FALSE; /* force update rest of the line */ | |
5580 int redraw_this /* bool: does character need redraw? */ | |
5581 #ifdef FEAT_GUI | |
5582 = TRUE /* For GUI when while-loop empty */ | |
5583 #endif | |
5584 ; | |
5585 int redraw_next; /* redraw_this for next character */ | |
5586 #ifdef FEAT_MBYTE | |
5587 int clear_next = FALSE; | |
5588 int char_cells; /* 1: normal char */ | |
5589 /* 2: occupies two display cells */ | |
5590 # define CHAR_CELLS char_cells | |
5591 #else | |
5592 # define CHAR_CELLS 1 | |
5593 #endif | |
5594 | |
3413 | 5595 /* Check for illegal row and col, just in case. */ |
5596 if (row >= Rows) | |
5597 row = Rows - 1; | |
5598 if (endcol > Columns) | |
5599 endcol = Columns; | |
5600 | |
7 | 5601 # ifdef FEAT_CLIPBOARD |
5602 clip_may_clear_selection(row, row); | |
5603 # endif | |
5604 | |
5605 off_from = (unsigned)(current_ScreenLine - ScreenLines); | |
5606 off_to = LineOffset[row] + coloff; | |
1378 | 5607 #ifdef FEAT_MBYTE |
5608 max_off_from = off_from + screen_Columns; | |
5609 max_off_to = LineOffset[row] + screen_Columns; | |
5610 #endif | |
7 | 5611 |
5612 #ifdef FEAT_RIGHTLEFT | |
5613 if (rlflag) | |
5614 { | |
5615 /* Clear rest first, because it's left of the text. */ | |
5616 if (clear_width > 0) | |
5617 { | |
5618 while (col <= endcol && ScreenLines[off_to] == ' ' | |
5619 && ScreenAttrs[off_to] == 0 | |
5620 # ifdef FEAT_MBYTE | |
5621 && (!enc_utf8 || ScreenLinesUC[off_to] == 0) | |
5622 # endif | |
5623 ) | |
5624 { | |
5625 ++off_to; | |
5626 ++col; | |
5627 } | |
5628 if (col <= endcol) | |
5629 screen_fill(row, row + 1, col + coloff, | |
5630 endcol + coloff + 1, ' ', ' ', 0); | |
5631 } | |
5632 col = endcol + 1; | |
5633 off_to = LineOffset[row] + col + coloff; | |
5634 off_from += col; | |
5635 endcol = (clear_width > 0 ? clear_width : -clear_width); | |
5636 } | |
5637 #endif /* FEAT_RIGHTLEFT */ | |
5638 | |
5639 redraw_next = char_needs_redraw(off_from, off_to, endcol - col); | |
5640 | |
5641 while (col < endcol) | |
5642 { | |
5643 #ifdef FEAT_MBYTE | |
5644 if (has_mbyte && (col + 1 < endcol)) | |
1378 | 5645 char_cells = (*mb_off2cells)(off_from, max_off_from); |
7 | 5646 else |
5647 char_cells = 1; | |
5648 #endif | |
5649 | |
5650 redraw_this = redraw_next; | |
5651 redraw_next = force || char_needs_redraw(off_from + CHAR_CELLS, | |
5652 off_to + CHAR_CELLS, endcol - col - CHAR_CELLS); | |
5653 | |
5654 #ifdef FEAT_GUI | |
5655 /* If the next character was bold, then redraw the current character to | |
5656 * remove any pixels that might have spilt over into us. This only | |
5657 * happens in the GUI. | |
5658 */ | |
5659 if (redraw_next && gui.in_use) | |
5660 { | |
5661 hl = ScreenAttrs[off_to + CHAR_CELLS]; | |
743 | 5662 if (hl > HL_ALL) |
5663 hl = syn_attr2attr(hl); | |
5664 if (hl & HL_BOLD) | |
7 | 5665 redraw_this = TRUE; |
5666 } | |
5667 #endif | |
5668 | |
5669 if (redraw_this) | |
5670 { | |
5671 /* | |
5672 * Special handling when 'xs' termcap flag set (hpterm): | |
5673 * Attributes for characters are stored at the position where the | |
5674 * cursor is when writing the highlighting code. The | |
5675 * start-highlighting code must be written with the cursor on the | |
5676 * first highlighted character. The stop-highlighting code must | |
5677 * be written with the cursor just after the last highlighted | |
5678 * character. | |
5679 * Overwriting a character doesn't remove it's highlighting. Need | |
5680 * to clear the rest of the line, and force redrawing it | |
5681 * completely. | |
5682 */ | |
5683 if ( p_wiv | |
5684 && !force | |
5685 #ifdef FEAT_GUI | |
5686 && !gui.in_use | |
5687 #endif | |
5688 && ScreenAttrs[off_to] != 0 | |
5689 && ScreenAttrs[off_from] != ScreenAttrs[off_to]) | |
5690 { | |
5691 /* | |
5692 * Need to remove highlighting attributes here. | |
5693 */ | |
5694 windgoto(row, col + coloff); | |
5695 out_str(T_CE); /* clear rest of this screen line */ | |
5696 screen_start(); /* don't know where cursor is now */ | |
5697 force = TRUE; /* force redraw of rest of the line */ | |
5698 redraw_next = TRUE; /* or else next char would miss out */ | |
5699 | |
5700 /* | |
5701 * If the previous character was highlighted, need to stop | |
5702 * highlighting at this character. | |
5703 */ | |
5704 if (col + coloff > 0 && ScreenAttrs[off_to - 1] != 0) | |
5705 { | |
5706 screen_attr = ScreenAttrs[off_to - 1]; | |
5707 term_windgoto(row, col + coloff); | |
5708 screen_stop_highlight(); | |
5709 } | |
5710 else | |
5711 screen_attr = 0; /* highlighting has stopped */ | |
5712 } | |
5713 #ifdef FEAT_MBYTE | |
5714 if (enc_dbcs != 0) | |
5715 { | |
5716 /* Check if overwriting a double-byte with a single-byte or | |
5717 * the other way around requires another character to be | |
5718 * redrawn. For UTF-8 this isn't needed, because comparing | |
5719 * ScreenLinesUC[] is sufficient. */ | |
5720 if (char_cells == 1 | |
5721 && col + 1 < endcol | |
1378 | 5722 && (*mb_off2cells)(off_to, max_off_to) > 1) |
7 | 5723 { |
5724 /* Writing a single-cell character over a double-cell | |
5725 * character: need to redraw the next cell. */ | |
5726 ScreenLines[off_to + 1] = 0; | |
5727 redraw_next = TRUE; | |
5728 } | |
5729 else if (char_cells == 2 | |
5730 && col + 2 < endcol | |
1378 | 5731 && (*mb_off2cells)(off_to, max_off_to) == 1 |
5732 && (*mb_off2cells)(off_to + 1, max_off_to) > 1) | |
7 | 5733 { |
5734 /* Writing the second half of a double-cell character over | |
5735 * a double-cell character: need to redraw the second | |
5736 * cell. */ | |
5737 ScreenLines[off_to + 2] = 0; | |
5738 redraw_next = TRUE; | |
5739 } | |
5740 | |
5741 if (enc_dbcs == DBCS_JPNU) | |
5742 ScreenLines2[off_to] = ScreenLines2[off_from]; | |
5743 } | |
5744 /* When writing a single-width character over a double-width | |
5745 * character and at the end of the redrawn text, need to clear out | |
5746 * the right halve of the old character. | |
5747 * Also required when writing the right halve of a double-width | |
5748 * char over the left halve of an existing one. */ | |
5749 if (has_mbyte && col + char_cells == endcol | |
5750 && ((char_cells == 1 | |
1378 | 5751 && (*mb_off2cells)(off_to, max_off_to) > 1) |
7 | 5752 || (char_cells == 2 |
1378 | 5753 && (*mb_off2cells)(off_to, max_off_to) == 1 |
5754 && (*mb_off2cells)(off_to + 1, max_off_to) > 1))) | |
7 | 5755 clear_next = TRUE; |
5756 #endif | |
5757 | |
5758 ScreenLines[off_to] = ScreenLines[off_from]; | |
5759 #ifdef FEAT_MBYTE | |
5760 if (enc_utf8) | |
5761 { | |
5762 ScreenLinesUC[off_to] = ScreenLinesUC[off_from]; | |
5763 if (ScreenLinesUC[off_from] != 0) | |
5764 { | |
714 | 5765 int i; |
5766 | |
5767 for (i = 0; i < Screen_mco; ++i) | |
5768 ScreenLinesC[i][off_to] = ScreenLinesC[i][off_from]; | |
7 | 5769 } |
5770 } | |
5771 if (char_cells == 2) | |
5772 ScreenLines[off_to + 1] = ScreenLines[off_from + 1]; | |
5773 #endif | |
5774 | |
5775 #if defined(FEAT_GUI) || defined(UNIX) | |
1843 | 5776 /* The bold trick makes a single column of pixels appear in the |
5777 * next character. When a bold character is removed, the next | |
7 | 5778 * character should be redrawn too. This happens for our own GUI |
5779 * and for some xterms. */ | |
5780 if ( | |
5781 # ifdef FEAT_GUI | |
5782 gui.in_use | |
5783 # endif | |
5784 # if defined(FEAT_GUI) && defined(UNIX) | |
5785 || | |
5786 # endif | |
5787 # ifdef UNIX | |
5788 term_is_xterm | |
5789 # endif | |
5790 ) | |
5791 { | |
5792 hl = ScreenAttrs[off_to]; | |
743 | 5793 if (hl > HL_ALL) |
5794 hl = syn_attr2attr(hl); | |
5795 if (hl & HL_BOLD) | |
7 | 5796 redraw_next = TRUE; |
5797 } | |
5798 #endif | |
5799 ScreenAttrs[off_to] = ScreenAttrs[off_from]; | |
5800 #ifdef FEAT_MBYTE | |
819 | 5801 /* For simplicity set the attributes of second half of a |
5802 * double-wide character equal to the first half. */ | |
5803 if (char_cells == 2) | |
5804 ScreenAttrs[off_to + 1] = ScreenAttrs[off_from]; | |
5805 | |
7 | 5806 if (enc_dbcs != 0 && char_cells == 2) |
5807 screen_char_2(off_to, row, col + coloff); | |
5808 else | |
5809 #endif | |
5810 screen_char(off_to, row, col + coloff); | |
5811 } | |
5812 else if ( p_wiv | |
5813 #ifdef FEAT_GUI | |
5814 && !gui.in_use | |
5815 #endif | |
5816 && col + coloff > 0) | |
5817 { | |
5818 if (ScreenAttrs[off_to] == ScreenAttrs[off_to - 1]) | |
5819 { | |
5820 /* | |
5821 * Don't output stop-highlight when moving the cursor, it will | |
5822 * stop the highlighting when it should continue. | |
5823 */ | |
5824 screen_attr = 0; | |
5825 } | |
5826 else if (screen_attr != 0) | |
5827 screen_stop_highlight(); | |
5828 } | |
5829 | |
5830 off_to += CHAR_CELLS; | |
5831 off_from += CHAR_CELLS; | |
5832 col += CHAR_CELLS; | |
5833 } | |
5834 | |
5835 #ifdef FEAT_MBYTE | |
5836 if (clear_next) | |
5837 { | |
5838 /* Clear the second half of a double-wide character of which the left | |
5839 * half was overwritten with a single-wide character. */ | |
5840 ScreenLines[off_to] = ' '; | |
5841 if (enc_utf8) | |
5842 ScreenLinesUC[off_to] = 0; | |
5843 screen_char(off_to, row, col + coloff); | |
5844 } | |
5845 #endif | |
5846 | |
5847 if (clear_width > 0 | |
5848 #ifdef FEAT_RIGHTLEFT | |
5849 && !rlflag | |
5850 #endif | |
5851 ) | |
5852 { | |
5853 #ifdef FEAT_GUI | |
5854 int startCol = col; | |
5855 #endif | |
5856 | |
5857 /* blank out the rest of the line */ | |
5858 while (col < clear_width && ScreenLines[off_to] == ' ' | |
5859 && ScreenAttrs[off_to] == 0 | |
5860 #ifdef FEAT_MBYTE | |
5861 && (!enc_utf8 || ScreenLinesUC[off_to] == 0) | |
5862 #endif | |
5863 ) | |
5864 { | |
5865 ++off_to; | |
5866 ++col; | |
5867 } | |
5868 if (col < clear_width) | |
5869 { | |
5870 #ifdef FEAT_GUI | |
5871 /* | |
5872 * In the GUI, clearing the rest of the line may leave pixels | |
5873 * behind if the first character cleared was bold. Some bold | |
5874 * fonts spill over the left. In this case we redraw the previous | |
5875 * character too. If we didn't skip any blanks above, then we | |
5876 * only redraw if the character wasn't already redrawn anyway. | |
5877 */ | |
996 | 5878 if (gui.in_use && (col > startCol || !redraw_this)) |
7 | 5879 { |
5880 hl = ScreenAttrs[off_to]; | |
5881 if (hl > HL_ALL || (hl & HL_BOLD)) | |
996 | 5882 { |
5883 int prev_cells = 1; | |
5884 # ifdef FEAT_MBYTE | |
5885 if (enc_utf8) | |
5886 /* for utf-8, ScreenLines[char_offset + 1] == 0 means | |
5887 * that its width is 2. */ | |
5888 prev_cells = ScreenLines[off_to - 1] == 0 ? 2 : 1; | |
5889 else if (enc_dbcs != 0) | |
5890 { | |
5891 /* find previous character by counting from first | |
5892 * column and get its width. */ | |
5893 unsigned off = LineOffset[row]; | |
1378 | 5894 unsigned max_off = LineOffset[row] + screen_Columns; |
996 | 5895 |
5896 while (off < off_to) | |
5897 { | |
1378 | 5898 prev_cells = (*mb_off2cells)(off, max_off); |
996 | 5899 off += prev_cells; |
5900 } | |
5901 } | |
5902 | |
5903 if (enc_dbcs != 0 && prev_cells > 1) | |
5904 screen_char_2(off_to - prev_cells, row, | |
5905 col + coloff - prev_cells); | |
5906 else | |
5907 # endif | |
5908 screen_char(off_to - prev_cells, row, | |
5909 col + coloff - prev_cells); | |
5910 } | |
7 | 5911 } |
5912 #endif | |
5913 screen_fill(row, row + 1, col + coloff, clear_width + coloff, | |
5914 ' ', ' ', 0); | |
5915 #ifdef FEAT_VERTSPLIT | |
5916 off_to += clear_width - col; | |
5917 col = clear_width; | |
5918 #endif | |
5919 } | |
5920 } | |
5921 | |
5922 if (clear_width > 0) | |
5923 { | |
5924 #ifdef FEAT_VERTSPLIT | |
5925 /* For a window that's left of another, draw the separator char. */ | |
5926 if (col + coloff < Columns) | |
5927 { | |
5928 int c; | |
5929 | |
5930 c = fillchar_vsep(&hl); | |
5931 if (ScreenLines[off_to] != c | |
5932 # ifdef FEAT_MBYTE | |
714 | 5933 || (enc_utf8 && (int)ScreenLinesUC[off_to] |
5934 != (c >= 0x80 ? c : 0)) | |
7 | 5935 # endif |
5936 || ScreenAttrs[off_to] != hl) | |
5937 { | |
5938 ScreenLines[off_to] = c; | |
5939 ScreenAttrs[off_to] = hl; | |
5940 # ifdef FEAT_MBYTE | |
5941 if (enc_utf8) | |
5942 { | |
5943 if (c >= 0x80) | |
5944 { | |
5945 ScreenLinesUC[off_to] = c; | |
714 | 5946 ScreenLinesC[0][off_to] = 0; |
7 | 5947 } |
5948 else | |
5949 ScreenLinesUC[off_to] = 0; | |
5950 } | |
5951 # endif | |
5952 screen_char(off_to, row, col + coloff); | |
5953 } | |
5954 } | |
5955 else | |
5956 #endif | |
5957 LineWraps[row] = FALSE; | |
5958 } | |
5959 } | |
5960 | |
474 | 5961 #if defined(FEAT_RIGHTLEFT) || defined(PROTO) |
7 | 5962 /* |
474 | 5963 * Mirror text "str" for right-left displaying. |
5964 * Only works for single-byte characters (e.g., numbers). | |
7 | 5965 */ |
474 | 5966 void |
7 | 5967 rl_mirror(str) |
5968 char_u *str; | |
5969 { | |
5970 char_u *p1, *p2; | |
5971 int t; | |
5972 | |
5973 for (p1 = str, p2 = str + STRLEN(str) - 1; p1 < p2; ++p1, --p2) | |
5974 { | |
5975 t = *p1; | |
5976 *p1 = *p2; | |
5977 *p2 = t; | |
5978 } | |
5979 } | |
5980 #endif | |
5981 | |
5982 #if defined(FEAT_WINDOWS) || defined(PROTO) | |
5983 /* | |
5984 * mark all status lines for redraw; used after first :cd | |
5985 */ | |
5986 void | |
5987 status_redraw_all() | |
5988 { | |
5989 win_T *wp; | |
5990 | |
5991 for (wp = firstwin; wp; wp = wp->w_next) | |
5992 if (wp->w_status_height) | |
5993 { | |
5994 wp->w_redr_status = TRUE; | |
5995 redraw_later(VALID); | |
5996 } | |
5997 } | |
5998 | |
5999 /* | |
6000 * mark all status lines of the current buffer for redraw | |
6001 */ | |
6002 void | |
6003 status_redraw_curbuf() | |
6004 { | |
6005 win_T *wp; | |
6006 | |
6007 for (wp = firstwin; wp; wp = wp->w_next) | |
6008 if (wp->w_status_height != 0 && wp->w_buffer == curbuf) | |
6009 { | |
6010 wp->w_redr_status = TRUE; | |
6011 redraw_later(VALID); | |
6012 } | |
6013 } | |
6014 | |
6015 /* | |
6016 * Redraw all status lines that need to be redrawn. | |
6017 */ | |
6018 void | |
6019 redraw_statuslines() | |
6020 { | |
6021 win_T *wp; | |
6022 | |
6023 for (wp = firstwin; wp; wp = wp->w_next) | |
6024 if (wp->w_redr_status) | |
6025 win_redr_status(wp); | |
673 | 6026 if (redraw_tabline) |
677 | 6027 draw_tabline(); |
7 | 6028 } |
6029 #endif | |
6030 | |
6031 #if (defined(FEAT_WILDMENU) && defined(FEAT_VERTSPLIT)) || defined(PROTO) | |
6032 /* | |
6033 * Redraw all status lines at the bottom of frame "frp". | |
6034 */ | |
6035 void | |
6036 win_redraw_last_status(frp) | |
6037 frame_T *frp; | |
6038 { | |
6039 if (frp->fr_layout == FR_LEAF) | |
6040 frp->fr_win->w_redr_status = TRUE; | |
6041 else if (frp->fr_layout == FR_ROW) | |
6042 { | |
6043 for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) | |
6044 win_redraw_last_status(frp); | |
6045 } | |
6046 else /* frp->fr_layout == FR_COL */ | |
6047 { | |
6048 frp = frp->fr_child; | |
6049 while (frp->fr_next != NULL) | |
6050 frp = frp->fr_next; | |
6051 win_redraw_last_status(frp); | |
6052 } | |
6053 } | |
6054 #endif | |
6055 | |
6056 #ifdef FEAT_VERTSPLIT | |
6057 /* | |
6058 * Draw the verticap separator right of window "wp" starting with line "row". | |
6059 */ | |
6060 static void | |
6061 draw_vsep_win(wp, row) | |
6062 win_T *wp; | |
6063 int row; | |
6064 { | |
6065 int hl; | |
6066 int c; | |
6067 | |
6068 if (wp->w_vsep_width) | |
6069 { | |
6070 /* draw the vertical separator right of this window */ | |
6071 c = fillchar_vsep(&hl); | |
6072 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height, | |
6073 W_ENDCOL(wp), W_ENDCOL(wp) + 1, | |
6074 c, ' ', hl); | |
6075 } | |
6076 } | |
6077 #endif | |
6078 | |
6079 #ifdef FEAT_WILDMENU | |
6080 static int status_match_len __ARGS((expand_T *xp, char_u *s)); | |
277 | 6081 static int skip_status_match_char __ARGS((expand_T *xp, char_u *s)); |
7 | 6082 |
6083 /* | |
1378 | 6084 * Get the length of an item as it will be shown in the status line. |
7 | 6085 */ |
6086 static int | |
6087 status_match_len(xp, s) | |
6088 expand_T *xp; | |
6089 char_u *s; | |
6090 { | |
6091 int len = 0; | |
6092 | |
6093 #ifdef FEAT_MENU | |
6094 int emenu = (xp->xp_context == EXPAND_MENUS | |
6095 || xp->xp_context == EXPAND_MENUNAMES); | |
6096 | |
6097 /* Check for menu separators - replace with '|'. */ | |
6098 if (emenu && menu_is_separator(s)) | |
6099 return 1; | |
6100 #endif | |
6101 | |
6102 while (*s != NUL) | |
6103 { | |
1685 | 6104 s += skip_status_match_char(xp, s); |
42 | 6105 len += ptr2cells(s); |
39 | 6106 mb_ptr_adv(s); |
7 | 6107 } |
6108 | |
6109 return len; | |
6110 } | |
6111 | |
6112 /* | |
1685 | 6113 * Return the number of characters that should be skipped in a status match. |
277 | 6114 * These are backslashes used for escaping. Do show backslashes in help tags. |
6115 */ | |
6116 static int | |
6117 skip_status_match_char(xp, s) | |
6118 expand_T *xp; | |
6119 char_u *s; | |
6120 { | |
1685 | 6121 if ((rem_backslash(s) && xp->xp_context != EXPAND_HELP) |
277 | 6122 #ifdef FEAT_MENU |
6123 || ((xp->xp_context == EXPAND_MENUS | |
6124 || xp->xp_context == EXPAND_MENUNAMES) | |
6125 && (s[0] == '\t' || (s[0] == '\\' && s[1] != NUL))) | |
6126 #endif | |
1685 | 6127 ) |
6128 { | |
6129 #ifndef BACKSLASH_IN_FILENAME | |
6130 if (xp->xp_shell && csh_like_shell() && s[1] == '\\' && s[2] == '!') | |
6131 return 2; | |
6132 #endif | |
6133 return 1; | |
6134 } | |
6135 return 0; | |
277 | 6136 } |
6137 | |
6138 /* | |
7 | 6139 * Show wildchar matches in the status line. |
6140 * Show at least the "match" item. | |
6141 * We start at item 'first_match' in the list and show all matches that fit. | |
6142 * | |
6143 * If inversion is possible we use it. Else '=' characters are used. | |
6144 */ | |
6145 void | |
6146 win_redr_status_matches(xp, num_matches, matches, match, showtail) | |
6147 expand_T *xp; | |
6148 int num_matches; | |
6149 char_u **matches; /* list of matches */ | |
6150 int match; | |
6151 int showtail; | |
6152 { | |
6153 #define L_MATCH(m) (showtail ? sm_gettail(matches[m]) : matches[m]) | |
6154 int row; | |
6155 char_u *buf; | |
6156 int len; | |
1378 | 6157 int clen; /* length in screen cells */ |
7 | 6158 int fillchar; |
6159 int attr; | |
6160 int i; | |
6161 int highlight = TRUE; | |
6162 char_u *selstart = NULL; | |
6163 int selstart_col = 0; | |
6164 char_u *selend = NULL; | |
6165 static int first_match = 0; | |
6166 int add_left = FALSE; | |
6167 char_u *s; | |
6168 #ifdef FEAT_MENU | |
6169 int emenu; | |
6170 #endif | |
6171 #if defined(FEAT_MBYTE) || defined(FEAT_MENU) | |
6172 int l; | |
6173 #endif | |
6174 | |
6175 if (matches == NULL) /* interrupted completion? */ | |
6176 return; | |
6177 | |
39 | 6178 #ifdef FEAT_MBYTE |
6179 if (has_mbyte) | |
6180 buf = alloc((unsigned)Columns * MB_MAXBYTES + 1); | |
6181 else | |
6182 #endif | |
6183 buf = alloc((unsigned)Columns + 1); | |
7 | 6184 if (buf == NULL) |
6185 return; | |
6186 | |
6187 if (match == -1) /* don't show match but original text */ | |
6188 { | |
6189 match = 0; | |
6190 highlight = FALSE; | |
6191 } | |
6192 /* count 1 for the ending ">" */ | |
6193 clen = status_match_len(xp, L_MATCH(match)) + 3; | |
6194 if (match == 0) | |
6195 first_match = 0; | |
6196 else if (match < first_match) | |
6197 { | |
6198 /* jumping left, as far as we can go */ | |
6199 first_match = match; | |
6200 add_left = TRUE; | |
6201 } | |
6202 else | |
6203 { | |
6204 /* check if match fits on the screen */ | |
6205 for (i = first_match; i < match; ++i) | |
6206 clen += status_match_len(xp, L_MATCH(i)) + 2; | |
6207 if (first_match > 0) | |
6208 clen += 2; | |
6209 /* jumping right, put match at the left */ | |
6210 if ((long)clen > Columns) | |
6211 { | |
6212 first_match = match; | |
6213 /* if showing the last match, we can add some on the left */ | |
6214 clen = 2; | |
6215 for (i = match; i < num_matches; ++i) | |
6216 { | |
6217 clen += status_match_len(xp, L_MATCH(i)) + 2; | |
6218 if ((long)clen >= Columns) | |
6219 break; | |
6220 } | |
6221 if (i == num_matches) | |
6222 add_left = TRUE; | |
6223 } | |
6224 } | |
6225 if (add_left) | |
6226 while (first_match > 0) | |
6227 { | |
6228 clen += status_match_len(xp, L_MATCH(first_match - 1)) + 2; | |
6229 if ((long)clen >= Columns) | |
6230 break; | |
6231 --first_match; | |
6232 } | |
6233 | |
6234 fillchar = fillchar_status(&attr, TRUE); | |
6235 | |
6236 if (first_match == 0) | |
6237 { | |
6238 *buf = NUL; | |
6239 len = 0; | |
6240 } | |
6241 else | |
6242 { | |
6243 STRCPY(buf, "< "); | |
6244 len = 2; | |
6245 } | |
6246 clen = len; | |
6247 | |
6248 i = first_match; | |
6249 while ((long)(clen + status_match_len(xp, L_MATCH(i)) + 2) < Columns) | |
6250 { | |
6251 if (i == match) | |
6252 { | |
6253 selstart = buf + len; | |
6254 selstart_col = clen; | |
6255 } | |
6256 | |
6257 s = L_MATCH(i); | |
6258 /* Check for menu separators - replace with '|' */ | |
6259 #ifdef FEAT_MENU | |
6260 emenu = (xp->xp_context == EXPAND_MENUS | |
6261 || xp->xp_context == EXPAND_MENUNAMES); | |
6262 if (emenu && menu_is_separator(s)) | |
6263 { | |
6264 STRCPY(buf + len, transchar('|')); | |
6265 l = (int)STRLEN(buf + len); | |
6266 len += l; | |
6267 clen += l; | |
6268 } | |
6269 else | |
6270 #endif | |
6271 for ( ; *s != NUL; ++s) | |
6272 { | |
1685 | 6273 s += skip_status_match_char(xp, s); |
7 | 6274 clen += ptr2cells(s); |
6275 #ifdef FEAT_MBYTE | |
474 | 6276 if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1) |
7 | 6277 { |
6278 STRNCPY(buf + len, s, l); | |
6279 s += l - 1; | |
6280 len += l; | |
6281 } | |
6282 else | |
6283 #endif | |
6284 { | |
6285 STRCPY(buf + len, transchar_byte(*s)); | |
6286 len += (int)STRLEN(buf + len); | |
6287 } | |
6288 } | |
6289 if (i == match) | |
6290 selend = buf + len; | |
6291 | |
6292 *(buf + len++) = ' '; | |
6293 *(buf + len++) = ' '; | |
6294 clen += 2; | |
6295 if (++i == num_matches) | |
6296 break; | |
6297 } | |
6298 | |
6299 if (i != num_matches) | |
6300 { | |
6301 *(buf + len++) = '>'; | |
6302 ++clen; | |
6303 } | |
6304 | |
6305 buf[len] = NUL; | |
6306 | |
6307 row = cmdline_row - 1; | |
6308 if (row >= 0) | |
6309 { | |
6310 if (wild_menu_showing == 0) | |
6311 { | |
6312 if (msg_scrolled > 0) | |
6313 { | |
6314 /* Put the wildmenu just above the command line. If there is | |
6315 * no room, scroll the screen one line up. */ | |
6316 if (cmdline_row == Rows - 1) | |
6317 { | |
6318 screen_del_lines(0, 0, 1, (int)Rows, TRUE, NULL); | |
6319 ++msg_scrolled; | |
6320 } | |
6321 else | |
6322 { | |
6323 ++cmdline_row; | |
6324 ++row; | |
6325 } | |
6326 wild_menu_showing = WM_SCROLLED; | |
6327 } | |
6328 else | |
6329 { | |
6330 /* Create status line if needed by setting 'laststatus' to 2. | |
6331 * Set 'winminheight' to zero to avoid that the window is | |
6332 * resized. */ | |
6333 if (lastwin->w_status_height == 0) | |
6334 { | |
6335 save_p_ls = p_ls; | |
6336 save_p_wmh = p_wmh; | |
6337 p_ls = 2; | |
6338 p_wmh = 0; | |
6339 last_status(FALSE); | |
6340 } | |
6341 wild_menu_showing = WM_SHOWN; | |
6342 } | |
6343 } | |
6344 | |
6345 screen_puts(buf, row, 0, attr); | |
6346 if (selstart != NULL && highlight) | |
6347 { | |
6348 *selend = NUL; | |
6349 screen_puts(selstart, row, selstart_col, hl_attr(HLF_WM)); | |
6350 } | |
6351 | |
6352 screen_fill(row, row + 1, clen, (int)Columns, fillchar, fillchar, attr); | |
6353 } | |
6354 | |
6355 #ifdef FEAT_VERTSPLIT | |
6356 win_redraw_last_status(topframe); | |
6357 #else | |
6358 lastwin->w_redr_status = TRUE; | |
6359 #endif | |
6360 vim_free(buf); | |
6361 } | |
6362 #endif | |
6363 | |
6364 #if defined(FEAT_WINDOWS) || defined(PROTO) | |
6365 /* | |
6366 * Redraw the status line of window wp. | |
6367 * | |
6368 * If inversion is possible we use it. Else '=' characters are used. | |
6369 */ | |
6370 void | |
6371 win_redr_status(wp) | |
6372 win_T *wp; | |
6373 { | |
6374 int row; | |
6375 char_u *p; | |
6376 int len; | |
6377 int fillchar; | |
6378 int attr; | |
6379 int this_ru_col; | |
1910 | 6380 static int busy = FALSE; |
6381 | |
6382 /* It's possible to get here recursively when 'statusline' (indirectly) | |
6383 * invokes ":redrawstatus". Simply ignore the call then. */ | |
6384 if (busy) | |
6385 return; | |
6386 busy = TRUE; | |
7 | 6387 |
6388 wp->w_redr_status = FALSE; | |
6389 if (wp->w_status_height == 0) | |
6390 { | |
6391 /* no status line, can only be last window */ | |
6392 redraw_cmdline = TRUE; | |
6393 } | |
540 | 6394 else if (!redrawing() |
6395 #ifdef FEAT_INS_EXPAND | |
6396 /* don't update status line when popup menu is visible and may be | |
6397 * drawn over it */ | |
6398 || pum_visible() | |
6399 #endif | |
6400 ) | |
7 | 6401 { |
6402 /* Don't redraw right now, do it later. */ | |
6403 wp->w_redr_status = TRUE; | |
6404 } | |
6405 #ifdef FEAT_STL_OPT | |
40 | 6406 else if (*p_stl != NUL || *wp->w_p_stl != NUL) |
7 | 6407 { |
6408 /* redraw custom status line */ | |
1983 | 6409 redraw_custom_statusline(wp); |
7 | 6410 } |
6411 #endif | |
6412 else | |
6413 { | |
6414 fillchar = fillchar_status(&attr, wp == curwin); | |
6415 | |
685 | 6416 get_trans_bufname(wp->w_buffer); |
7 | 6417 p = NameBuff; |
6418 len = (int)STRLEN(p); | |
6419 | |
6420 if (wp->w_buffer->b_help | |
6421 #ifdef FEAT_QUICKFIX | |
6422 || wp->w_p_pvw | |
6423 #endif | |
6424 || bufIsChanged(wp->w_buffer) | |
6425 || wp->w_buffer->b_p_ro) | |
6426 *(p + len++) = ' '; | |
6427 if (wp->w_buffer->b_help) | |
6428 { | |
809 | 6429 STRCPY(p + len, _("[Help]")); |
7 | 6430 len += (int)STRLEN(p + len); |
6431 } | |
6432 #ifdef FEAT_QUICKFIX | |
6433 if (wp->w_p_pvw) | |
6434 { | |
6435 STRCPY(p + len, _("[Preview]")); | |
6436 len += (int)STRLEN(p + len); | |
6437 } | |
6438 #endif | |
6439 if (bufIsChanged(wp->w_buffer)) | |
6440 { | |
6441 STRCPY(p + len, "[+]"); | |
6442 len += 3; | |
6443 } | |
6444 if (wp->w_buffer->b_p_ro) | |
6445 { | |
4795
8360a59aa04b
updated for version 7.3.1144
Bram Moolenaar <bram@vim.org>
parents:
4736
diff
changeset
|
6446 STRCPY(p + len, _("[RO]")); |
7 | 6447 len += 4; |
6448 } | |
6449 | |
6450 #ifndef FEAT_VERTSPLIT | |
6451 this_ru_col = ru_col; | |
6452 if (this_ru_col < (Columns + 1) / 2) | |
6453 this_ru_col = (Columns + 1) / 2; | |
6454 #else | |
6455 this_ru_col = ru_col - (Columns - W_WIDTH(wp)); | |
6456 if (this_ru_col < (W_WIDTH(wp) + 1) / 2) | |
6457 this_ru_col = (W_WIDTH(wp) + 1) / 2; | |
6458 if (this_ru_col <= 1) | |
6459 { | |
6460 p = (char_u *)"<"; /* No room for file name! */ | |
6461 len = 1; | |
6462 } | |
6463 else | |
6464 #endif | |
6465 #ifdef FEAT_MBYTE | |
6466 if (has_mbyte) | |
6467 { | |
6468 int clen = 0, i; | |
6469 | |
6470 /* Count total number of display cells. */ | |
2338
da6ec32d8d8f
Added strwidth() and strchars() functions.
Bram Moolenaar <bram@vim.org>
parents:
2332
diff
changeset
|
6471 clen = mb_string2cells(p, -1); |
da6ec32d8d8f
Added strwidth() and strchars() functions.
Bram Moolenaar <bram@vim.org>
parents:
2332
diff
changeset
|
6472 |
7 | 6473 /* Find first character that will fit. |
6474 * Going from start to end is much faster for DBCS. */ | |
6475 for (i = 0; p[i] != NUL && clen >= this_ru_col - 1; | |
474 | 6476 i += (*mb_ptr2len)(p + i)) |
7 | 6477 clen -= (*mb_ptr2cells)(p + i); |
6478 len = clen; | |
6479 if (i > 0) | |
6480 { | |
6481 p = p + i - 1; | |
6482 *p = '<'; | |
6483 ++len; | |
6484 } | |
6485 | |
6486 } | |
6487 else | |
6488 #endif | |
6489 if (len > this_ru_col - 1) | |
6490 { | |
6491 p += len - (this_ru_col - 1); | |
6492 *p = '<'; | |
6493 len = this_ru_col - 1; | |
6494 } | |
6495 | |
6496 row = W_WINROW(wp) + wp->w_height; | |
6497 screen_puts(p, row, W_WINCOL(wp), attr); | |
6498 screen_fill(row, row + 1, len + W_WINCOL(wp), | |
6499 this_ru_col + W_WINCOL(wp), fillchar, fillchar, attr); | |
6500 | |
6501 if (get_keymap_str(wp, NameBuff, MAXPATHL) | |
6502 && (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1)) | |
6503 screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff) | |
6504 - 1 + W_WINCOL(wp)), attr); | |
6505 | |
6506 #ifdef FEAT_CMDL_INFO | |
6507 win_redr_ruler(wp, TRUE); | |
6508 #endif | |
6509 } | |
6510 | |
6511 #ifdef FEAT_VERTSPLIT | |
6512 /* | |
6513 * May need to draw the character below the vertical separator. | |
6514 */ | |
6515 if (wp->w_vsep_width != 0 && wp->w_status_height != 0 && redrawing()) | |
6516 { | |
6517 if (stl_connected(wp)) | |
6518 fillchar = fillchar_status(&attr, wp == curwin); | |
6519 else | |
6520 fillchar = fillchar_vsep(&attr); | |
6521 screen_putchar(fillchar, W_WINROW(wp) + wp->w_height, W_ENDCOL(wp), | |
6522 attr); | |
6523 } | |
6524 #endif | |
1910 | 6525 busy = FALSE; |
7 | 6526 } |
6527 | |
680 | 6528 #ifdef FEAT_STL_OPT |
6529 /* | |
6530 * Redraw the status line according to 'statusline' and take care of any | |
6531 * errors encountered. | |
6532 */ | |
6533 static void | |
1983 | 6534 redraw_custom_statusline(wp) |
680 | 6535 win_T *wp; |
6536 { | |
1983 | 6537 static int entered = FALSE; |
6538 int save_called_emsg = called_emsg; | |
6539 | |
6540 /* When called recursively return. This can happen when the statusline | |
6541 * contains an expression that triggers a redraw. */ | |
6542 if (entered) | |
6543 return; | |
6544 entered = TRUE; | |
680 | 6545 |
6546 called_emsg = FALSE; | |
6547 win_redr_custom(wp, FALSE); | |
6548 if (called_emsg) | |
1983 | 6549 { |
6550 /* When there is an error disable the statusline, otherwise the | |
6551 * display is messed up with errors and a redraw triggers the problem | |
6552 * again and again. */ | |
680 | 6553 set_string_option_direct((char_u *)"statusline", -1, |
6554 (char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL | |
694 | 6555 ? OPT_LOCAL : OPT_GLOBAL), SID_ERROR); |
1983 | 6556 } |
680 | 6557 called_emsg |= save_called_emsg; |
1983 | 6558 entered = FALSE; |
680 | 6559 } |
6560 #endif | |
6561 | |
7 | 6562 # ifdef FEAT_VERTSPLIT |
6563 /* | |
6564 * Return TRUE if the status line of window "wp" is connected to the status | |
6565 * line of the window right of it. If not, then it's a vertical separator. | |
6566 * Only call if (wp->w_vsep_width != 0). | |
6567 */ | |
6568 int | |
6569 stl_connected(wp) | |
6570 win_T *wp; | |
6571 { | |
6572 frame_T *fr; | |
6573 | |
6574 fr = wp->w_frame; | |
6575 while (fr->fr_parent != NULL) | |
6576 { | |
6577 if (fr->fr_parent->fr_layout == FR_COL) | |
6578 { | |
6579 if (fr->fr_next != NULL) | |
6580 break; | |
6581 } | |
6582 else | |
6583 { | |
6584 if (fr->fr_next != NULL) | |
6585 return TRUE; | |
6586 } | |
6587 fr = fr->fr_parent; | |
6588 } | |
6589 return FALSE; | |
6590 } | |
6591 # endif | |
6592 | |
6593 #endif /* FEAT_WINDOWS */ | |
6594 | |
6595 #if defined(FEAT_WINDOWS) || defined(FEAT_STL_OPT) || defined(PROTO) | |
6596 /* | |
6597 * Get the value to show for the language mappings, active 'keymap'. | |
6598 */ | |
6599 int | |
6600 get_keymap_str(wp, buf, len) | |
6601 win_T *wp; | |
6602 char_u *buf; /* buffer for the result */ | |
6603 int len; /* length of buffer */ | |
6604 { | |
6605 char_u *p; | |
6606 | |
6607 if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP) | |
6608 return FALSE; | |
6609 | |
6610 { | |
6611 #ifdef FEAT_EVAL | |
6612 buf_T *old_curbuf = curbuf; | |
6613 win_T *old_curwin = curwin; | |
6614 char_u *s; | |
6615 | |
6616 curbuf = wp->w_buffer; | |
6617 curwin = wp; | |
6618 STRCPY(buf, "b:keymap_name"); /* must be writable */ | |
6619 ++emsg_skip; | |
714 | 6620 s = p = eval_to_string(buf, NULL, FALSE); |
7 | 6621 --emsg_skip; |
6622 curbuf = old_curbuf; | |
6623 curwin = old_curwin; | |
6624 if (p == NULL || *p == NUL) | |
6625 #endif | |
6626 { | |
6627 #ifdef FEAT_KEYMAP | |
6628 if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED) | |
6629 p = wp->w_buffer->b_p_keymap; | |
6630 else | |
6631 #endif | |
6632 p = (char_u *)"lang"; | |
6633 } | |
6634 if ((int)(STRLEN(p) + 3) < len) | |
6635 sprintf((char *)buf, "<%s>", p); | |
6636 else | |
6637 buf[0] = NUL; | |
6638 #ifdef FEAT_EVAL | |
6639 vim_free(s); | |
6640 #endif | |
6641 } | |
6642 return buf[0] != NUL; | |
6643 } | |
6644 #endif | |
6645 | |
6646 #if defined(FEAT_STL_OPT) || defined(PROTO) | |
6647 /* | |
677 | 6648 * Redraw the status line or ruler of window "wp". |
6649 * When "wp" is NULL redraw the tab pages line from 'tabline'. | |
7 | 6650 */ |
6651 static void | |
574 | 6652 win_redr_custom(wp, draw_ruler) |
7 | 6653 win_T *wp; |
574 | 6654 int draw_ruler; /* TRUE or FALSE */ |
7 | 6655 { |
5539 | 6656 static int entered = FALSE; |
7 | 6657 int attr; |
6658 int curattr; | |
6659 int row; | |
6660 int col = 0; | |
6661 int maxwidth; | |
6662 int width; | |
6663 int n; | |
6664 int len; | |
6665 int fillchar; | |
6666 char_u buf[MAXPATHL]; | |
1983 | 6667 char_u *stl; |
7 | 6668 char_u *p; |
681 | 6669 struct stl_hlrec hltab[STL_MAX_ITEM]; |
6670 struct stl_hlrec tabtab[STL_MAX_ITEM]; | |
677 | 6671 int use_sandbox = FALSE; |
2693 | 6672 win_T *ewp; |
6673 int p_crb_save; | |
7 | 6674 |
5539 | 6675 /* There is a tiny chance that this gets called recursively: When |
6676 * redrawing a status line triggers redrawing the ruler or tabline. | |
6677 * Avoid trouble by not allowing recursion. */ | |
6678 if (entered) | |
6679 return; | |
6680 entered = TRUE; | |
6681 | |
7 | 6682 /* setup environment for the task at hand */ |
677 | 6683 if (wp == NULL) |
6684 { | |
6685 /* Use 'tabline'. Always at the first line of the screen. */ | |
1983 | 6686 stl = p_tal; |
677 | 6687 row = 0; |
707 | 6688 fillchar = ' '; |
677 | 6689 attr = hl_attr(HLF_TPF); |
6690 maxwidth = Columns; | |
6691 # ifdef FEAT_EVAL | |
681 | 6692 use_sandbox = was_set_insecurely((char_u *)"tabline", 0); |
677 | 6693 # endif |
6694 } | |
40 | 6695 else |
677 | 6696 { |
6697 row = W_WINROW(wp) + wp->w_height; | |
6698 fillchar = fillchar_status(&attr, wp == curwin); | |
6699 maxwidth = W_WIDTH(wp); | |
6700 | |
6701 if (draw_ruler) | |
6702 { | |
1983 | 6703 stl = p_ruf; |
677 | 6704 /* advance past any leading group spec - implicit in ru_col */ |
1983 | 6705 if (*stl == '%') |
6706 { | |
6707 if (*++stl == '-') | |
6708 stl++; | |
6709 if (atoi((char *)stl)) | |
6710 while (VIM_ISDIGIT(*stl)) | |
6711 stl++; | |
6712 if (*stl++ != '(') | |
6713 stl = p_ruf; | |
677 | 6714 } |
7 | 6715 #ifdef FEAT_VERTSPLIT |
677 | 6716 col = ru_col - (Columns - W_WIDTH(wp)); |
6717 if (col < (W_WIDTH(wp) + 1) / 2) | |
6718 col = (W_WIDTH(wp) + 1) / 2; | |
7 | 6719 #else |
677 | 6720 col = ru_col; |
6721 if (col > (Columns + 1) / 2) | |
6722 col = (Columns + 1) / 2; | |
6723 #endif | |
6724 maxwidth = W_WIDTH(wp) - col; | |
7 | 6725 #ifdef FEAT_WINDOWS |
677 | 6726 if (!wp->w_status_height) |
6727 #endif | |
6728 { | |
6729 row = Rows - 1; | |
6730 --maxwidth; /* writing in last column may cause scrolling */ | |
6731 fillchar = ' '; | |
6732 attr = 0; | |
6733 } | |
6734 | |
6735 # ifdef FEAT_EVAL | |
681 | 6736 use_sandbox = was_set_insecurely((char_u *)"rulerformat", 0); |
677 | 6737 # endif |
6738 } | |
6739 else | |
6740 { | |
6741 if (*wp->w_p_stl != NUL) | |
1983 | 6742 stl = wp->w_p_stl; |
677 | 6743 else |
1983 | 6744 stl = p_stl; |
677 | 6745 # ifdef FEAT_EVAL |
681 | 6746 use_sandbox = was_set_insecurely((char_u *)"statusline", |
6747 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL); | |
677 | 6748 # endif |
6749 } | |
6750 | |
6751 #ifdef FEAT_VERTSPLIT | |
6752 col += W_WINCOL(wp); | |
6753 #endif | |
6754 } | |
6755 | |
7 | 6756 if (maxwidth <= 0) |
5539 | 6757 goto theend; |
677 | 6758 |
2693 | 6759 /* Temporarily reset 'cursorbind', we don't want a side effect from moving |
6760 * the cursor away and back. */ | |
6761 ewp = wp == NULL ? curwin : wp; | |
6762 p_crb_save = ewp->w_p_crb; | |
6763 ewp->w_p_crb = FALSE; | |
6764 | |
1983 | 6765 /* Make a copy, because the statusline may include a function call that |
6766 * might change the option value and free the memory. */ | |
6767 stl = vim_strsave(stl); | |
2693 | 6768 width = build_stl_str_hl(ewp, buf, sizeof(buf), |
1983 | 6769 stl, use_sandbox, |
681 | 6770 fillchar, maxwidth, hltab, tabtab); |
1983 | 6771 vim_free(stl); |
2693 | 6772 ewp->w_p_crb = p_crb_save; |
2661 | 6773 |
6774 /* Make all characters printable. */ | |
6775 p = transstr(buf); | |
6776 if (p != NULL) | |
6777 { | |
6778 vim_strncpy(buf, p, sizeof(buf) - 1); | |
6779 vim_free(p); | |
6780 } | |
6781 | |
6782 /* fill up with "fillchar" */ | |
835 | 6783 len = (int)STRLEN(buf); |
1883 | 6784 while (width < maxwidth && len < (int)sizeof(buf) - 1) |
7 | 6785 { |
6786 #ifdef FEAT_MBYTE | |
6787 len += (*mb_char2bytes)(fillchar, buf + len); | |
6788 #else | |
6789 buf[len++] = fillchar; | |
6790 #endif | |
6791 ++width; | |
6792 } | |
6793 buf[len] = NUL; | |
6794 | |
681 | 6795 /* |
6796 * Draw each snippet with the specified highlighting. | |
6797 */ | |
7 | 6798 curattr = attr; |
6799 p = buf; | |
681 | 6800 for (n = 0; hltab[n].start != NULL; n++) |
6801 { | |
6802 len = (int)(hltab[n].start - p); | |
7 | 6803 screen_puts_len(p, len, row, col, curattr); |
6804 col += vim_strnsize(p, len); | |
681 | 6805 p = hltab[n].start; |
6806 | |
6807 if (hltab[n].userhl == 0) | |
7 | 6808 curattr = attr; |
681 | 6809 else if (hltab[n].userhl < 0) |
6810 curattr = syn_id2attr(-hltab[n].userhl); | |
7 | 6811 #ifdef FEAT_WINDOWS |
680 | 6812 else if (wp != NULL && wp != curwin && wp->w_status_height != 0) |
681 | 6813 curattr = highlight_stlnc[hltab[n].userhl - 1]; |
7 | 6814 #endif |
6815 else | |
681 | 6816 curattr = highlight_user[hltab[n].userhl - 1]; |
7 | 6817 } |
6818 screen_puts(p, row, col, curattr); | |
681 | 6819 |
6820 if (wp == NULL) | |
6821 { | |
6822 /* Fill the TabPageIdxs[] array for clicking in the tab pagesline. */ | |
6823 col = 0; | |
6824 len = 0; | |
6825 p = buf; | |
6826 fillchar = 0; | |
6827 for (n = 0; tabtab[n].start != NULL; n++) | |
6828 { | |
6829 len += vim_strnsize(p, (int)(tabtab[n].start - p)); | |
6830 while (col < len) | |
6831 TabPageIdxs[col++] = fillchar; | |
6832 p = tabtab[n].start; | |
6833 fillchar = tabtab[n].userhl; | |
6834 } | |
6835 while (col < Columns) | |
6836 TabPageIdxs[col++] = fillchar; | |
6837 } | |
5539 | 6838 |
6839 theend: | |
6840 entered = FALSE; | |
7 | 6841 } |
6842 | |
6843 #endif /* FEAT_STL_OPT */ | |
6844 | |
6845 /* | |
6846 * Output a single character directly to the screen and update ScreenLines. | |
6847 */ | |
6848 void | |
6849 screen_putchar(c, row, col, attr) | |
6850 int c; | |
6851 int row, col; | |
6852 int attr; | |
6853 { | |
3549 | 6854 char_u buf[MB_MAXBYTES + 1]; |
6855 | |
7 | 6856 #ifdef FEAT_MBYTE |
3549 | 6857 if (has_mbyte) |
6858 buf[(*mb_char2bytes)(c, buf)] = NUL; | |
6859 else | |
6860 #endif | |
6861 { | |
6862 buf[0] = c; | |
6863 buf[1] = NUL; | |
6864 } | |
7 | 6865 screen_puts(buf, row, col, attr); |
6866 } | |
6867 | |
6868 /* | |
6869 * Get a single character directly from ScreenLines into "bytes[]". | |
6870 * Also return its attribute in *attrp; | |
6871 */ | |
6872 void | |
6873 screen_getbytes(row, col, bytes, attrp) | |
6874 int row, col; | |
6875 char_u *bytes; | |
6876 int *attrp; | |
6877 { | |
6878 unsigned off; | |
6879 | |
6880 /* safety check */ | |
6881 if (ScreenLines != NULL && row < screen_Rows && col < screen_Columns) | |
6882 { | |
6883 off = LineOffset[row] + col; | |
6884 *attrp = ScreenAttrs[off]; | |
6885 bytes[0] = ScreenLines[off]; | |
6886 bytes[1] = NUL; | |
6887 | |
6888 #ifdef FEAT_MBYTE | |
6889 if (enc_utf8 && ScreenLinesUC[off] != 0) | |
6890 bytes[utfc_char2bytes(off, bytes)] = NUL; | |
6891 else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) | |
6892 { | |
6893 bytes[0] = ScreenLines[off]; | |
6894 bytes[1] = ScreenLines2[off]; | |
6895 bytes[2] = NUL; | |
6896 } | |
6897 else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1) | |
6898 { | |
6899 bytes[1] = ScreenLines[off + 1]; | |
6900 bytes[2] = NUL; | |
6901 } | |
6902 #endif | |
6903 } | |
6904 } | |
6905 | |
714 | 6906 #ifdef FEAT_MBYTE |
6907 static int screen_comp_differs __ARGS((int, int*)); | |
6908 | |
6909 /* | |
6910 * Return TRUE if composing characters for screen posn "off" differs from | |
6911 * composing characters in "u8cc". | |
2124
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
6912 * Only to be used when ScreenLinesUC[off] != 0. |
714 | 6913 */ |
6914 static int | |
6915 screen_comp_differs(off, u8cc) | |
6916 int off; | |
6917 int *u8cc; | |
6918 { | |
6919 int i; | |
6920 | |
6921 for (i = 0; i < Screen_mco; ++i) | |
6922 { | |
6923 if (ScreenLinesC[i][off] != (u8char_T)u8cc[i]) | |
6924 return TRUE; | |
6925 if (u8cc[i] == 0) | |
6926 break; | |
6927 } | |
6928 return FALSE; | |
6929 } | |
6930 #endif | |
6931 | |
7 | 6932 /* |
6933 * Put string '*text' on the screen at position 'row' and 'col', with | |
6934 * attributes 'attr', and update ScreenLines[] and ScreenAttrs[]. | |
6935 * Note: only outputs within one row, message is truncated at screen boundary! | |
6936 * Note: if ScreenLines[], row and/or col is invalid, nothing is done. | |
6937 */ | |
6938 void | |
6939 screen_puts(text, row, col, attr) | |
6940 char_u *text; | |
6941 int row; | |
6942 int col; | |
6943 int attr; | |
6944 { | |
6945 screen_puts_len(text, -1, row, col, attr); | |
6946 } | |
6947 | |
6948 /* | |
6949 * Like screen_puts(), but output "text[len]". When "len" is -1 output up to | |
6950 * a NUL. | |
6951 */ | |
6952 void | |
6953 screen_puts_len(text, len, row, col, attr) | |
6954 char_u *text; | |
6955 int len; | |
6956 int row; | |
6957 int col; | |
6958 int attr; | |
6959 { | |
6960 unsigned off; | |
6961 char_u *ptr = text; | |
6962 int c; | |
6963 #ifdef FEAT_MBYTE | |
1378 | 6964 unsigned max_off; |
7 | 6965 int mbyte_blen = 1; |
6966 int mbyte_cells = 1; | |
6967 int u8c = 0; | |
714 | 6968 int u8cc[MAX_MCO]; |
7 | 6969 int clear_next_cell = FALSE; |
6970 # ifdef FEAT_ARABIC | |
6971 int prev_c = 0; /* previous Arabic character */ | |
714 | 6972 int pc, nc, nc1; |
6973 int pcc[MAX_MCO]; | |
7 | 6974 # endif |
6975 #endif | |
1843 | 6976 #if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX) |
6977 int force_redraw_this; | |
6978 int force_redraw_next = FALSE; | |
6979 #endif | |
6980 int need_redraw; | |
7 | 6981 |
6982 if (ScreenLines == NULL || row >= screen_Rows) /* safety check */ | |
6983 return; | |
1843 | 6984 off = LineOffset[row] + col; |
7 | 6985 |
1668 | 6986 #ifdef FEAT_MBYTE |
6987 /* When drawing over the right halve of a double-wide char clear out the | |
6988 * left halve. Only needed in a terminal. */ | |
1685 | 6989 if (has_mbyte && col > 0 && col < screen_Columns |
1668 | 6990 # ifdef FEAT_GUI |
6991 && !gui.in_use | |
6992 # endif | |
6993 && mb_fix_col(col, row) != col) | |
1843 | 6994 { |
6995 ScreenLines[off - 1] = ' '; | |
6996 ScreenAttrs[off - 1] = 0; | |
6997 if (enc_utf8) | |
6998 { | |
6999 ScreenLinesUC[off - 1] = 0; | |
7000 ScreenLinesC[0][off - 1] = 0; | |
7001 } | |
7002 /* redraw the previous cell, make it empty */ | |
7003 screen_char(off - 1, row, col - 1); | |
7004 /* force the cell at "col" to be redrawn */ | |
7005 force_redraw_next = TRUE; | |
7006 } | |
7007 #endif | |
7008 | |
1378 | 7009 #ifdef FEAT_MBYTE |
7010 max_off = LineOffset[row] + screen_Columns; | |
7011 #endif | |
1340 | 7012 while (col < screen_Columns |
7013 && (len < 0 || (int)(ptr - text) < len) | |
7014 && *ptr != NUL) | |
7 | 7015 { |
7016 c = *ptr; | |
7017 #ifdef FEAT_MBYTE | |
7018 /* check if this is the first byte of a multibyte */ | |
7019 if (has_mbyte) | |
7020 { | |
7021 if (enc_utf8 && len > 0) | |
474 | 7022 mbyte_blen = utfc_ptr2len_len(ptr, (int)((text + len) - ptr)); |
7 | 7023 else |
474 | 7024 mbyte_blen = (*mb_ptr2len)(ptr); |
7 | 7025 if (enc_dbcs == DBCS_JPNU && c == 0x8e) |
7026 mbyte_cells = 1; | |
7027 else if (enc_dbcs != 0) | |
7028 mbyte_cells = mbyte_blen; | |
7029 else /* enc_utf8 */ | |
7030 { | |
7031 if (len >= 0) | |
714 | 7032 u8c = utfc_ptr2char_len(ptr, u8cc, |
7 | 7033 (int)((text + len) - ptr)); |
7034 else | |
714 | 7035 u8c = utfc_ptr2char(ptr, u8cc); |
7 | 7036 mbyte_cells = utf_char2cells(u8c); |
1401 | 7037 # ifdef UNICODE16 |
7 | 7038 /* Non-BMP character: display as ? or fullwidth ?. */ |
7039 if (u8c >= 0x10000) | |
7040 { | |
7041 u8c = (mbyte_cells == 2) ? 0xff1f : (int)'?'; | |
7042 if (attr == 0) | |
7043 attr = hl_attr(HLF_8); | |
7044 } | |
1401 | 7045 # endif |
7 | 7046 # ifdef FEAT_ARABIC |
7047 if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c)) | |
7048 { | |
7049 /* Do Arabic shaping. */ | |
7050 if (len >= 0 && (int)(ptr - text) + mbyte_blen >= len) | |
7051 { | |
7052 /* Past end of string to be displayed. */ | |
7053 nc = NUL; | |
7054 nc1 = NUL; | |
7055 } | |
7056 else | |
714 | 7057 { |
1994 | 7058 nc = utfc_ptr2char_len(ptr + mbyte_blen, pcc, |
7059 (int)((text + len) - ptr - mbyte_blen)); | |
714 | 7060 nc1 = pcc[0]; |
7061 } | |
7 | 7062 pc = prev_c; |
7063 prev_c = u8c; | |
714 | 7064 u8c = arabic_shape(u8c, &c, &u8cc[0], nc, nc1, pc); |
7 | 7065 } |
7066 else | |
7067 prev_c = u8c; | |
7068 # endif | |
2055
4aa4510d548c
updated for version 7.2.341
Bram Moolenaar <bram@zimbu.org>
parents:
2008
diff
changeset
|
7069 if (col + mbyte_cells > screen_Columns) |
4aa4510d548c
updated for version 7.2.341
Bram Moolenaar <bram@zimbu.org>
parents:
2008
diff
changeset
|
7070 { |
4aa4510d548c
updated for version 7.2.341
Bram Moolenaar <bram@zimbu.org>
parents:
2008
diff
changeset
|
7071 /* Only 1 cell left, but character requires 2 cells: |
4aa4510d548c
updated for version 7.2.341
Bram Moolenaar <bram@zimbu.org>
parents:
2008
diff
changeset
|
7072 * display a '>' in the last column to avoid wrapping. */ |
4aa4510d548c
updated for version 7.2.341
Bram Moolenaar <bram@zimbu.org>
parents:
2008
diff
changeset
|
7073 c = '>'; |
4aa4510d548c
updated for version 7.2.341
Bram Moolenaar <bram@zimbu.org>
parents:
2008
diff
changeset
|
7074 mbyte_cells = 1; |
4aa4510d548c
updated for version 7.2.341
Bram Moolenaar <bram@zimbu.org>
parents:
2008
diff
changeset
|
7075 } |
7 | 7076 } |
7077 } | |
7078 #endif | |
7079 | |
1843 | 7080 #if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX) |
7081 force_redraw_this = force_redraw_next; | |
7082 force_redraw_next = FALSE; | |
7083 #endif | |
7084 | |
7085 need_redraw = ScreenLines[off] != c | |
7 | 7086 #ifdef FEAT_MBYTE |
7087 || (mbyte_cells == 2 | |
7088 && ScreenLines[off + 1] != (enc_dbcs ? ptr[1] : 0)) | |
7089 || (enc_dbcs == DBCS_JPNU | |
7090 && c == 0x8e | |
7091 && ScreenLines2[off] != ptr[1]) | |
7092 || (enc_utf8 | |
2124
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
7093 && (ScreenLinesUC[off] != |
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
7094 (u8char_T)(c < 0x80 && u8cc[0] == 0 ? 0 : u8c) |
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
7095 || (ScreenLinesUC[off] != 0 |
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
7096 && screen_comp_differs(off, u8cc)))) |
7 | 7097 #endif |
7098 || ScreenAttrs[off] != attr | |
1843 | 7099 || exmode_active; |
7100 | |
7101 if (need_redraw | |
7102 #if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX) | |
7103 || force_redraw_this | |
7104 #endif | |
7 | 7105 ) |
7106 { | |
7107 #if defined(FEAT_GUI) || defined(UNIX) | |
7108 /* The bold trick makes a single row of pixels appear in the next | |
7109 * character. When a bold character is removed, the next | |
7110 * character should be redrawn too. This happens for our own GUI | |
1843 | 7111 * and for some xterms. */ |
7112 if (need_redraw && ScreenLines[off] != ' ' && ( | |
7 | 7113 # ifdef FEAT_GUI |
7114 gui.in_use | |
7115 # endif | |
7116 # if defined(FEAT_GUI) && defined(UNIX) | |
7117 || | |
7118 # endif | |
7119 # ifdef UNIX | |
7120 term_is_xterm | |
7121 # endif | |
1843 | 7122 )) |
7123 { | |
7124 int n = ScreenAttrs[off]; | |
7125 | |
7126 if (n > HL_ALL) | |
7127 n = syn_attr2attr(n); | |
7128 if (n & HL_BOLD) | |
7129 force_redraw_next = TRUE; | |
7 | 7130 } |
7131 #endif | |
7132 #ifdef FEAT_MBYTE | |
7133 /* When at the end of the text and overwriting a two-cell | |
7134 * character with a one-cell character, need to clear the next | |
7135 * cell. Also when overwriting the left halve of a two-cell char | |
7136 * with the right halve of a two-cell char. Do this only once | |
7137 * (mb_off2cells() may return 2 on the right halve). */ | |
7138 if (clear_next_cell) | |
7139 clear_next_cell = FALSE; | |
7140 else if (has_mbyte | |
7141 && (len < 0 ? ptr[mbyte_blen] == NUL | |
7142 : ptr + mbyte_blen >= text + len) | |
1378 | 7143 && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1) |
7 | 7144 || (mbyte_cells == 2 |
1378 | 7145 && (*mb_off2cells)(off, max_off) == 1 |
7146 && (*mb_off2cells)(off + 1, max_off) > 1))) | |
7 | 7147 clear_next_cell = TRUE; |
7148 | |
7149 /* Make sure we never leave a second byte of a double-byte behind, | |
7150 * it confuses mb_off2cells(). */ | |
7151 if (enc_dbcs | |
1378 | 7152 && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1) |
7 | 7153 || (mbyte_cells == 2 |
1378 | 7154 && (*mb_off2cells)(off, max_off) == 1 |
7155 && (*mb_off2cells)(off + 1, max_off) > 1))) | |
7 | 7156 ScreenLines[off + mbyte_blen] = 0; |
7157 #endif | |
7158 ScreenLines[off] = c; | |
7159 ScreenAttrs[off] = attr; | |
7160 #ifdef FEAT_MBYTE | |
7161 if (enc_utf8) | |
7162 { | |
714 | 7163 if (c < 0x80 && u8cc[0] == 0) |
7 | 7164 ScreenLinesUC[off] = 0; |
7165 else | |
7166 { | |
714 | 7167 int i; |
7168 | |
7 | 7169 ScreenLinesUC[off] = u8c; |
714 | 7170 for (i = 0; i < Screen_mco; ++i) |
7171 { | |
7172 ScreenLinesC[i][off] = u8cc[i]; | |
7173 if (u8cc[i] == 0) | |
7174 break; | |
7175 } | |
7 | 7176 } |
7177 if (mbyte_cells == 2) | |
7178 { | |
7179 ScreenLines[off + 1] = 0; | |
7180 ScreenAttrs[off + 1] = attr; | |
7181 } | |
7182 screen_char(off, row, col); | |
7183 } | |
7184 else if (mbyte_cells == 2) | |
7185 { | |
7186 ScreenLines[off + 1] = ptr[1]; | |
7187 ScreenAttrs[off + 1] = attr; | |
7188 screen_char_2(off, row, col); | |
7189 } | |
7190 else if (enc_dbcs == DBCS_JPNU && c == 0x8e) | |
7191 { | |
7192 ScreenLines2[off] = ptr[1]; | |
7193 screen_char(off, row, col); | |
7194 } | |
7195 else | |
7196 #endif | |
7197 screen_char(off, row, col); | |
7198 } | |
7199 #ifdef FEAT_MBYTE | |
7200 if (has_mbyte) | |
7201 { | |
7202 off += mbyte_cells; | |
7203 col += mbyte_cells; | |
7204 ptr += mbyte_blen; | |
7205 if (clear_next_cell) | |
7206 ptr = (char_u *)" "; | |
7207 } | |
7208 else | |
7209 #endif | |
7210 { | |
7211 ++off; | |
7212 ++col; | |
7213 ++ptr; | |
7214 } | |
7215 } | |
1843 | 7216 |
7217 #if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX) | |
7218 /* If we detected the next character needs to be redrawn, but the text | |
7219 * doesn't extend up to there, update the character here. */ | |
7220 if (force_redraw_next && col < screen_Columns) | |
7221 { | |
7222 # ifdef FEAT_MBYTE | |
7223 if (enc_dbcs != 0 && dbcs_off2cells(off, max_off) > 1) | |
7224 screen_char_2(off, row, col); | |
7225 else | |
7226 # endif | |
7227 screen_char(off, row, col); | |
7228 } | |
7229 #endif | |
7 | 7230 } |
7231 | |
7232 #ifdef FEAT_SEARCH_EXTRA | |
7233 /* | |
1326 | 7234 * Prepare for 'hlsearch' highlighting. |
7 | 7235 */ |
7236 static void | |
7237 start_search_hl() | |
7238 { | |
7239 if (p_hls && !no_hlsearch) | |
7240 { | |
7241 last_pat_prog(&search_hl.rm); | |
7242 search_hl.attr = hl_attr(HLF_L); | |
1521 | 7243 # ifdef FEAT_RELTIME |
7244 /* Set the time limit to 'redrawtime'. */ | |
7245 profile_setlimit(p_rdt, &search_hl.tm); | |
7246 # endif | |
7 | 7247 } |
7248 } | |
7249 | |
7250 /* | |
1326 | 7251 * Clean up for 'hlsearch' highlighting. |
7 | 7252 */ |
7253 static void | |
7254 end_search_hl() | |
7255 { | |
7256 if (search_hl.rm.regprog != NULL) | |
7257 { | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4795
diff
changeset
|
7258 vim_regfree(search_hl.rm.regprog); |
7 | 7259 search_hl.rm.regprog = NULL; |
7260 } | |
7261 } | |
7262 | |
7263 /* | |
2284
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7264 * Init for calling prepare_search_hl(). |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7265 */ |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7266 static void |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7267 init_search_hl(wp) |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7268 win_T *wp; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7269 { |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7270 matchitem_T *cur; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7271 |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7272 /* Setup for match and 'hlsearch' highlighting. Disable any previous |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7273 * match */ |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7274 cur = wp->w_match_head; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7275 while (cur != NULL) |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7276 { |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7277 cur->hl.rm = cur->match; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7278 if (cur->hlg_id == 0) |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7279 cur->hl.attr = 0; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7280 else |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7281 cur->hl.attr = syn_id2attr(cur->hlg_id); |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7282 cur->hl.buf = wp->w_buffer; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7283 cur->hl.lnum = 0; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7284 cur->hl.first_lnum = 0; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7285 # ifdef FEAT_RELTIME |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7286 /* Set the time limit to 'redrawtime'. */ |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7287 profile_setlimit(p_rdt, &(cur->hl.tm)); |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7288 # endif |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7289 cur = cur->next; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7290 } |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7291 search_hl.buf = wp->w_buffer; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7292 search_hl.lnum = 0; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7293 search_hl.first_lnum = 0; |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7294 /* time limit is set at the toplevel, for all windows */ |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7295 } |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7296 |
cca510a8b85b
Better init for match highlighting when using conceal feature.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
7297 /* |
7 | 7298 * Advance to the match in window "wp" line "lnum" or past it. |
7299 */ | |
7300 static void | |
7301 prepare_search_hl(wp, lnum) | |
7302 win_T *wp; | |
7303 linenr_T lnum; | |
7304 { | |
1326 | 7305 matchitem_T *cur; /* points to the match list */ |
7306 match_T *shl; /* points to search_hl or a match */ | |
7307 int shl_flag; /* flag to indicate whether search_hl | |
7308 has been processed or not */ | |
7 | 7309 int n; |
7310 | |
7311 /* | |
7312 * When using a multi-line pattern, start searching at the top | |
7313 * of the window or just after a closed fold. | |
1326 | 7314 * Do this both for search_hl and the match list. |
7 | 7315 */ |
1326 | 7316 cur = wp->w_match_head; |
7317 shl_flag = FALSE; | |
7318 while (cur != NULL || shl_flag == FALSE) | |
7319 { | |
7320 if (shl_flag == FALSE) | |
7321 { | |
7322 shl = &search_hl; | |
7323 shl_flag = TRUE; | |
7324 } | |
7325 else | |
7326 shl = &cur->hl; | |
7 | 7327 if (shl->rm.regprog != NULL |
7328 && shl->lnum == 0 | |
7329 && re_multiline(shl->rm.regprog)) | |
7330 { | |
7331 if (shl->first_lnum == 0) | |
7332 { | |
7333 # ifdef FEAT_FOLDING | |
7334 for (shl->first_lnum = lnum; | |
7335 shl->first_lnum > wp->w_topline; --shl->first_lnum) | |
7336 if (hasFoldingWin(wp, shl->first_lnum - 1, | |
7337 NULL, NULL, TRUE, NULL)) | |
7338 break; | |
7339 # else | |
7340 shl->first_lnum = wp->w_topline; | |
7341 # endif | |
7342 } | |
7343 n = 0; | |
7344 while (shl->first_lnum < lnum && shl->rm.regprog != NULL) | |
7345 { | |
7346 next_search_hl(wp, shl, shl->first_lnum, (colnr_T)n); | |
7347 if (shl->lnum != 0) | |
7348 { | |
7349 shl->first_lnum = shl->lnum | |
7350 + shl->rm.endpos[0].lnum | |
7351 - shl->rm.startpos[0].lnum; | |
7352 n = shl->rm.endpos[0].col; | |
7353 } | |
7354 else | |
7355 { | |
7356 ++shl->first_lnum; | |
7357 n = 0; | |
7358 } | |
7359 } | |
7360 } | |
1326 | 7361 if (shl != &search_hl && cur != NULL) |
7362 cur = cur->next; | |
7 | 7363 } |
7364 } | |
7365 | |
7366 /* | |
1326 | 7367 * Search for a next 'hlsearch' or match. |
7 | 7368 * Uses shl->buf. |
7369 * Sets shl->lnum and shl->rm contents. | |
7370 * Note: Assumes a previous match is always before "lnum", unless | |
7371 * shl->lnum is zero. | |
7372 * Careful: Any pointers for buffer lines will become invalid. | |
7373 */ | |
7374 static void | |
7375 next_search_hl(win, shl, lnum, mincol) | |
7376 win_T *win; | |
1326 | 7377 match_T *shl; /* points to search_hl or a match */ |
7 | 7378 linenr_T lnum; |
7379 colnr_T mincol; /* minimal column for a match */ | |
7380 { | |
7381 linenr_T l; | |
7382 colnr_T matchcol; | |
7383 long nmatched; | |
7384 | |
7385 if (shl->lnum != 0) | |
7386 { | |
7387 /* Check for three situations: | |
7388 * 1. If the "lnum" is below a previous match, start a new search. | |
7389 * 2. If the previous match includes "mincol", use it. | |
7390 * 3. Continue after the previous match. | |
7391 */ | |
7392 l = shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum; | |
7393 if (lnum > l) | |
7394 shl->lnum = 0; | |
7395 else if (lnum < l || shl->rm.endpos[0].col > mincol) | |
7396 return; | |
7397 } | |
7398 | |
7399 /* | |
7400 * Repeat searching for a match until one is found that includes "mincol" | |
7401 * or none is found in this line. | |
7402 */ | |
7403 called_emsg = FALSE; | |
7404 for (;;) | |
7405 { | |
1521 | 7406 #ifdef FEAT_RELTIME |
7407 /* Stop searching after passing the time limit. */ | |
7408 if (profile_passed_limit(&(shl->tm))) | |
7409 { | |
7410 shl->lnum = 0; /* no match found in time */ | |
7411 break; | |
7412 } | |
7413 #endif | |
7 | 7414 /* Three situations: |
7415 * 1. No useful previous match: search from start of line. | |
7416 * 2. Not Vi compatible or empty match: continue at next character. | |
7417 * Break the loop if this is beyond the end of the line. | |
7418 * 3. Vi compatible searching: continue at end of previous match. | |
7419 */ | |
7420 if (shl->lnum == 0) | |
7421 matchcol = 0; | |
7422 else if (vim_strchr(p_cpo, CPO_SEARCH) == NULL | |
7423 || (shl->rm.endpos[0].lnum == 0 | |
685 | 7424 && shl->rm.endpos[0].col <= shl->rm.startpos[0].col)) |
7425 { | |
688 | 7426 char_u *ml; |
685 | 7427 |
7428 matchcol = shl->rm.startpos[0].col; | |
688 | 7429 ml = ml_get_buf(shl->buf, lnum, FALSE) + matchcol; |
685 | 7430 if (*ml == NUL) |
7431 { | |
7432 ++matchcol; | |
7 | 7433 shl->lnum = 0; |
7434 break; | |
7435 } | |
685 | 7436 #ifdef FEAT_MBYTE |
7437 if (has_mbyte) | |
7438 matchcol += mb_ptr2len(ml); | |
7439 else | |
7440 #endif | |
7441 ++matchcol; | |
7 | 7442 } |
7443 else | |
7444 matchcol = shl->rm.endpos[0].col; | |
7445 | |
7446 shl->lnum = lnum; | |
1521 | 7447 nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum, matchcol, |
7448 #ifdef FEAT_RELTIME | |
7449 &(shl->tm) | |
7450 #else | |
7451 NULL | |
7452 #endif | |
7453 ); | |
2359
496feb41b83f
Fix: When 'searchhl' causes a hang make CTRL-C disable 'shearchhl'.
Bram Moolenaar <bram@vim.org>
parents:
2356
diff
changeset
|
7454 if (called_emsg || got_int) |
7 | 7455 { |
7456 /* Error while handling regexp: stop using this regexp. */ | |
1112 | 7457 if (shl == &search_hl) |
7458 { | |
1326 | 7459 /* don't free regprog in the match list, it's a copy */ |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4795
diff
changeset
|
7460 vim_regfree(shl->rm.regprog); |
5458 | 7461 SET_NO_HLSEARCH(TRUE); |
1112 | 7462 } |
7 | 7463 shl->rm.regprog = NULL; |
1112 | 7464 shl->lnum = 0; |
7465 got_int = FALSE; /* avoid the "Type :quit to exit Vim" message */ | |
7 | 7466 break; |
7467 } | |
7468 if (nmatched == 0) | |
7469 { | |
7470 shl->lnum = 0; /* no match found */ | |
7471 break; | |
7472 } | |
7473 if (shl->rm.startpos[0].lnum > 0 | |
7474 || shl->rm.startpos[0].col >= mincol | |
7475 || nmatched > 1 | |
7476 || shl->rm.endpos[0].col > mincol) | |
7477 { | |
7478 shl->lnum += shl->rm.startpos[0].lnum; | |
7479 break; /* useful match found */ | |
7480 } | |
7481 } | |
7482 } | |
7483 #endif | |
7484 | |
7485 static void | |
7486 screen_start_highlight(attr) | |
7487 int attr; | |
7488 { | |
7489 attrentry_T *aep = NULL; | |
7490 | |
7491 screen_attr = attr; | |
7492 if (full_screen | |
7493 #ifdef WIN3264 | |
7494 && termcap_active | |
7495 #endif | |
7496 ) | |
7497 { | |
7498 #ifdef FEAT_GUI | |
7499 if (gui.in_use) | |
7500 { | |
7501 char buf[20]; | |
7502 | |
681 | 7503 /* The GUI handles this internally. */ |
7504 sprintf(buf, IF_EB("\033|%dh", ESC_STR "|%dh"), attr); | |
7 | 7505 OUT_STR(buf); |
7506 } | |
7507 else | |
7508 #endif | |
7509 { | |
7510 if (attr > HL_ALL) /* special HL attr. */ | |
7511 { | |
7512 if (t_colors > 1) | |
7513 aep = syn_cterm_attr2entry(attr); | |
7514 else | |
7515 aep = syn_term_attr2entry(attr); | |
7516 if (aep == NULL) /* did ":syntax clear" */ | |
7517 attr = 0; | |
7518 else | |
7519 attr = aep->ae_attr; | |
7520 } | |
7521 if ((attr & HL_BOLD) && T_MD != NULL) /* bold */ | |
7522 out_str(T_MD); | |
681 | 7523 else if (aep != NULL && t_colors > 1 && aep->ae_u.cterm.fg_color |
7524 && cterm_normal_fg_bold) | |
7525 /* If the Normal FG color has BOLD attribute and the new HL | |
7526 * has a FG color defined, clear BOLD. */ | |
7527 out_str(T_ME); | |
7 | 7528 if ((attr & HL_STANDOUT) && T_SO != NULL) /* standout */ |
7529 out_str(T_SO); | |
205 | 7530 if ((attr & (HL_UNDERLINE | HL_UNDERCURL)) && T_US != NULL) |
7531 /* underline or undercurl */ | |
7 | 7532 out_str(T_US); |
7533 if ((attr & HL_ITALIC) && T_CZH != NULL) /* italic */ | |
7534 out_str(T_CZH); | |
7535 if ((attr & HL_INVERSE) && T_MR != NULL) /* inverse (reverse) */ | |
7536 out_str(T_MR); | |
7537 | |
7538 /* | |
7539 * Output the color or start string after bold etc., in case the | |
7540 * bold etc. override the color setting. | |
7541 */ | |
7542 if (aep != NULL) | |
7543 { | |
7544 if (t_colors > 1) | |
7545 { | |
7546 if (aep->ae_u.cterm.fg_color) | |
7547 term_fg_color(aep->ae_u.cterm.fg_color - 1); | |
7548 if (aep->ae_u.cterm.bg_color) | |
7549 term_bg_color(aep->ae_u.cterm.bg_color - 1); | |
7550 } | |
7551 else | |
7552 { | |
7553 if (aep->ae_u.term.start != NULL) | |
7554 out_str(aep->ae_u.term.start); | |
7555 } | |
7556 } | |
7557 } | |
7558 } | |
7559 } | |
7560 | |
7561 void | |
7562 screen_stop_highlight() | |
7563 { | |
7564 int do_ME = FALSE; /* output T_ME code */ | |
7565 | |
7566 if (screen_attr != 0 | |
7567 #ifdef WIN3264 | |
7568 && termcap_active | |
7569 #endif | |
7570 ) | |
7571 { | |
7572 #ifdef FEAT_GUI | |
7573 if (gui.in_use) | |
7574 { | |
7575 char buf[20]; | |
7576 | |
7577 /* use internal GUI code */ | |
7578 sprintf(buf, IF_EB("\033|%dH", ESC_STR "|%dH"), screen_attr); | |
7579 OUT_STR(buf); | |
7580 } | |
7581 else | |
7582 #endif | |
7583 { | |
7584 if (screen_attr > HL_ALL) /* special HL attr. */ | |
7585 { | |
7586 attrentry_T *aep; | |
7587 | |
7588 if (t_colors > 1) | |
7589 { | |
7590 /* | |
7591 * Assume that t_me restores the original colors! | |
7592 */ | |
7593 aep = syn_cterm_attr2entry(screen_attr); | |
7594 if (aep != NULL && (aep->ae_u.cterm.fg_color | |
7595 || aep->ae_u.cterm.bg_color)) | |
7596 do_ME = TRUE; | |
7597 } | |
7598 else | |
7599 { | |
7600 aep = syn_term_attr2entry(screen_attr); | |
7601 if (aep != NULL && aep->ae_u.term.stop != NULL) | |
7602 { | |
7603 if (STRCMP(aep->ae_u.term.stop, T_ME) == 0) | |
7604 do_ME = TRUE; | |
7605 else | |
7606 out_str(aep->ae_u.term.stop); | |
7607 } | |
7608 } | |
7609 if (aep == NULL) /* did ":syntax clear" */ | |
7610 screen_attr = 0; | |
7611 else | |
7612 screen_attr = aep->ae_attr; | |
7613 } | |
7614 | |
7615 /* | |
7616 * Often all ending-codes are equal to T_ME. Avoid outputting the | |
7617 * same sequence several times. | |
7618 */ | |
7619 if (screen_attr & HL_STANDOUT) | |
7620 { | |
7621 if (STRCMP(T_SE, T_ME) == 0) | |
7622 do_ME = TRUE; | |
7623 else | |
7624 out_str(T_SE); | |
7625 } | |
205 | 7626 if (screen_attr & (HL_UNDERLINE | HL_UNDERCURL)) |
7 | 7627 { |
7628 if (STRCMP(T_UE, T_ME) == 0) | |
7629 do_ME = TRUE; | |
7630 else | |
7631 out_str(T_UE); | |
7632 } | |
7633 if (screen_attr & HL_ITALIC) | |
7634 { | |
7635 if (STRCMP(T_CZR, T_ME) == 0) | |
7636 do_ME = TRUE; | |
7637 else | |
7638 out_str(T_CZR); | |
7639 } | |
7640 if (do_ME || (screen_attr & (HL_BOLD | HL_INVERSE))) | |
7641 out_str(T_ME); | |
7642 | |
7643 if (t_colors > 1) | |
7644 { | |
7645 /* set Normal cterm colors */ | |
7646 if (cterm_normal_fg_color != 0) | |
7647 term_fg_color(cterm_normal_fg_color - 1); | |
7648 if (cterm_normal_bg_color != 0) | |
7649 term_bg_color(cterm_normal_bg_color - 1); | |
7650 if (cterm_normal_fg_bold) | |
7651 out_str(T_MD); | |
7652 } | |
7653 } | |
7654 } | |
7655 screen_attr = 0; | |
7656 } | |
7657 | |
7658 /* | |
7659 * Reset the colors for a cterm. Used when leaving Vim. | |
7660 * The machine specific code may override this again. | |
7661 */ | |
7662 void | |
7663 reset_cterm_colors() | |
7664 { | |
7665 if (t_colors > 1) | |
7666 { | |
7667 /* set Normal cterm colors */ | |
7668 if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0) | |
7669 { | |
7670 out_str(T_OP); | |
7671 screen_attr = -1; | |
7672 } | |
7673 if (cterm_normal_fg_bold) | |
7674 { | |
7675 out_str(T_ME); | |
7676 screen_attr = -1; | |
7677 } | |
7678 } | |
7679 } | |
7680 | |
7681 /* | |
7682 * Put character ScreenLines["off"] on the screen at position "row" and "col", | |
7683 * using the attributes from ScreenAttrs["off"]. | |
7684 */ | |
7685 static void | |
7686 screen_char(off, row, col) | |
7687 unsigned off; | |
7688 int row; | |
7689 int col; | |
7690 { | |
7691 int attr; | |
7692 | |
7693 /* Check for illegal values, just in case (could happen just after | |
7694 * resizing). */ | |
7695 if (row >= screen_Rows || col >= screen_Columns) | |
7696 return; | |
7697 | |
7698 /* Outputting the last character on the screen may scrollup the screen. | |
7699 * Don't to it! Mark the character invalid (update it when scrolled up) */ | |
7700 if (row == screen_Rows - 1 && col == screen_Columns - 1 | |
7701 #ifdef FEAT_RIGHTLEFT | |
7702 /* account for first command-line character in rightleft mode */ | |
7703 && !cmdmsg_rl | |
7704 #endif | |
7705 ) | |
7706 { | |
7707 ScreenAttrs[off] = (sattr_T)-1; | |
7708 return; | |
7709 } | |
7710 | |
7711 /* | |
7712 * Stop highlighting first, so it's easier to move the cursor. | |
7713 */ | |
7714 #if defined(FEAT_CLIPBOARD) || defined(FEAT_VERTSPLIT) | |
7715 if (screen_char_attr != 0) | |
7716 attr = screen_char_attr; | |
7717 else | |
7718 #endif | |
7719 attr = ScreenAttrs[off]; | |
7720 if (screen_attr != attr) | |
7721 screen_stop_highlight(); | |
7722 | |
7723 windgoto(row, col); | |
7724 | |
7725 if (screen_attr != attr) | |
7726 screen_start_highlight(attr); | |
7727 | |
7728 #ifdef FEAT_MBYTE | |
7729 if (enc_utf8 && ScreenLinesUC[off] != 0) | |
7730 { | |
7731 char_u buf[MB_MAXBYTES + 1]; | |
7732 | |
7733 /* Convert UTF-8 character to bytes and write it. */ | |
7734 | |
7735 buf[utfc_char2bytes(off, buf)] = NUL; | |
7736 | |
7737 out_str(buf); | |
7738 if (utf_char2cells(ScreenLinesUC[off]) > 1) | |
7739 ++screen_cur_col; | |
7740 } | |
7741 else | |
7742 #endif | |
7743 { | |
7744 #ifdef FEAT_MBYTE | |
7745 out_flush_check(); | |
7746 #endif | |
7747 out_char(ScreenLines[off]); | |
7748 #ifdef FEAT_MBYTE | |
7749 /* double-byte character in single-width cell */ | |
7750 if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) | |
7751 out_char(ScreenLines2[off]); | |
7752 #endif | |
7753 } | |
7754 | |
7755 screen_cur_col++; | |
7756 } | |
7757 | |
7758 #ifdef FEAT_MBYTE | |
7759 | |
7760 /* | |
7761 * Used for enc_dbcs only: Put one double-wide character at ScreenLines["off"] | |
7762 * on the screen at position 'row' and 'col'. | |
7763 * The attributes of the first byte is used for all. This is required to | |
7764 * output the two bytes of a double-byte character with nothing in between. | |
7765 */ | |
7766 static void | |
7767 screen_char_2(off, row, col) | |
7768 unsigned off; | |
7769 int row; | |
7770 int col; | |
7771 { | |
7772 /* Check for illegal values (could be wrong when screen was resized). */ | |
7773 if (off + 1 >= (unsigned)(screen_Rows * screen_Columns)) | |
7774 return; | |
7775 | |
7776 /* Outputting the last character on the screen may scrollup the screen. | |
7777 * Don't to it! Mark the character invalid (update it when scrolled up) */ | |
7778 if (row == screen_Rows - 1 && col >= screen_Columns - 2) | |
7779 { | |
7780 ScreenAttrs[off] = (sattr_T)-1; | |
7781 return; | |
7782 } | |
7783 | |
7784 /* Output the first byte normally (positions the cursor), then write the | |
7785 * second byte directly. */ | |
7786 screen_char(off, row, col); | |
7787 out_char(ScreenLines[off + 1]); | |
7788 ++screen_cur_col; | |
7789 } | |
7790 #endif | |
7791 | |
7792 #if defined(FEAT_CLIPBOARD) || defined(FEAT_VERTSPLIT) || defined(PROTO) | |
7793 /* | |
7794 * Draw a rectangle of the screen, inverted when "invert" is TRUE. | |
7795 * This uses the contents of ScreenLines[] and doesn't change it. | |
7796 */ | |
7797 void | |
7798 screen_draw_rectangle(row, col, height, width, invert) | |
7799 int row; | |
7800 int col; | |
7801 int height; | |
7802 int width; | |
7803 int invert; | |
7804 { | |
7805 int r, c; | |
7806 int off; | |
1378 | 7807 #ifdef FEAT_MBYTE |
7808 int max_off; | |
7809 #endif | |
7 | 7810 |
534 | 7811 /* Can't use ScreenLines unless initialized */ |
7812 if (ScreenLines == NULL) | |
7813 return; | |
7814 | |
7 | 7815 if (invert) |
7816 screen_char_attr = HL_INVERSE; | |
7817 for (r = row; r < row + height; ++r) | |
7818 { | |
7819 off = LineOffset[r]; | |
1378 | 7820 #ifdef FEAT_MBYTE |
7821 max_off = off + screen_Columns; | |
7822 #endif | |
7 | 7823 for (c = col; c < col + width; ++c) |
7824 { | |
7825 #ifdef FEAT_MBYTE | |
1378 | 7826 if (enc_dbcs != 0 && dbcs_off2cells(off + c, max_off) > 1) |
7 | 7827 { |
7828 screen_char_2(off + c, r, c); | |
7829 ++c; | |
7830 } | |
7831 else | |
7832 #endif | |
7833 { | |
7834 screen_char(off + c, r, c); | |
7835 #ifdef FEAT_MBYTE | |
1378 | 7836 if (utf_off2cells(off + c, max_off) > 1) |
7 | 7837 ++c; |
7838 #endif | |
7839 } | |
7840 } | |
7841 } | |
7842 screen_char_attr = 0; | |
7843 } | |
7844 #endif | |
7845 | |
7846 #ifdef FEAT_VERTSPLIT | |
7847 /* | |
7848 * Redraw the characters for a vertically split window. | |
7849 */ | |
7850 static void | |
7851 redraw_block(row, end, wp) | |
7852 int row; | |
7853 int end; | |
7854 win_T *wp; | |
7855 { | |
7856 int col; | |
7857 int width; | |
7858 | |
7859 # ifdef FEAT_CLIPBOARD | |
7860 clip_may_clear_selection(row, end - 1); | |
7861 # endif | |
7862 | |
7863 if (wp == NULL) | |
7864 { | |
7865 col = 0; | |
7866 width = Columns; | |
7867 } | |
7868 else | |
7869 { | |
7870 col = wp->w_wincol; | |
7871 width = wp->w_width; | |
7872 } | |
7873 screen_draw_rectangle(row, col, end - row, width, FALSE); | |
7874 } | |
7875 #endif | |
7876 | |
7877 /* | |
7878 * Fill the screen from 'start_row' to 'end_row', from 'start_col' to 'end_col' | |
7879 * with character 'c1' in first column followed by 'c2' in the other columns. | |
7880 * Use attributes 'attr'. | |
7881 */ | |
7882 void | |
7883 screen_fill(start_row, end_row, start_col, end_col, c1, c2, attr) | |
7884 int start_row, end_row; | |
7885 int start_col, end_col; | |
7886 int c1, c2; | |
7887 int attr; | |
7888 { | |
7889 int row; | |
7890 int col; | |
7891 int off; | |
7892 int end_off; | |
7893 int did_delete; | |
7894 int c; | |
7895 int norm_term; | |
7896 #if defined(FEAT_GUI) || defined(UNIX) | |
7897 int force_next = FALSE; | |
7898 #endif | |
7899 | |
7900 if (end_row > screen_Rows) /* safety check */ | |
7901 end_row = screen_Rows; | |
7902 if (end_col > screen_Columns) /* safety check */ | |
7903 end_col = screen_Columns; | |
7904 if (ScreenLines == NULL | |
7905 || start_row >= end_row | |
7906 || start_col >= end_col) /* nothing to do */ | |
7907 return; | |
7908 | |
7909 /* it's a "normal" terminal when not in a GUI or cterm */ | |
7910 norm_term = ( | |
7911 #ifdef FEAT_GUI | |
7912 !gui.in_use && | |
7913 #endif | |
7914 t_colors <= 1); | |
7915 for (row = start_row; row < end_row; ++row) | |
7916 { | |
1668 | 7917 #ifdef FEAT_MBYTE |
7918 if (has_mbyte | |
7919 # ifdef FEAT_GUI | |
7920 && !gui.in_use | |
7921 # endif | |
7922 ) | |
7923 { | |
7924 /* When drawing over the right halve of a double-wide char clear | |
7925 * out the left halve. When drawing over the left halve of a | |
7926 * double wide-char clear out the right halve. Only needed in a | |
7927 * terminal. */ | |
1685 | 7928 if (start_col > 0 && mb_fix_col(start_col, row) != start_col) |
1670 | 7929 screen_puts_len((char_u *)" ", 1, row, start_col - 1, 0); |
1677 | 7930 if (end_col < screen_Columns && mb_fix_col(end_col, row) != end_col) |
1670 | 7931 screen_puts_len((char_u *)" ", 1, row, end_col, 0); |
1668 | 7932 } |
7933 #endif | |
7 | 7934 /* |
7935 * Try to use delete-line termcap code, when no attributes or in a | |
7936 * "normal" terminal, where a bold/italic space is just a | |
7937 * space. | |
7938 */ | |
7939 did_delete = FALSE; | |
7940 if (c2 == ' ' | |
7941 && end_col == Columns | |
7942 && can_clear(T_CE) | |
7943 && (attr == 0 | |
7944 || (norm_term | |
7945 && attr <= HL_ALL | |
7946 && ((attr & ~(HL_BOLD | HL_ITALIC)) == 0)))) | |
7947 { | |
7948 /* | |
7949 * check if we really need to clear something | |
7950 */ | |
7951 col = start_col; | |
7952 if (c1 != ' ') /* don't clear first char */ | |
7953 ++col; | |
7954 | |
7955 off = LineOffset[row] + col; | |
7956 end_off = LineOffset[row] + end_col; | |
7957 | |
7958 /* skip blanks (used often, keep it fast!) */ | |
7959 #ifdef FEAT_MBYTE | |
7960 if (enc_utf8) | |
7961 while (off < end_off && ScreenLines[off] == ' ' | |
7962 && ScreenAttrs[off] == 0 && ScreenLinesUC[off] == 0) | |
7963 ++off; | |
7964 else | |
7965 #endif | |
7966 while (off < end_off && ScreenLines[off] == ' ' | |
7967 && ScreenAttrs[off] == 0) | |
7968 ++off; | |
7969 if (off < end_off) /* something to be cleared */ | |
7970 { | |
7971 col = off - LineOffset[row]; | |
7972 screen_stop_highlight(); | |
7973 term_windgoto(row, col);/* clear rest of this screen line */ | |
7974 out_str(T_CE); | |
7975 screen_start(); /* don't know where cursor is now */ | |
7976 col = end_col - col; | |
7977 while (col--) /* clear chars in ScreenLines */ | |
7978 { | |
7979 ScreenLines[off] = ' '; | |
7980 #ifdef FEAT_MBYTE | |
7981 if (enc_utf8) | |
7982 ScreenLinesUC[off] = 0; | |
7983 #endif | |
7984 ScreenAttrs[off] = 0; | |
7985 ++off; | |
7986 } | |
7987 } | |
7988 did_delete = TRUE; /* the chars are cleared now */ | |
7989 } | |
7990 | |
7991 off = LineOffset[row] + start_col; | |
7992 c = c1; | |
7993 for (col = start_col; col < end_col; ++col) | |
7994 { | |
7995 if (ScreenLines[off] != c | |
7996 #ifdef FEAT_MBYTE | |
714 | 7997 || (enc_utf8 && (int)ScreenLinesUC[off] |
7998 != (c >= 0x80 ? c : 0)) | |
7 | 7999 #endif |
8000 || ScreenAttrs[off] != attr | |
8001 #if defined(FEAT_GUI) || defined(UNIX) | |
8002 || force_next | |
8003 #endif | |
8004 ) | |
8005 { | |
8006 #if defined(FEAT_GUI) || defined(UNIX) | |
8007 /* The bold trick may make a single row of pixels appear in | |
8008 * the next character. When a bold character is removed, the | |
8009 * next character should be redrawn too. This happens for our | |
8010 * own GUI and for some xterms. */ | |
8011 if ( | |
8012 # ifdef FEAT_GUI | |
8013 gui.in_use | |
8014 # endif | |
8015 # if defined(FEAT_GUI) && defined(UNIX) | |
8016 || | |
8017 # endif | |
8018 # ifdef UNIX | |
8019 term_is_xterm | |
8020 # endif | |
8021 ) | |
8022 { | |
8023 if (ScreenLines[off] != ' ' | |
8024 && (ScreenAttrs[off] > HL_ALL | |
8025 || ScreenAttrs[off] & HL_BOLD)) | |
8026 force_next = TRUE; | |
8027 else | |
8028 force_next = FALSE; | |
8029 } | |
8030 #endif | |
8031 ScreenLines[off] = c; | |
8032 #ifdef FEAT_MBYTE | |
8033 if (enc_utf8) | |
8034 { | |
8035 if (c >= 0x80) | |
8036 { | |
8037 ScreenLinesUC[off] = c; | |
714 | 8038 ScreenLinesC[0][off] = 0; |
7 | 8039 } |
8040 else | |
8041 ScreenLinesUC[off] = 0; | |
8042 } | |
8043 #endif | |
8044 ScreenAttrs[off] = attr; | |
8045 if (!did_delete || c != ' ') | |
8046 screen_char(off, row, col); | |
8047 } | |
8048 ++off; | |
8049 if (col == start_col) | |
8050 { | |
8051 if (did_delete) | |
8052 break; | |
8053 c = c2; | |
8054 } | |
8055 } | |
8056 if (end_col == Columns) | |
8057 LineWraps[row] = FALSE; | |
8058 if (row == Rows - 1) /* overwritten the command line */ | |
8059 { | |
8060 redraw_cmdline = TRUE; | |
8061 if (c1 == ' ' && c2 == ' ') | |
8062 clear_cmdline = FALSE; /* command line has been cleared */ | |
644 | 8063 if (start_col == 0) |
8064 mode_displayed = FALSE; /* mode cleared or overwritten */ | |
7 | 8065 } |
8066 } | |
8067 } | |
8068 | |
8069 /* | |
8070 * Check if there should be a delay. Used before clearing or redrawing the | |
8071 * screen or the command line. | |
8072 */ | |
8073 void | |
8074 check_for_delay(check_msg_scroll) | |
8075 int check_msg_scroll; | |
8076 { | |
8077 if ((emsg_on_display || (check_msg_scroll && msg_scroll)) | |
8078 && !did_wait_return | |
8079 && emsg_silent == 0) | |
8080 { | |
8081 out_flush(); | |
8082 ui_delay(1000L, TRUE); | |
8083 emsg_on_display = FALSE; | |
8084 if (check_msg_scroll) | |
8085 msg_scroll = FALSE; | |
8086 } | |
8087 } | |
8088 | |
8089 /* | |
8090 * screen_valid - allocate screen buffers if size changed | |
3263 | 8091 * If "doclear" is TRUE: clear screen if it has been resized. |
7 | 8092 * Returns TRUE if there is a valid screen to write to. |
8093 * Returns FALSE when starting up and screen not initialized yet. | |
8094 */ | |
8095 int | |
3263 | 8096 screen_valid(doclear) |
8097 int doclear; | |
7 | 8098 { |
3263 | 8099 screenalloc(doclear); /* allocate screen buffers if size changed */ |
7 | 8100 return (ScreenLines != NULL); |
8101 } | |
8102 | |
8103 /* | |
8104 * Resize the shell to Rows and Columns. | |
8105 * Allocate ScreenLines[] and associated items. | |
8106 * | |
8107 * There may be some time between setting Rows and Columns and (re)allocating | |
8108 * ScreenLines[]. This happens when starting up and when (manually) changing | |
8109 * the shell size. Always use screen_Rows and screen_Columns to access items | |
8110 * in ScreenLines[]. Use Rows and Columns for positioning text etc. where the | |
8111 * final size of the shell is needed. | |
8112 */ | |
8113 void | |
3263 | 8114 screenalloc(doclear) |
8115 int doclear; | |
7 | 8116 { |
8117 int new_row, old_row; | |
8118 #ifdef FEAT_GUI | |
8119 int old_Rows; | |
8120 #endif | |
8121 win_T *wp; | |
8122 int outofmem = FALSE; | |
8123 int len; | |
8124 schar_T *new_ScreenLines; | |
8125 #ifdef FEAT_MBYTE | |
8126 u8char_T *new_ScreenLinesUC = NULL; | |
714 | 8127 u8char_T *new_ScreenLinesC[MAX_MCO]; |
7 | 8128 schar_T *new_ScreenLines2 = NULL; |
714 | 8129 int i; |
7 | 8130 #endif |
8131 sattr_T *new_ScreenAttrs; | |
8132 unsigned *new_LineOffset; | |
8133 char_u *new_LineWraps; | |
671 | 8134 #ifdef FEAT_WINDOWS |
681 | 8135 short *new_TabPageIdxs; |
671 | 8136 tabpage_T *tp; |
8137 #endif | |
7 | 8138 static int entered = FALSE; /* avoid recursiveness */ |
944 | 8139 static int done_outofmem_msg = FALSE; /* did outofmem message */ |
1824 | 8140 #ifdef FEAT_AUTOCMD |
8141 int retry_count = 0; | |
8142 | |
8143 retry: | |
8144 #endif | |
7 | 8145 /* |
8146 * Allocation of the screen buffers is done only when the size changes and | |
8147 * when Rows and Columns have been set and we have started doing full | |
8148 * screen stuff. | |
8149 */ | |
8150 if ((ScreenLines != NULL | |
8151 && Rows == screen_Rows | |
8152 && Columns == screen_Columns | |
8153 #ifdef FEAT_MBYTE | |
8154 && enc_utf8 == (ScreenLinesUC != NULL) | |
8155 && (enc_dbcs == DBCS_JPNU) == (ScreenLines2 != NULL) | |
714 | 8156 && p_mco == Screen_mco |
7 | 8157 #endif |
8158 ) | |
8159 || Rows == 0 | |
8160 || Columns == 0 | |
8161 || (!full_screen && ScreenLines == NULL)) | |
8162 return; | |
8163 | |
8164 /* | |
8165 * It's possible that we produce an out-of-memory message below, which | |
8166 * will cause this function to be called again. To break the loop, just | |
8167 * return here. | |
8168 */ | |
8169 if (entered) | |
8170 return; | |
8171 entered = TRUE; | |
8172 | |
911 | 8173 /* |
8174 * Note that the window sizes are updated before reallocating the arrays, | |
8175 * thus we must not redraw here! | |
8176 */ | |
8177 ++RedrawingDisabled; | |
8178 | |
7 | 8179 win_new_shellsize(); /* fit the windows in the new sized shell */ |
8180 | |
8181 comp_col(); /* recompute columns for shown command and ruler */ | |
8182 | |
8183 /* | |
8184 * We're changing the size of the screen. | |
8185 * - Allocate new arrays for ScreenLines and ScreenAttrs. | |
8186 * - Move lines from the old arrays into the new arrays, clear extra | |
8187 * lines (unless the screen is going to be cleared). | |
8188 * - Free the old arrays. | |
8189 * | |
8190 * If anything fails, make ScreenLines NULL, so we don't do anything! | |
8191 * Continuing with the old ScreenLines may result in a crash, because the | |
8192 * size is wrong. | |
8193 */ | |
671 | 8194 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 8195 win_free_lsize(wp); |
1946 | 8196 #ifdef FEAT_AUTOCMD |
8197 if (aucmd_win != NULL) | |
8198 win_free_lsize(aucmd_win); | |
8199 #endif | |
7 | 8200 |
8201 new_ScreenLines = (schar_T *)lalloc((long_u)( | |
8202 (Rows + 1) * Columns * sizeof(schar_T)), FALSE); | |
8203 #ifdef FEAT_MBYTE | |
2122
476336a5ae95
updated for version 7.2.404
Bram Moolenaar <bram@zimbu.org>
parents:
2069
diff
changeset
|
8204 vim_memset(new_ScreenLinesC, 0, sizeof(u8char_T *) * MAX_MCO); |
7 | 8205 if (enc_utf8) |
8206 { | |
8207 new_ScreenLinesUC = (u8char_T *)lalloc((long_u)( | |
8208 (Rows + 1) * Columns * sizeof(u8char_T)), FALSE); | |
714 | 8209 for (i = 0; i < p_mco; ++i) |
2124
dc8a5699253b
updated for version 7.2.406
Bram Moolenaar <bram@zimbu.org>
parents:
2122
diff
changeset
|
8210 new_ScreenLinesC[i] = (u8char_T *)lalloc_clear((long_u)( |
7 | 8211 (Rows + 1) * Columns * sizeof(u8char_T)), FALSE); |
8212 } | |
8213 if (enc_dbcs == DBCS_JPNU) | |
8214 new_ScreenLines2 = (schar_T *)lalloc((long_u)( | |
8215 (Rows + 1) * Columns * sizeof(schar_T)), FALSE); | |
8216 #endif | |
8217 new_ScreenAttrs = (sattr_T *)lalloc((long_u)( | |
8218 (Rows + 1) * Columns * sizeof(sattr_T)), FALSE); | |
8219 new_LineOffset = (unsigned *)lalloc((long_u)( | |
8220 Rows * sizeof(unsigned)), FALSE); | |
8221 new_LineWraps = (char_u *)lalloc((long_u)(Rows * sizeof(char_u)), FALSE); | |
671 | 8222 #ifdef FEAT_WINDOWS |
681 | 8223 new_TabPageIdxs = (short *)lalloc((long_u)(Columns * sizeof(short)), FALSE); |
671 | 8224 #endif |
7 | 8225 |
677 | 8226 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 8227 { |
8228 if (win_alloc_lines(wp) == FAIL) | |
8229 { | |
8230 outofmem = TRUE; | |
8231 #ifdef FEAT_WINDOWS | |
1819 | 8232 goto give_up; |
8233 #endif | |
8234 } | |
8235 } | |
1906 | 8236 #ifdef FEAT_AUTOCMD |
1946 | 8237 if (aucmd_win != NULL && aucmd_win->w_lines == NULL |
8238 && win_alloc_lines(aucmd_win) == FAIL) | |
1906 | 8239 outofmem = TRUE; |
8240 #endif | |
1819 | 8241 #ifdef FEAT_WINDOWS |
8242 give_up: | |
8243 #endif | |
7 | 8244 |
714 | 8245 #ifdef FEAT_MBYTE |
8246 for (i = 0; i < p_mco; ++i) | |
8247 if (new_ScreenLinesC[i] == NULL) | |
8248 break; | |
8249 #endif | |
7 | 8250 if (new_ScreenLines == NULL |
8251 #ifdef FEAT_MBYTE | |
714 | 8252 || (enc_utf8 && (new_ScreenLinesUC == NULL || i != p_mco)) |
7 | 8253 || (enc_dbcs == DBCS_JPNU && new_ScreenLines2 == NULL) |
8254 #endif | |
8255 || new_ScreenAttrs == NULL | |
8256 || new_LineOffset == NULL | |
8257 || new_LineWraps == NULL | |
671 | 8258 #ifdef FEAT_WINDOWS |
8259 || new_TabPageIdxs == NULL | |
8260 #endif | |
7 | 8261 || outofmem) |
8262 { | |
944 | 8263 if (ScreenLines != NULL || !done_outofmem_msg) |
534 | 8264 { |
8265 /* guess the size */ | |
8266 do_outofmem_msg((long_u)((Rows + 1) * Columns)); | |
8267 | |
8268 /* Remember we did this to avoid getting outofmem messages over | |
8269 * and over again. */ | |
944 | 8270 done_outofmem_msg = TRUE; |
534 | 8271 } |
7 | 8272 vim_free(new_ScreenLines); |
8273 new_ScreenLines = NULL; | |
8274 #ifdef FEAT_MBYTE | |
8275 vim_free(new_ScreenLinesUC); | |
8276 new_ScreenLinesUC = NULL; | |
714 | 8277 for (i = 0; i < p_mco; ++i) |
8278 { | |
8279 vim_free(new_ScreenLinesC[i]); | |
8280 new_ScreenLinesC[i] = NULL; | |
8281 } | |
7 | 8282 vim_free(new_ScreenLines2); |
8283 new_ScreenLines2 = NULL; | |
8284 #endif | |
8285 vim_free(new_ScreenAttrs); | |
8286 new_ScreenAttrs = NULL; | |
8287 vim_free(new_LineOffset); | |
8288 new_LineOffset = NULL; | |
8289 vim_free(new_LineWraps); | |
8290 new_LineWraps = NULL; | |
671 | 8291 #ifdef FEAT_WINDOWS |
8292 vim_free(new_TabPageIdxs); | |
8293 new_TabPageIdxs = NULL; | |
8294 #endif | |
7 | 8295 } |
8296 else | |
8297 { | |
944 | 8298 done_outofmem_msg = FALSE; |
534 | 8299 |
7 | 8300 for (new_row = 0; new_row < Rows; ++new_row) |
8301 { | |
8302 new_LineOffset[new_row] = new_row * Columns; | |
8303 new_LineWraps[new_row] = FALSE; | |
8304 | |
8305 /* | |
8306 * If the screen is not going to be cleared, copy as much as | |
8307 * possible from the old screen to the new one and clear the rest | |
8308 * (used when resizing the window at the "--more--" prompt or when | |
8309 * executing an external command, for the GUI). | |
8310 */ | |
3263 | 8311 if (!doclear) |
7 | 8312 { |
8313 (void)vim_memset(new_ScreenLines + new_row * Columns, | |
8314 ' ', (size_t)Columns * sizeof(schar_T)); | |
8315 #ifdef FEAT_MBYTE | |
8316 if (enc_utf8) | |
8317 { | |
8318 (void)vim_memset(new_ScreenLinesUC + new_row * Columns, | |
8319 0, (size_t)Columns * sizeof(u8char_T)); | |
714 | 8320 for (i = 0; i < p_mco; ++i) |
8321 (void)vim_memset(new_ScreenLinesC[i] | |
8322 + new_row * Columns, | |
7 | 8323 0, (size_t)Columns * sizeof(u8char_T)); |
8324 } | |
8325 if (enc_dbcs == DBCS_JPNU) | |
8326 (void)vim_memset(new_ScreenLines2 + new_row * Columns, | |
8327 0, (size_t)Columns * sizeof(schar_T)); | |
8328 #endif | |
8329 (void)vim_memset(new_ScreenAttrs + new_row * Columns, | |
8330 0, (size_t)Columns * sizeof(sattr_T)); | |
8331 old_row = new_row + (screen_Rows - Rows); | |
534 | 8332 if (old_row >= 0 && ScreenLines != NULL) |
7 | 8333 { |
8334 if (screen_Columns < Columns) | |
8335 len = screen_Columns; | |
8336 else | |
8337 len = Columns; | |
26 | 8338 #ifdef FEAT_MBYTE |
571 | 8339 /* When switching to utf-8 don't copy characters, they |
714 | 8340 * may be invalid now. Also when p_mco changes. */ |
8341 if (!(enc_utf8 && ScreenLinesUC == NULL) | |
8342 && p_mco == Screen_mco) | |
26 | 8343 #endif |
8344 mch_memmove(new_ScreenLines + new_LineOffset[new_row], | |
8345 ScreenLines + LineOffset[old_row], | |
8346 (size_t)len * sizeof(schar_T)); | |
7 | 8347 #ifdef FEAT_MBYTE |
714 | 8348 if (enc_utf8 && ScreenLinesUC != NULL |
8349 && p_mco == Screen_mco) | |
7 | 8350 { |
8351 mch_memmove(new_ScreenLinesUC + new_LineOffset[new_row], | |
8352 ScreenLinesUC + LineOffset[old_row], | |
8353 (size_t)len * sizeof(u8char_T)); | |
714 | 8354 for (i = 0; i < p_mco; ++i) |
8355 mch_memmove(new_ScreenLinesC[i] | |
8356 + new_LineOffset[new_row], | |
8357 ScreenLinesC[i] + LineOffset[old_row], | |
7 | 8358 (size_t)len * sizeof(u8char_T)); |
8359 } | |
8360 if (enc_dbcs == DBCS_JPNU && ScreenLines2 != NULL) | |
8361 mch_memmove(new_ScreenLines2 + new_LineOffset[new_row], | |
8362 ScreenLines2 + LineOffset[old_row], | |
8363 (size_t)len * sizeof(schar_T)); | |
8364 #endif | |
8365 mch_memmove(new_ScreenAttrs + new_LineOffset[new_row], | |
8366 ScreenAttrs + LineOffset[old_row], | |
8367 (size_t)len * sizeof(sattr_T)); | |
8368 } | |
8369 } | |
8370 } | |
8371 /* Use the last line of the screen for the current line. */ | |
8372 current_ScreenLine = new_ScreenLines + Rows * Columns; | |
8373 } | |
8374 | |
356 | 8375 free_screenlines(); |
8376 | |
7 | 8377 ScreenLines = new_ScreenLines; |
8378 #ifdef FEAT_MBYTE | |
8379 ScreenLinesUC = new_ScreenLinesUC; | |
714 | 8380 for (i = 0; i < p_mco; ++i) |
8381 ScreenLinesC[i] = new_ScreenLinesC[i]; | |
8382 Screen_mco = p_mco; | |
7 | 8383 ScreenLines2 = new_ScreenLines2; |
8384 #endif | |
8385 ScreenAttrs = new_ScreenAttrs; | |
8386 LineOffset = new_LineOffset; | |
8387 LineWraps = new_LineWraps; | |
671 | 8388 #ifdef FEAT_WINDOWS |
8389 TabPageIdxs = new_TabPageIdxs; | |
8390 #endif | |
7 | 8391 |
8392 /* It's important that screen_Rows and screen_Columns reflect the actual | |
8393 * size of ScreenLines[]. Set them before calling anything. */ | |
8394 #ifdef FEAT_GUI | |
8395 old_Rows = screen_Rows; | |
8396 #endif | |
8397 screen_Rows = Rows; | |
8398 screen_Columns = Columns; | |
8399 | |
8400 must_redraw = CLEAR; /* need to clear the screen later */ | |
3263 | 8401 if (doclear) |
7 | 8402 screenclear2(); |
8403 | |
8404 #ifdef FEAT_GUI | |
8405 else if (gui.in_use | |
8406 && !gui.starting | |
8407 && ScreenLines != NULL | |
8408 && old_Rows != Rows) | |
8409 { | |
8410 (void)gui_redraw_block(0, 0, (int)Rows - 1, (int)Columns - 1, 0); | |
8411 /* | |
8412 * Adjust the position of the cursor, for when executing an external | |
8413 * command. | |
8414 */ | |
8415 if (msg_row >= Rows) /* Rows got smaller */ | |
8416 msg_row = Rows - 1; /* put cursor at last row */ | |
8417 else if (Rows > old_Rows) /* Rows got bigger */ | |
8418 msg_row += Rows - old_Rows; /* put cursor in same place */ | |
8419 if (msg_col >= Columns) /* Columns got smaller */ | |
8420 msg_col = Columns - 1; /* put cursor at last column */ | |
8421 } | |
8422 #endif | |
8423 | |
8424 entered = FALSE; | |
911 | 8425 --RedrawingDisabled; |
766 | 8426 |
8427 #ifdef FEAT_AUTOCMD | |
1824 | 8428 /* |
8429 * Do not apply autocommands more than 3 times to avoid an endless loop | |
8430 * in case applying autocommands always changes Rows or Columns. | |
8431 */ | |
8432 if (starting == 0 && ++retry_count <= 3) | |
8433 { | |
766 | 8434 apply_autocmds(EVENT_VIMRESIZED, NULL, NULL, FALSE, curbuf); |
1824 | 8435 /* In rare cases, autocommands may have altered Rows or Columns, |
8436 * jump back to check if we need to allocate the screen again. */ | |
8437 goto retry; | |
8438 } | |
766 | 8439 #endif |
7 | 8440 } |
8441 | |
8442 void | |
356 | 8443 free_screenlines() |
8444 { | |
8445 #ifdef FEAT_MBYTE | |
714 | 8446 int i; |
8447 | |
356 | 8448 vim_free(ScreenLinesUC); |
714 | 8449 for (i = 0; i < Screen_mco; ++i) |
8450 vim_free(ScreenLinesC[i]); | |
356 | 8451 vim_free(ScreenLines2); |
8452 #endif | |
714 | 8453 vim_free(ScreenLines); |
356 | 8454 vim_free(ScreenAttrs); |
8455 vim_free(LineOffset); | |
8456 vim_free(LineWraps); | |
671 | 8457 #ifdef FEAT_WINDOWS |
8458 vim_free(TabPageIdxs); | |
8459 #endif | |
356 | 8460 } |
8461 | |
8462 void | |
7 | 8463 screenclear() |
8464 { | |
8465 check_for_delay(FALSE); | |
8466 screenalloc(FALSE); /* allocate screen buffers if size changed */ | |
8467 screenclear2(); /* clear the screen */ | |
8468 } | |
8469 | |
8470 static void | |
8471 screenclear2() | |
8472 { | |
8473 int i; | |
8474 | |
8475 if (starting == NO_SCREEN || ScreenLines == NULL | |
8476 #ifdef FEAT_GUI | |
8477 || (gui.in_use && gui.starting) | |
8478 #endif | |
8479 ) | |
8480 return; | |
8481 | |
8482 #ifdef FEAT_GUI | |
8483 if (!gui.in_use) | |
8484 #endif | |
8485 screen_attr = -1; /* force setting the Normal colors */ | |
8486 screen_stop_highlight(); /* don't want highlighting here */ | |
8487 | |
8488 #ifdef FEAT_CLIPBOARD | |
8489 /* disable selection without redrawing it */ | |
8490 clip_scroll_selection(9999); | |
8491 #endif | |
8492 | |
8493 /* blank out ScreenLines */ | |
8494 for (i = 0; i < Rows; ++i) | |
8495 { | |
8496 lineclear(LineOffset[i], (int)Columns); | |
8497 LineWraps[i] = FALSE; | |
8498 } | |
8499 | |
8500 if (can_clear(T_CL)) | |
8501 { | |
8502 out_str(T_CL); /* clear the display */ | |
8503 clear_cmdline = FALSE; | |
644 | 8504 mode_displayed = FALSE; |
7 | 8505 } |
8506 else | |
8507 { | |
8508 /* can't clear the screen, mark all chars with invalid attributes */ | |
8509 for (i = 0; i < Rows; ++i) | |
8510 lineinvalid(LineOffset[i], (int)Columns); | |
8511 clear_cmdline = TRUE; | |
8512 } | |
8513 | |
8514 screen_cleared = TRUE; /* can use contents of ScreenLines now */ | |
8515 | |
8516 win_rest_invalid(firstwin); | |
8517 redraw_cmdline = TRUE; | |
670 | 8518 #ifdef FEAT_WINDOWS |
673 | 8519 redraw_tabline = TRUE; |
670 | 8520 #endif |
7 | 8521 if (must_redraw == CLEAR) /* no need to clear again */ |
8522 must_redraw = NOT_VALID; | |
8523 compute_cmdrow(); | |
8524 msg_row = cmdline_row; /* put cursor on last line for messages */ | |
8525 msg_col = 0; | |
8526 screen_start(); /* don't know where cursor is now */ | |
8527 msg_scrolled = 0; /* can't scroll back */ | |
8528 msg_didany = FALSE; | |
8529 msg_didout = FALSE; | |
8530 } | |
8531 | |
8532 /* | |
8533 * Clear one line in ScreenLines. | |
8534 */ | |
8535 static void | |
8536 lineclear(off, width) | |
8537 unsigned off; | |
8538 int width; | |
8539 { | |
8540 (void)vim_memset(ScreenLines + off, ' ', (size_t)width * sizeof(schar_T)); | |
8541 #ifdef FEAT_MBYTE | |
8542 if (enc_utf8) | |
8543 (void)vim_memset(ScreenLinesUC + off, 0, | |
8544 (size_t)width * sizeof(u8char_T)); | |
8545 #endif | |
8546 (void)vim_memset(ScreenAttrs + off, 0, (size_t)width * sizeof(sattr_T)); | |
8547 } | |
8548 | |
8549 /* | |
8550 * Mark one line in ScreenLines invalid by setting the attributes to an | |
8551 * invalid value. | |
8552 */ | |
8553 static void | |
8554 lineinvalid(off, width) | |
8555 unsigned off; | |
8556 int width; | |
8557 { | |
8558 (void)vim_memset(ScreenAttrs + off, -1, (size_t)width * sizeof(sattr_T)); | |
8559 } | |
8560 | |
8561 #ifdef FEAT_VERTSPLIT | |
8562 /* | |
8563 * Copy part of a Screenline for vertically split window "wp". | |
8564 */ | |
8565 static void | |
8566 linecopy(to, from, wp) | |
8567 int to; | |
8568 int from; | |
8569 win_T *wp; | |
8570 { | |
8571 unsigned off_to = LineOffset[to] + wp->w_wincol; | |
8572 unsigned off_from = LineOffset[from] + wp->w_wincol; | |
8573 | |
8574 mch_memmove(ScreenLines + off_to, ScreenLines + off_from, | |
8575 wp->w_width * sizeof(schar_T)); | |
8576 # ifdef FEAT_MBYTE | |
8577 if (enc_utf8) | |
8578 { | |
714 | 8579 int i; |
8580 | |
7 | 8581 mch_memmove(ScreenLinesUC + off_to, ScreenLinesUC + off_from, |
8582 wp->w_width * sizeof(u8char_T)); | |
714 | 8583 for (i = 0; i < p_mco; ++i) |
8584 mch_memmove(ScreenLinesC[i] + off_to, ScreenLinesC[i] + off_from, | |
8585 wp->w_width * sizeof(u8char_T)); | |
7 | 8586 } |
8587 if (enc_dbcs == DBCS_JPNU) | |
8588 mch_memmove(ScreenLines2 + off_to, ScreenLines2 + off_from, | |
8589 wp->w_width * sizeof(schar_T)); | |
8590 # endif | |
8591 mch_memmove(ScreenAttrs + off_to, ScreenAttrs + off_from, | |
8592 wp->w_width * sizeof(sattr_T)); | |
8593 } | |
8594 #endif | |
8595 | |
8596 /* | |
8597 * Return TRUE if clearing with term string "p" would work. | |
8598 * It can't work when the string is empty or it won't set the right background. | |
8599 */ | |
8600 int | |
8601 can_clear(p) | |
8602 char_u *p; | |
8603 { | |
8604 return (*p != NUL && (t_colors <= 1 | |
8605 #ifdef FEAT_GUI | |
8606 || gui.in_use | |
8607 #endif | |
8608 || cterm_normal_bg_color == 0 || *T_UT != NUL)); | |
8609 } | |
8610 | |
8611 /* | |
8612 * Reset cursor position. Use whenever cursor was moved because of outputting | |
8613 * something directly to the screen (shell commands) or a terminal control | |
8614 * code. | |
8615 */ | |
8616 void | |
8617 screen_start() | |
8618 { | |
8619 screen_cur_row = screen_cur_col = 9999; | |
8620 } | |
8621 | |
8622 /* | |
8623 * Move the cursor to position "row","col" in the screen. | |
8624 * This tries to find the most efficient way to move, minimizing the number of | |
8625 * characters sent to the terminal. | |
8626 */ | |
8627 void | |
8628 windgoto(row, col) | |
8629 int row; | |
8630 int col; | |
8631 { | |
205 | 8632 sattr_T *p; |
7 | 8633 int i; |
8634 int plan; | |
8635 int cost; | |
8636 int wouldbe_col; | |
8637 int noinvcurs; | |
8638 char_u *bs; | |
8639 int goto_cost; | |
8640 int attr; | |
8641 | |
1213 | 8642 #define GOTO_COST 7 /* assume a term_windgoto() takes about 7 chars */ |
7 | 8643 #define HIGHL_COST 5 /* assume unhighlight takes 5 chars */ |
8644 | |
8645 #define PLAN_LE 1 | |
8646 #define PLAN_CR 2 | |
8647 #define PLAN_NL 3 | |
8648 #define PLAN_WRITE 4 | |
8649 /* Can't use ScreenLines unless initialized */ | |
8650 if (ScreenLines == NULL) | |
8651 return; | |
8652 | |
8653 if (col != screen_cur_col || row != screen_cur_row) | |
8654 { | |
8655 /* Check for valid position. */ | |
8656 if (row < 0) /* window without text lines? */ | |
8657 row = 0; | |
8658 if (row >= screen_Rows) | |
8659 row = screen_Rows - 1; | |
8660 if (col >= screen_Columns) | |
8661 col = screen_Columns - 1; | |
8662 | |
8663 /* check if no cursor movement is allowed in highlight mode */ | |
8664 if (screen_attr && *T_MS == NUL) | |
8665 noinvcurs = HIGHL_COST; | |
8666 else | |
8667 noinvcurs = 0; | |
8668 goto_cost = GOTO_COST + noinvcurs; | |
8669 | |
8670 /* | |
8671 * Plan how to do the positioning: | |
8672 * 1. Use CR to move it to column 0, same row. | |
8673 * 2. Use T_LE to move it a few columns to the left. | |
8674 * 3. Use NL to move a few lines down, column 0. | |
8675 * 4. Move a few columns to the right with T_ND or by writing chars. | |
8676 * | |
8677 * Don't do this if the cursor went beyond the last column, the cursor | |
8678 * position is unknown then (some terminals wrap, some don't ) | |
8679 * | |
1213 | 8680 * First check if the highlighting attributes allow us to write |
7 | 8681 * characters to move the cursor to the right. |
8682 */ | |
8683 if (row >= screen_cur_row && screen_cur_col < Columns) | |
8684 { | |
8685 /* | |
8686 * If the cursor is in the same row, bigger col, we can use CR | |
8687 * or T_LE. | |
8688 */ | |
8689 bs = NULL; /* init for GCC */ | |
8690 attr = screen_attr; | |
8691 if (row == screen_cur_row && col < screen_cur_col) | |
8692 { | |
8693 /* "le" is preferred over "bc", because "bc" is obsolete */ | |
8694 if (*T_LE) | |
8695 bs = T_LE; /* "cursor left" */ | |
8696 else | |
8697 bs = T_BC; /* "backspace character (old) */ | |
8698 if (*bs) | |
8699 cost = (screen_cur_col - col) * (int)STRLEN(bs); | |
8700 else | |
8701 cost = 999; | |
8702 if (col + 1 < cost) /* using CR is less characters */ | |
8703 { | |
8704 plan = PLAN_CR; | |
8705 wouldbe_col = 0; | |
8706 cost = 1; /* CR is just one character */ | |
8707 } | |
8708 else | |
8709 { | |
8710 plan = PLAN_LE; | |
8711 wouldbe_col = col; | |
8712 } | |
8713 if (noinvcurs) /* will stop highlighting */ | |
8714 { | |
8715 cost += noinvcurs; | |
8716 attr = 0; | |
8717 } | |
8718 } | |
8719 | |
8720 /* | |
8721 * If the cursor is above where we want to be, we can use CR LF. | |
8722 */ | |
8723 else if (row > screen_cur_row) | |
8724 { | |
8725 plan = PLAN_NL; | |
8726 wouldbe_col = 0; | |
8727 cost = (row - screen_cur_row) * 2; /* CR LF */ | |
8728 if (noinvcurs) /* will stop highlighting */ | |
8729 { | |
8730 cost += noinvcurs; | |
8731 attr = 0; | |
8732 } | |
8733 } | |
8734 | |
8735 /* | |
8736 * If the cursor is in the same row, smaller col, just use write. | |
8737 */ | |
8738 else | |
8739 { | |
8740 plan = PLAN_WRITE; | |
8741 wouldbe_col = screen_cur_col; | |
8742 cost = 0; | |
8743 } | |
8744 | |
8745 /* | |
8746 * Check if any characters that need to be written have the | |
8747 * correct attributes. Also avoid UTF-8 characters. | |
8748 */ | |
8749 i = col - wouldbe_col; | |
8750 if (i > 0) | |
8751 cost += i; | |
8752 if (cost < goto_cost && i > 0) | |
8753 { | |
8754 /* | |
8755 * Check if the attributes are correct without additionally | |
8756 * stopping highlighting. | |
8757 */ | |
8758 p = ScreenAttrs + LineOffset[row] + wouldbe_col; | |
8759 while (i && *p++ == attr) | |
8760 --i; | |
8761 if (i != 0) | |
8762 { | |
8763 /* | |
8764 * Try if it works when highlighting is stopped here. | |
8765 */ | |
8766 if (*--p == 0) | |
8767 { | |
8768 cost += noinvcurs; | |
8769 while (i && *p++ == 0) | |
8770 --i; | |
8771 } | |
8772 if (i != 0) | |
8773 cost = 999; /* different attributes, don't do it */ | |
8774 } | |
8775 #ifdef FEAT_MBYTE | |
8776 if (enc_utf8) | |
8777 { | |
8778 /* Don't use an UTF-8 char for positioning, it's slow. */ | |
8779 for (i = wouldbe_col; i < col; ++i) | |
8780 if (ScreenLinesUC[LineOffset[row] + i] != 0) | |
8781 { | |
8782 cost = 999; | |
8783 break; | |
8784 } | |
8785 } | |
8786 #endif | |
8787 } | |
8788 | |
8789 /* | |
8790 * We can do it without term_windgoto()! | |
8791 */ | |
8792 if (cost < goto_cost) | |
8793 { | |
8794 if (plan == PLAN_LE) | |
8795 { | |
8796 if (noinvcurs) | |
8797 screen_stop_highlight(); | |
8798 while (screen_cur_col > col) | |
8799 { | |
8800 out_str(bs); | |
8801 --screen_cur_col; | |
8802 } | |
8803 } | |
8804 else if (plan == PLAN_CR) | |
8805 { | |
8806 if (noinvcurs) | |
8807 screen_stop_highlight(); | |
8808 out_char('\r'); | |
8809 screen_cur_col = 0; | |
8810 } | |
8811 else if (plan == PLAN_NL) | |
8812 { | |
8813 if (noinvcurs) | |
8814 screen_stop_highlight(); | |
8815 while (screen_cur_row < row) | |
8816 { | |
8817 out_char('\n'); | |
8818 ++screen_cur_row; | |
8819 } | |
8820 screen_cur_col = 0; | |
8821 } | |
8822 | |
8823 i = col - screen_cur_col; | |
8824 if (i > 0) | |
8825 { | |
8826 /* | |
8827 * Use cursor-right if it's one character only. Avoids | |
8828 * removing a line of pixels from the last bold char, when | |
8829 * using the bold trick in the GUI. | |
8830 */ | |
8831 if (T_ND[0] != NUL && T_ND[1] == NUL) | |
8832 { | |
8833 while (i-- > 0) | |
8834 out_char(*T_ND); | |
8835 } | |
8836 else | |
8837 { | |
8838 int off; | |
8839 | |
8840 off = LineOffset[row] + screen_cur_col; | |
8841 while (i-- > 0) | |
8842 { | |
8843 if (ScreenAttrs[off] != screen_attr) | |
8844 screen_stop_highlight(); | |
8845 #ifdef FEAT_MBYTE | |
8846 out_flush_check(); | |
8847 #endif | |
8848 out_char(ScreenLines[off]); | |
8849 #ifdef FEAT_MBYTE | |
8850 if (enc_dbcs == DBCS_JPNU | |
8851 && ScreenLines[off] == 0x8e) | |
8852 out_char(ScreenLines2[off]); | |
8853 #endif | |
8854 ++off; | |
8855 } | |
8856 } | |
8857 } | |
8858 } | |
8859 } | |
8860 else | |
8861 cost = 999; | |
8862 | |
8863 if (cost >= goto_cost) | |
8864 { | |
8865 if (noinvcurs) | |
8866 screen_stop_highlight(); | |
8867 if (row == screen_cur_row && (col > screen_cur_col) && | |
8868 *T_CRI != NUL) | |
8869 term_cursor_right(col - screen_cur_col); | |
8870 else | |
8871 term_windgoto(row, col); | |
8872 } | |
8873 screen_cur_row = row; | |
8874 screen_cur_col = col; | |
8875 } | |
8876 } | |
8877 | |
8878 /* | |
8879 * Set cursor to its position in the current window. | |
8880 */ | |
8881 void | |
8882 setcursor() | |
8883 { | |
8884 if (redrawing()) | |
8885 { | |
8886 validate_cursor(); | |
8887 windgoto(W_WINROW(curwin) + curwin->w_wrow, | |
8888 W_WINCOL(curwin) + ( | |
8889 #ifdef FEAT_RIGHTLEFT | |
1545 | 8890 /* With 'rightleft' set and the cursor on a double-wide |
8891 * character, position it on the leftmost column. */ | |
7 | 8892 curwin->w_p_rl ? ((int)W_WIDTH(curwin) - curwin->w_wcol - ( |
8893 # ifdef FEAT_MBYTE | |
1545 | 8894 (has_mbyte |
8895 && (*mb_ptr2cells)(ml_get_cursor()) == 2 | |
8896 && vim_isprintc(gchar_cursor())) ? 2 : | |
7 | 8897 # endif |
8898 1)) : | |
8899 #endif | |
8900 curwin->w_wcol)); | |
8901 } | |
8902 } | |
8903 | |
8904 | |
8905 /* | |
8906 * insert 'line_count' lines at 'row' in window 'wp' | |
8907 * if 'invalid' is TRUE the wp->w_lines[].wl_lnum is invalidated. | |
8908 * if 'mayclear' is TRUE the screen will be cleared if it is faster than | |
8909 * scrolling. | |
8910 * Returns FAIL if the lines are not inserted, OK for success. | |
8911 */ | |
8912 int | |
8913 win_ins_lines(wp, row, line_count, invalid, mayclear) | |
8914 win_T *wp; | |
8915 int row; | |
8916 int line_count; | |
8917 int invalid; | |
8918 int mayclear; | |
8919 { | |
8920 int did_delete; | |
8921 int nextrow; | |
8922 int lastrow; | |
8923 int retval; | |
8924 | |
8925 if (invalid) | |
8926 wp->w_lines_valid = 0; | |
8927 | |
8928 if (wp->w_height < 5) | |
8929 return FAIL; | |
8930 | |
8931 if (line_count > wp->w_height - row) | |
8932 line_count = wp->w_height - row; | |
8933 | |
8934 retval = win_do_lines(wp, row, line_count, mayclear, FALSE); | |
8935 if (retval != MAYBE) | |
8936 return retval; | |
8937 | |
8938 /* | |
8939 * If there is a next window or a status line, we first try to delete the | |
8940 * lines at the bottom to avoid messing what is after the window. | |
8941 * If this fails and there are following windows, don't do anything to avoid | |
8942 * messing up those windows, better just redraw. | |
8943 */ | |
8944 did_delete = FALSE; | |
8945 #ifdef FEAT_WINDOWS | |
8946 if (wp->w_next != NULL || wp->w_status_height) | |
8947 { | |
8948 if (screen_del_lines(0, W_WINROW(wp) + wp->w_height - line_count, | |
8949 line_count, (int)Rows, FALSE, NULL) == OK) | |
8950 did_delete = TRUE; | |
8951 else if (wp->w_next) | |
8952 return FAIL; | |
8953 } | |
8954 #endif | |
8955 /* | |
8956 * if no lines deleted, blank the lines that will end up below the window | |
8957 */ | |
8958 if (!did_delete) | |
8959 { | |
8960 #ifdef FEAT_WINDOWS | |
8961 wp->w_redr_status = TRUE; | |
8962 #endif | |
8963 redraw_cmdline = TRUE; | |
8964 nextrow = W_WINROW(wp) + wp->w_height + W_STATUS_HEIGHT(wp); | |
8965 lastrow = nextrow + line_count; | |
8966 if (lastrow > Rows) | |
8967 lastrow = Rows; | |
8968 screen_fill(nextrow - line_count, lastrow - line_count, | |
8969 W_WINCOL(wp), (int)W_ENDCOL(wp), | |
8970 ' ', ' ', 0); | |
8971 } | |
8972 | |
8973 if (screen_ins_lines(0, W_WINROW(wp) + row, line_count, (int)Rows, NULL) | |
8974 == FAIL) | |
8975 { | |
8976 /* deletion will have messed up other windows */ | |
8977 if (did_delete) | |
8978 { | |
8979 #ifdef FEAT_WINDOWS | |
8980 wp->w_redr_status = TRUE; | |
8981 #endif | |
8982 win_rest_invalid(W_NEXT(wp)); | |
8983 } | |
8984 return FAIL; | |
8985 } | |
8986 | |
8987 return OK; | |
8988 } | |
8989 | |
8990 /* | |
8991 * delete "line_count" window lines at "row" in window "wp" | |
8992 * If "invalid" is TRUE curwin->w_lines[] is invalidated. | |
8993 * If "mayclear" is TRUE the screen will be cleared if it is faster than | |
8994 * scrolling | |
8995 * Return OK for success, FAIL if the lines are not deleted. | |
8996 */ | |
8997 int | |
8998 win_del_lines(wp, row, line_count, invalid, mayclear) | |
8999 win_T *wp; | |
9000 int row; | |
9001 int line_count; | |
9002 int invalid; | |
9003 int mayclear; | |
9004 { | |
9005 int retval; | |
9006 | |
9007 if (invalid) | |
9008 wp->w_lines_valid = 0; | |
9009 | |
9010 if (line_count > wp->w_height - row) | |
9011 line_count = wp->w_height - row; | |
9012 | |
9013 retval = win_do_lines(wp, row, line_count, mayclear, TRUE); | |
9014 if (retval != MAYBE) | |
9015 return retval; | |
9016 | |
9017 if (screen_del_lines(0, W_WINROW(wp) + row, line_count, | |
9018 (int)Rows, FALSE, NULL) == FAIL) | |
9019 return FAIL; | |
9020 | |
9021 #ifdef FEAT_WINDOWS | |
9022 /* | |
9023 * If there are windows or status lines below, try to put them at the | |
9024 * correct place. If we can't do that, they have to be redrawn. | |
9025 */ | |
9026 if (wp->w_next || wp->w_status_height || cmdline_row < Rows - 1) | |
9027 { | |
9028 if (screen_ins_lines(0, W_WINROW(wp) + wp->w_height - line_count, | |
9029 line_count, (int)Rows, NULL) == FAIL) | |
9030 { | |
9031 wp->w_redr_status = TRUE; | |
9032 win_rest_invalid(wp->w_next); | |
9033 } | |
9034 } | |
9035 /* | |
9036 * If this is the last window and there is no status line, redraw the | |
9037 * command line later. | |
9038 */ | |
9039 else | |
9040 #endif | |
9041 redraw_cmdline = TRUE; | |
9042 return OK; | |
9043 } | |
9044 | |
9045 /* | |
9046 * Common code for win_ins_lines() and win_del_lines(). | |
9047 * Returns OK or FAIL when the work has been done. | |
9048 * Returns MAYBE when not finished yet. | |
9049 */ | |
9050 static int | |
9051 win_do_lines(wp, row, line_count, mayclear, del) | |
9052 win_T *wp; | |
9053 int row; | |
9054 int line_count; | |
9055 int mayclear; | |
9056 int del; | |
9057 { | |
9058 int retval; | |
9059 | |
9060 if (!redrawing() || line_count <= 0) | |
9061 return FAIL; | |
9062 | |
9063 /* only a few lines left: redraw is faster */ | |
9064 if (mayclear && Rows - line_count < 5 | |
9065 #ifdef FEAT_VERTSPLIT | |
9066 && wp->w_width == Columns | |
9067 #endif | |
9068 ) | |
9069 { | |
9070 screenclear(); /* will set wp->w_lines_valid to 0 */ | |
9071 return FAIL; | |
9072 } | |
9073 | |
9074 /* | |
9075 * Delete all remaining lines | |
9076 */ | |
9077 if (row + line_count >= wp->w_height) | |
9078 { | |
9079 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height, | |
9080 W_WINCOL(wp), (int)W_ENDCOL(wp), | |
9081 ' ', ' ', 0); | |
9082 return OK; | |
9083 } | |
9084 | |
9085 /* | |
9086 * when scrolling, the message on the command line should be cleared, | |
9087 * otherwise it will stay there forever. | |
9088 */ | |
9089 clear_cmdline = TRUE; | |
9090 | |
9091 /* | |
9092 * If the terminal can set a scroll region, use that. | |
9093 * Always do this in a vertically split window. This will redraw from | |
9094 * ScreenLines[] when t_CV isn't defined. That's faster than using | |
9095 * win_line(). | |
9096 * Don't use a scroll region when we are going to redraw the text, writing | |
9097 * a character in the lower right corner of the scroll region causes a | |
9098 * scroll-up in the DJGPP version. | |
9099 */ | |
9100 if (scroll_region | |
9101 #ifdef FEAT_VERTSPLIT | |
9102 || W_WIDTH(wp) != Columns | |
9103 #endif | |
9104 ) | |
9105 { | |
9106 #ifdef FEAT_VERTSPLIT | |
9107 if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL)) | |
9108 #endif | |
9109 scroll_region_set(wp, row); | |
9110 if (del) | |
9111 retval = screen_del_lines(W_WINROW(wp) + row, 0, line_count, | |
9112 wp->w_height - row, FALSE, wp); | |
9113 else | |
9114 retval = screen_ins_lines(W_WINROW(wp) + row, 0, line_count, | |
9115 wp->w_height - row, wp); | |
9116 #ifdef FEAT_VERTSPLIT | |
9117 if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL)) | |
9118 #endif | |
9119 scroll_region_reset(); | |
9120 return retval; | |
9121 } | |
9122 | |
9123 #ifdef FEAT_WINDOWS | |
9124 if (wp->w_next != NULL && p_tf) /* don't delete/insert on fast terminal */ | |
9125 return FAIL; | |
9126 #endif | |
9127 | |
9128 return MAYBE; | |
9129 } | |
9130 | |
9131 /* | |
9132 * window 'wp' and everything after it is messed up, mark it for redraw | |
9133 */ | |
9134 static void | |
9135 win_rest_invalid(wp) | |
9136 win_T *wp; | |
9137 { | |
9138 #ifdef FEAT_WINDOWS | |
9139 while (wp != NULL) | |
9140 #else | |
9141 if (wp != NULL) | |
9142 #endif | |
9143 { | |
9144 redraw_win_later(wp, NOT_VALID); | |
9145 #ifdef FEAT_WINDOWS | |
9146 wp->w_redr_status = TRUE; | |
9147 wp = wp->w_next; | |
9148 #endif | |
9149 } | |
9150 redraw_cmdline = TRUE; | |
9151 } | |
9152 | |
9153 /* | |
9154 * The rest of the routines in this file perform screen manipulations. The | |
9155 * given operation is performed physically on the screen. The corresponding | |
9156 * change is also made to the internal screen image. In this way, the editor | |
9157 * anticipates the effect of editing changes on the appearance of the screen. | |
9158 * That way, when we call screenupdate a complete redraw isn't usually | |
9159 * necessary. Another advantage is that we can keep adding code to anticipate | |
9160 * screen changes, and in the meantime, everything still works. | |
9161 */ | |
9162 | |
9163 /* | |
9164 * types for inserting or deleting lines | |
9165 */ | |
9166 #define USE_T_CAL 1 | |
9167 #define USE_T_CDL 2 | |
9168 #define USE_T_AL 3 | |
9169 #define USE_T_CE 4 | |
9170 #define USE_T_DL 5 | |
9171 #define USE_T_SR 6 | |
9172 #define USE_NL 7 | |
9173 #define USE_T_CD 8 | |
9174 #define USE_REDRAW 9 | |
9175 | |
9176 /* | |
9177 * insert lines on the screen and update ScreenLines[] | |
9178 * 'end' is the line after the scrolled part. Normally it is Rows. | |
9179 * When scrolling region used 'off' is the offset from the top for the region. | |
9180 * 'row' and 'end' are relative to the start of the region. | |
9181 * | |
9182 * return FAIL for failure, OK for success. | |
9183 */ | |
446 | 9184 int |
7 | 9185 screen_ins_lines(off, row, line_count, end, wp) |
9186 int off; | |
9187 int row; | |
9188 int line_count; | |
9189 int end; | |
9190 win_T *wp; /* NULL or window to use width from */ | |
9191 { | |
9192 int i; | |
9193 int j; | |
9194 unsigned temp; | |
9195 int cursor_row; | |
9196 int type; | |
9197 int result_empty; | |
9198 int can_ce = can_clear(T_CE); | |
9199 | |
9200 /* | |
9201 * FAIL if | |
9202 * - there is no valid screen | |
9203 * - the screen has to be redrawn completely | |
9204 * - the line count is less than one | |
9205 * - the line count is more than 'ttyscroll' | |
9206 */ | |
9207 if (!screen_valid(TRUE) || line_count <= 0 || line_count > p_ttyscroll) | |
9208 return FAIL; | |
9209 | |
9210 /* | |
9211 * There are seven ways to insert lines: | |
9212 * 0. When in a vertically split window and t_CV isn't set, redraw the | |
9213 * characters from ScreenLines[]. | |
9214 * 1. Use T_CD (clear to end of display) if it exists and the result of | |
9215 * the insert is just empty lines | |
9216 * 2. Use T_CAL (insert multiple lines) if it exists and T_AL is not | |
9217 * present or line_count > 1. It looks better if we do all the inserts | |
9218 * at once. | |
9219 * 3. Use T_CDL (delete multiple lines) if it exists and the result of the | |
9220 * insert is just empty lines and T_CE is not present or line_count > | |
9221 * 1. | |
9222 * 4. Use T_AL (insert line) if it exists. | |
9223 * 5. Use T_CE (erase line) if it exists and the result of the insert is | |
9224 * just empty lines. | |
9225 * 6. Use T_DL (delete line) if it exists and the result of the insert is | |
9226 * just empty lines. | |
9227 * 7. Use T_SR (scroll reverse) if it exists and inserting at row 0 and | |
9228 * the 'da' flag is not set or we have clear line capability. | |
9229 * 8. redraw the characters from ScreenLines[]. | |
9230 * | |
9231 * Careful: In a hpterm scroll reverse doesn't work as expected, it moves | |
9232 * the scrollbar for the window. It does have insert line, use that if it | |
9233 * exists. | |
9234 */ | |
9235 result_empty = (row + line_count >= end); | |
9236 #ifdef FEAT_VERTSPLIT | |
9237 if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL) | |
9238 type = USE_REDRAW; | |
9239 else | |
9240 #endif | |
9241 if (can_clear(T_CD) && result_empty) | |
9242 type = USE_T_CD; | |
9243 else if (*T_CAL != NUL && (line_count > 1 || *T_AL == NUL)) | |
9244 type = USE_T_CAL; | |
9245 else if (*T_CDL != NUL && result_empty && (line_count > 1 || !can_ce)) | |
9246 type = USE_T_CDL; | |
9247 else if (*T_AL != NUL) | |
9248 type = USE_T_AL; | |
9249 else if (can_ce && result_empty) | |
9250 type = USE_T_CE; | |
9251 else if (*T_DL != NUL && result_empty) | |
9252 type = USE_T_DL; | |
9253 else if (*T_SR != NUL && row == 0 && (*T_DA == NUL || can_ce)) | |
9254 type = USE_T_SR; | |
9255 else | |
9256 return FAIL; | |
9257 | |
9258 /* | |
9259 * For clearing the lines screen_del_lines() is used. This will also take | |
9260 * care of t_db if necessary. | |
9261 */ | |
9262 if (type == USE_T_CD || type == USE_T_CDL || | |
9263 type == USE_T_CE || type == USE_T_DL) | |
9264 return screen_del_lines(off, row, line_count, end, FALSE, wp); | |
9265 | |
9266 /* | |
9267 * If text is retained below the screen, first clear or delete as many | |
9268 * lines at the bottom of the window as are about to be inserted so that | |
9269 * the deleted lines won't later surface during a screen_del_lines. | |
9270 */ | |
9271 if (*T_DB) | |
9272 screen_del_lines(off, end - line_count, line_count, end, FALSE, wp); | |
9273 | |
9274 #ifdef FEAT_CLIPBOARD | |
9275 /* Remove a modeless selection when inserting lines halfway the screen | |
9276 * or not the full width of the screen. */ | |
9277 if (off + row > 0 | |
9278 # ifdef FEAT_VERTSPLIT | |
9279 || (wp != NULL && wp->w_width != Columns) | |
9280 # endif | |
9281 ) | |
3674 | 9282 clip_clear_selection(&clip_star); |
7 | 9283 else |
9284 clip_scroll_selection(-line_count); | |
9285 #endif | |
9286 | |
9287 #ifdef FEAT_GUI | |
9288 /* Don't update the GUI cursor here, ScreenLines[] is invalid until the | |
9289 * scrolling is actually carried out. */ | |
9290 gui_dont_update_cursor(); | |
9291 #endif | |
9292 | |
9293 if (*T_CCS != NUL) /* cursor relative to region */ | |
9294 cursor_row = row; | |
9295 else | |
9296 cursor_row = row + off; | |
9297 | |
9298 /* | |
9299 * Shift LineOffset[] line_count down to reflect the inserted lines. | |
9300 * Clear the inserted lines in ScreenLines[]. | |
9301 */ | |
9302 row += off; | |
9303 end += off; | |
9304 for (i = 0; i < line_count; ++i) | |
9305 { | |
9306 #ifdef FEAT_VERTSPLIT | |
9307 if (wp != NULL && wp->w_width != Columns) | |
9308 { | |
9309 /* need to copy part of a line */ | |
9310 j = end - 1 - i; | |
9311 while ((j -= line_count) >= row) | |
9312 linecopy(j + line_count, j, wp); | |
9313 j += line_count; | |
9314 if (can_clear((char_u *)" ")) | |
9315 lineclear(LineOffset[j] + wp->w_wincol, wp->w_width); | |
9316 else | |
9317 lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width); | |
9318 LineWraps[j] = FALSE; | |
9319 } | |
9320 else | |
9321 #endif | |
9322 { | |
9323 j = end - 1 - i; | |
9324 temp = LineOffset[j]; | |
9325 while ((j -= line_count) >= row) | |
9326 { | |
9327 LineOffset[j + line_count] = LineOffset[j]; | |
9328 LineWraps[j + line_count] = LineWraps[j]; | |
9329 } | |
9330 LineOffset[j + line_count] = temp; | |
9331 LineWraps[j + line_count] = FALSE; | |
9332 if (can_clear((char_u *)" ")) | |
9333 lineclear(temp, (int)Columns); | |
9334 else | |
9335 lineinvalid(temp, (int)Columns); | |
9336 } | |
9337 } | |
9338 | |
9339 screen_stop_highlight(); | |
9340 windgoto(cursor_row, 0); | |
9341 | |
9342 #ifdef FEAT_VERTSPLIT | |
9343 /* redraw the characters */ | |
9344 if (type == USE_REDRAW) | |
9345 redraw_block(row, end, wp); | |
9346 else | |
9347 #endif | |
9348 if (type == USE_T_CAL) | |
9349 { | |
9350 term_append_lines(line_count); | |
9351 screen_start(); /* don't know where cursor is now */ | |
9352 } | |
9353 else | |
9354 { | |
9355 for (i = 0; i < line_count; i++) | |
9356 { | |
9357 if (type == USE_T_AL) | |
9358 { | |
9359 if (i && cursor_row != 0) | |
9360 windgoto(cursor_row, 0); | |
9361 out_str(T_AL); | |
9362 } | |
9363 else /* type == USE_T_SR */ | |
9364 out_str(T_SR); | |
9365 screen_start(); /* don't know where cursor is now */ | |
9366 } | |
9367 } | |
9368 | |
9369 /* | |
9370 * With scroll-reverse and 'da' flag set we need to clear the lines that | |
9371 * have been scrolled down into the region. | |
9372 */ | |
9373 if (type == USE_T_SR && *T_DA) | |
9374 { | |
9375 for (i = 0; i < line_count; ++i) | |
9376 { | |
9377 windgoto(off + i, 0); | |
9378 out_str(T_CE); | |
9379 screen_start(); /* don't know where cursor is now */ | |
9380 } | |
9381 } | |
9382 | |
9383 #ifdef FEAT_GUI | |
9384 gui_can_update_cursor(); | |
9385 if (gui.in_use) | |
9386 out_flush(); /* always flush after a scroll */ | |
9387 #endif | |
9388 return OK; | |
9389 } | |
9390 | |
9391 /* | |
9392 * delete lines on the screen and update ScreenLines[] | |
9393 * 'end' is the line after the scrolled part. Normally it is Rows. | |
9394 * When scrolling region used 'off' is the offset from the top for the region. | |
9395 * 'row' and 'end' are relative to the start of the region. | |
9396 * | |
9397 * Return OK for success, FAIL if the lines are not deleted. | |
9398 */ | |
9399 int | |
9400 screen_del_lines(off, row, line_count, end, force, wp) | |
9401 int off; | |
9402 int row; | |
9403 int line_count; | |
9404 int end; | |
9405 int force; /* even when line_count > p_ttyscroll */ | |
1883 | 9406 win_T *wp UNUSED; /* NULL or window to use width from */ |
7 | 9407 { |
9408 int j; | |
9409 int i; | |
9410 unsigned temp; | |
9411 int cursor_row; | |
9412 int cursor_end; | |
9413 int result_empty; /* result is empty until end of region */ | |
9414 int can_delete; /* deleting line codes can be used */ | |
9415 int type; | |
9416 | |
9417 /* | |
9418 * FAIL if | |
9419 * - there is no valid screen | |
9420 * - the screen has to be redrawn completely | |
9421 * - the line count is less than one | |
9422 * - the line count is more than 'ttyscroll' | |
9423 */ | |
9424 if (!screen_valid(TRUE) || line_count <= 0 || | |
9425 (!force && line_count > p_ttyscroll)) | |
9426 return FAIL; | |
9427 | |
9428 /* | |
9429 * Check if the rest of the current region will become empty. | |
9430 */ | |
9431 result_empty = row + line_count >= end; | |
9432 | |
9433 /* | |
9434 * We can delete lines only when 'db' flag not set or when 'ce' option | |
9435 * available. | |
9436 */ | |
9437 can_delete = (*T_DB == NUL || can_clear(T_CE)); | |
9438 | |
9439 /* | |
9440 * There are six ways to delete lines: | |
9441 * 0. When in a vertically split window and t_CV isn't set, redraw the | |
9442 * characters from ScreenLines[]. | |
9443 * 1. Use T_CD if it exists and the result is empty. | |
9444 * 2. Use newlines if row == 0 and count == 1 or T_CDL does not exist. | |
9445 * 3. Use T_CDL (delete multiple lines) if it exists and line_count > 1 or | |
9446 * none of the other ways work. | |
9447 * 4. Use T_CE (erase line) if the result is empty. | |
9448 * 5. Use T_DL (delete line) if it exists. | |
9449 * 6. redraw the characters from ScreenLines[]. | |
9450 */ | |
9451 #ifdef FEAT_VERTSPLIT | |
9452 if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL) | |
9453 type = USE_REDRAW; | |
9454 else | |
9455 #endif | |
9456 if (can_clear(T_CD) && result_empty) | |
9457 type = USE_T_CD; | |
9458 #if defined(__BEOS__) && defined(BEOS_DR8) | |
9459 /* | |
9460 * USE_NL does not seem to work in Terminal of DR8 so we set T_DB="" in | |
9461 * its internal termcap... this works okay for tests which test *T_DB != | |
9462 * NUL. It has the disadvantage that the user cannot use any :set t_* | |
9463 * command to get T_DB (back) to empty_option, only :set term=... will do | |
9464 * the trick... | |
9465 * Anyway, this hack will hopefully go away with the next OS release. | |
9466 * (Olaf Seibert) | |
9467 */ | |
9468 else if (row == 0 && T_DB == empty_option | |
9469 && (line_count == 1 || *T_CDL == NUL)) | |
9470 #else | |
9471 else if (row == 0 && ( | |
9472 #ifndef AMIGA | |
9473 /* On the Amiga, somehow '\n' on the last line doesn't always scroll | |
9474 * up, so use delete-line command */ | |
9475 line_count == 1 || | |
9476 #endif | |
9477 *T_CDL == NUL)) | |
9478 #endif | |
9479 type = USE_NL; | |
9480 else if (*T_CDL != NUL && line_count > 1 && can_delete) | |
9481 type = USE_T_CDL; | |
9482 else if (can_clear(T_CE) && result_empty | |
9483 #ifdef FEAT_VERTSPLIT | |
9484 && (wp == NULL || wp->w_width == Columns) | |
9485 #endif | |
9486 ) | |
9487 type = USE_T_CE; | |
9488 else if (*T_DL != NUL && can_delete) | |
9489 type = USE_T_DL; | |
9490 else if (*T_CDL != NUL && can_delete) | |
9491 type = USE_T_CDL; | |
9492 else | |
9493 return FAIL; | |
9494 | |
9495 #ifdef FEAT_CLIPBOARD | |
9496 /* Remove a modeless selection when deleting lines halfway the screen or | |
9497 * not the full width of the screen. */ | |
9498 if (off + row > 0 | |
9499 # ifdef FEAT_VERTSPLIT | |
9500 || (wp != NULL && wp->w_width != Columns) | |
9501 # endif | |
9502 ) | |
3674 | 9503 clip_clear_selection(&clip_star); |
7 | 9504 else |
9505 clip_scroll_selection(line_count); | |
9506 #endif | |
9507 | |
9508 #ifdef FEAT_GUI | |
9509 /* Don't update the GUI cursor here, ScreenLines[] is invalid until the | |
9510 * scrolling is actually carried out. */ | |
9511 gui_dont_update_cursor(); | |
9512 #endif | |
9513 | |
9514 if (*T_CCS != NUL) /* cursor relative to region */ | |
9515 { | |
9516 cursor_row = row; | |
9517 cursor_end = end; | |
9518 } | |
9519 else | |
9520 { | |
9521 cursor_row = row + off; | |
9522 cursor_end = end + off; | |
9523 } | |
9524 | |
9525 /* | |
9526 * Now shift LineOffset[] line_count up to reflect the deleted lines. | |
9527 * Clear the inserted lines in ScreenLines[]. | |
9528 */ | |
9529 row += off; | |
9530 end += off; | |
9531 for (i = 0; i < line_count; ++i) | |
9532 { | |
9533 #ifdef FEAT_VERTSPLIT | |
9534 if (wp != NULL && wp->w_width != Columns) | |
9535 { | |
9536 /* need to copy part of a line */ | |
9537 j = row + i; | |
9538 while ((j += line_count) <= end - 1) | |
9539 linecopy(j - line_count, j, wp); | |
9540 j -= line_count; | |
9541 if (can_clear((char_u *)" ")) | |
9542 lineclear(LineOffset[j] + wp->w_wincol, wp->w_width); | |
9543 else | |
9544 lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width); | |
9545 LineWraps[j] = FALSE; | |
9546 } | |
9547 else | |
9548 #endif | |
9549 { | |
9550 /* whole width, moving the line pointers is faster */ | |
9551 j = row + i; | |
9552 temp = LineOffset[j]; | |
9553 while ((j += line_count) <= end - 1) | |
9554 { | |
9555 LineOffset[j - line_count] = LineOffset[j]; | |
9556 LineWraps[j - line_count] = LineWraps[j]; | |
9557 } | |
9558 LineOffset[j - line_count] = temp; | |
9559 LineWraps[j - line_count] = FALSE; | |
9560 if (can_clear((char_u *)" ")) | |
9561 lineclear(temp, (int)Columns); | |
9562 else | |
9563 lineinvalid(temp, (int)Columns); | |
9564 } | |
9565 } | |
9566 | |
9567 screen_stop_highlight(); | |
9568 | |
9569 #ifdef FEAT_VERTSPLIT | |
9570 /* redraw the characters */ | |
9571 if (type == USE_REDRAW) | |
9572 redraw_block(row, end, wp); | |
9573 else | |
9574 #endif | |
9575 if (type == USE_T_CD) /* delete the lines */ | |
9576 { | |
9577 windgoto(cursor_row, 0); | |
9578 out_str(T_CD); | |
9579 screen_start(); /* don't know where cursor is now */ | |
9580 } | |
9581 else if (type == USE_T_CDL) | |
9582 { | |
9583 windgoto(cursor_row, 0); | |
9584 term_delete_lines(line_count); | |
9585 screen_start(); /* don't know where cursor is now */ | |
9586 } | |
9587 /* | |
9588 * Deleting lines at top of the screen or scroll region: Just scroll | |
9589 * the whole screen (scroll region) up by outputting newlines on the | |
9590 * last line. | |
9591 */ | |
9592 else if (type == USE_NL) | |
9593 { | |
9594 windgoto(cursor_end - 1, 0); | |
9595 for (i = line_count; --i >= 0; ) | |
9596 out_char('\n'); /* cursor will remain on same line */ | |
9597 } | |
9598 else | |
9599 { | |
9600 for (i = line_count; --i >= 0; ) | |
9601 { | |
9602 if (type == USE_T_DL) | |
9603 { | |
9604 windgoto(cursor_row, 0); | |
9605 out_str(T_DL); /* delete a line */ | |
9606 } | |
9607 else /* type == USE_T_CE */ | |
9608 { | |
9609 windgoto(cursor_row + i, 0); | |
9610 out_str(T_CE); /* erase a line */ | |
9611 } | |
9612 screen_start(); /* don't know where cursor is now */ | |
9613 } | |
9614 } | |
9615 | |
9616 /* | |
9617 * If the 'db' flag is set, we need to clear the lines that have been | |
9618 * scrolled up at the bottom of the region. | |
9619 */ | |
9620 if (*T_DB && (type == USE_T_DL || type == USE_T_CDL)) | |
9621 { | |
9622 for (i = line_count; i > 0; --i) | |
9623 { | |
9624 windgoto(cursor_end - i, 0); | |
9625 out_str(T_CE); /* erase a line */ | |
9626 screen_start(); /* don't know where cursor is now */ | |
9627 } | |
9628 } | |
9629 | |
9630 #ifdef FEAT_GUI | |
9631 gui_can_update_cursor(); | |
9632 if (gui.in_use) | |
9633 out_flush(); /* always flush after a scroll */ | |
9634 #endif | |
9635 | |
9636 return OK; | |
9637 } | |
9638 | |
9639 /* | |
9640 * show the current mode and ruler | |
9641 * | |
9642 * If clear_cmdline is TRUE, clear the rest of the cmdline. | |
9643 * If clear_cmdline is FALSE there may be a message there that needs to be | |
9644 * cleared only if a mode is shown. | |
9645 * Return the length of the message (0 if no message). | |
9646 */ | |
9647 int | |
9648 showmode() | |
9649 { | |
9650 int need_clear; | |
9651 int length = 0; | |
9652 int do_mode; | |
9653 int attr; | |
9654 int nwr_save; | |
9655 #ifdef FEAT_INS_EXPAND | |
9656 int sub_attr; | |
9657 #endif | |
9658 | |
642 | 9659 do_mode = ((p_smd && msg_silent == 0) |
9660 && ((State & INSERT) | |
9661 || restart_edit | |
7 | 9662 #ifdef FEAT_VISUAL |
9663 || VIsual_active | |
9664 #endif | |
9665 )); | |
9666 if (do_mode || Recording) | |
9667 { | |
9668 /* | |
9669 * Don't show mode right now, when not redrawing or inside a mapping. | |
9670 * Call char_avail() only when we are going to show something, because | |
9671 * it takes a bit of time. | |
9672 */ | |
9673 if (!redrawing() || (char_avail() && !KeyTyped) || msg_silent != 0) | |
9674 { | |
9675 redraw_cmdline = TRUE; /* show mode later */ | |
9676 return 0; | |
9677 } | |
9678 | |
9679 nwr_save = need_wait_return; | |
9680 | |
9681 /* wait a bit before overwriting an important message */ | |
9682 check_for_delay(FALSE); | |
9683 | |
9684 /* if the cmdline is more than one line high, erase top lines */ | |
9685 need_clear = clear_cmdline; | |
9686 if (clear_cmdline && cmdline_row < Rows - 1) | |
9687 msg_clr_cmdline(); /* will reset clear_cmdline */ | |
9688 | |
9689 /* Position on the last line in the window, column 0 */ | |
9690 msg_pos_mode(); | |
9691 cursor_off(); | |
9692 attr = hl_attr(HLF_CM); /* Highlight mode */ | |
9693 if (do_mode) | |
9694 { | |
9695 MSG_PUTS_ATTR("--", attr); | |
9696 #if defined(FEAT_XIM) | |
2520 | 9697 if ( |
9698 # ifdef FEAT_GUI_GTK | |
9699 preedit_get_status() | |
1668 | 9700 # else |
9701 im_get_status() | |
2520 | 9702 # endif |
1668 | 9703 ) |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2269
diff
changeset
|
9704 # ifdef FEAT_GUI_GTK /* most of the time, it's not XIM being used */ |
7 | 9705 MSG_PUTS_ATTR(" IM", attr); |
9706 # else | |
9707 MSG_PUTS_ATTR(" XIM", attr); | |
9708 # endif | |
9709 #endif | |
9710 #if defined(FEAT_HANGULIN) && defined(FEAT_GUI) | |
9711 if (gui.in_use) | |
9712 { | |
9713 if (hangul_input_state_get()) | |
236 | 9714 MSG_PUTS_ATTR(" \307\321\261\333", attr); /* HANGUL */ |
7 | 9715 } |
9716 #endif | |
9717 #ifdef FEAT_INS_EXPAND | |
9718 if (edit_submode != NULL) /* CTRL-X in Insert mode */ | |
9719 { | |
9720 /* These messages can get long, avoid a wrap in a narrow | |
9721 * window. Prefer showing edit_submode_extra. */ | |
9722 length = (Rows - msg_row) * Columns - 3; | |
9723 if (edit_submode_extra != NULL) | |
9724 length -= vim_strsize(edit_submode_extra); | |
9725 if (length > 0) | |
9726 { | |
9727 if (edit_submode_pre != NULL) | |
9728 length -= vim_strsize(edit_submode_pre); | |
9729 if (length - vim_strsize(edit_submode) > 0) | |
9730 { | |
9731 if (edit_submode_pre != NULL) | |
9732 msg_puts_attr(edit_submode_pre, attr); | |
9733 msg_puts_attr(edit_submode, attr); | |
9734 } | |
9735 if (edit_submode_extra != NULL) | |
9736 { | |
9737 MSG_PUTS_ATTR(" ", attr); /* add a space in between */ | |
9738 if ((int)edit_submode_highl < (int)HLF_COUNT) | |
9739 sub_attr = hl_attr(edit_submode_highl); | |
9740 else | |
9741 sub_attr = attr; | |
9742 msg_puts_attr(edit_submode_extra, sub_attr); | |
9743 } | |
9744 } | |
9745 length = 0; | |
9746 } | |
9747 else | |
9748 #endif | |
9749 { | |
9750 #ifdef FEAT_VREPLACE | |
9751 if (State & VREPLACE_FLAG) | |
9752 MSG_PUTS_ATTR(_(" VREPLACE"), attr); | |
9753 else | |
9754 #endif | |
9755 if (State & REPLACE_FLAG) | |
9756 MSG_PUTS_ATTR(_(" REPLACE"), attr); | |
9757 else if (State & INSERT) | |
9758 { | |
9759 #ifdef FEAT_RIGHTLEFT | |
9760 if (p_ri) | |
9761 MSG_PUTS_ATTR(_(" REVERSE"), attr); | |
9762 #endif | |
9763 MSG_PUTS_ATTR(_(" INSERT"), attr); | |
9764 } | |
9765 else if (restart_edit == 'I') | |
9766 MSG_PUTS_ATTR(_(" (insert)"), attr); | |
9767 else if (restart_edit == 'R') | |
9768 MSG_PUTS_ATTR(_(" (replace)"), attr); | |
9769 else if (restart_edit == 'V') | |
9770 MSG_PUTS_ATTR(_(" (vreplace)"), attr); | |
9771 #ifdef FEAT_RIGHTLEFT | |
9772 if (p_hkmap) | |
9773 MSG_PUTS_ATTR(_(" Hebrew"), attr); | |
9774 # ifdef FEAT_FKMAP | |
9775 if (p_fkmap) | |
9776 MSG_PUTS_ATTR(farsi_text_5, attr); | |
9777 # endif | |
9778 #endif | |
9779 #ifdef FEAT_KEYMAP | |
9780 if (State & LANGMAP) | |
9781 { | |
9782 # ifdef FEAT_ARABIC | |
9783 if (curwin->w_p_arab) | |
9784 MSG_PUTS_ATTR(_(" Arabic"), attr); | |
9785 else | |
9786 # endif | |
9787 MSG_PUTS_ATTR(_(" (lang)"), attr); | |
9788 } | |
9789 #endif | |
9790 if ((State & INSERT) && p_paste) | |
9791 MSG_PUTS_ATTR(_(" (paste)"), attr); | |
9792 | |
9793 #ifdef FEAT_VISUAL | |
9794 if (VIsual_active) | |
9795 { | |
9796 char *p; | |
9797 | |
9798 /* Don't concatenate separate words to avoid translation | |
9799 * problems. */ | |
9800 switch ((VIsual_select ? 4 : 0) | |
9801 + (VIsual_mode == Ctrl_V) * 2 | |
9802 + (VIsual_mode == 'V')) | |
9803 { | |
9804 case 0: p = N_(" VISUAL"); break; | |
9805 case 1: p = N_(" VISUAL LINE"); break; | |
9806 case 2: p = N_(" VISUAL BLOCK"); break; | |
9807 case 4: p = N_(" SELECT"); break; | |
9808 case 5: p = N_(" SELECT LINE"); break; | |
9809 default: p = N_(" SELECT BLOCK"); break; | |
9810 } | |
9811 MSG_PUTS_ATTR(_(p), attr); | |
9812 } | |
9813 #endif | |
9814 MSG_PUTS_ATTR(" --", attr); | |
9815 } | |
644 | 9816 |
7 | 9817 need_clear = TRUE; |
9818 } | |
9819 if (Recording | |
9820 #ifdef FEAT_INS_EXPAND | |
9821 && edit_submode == NULL /* otherwise it gets too long */ | |
9822 #endif | |
9823 ) | |
9824 { | |
9825 MSG_PUTS_ATTR(_("recording"), attr); | |
9826 need_clear = TRUE; | |
9827 } | |
644 | 9828 |
9829 mode_displayed = TRUE; | |
7 | 9830 if (need_clear || clear_cmdline) |
9831 msg_clr_eos(); | |
9832 msg_didout = FALSE; /* overwrite this message */ | |
9833 length = msg_col; | |
9834 msg_col = 0; | |
9835 need_wait_return = nwr_save; /* never ask for hit-return for this */ | |
9836 } | |
9837 else if (clear_cmdline && msg_silent == 0) | |
9838 /* Clear the whole command line. Will reset "clear_cmdline". */ | |
9839 msg_clr_cmdline(); | |
9840 | |
9841 #ifdef FEAT_CMDL_INFO | |
9842 # ifdef FEAT_VISUAL | |
9843 /* In Visual mode the size of the selected area must be redrawn. */ | |
9844 if (VIsual_active) | |
9845 clear_showcmd(); | |
9846 # endif | |
9847 | |
9848 /* If the last window has no status line, the ruler is after the mode | |
9849 * message and must be redrawn */ | |
9850 if (redrawing() | |
9851 # ifdef FEAT_WINDOWS | |
9852 && lastwin->w_status_height == 0 | |
9853 # endif | |
9854 ) | |
9855 win_redr_ruler(lastwin, TRUE); | |
9856 #endif | |
9857 redraw_cmdline = FALSE; | |
9858 clear_cmdline = FALSE; | |
9859 | |
9860 return length; | |
9861 } | |
9862 | |
9863 /* | |
9864 * Position for a mode message. | |
9865 */ | |
9866 static void | |
9867 msg_pos_mode() | |
9868 { | |
9869 msg_col = 0; | |
9870 msg_row = Rows - 1; | |
9871 } | |
9872 | |
9873 /* | |
9874 * Delete mode message. Used when ESC is typed which is expected to end | |
9875 * Insert mode (but Insert mode didn't end yet!). | |
644 | 9876 * Caller should check "mode_displayed". |
7 | 9877 */ |
9878 void | |
9879 unshowmode(force) | |
9880 int force; | |
9881 { | |
9882 /* | |
2055
4aa4510d548c
updated for version 7.2.341
Bram Moolenaar <bram@zimbu.org>
parents:
2008
diff
changeset
|
9883 * Don't delete it right now, when not redrawing or inside a mapping. |
7 | 9884 */ |
9885 if (!redrawing() || (!force && char_avail() && !KeyTyped)) | |
9886 redraw_cmdline = TRUE; /* delete mode later */ | |
9887 else | |
9888 { | |
9889 msg_pos_mode(); | |
9890 if (Recording) | |
9891 MSG_PUTS_ATTR(_("recording"), hl_attr(HLF_CM)); | |
9892 msg_clr_eos(); | |
9893 } | |
9894 } | |
9895 | |
667 | 9896 #if defined(FEAT_WINDOWS) |
9897 /* | |
9898 * Draw the tab pages line at the top of the Vim window. | |
9899 */ | |
9900 static void | |
677 | 9901 draw_tabline() |
667 | 9902 { |
9903 int tabcount = 0; | |
9904 tabpage_T *tp; | |
9905 int tabwidth; | |
9906 int col = 0; | |
673 | 9907 int scol = 0; |
667 | 9908 int attr; |
9909 win_T *wp; | |
671 | 9910 win_T *cwp; |
9911 int wincount; | |
9912 int modified; | |
667 | 9913 int c; |
9914 int len; | |
9915 int attr_sel = hl_attr(HLF_TPS); | |
9916 int attr_nosel = hl_attr(HLF_TP); | |
9917 int attr_fill = hl_attr(HLF_TPF); | |
673 | 9918 char_u *p; |
677 | 9919 int room; |
9920 int use_sep_chars = (t_colors < 8 | |
9921 #ifdef FEAT_GUI | |
9922 && !gui.in_use | |
9923 #endif | |
9924 ); | |
673 | 9925 |
9926 redraw_tabline = FALSE; | |
667 | 9927 |
685 | 9928 #ifdef FEAT_GUI_TABLINE |
798 | 9929 /* Take care of a GUI tabline. */ |
685 | 9930 if (gui_use_tabline()) |
9931 { | |
9932 gui_update_tabline(); | |
9933 return; | |
9934 } | |
9935 #endif | |
9936 | |
9937 if (tabline_height() < 1) | |
667 | 9938 return; |
9939 | |
677 | 9940 #if defined(FEAT_STL_OPT) |
681 | 9941 |
9942 /* Init TabPageIdxs[] to zero: Clicking outside of tabs has no effect. */ | |
9943 for (scol = 0; scol < Columns; ++scol) | |
9944 TabPageIdxs[scol] = 0; | |
9945 | |
677 | 9946 /* Use the 'tabline' option if it's set. */ |
9947 if (*p_tal != NUL) | |
9948 { | |
680 | 9949 int save_called_emsg = called_emsg; |
9950 | |
9951 /* Check for an error. If there is one we would loop in redrawing the | |
9952 * screen. Avoid that by making 'tabline' empty. */ | |
9953 called_emsg = FALSE; | |
677 | 9954 win_redr_custom(NULL, FALSE); |
680 | 9955 if (called_emsg) |
9956 set_string_option_direct((char_u *)"tabline", -1, | |
694 | 9957 (char_u *)"", OPT_FREE, SID_ERROR); |
680 | 9958 called_emsg |= save_called_emsg; |
9959 } | |
9960 else | |
9961 #endif | |
9962 { | |
9963 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) | |
9964 ++tabcount; | |
9965 | |
9966 tabwidth = (Columns - 1 + tabcount / 2) / tabcount; | |
9967 if (tabwidth < 6) | |
9968 tabwidth = 6; | |
9969 | |
9970 attr = attr_nosel; | |
9971 tabcount = 0; | |
681 | 9972 scol = 0; |
699 | 9973 for (tp = first_tabpage; tp != NULL && col < Columns - 4; |
9974 tp = tp->tp_next) | |
680 | 9975 { |
9976 scol = col; | |
9977 | |
9978 if (tp->tp_topframe == topframe) | |
9979 attr = attr_sel; | |
9980 if (use_sep_chars && col > 0) | |
9981 screen_putchar('|', 0, col++, attr); | |
9982 | |
9983 if (tp->tp_topframe != topframe) | |
9984 attr = attr_nosel; | |
9985 | |
9986 screen_putchar(' ', 0, col++, attr); | |
9987 | |
9988 if (tp == curtab) | |
9989 { | |
9990 cwp = curwin; | |
9991 wp = firstwin; | |
9992 } | |
9993 else | |
9994 { | |
9995 cwp = tp->tp_curwin; | |
9996 wp = tp->tp_firstwin; | |
9997 } | |
9998 | |
9999 modified = FALSE; | |
10000 for (wincount = 0; wp != NULL; wp = wp->w_next, ++wincount) | |
10001 if (bufIsChanged(wp->w_buffer)) | |
10002 modified = TRUE; | |
10003 if (modified || wincount > 1) | |
10004 { | |
10005 if (wincount > 1) | |
10006 { | |
10007 vim_snprintf((char *)NameBuff, MAXPATHL, "%d", wincount); | |
835 | 10008 len = (int)STRLEN(NameBuff); |
699 | 10009 if (col + len >= Columns - 3) |
10010 break; | |
680 | 10011 screen_puts_len(NameBuff, len, 0, col, |
677 | 10012 #if defined(FEAT_SYN_HL) |
680 | 10013 hl_combine_attr(attr, hl_attr(HLF_T)) |
677 | 10014 #else |
680 | 10015 attr |
10016 #endif | |
10017 ); | |
10018 col += len; | |
10019 } | |
10020 if (modified) | |
10021 screen_puts_len((char_u *)"+", 1, 0, col++, attr); | |
10022 screen_putchar(' ', 0, col++, attr); | |
10023 } | |
10024 | |
10025 room = scol - col + tabwidth - 1; | |
10026 if (room > 0) | |
10027 { | |
685 | 10028 /* Get buffer name in NameBuff[] */ |
10029 get_trans_bufname(cwp->w_buffer); | |
819 | 10030 shorten_dir(NameBuff); |
680 | 10031 len = vim_strsize(NameBuff); |
10032 p = NameBuff; | |
677 | 10033 #ifdef FEAT_MBYTE |
680 | 10034 if (has_mbyte) |
10035 while (len > room) | |
10036 { | |
10037 len -= ptr2cells(p); | |
10038 mb_ptr_adv(p); | |
10039 } | |
10040 else | |
10041 #endif | |
10042 if (len > room) | |
677 | 10043 { |
680 | 10044 p += len - room; |
10045 len = room; | |
677 | 10046 } |
699 | 10047 if (len > Columns - col - 1) |
10048 len = Columns - col - 1; | |
680 | 10049 |
835 | 10050 screen_puts_len(p, (int)STRLEN(p), 0, col, attr); |
680 | 10051 col += len; |
10052 } | |
10053 screen_putchar(' ', 0, col++, attr); | |
10054 | |
10055 /* Store the tab page number in TabPageIdxs[], so that | |
10056 * jump_to_mouse() knows where each one is. */ | |
10057 ++tabcount; | |
10058 while (scol < col) | |
10059 TabPageIdxs[scol++] = tabcount; | |
10060 } | |
10061 | |
10062 if (use_sep_chars) | |
10063 c = '_'; | |
10064 else | |
10065 c = ' '; | |
10066 screen_fill(0, 1, col, (int)Columns, c, c, attr_fill); | |
681 | 10067 |
10068 /* Put an "X" for closing the current tab if there are several. */ | |
10069 if (first_tabpage->tp_next != NULL) | |
10070 { | |
10071 screen_putchar('X', 0, (int)Columns - 1, attr_nosel); | |
10072 TabPageIdxs[Columns - 1] = -999; | |
10073 } | |
10074 } | |
834 | 10075 |
10076 /* Reset the flag here again, in case evaluating 'tabline' causes it to be | |
10077 * set. */ | |
10078 redraw_tabline = FALSE; | |
667 | 10079 } |
685 | 10080 |
10081 /* | |
10082 * Get buffer name for "buf" into NameBuff[]. | |
10083 * Takes care of special buffer names and translates special characters. | |
10084 */ | |
10085 void | |
10086 get_trans_bufname(buf) | |
10087 buf_T *buf; | |
10088 { | |
10089 if (buf_spname(buf) != NULL) | |
3839 | 10090 vim_strncpy(NameBuff, buf_spname(buf), MAXPATHL - 1); |
685 | 10091 else |
10092 home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE); | |
10093 trans_characters(NameBuff, MAXPATHL); | |
10094 } | |
667 | 10095 #endif |
10096 | |
7 | 10097 #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT) |
10098 /* | |
10099 * Get the character to use in a status line. Get its attributes in "*attr". | |
10100 */ | |
10101 static int | |
10102 fillchar_status(attr, is_curwin) | |
10103 int *attr; | |
10104 int is_curwin; | |
10105 { | |
10106 int fill; | |
10107 if (is_curwin) | |
10108 { | |
10109 *attr = hl_attr(HLF_S); | |
10110 fill = fill_stl; | |
10111 } | |
10112 else | |
10113 { | |
10114 *attr = hl_attr(HLF_SNC); | |
10115 fill = fill_stlnc; | |
10116 } | |
10117 /* Use fill when there is highlighting, and highlighting of current | |
10118 * window differs, or the fillchars differ, or this is not the | |
10119 * current window */ | |
10120 if (*attr != 0 && ((hl_attr(HLF_S) != hl_attr(HLF_SNC) | |
10121 || !is_curwin || firstwin == lastwin) | |
10122 || (fill_stl != fill_stlnc))) | |
10123 return fill; | |
10124 if (is_curwin) | |
10125 return '^'; | |
10126 return '='; | |
10127 } | |
10128 #endif | |
10129 | |
10130 #ifdef FEAT_VERTSPLIT | |
10131 /* | |
10132 * Get the character to use in a separator between vertically split windows. | |
10133 * Get its attributes in "*attr". | |
10134 */ | |
10135 static int | |
10136 fillchar_vsep(attr) | |
10137 int *attr; | |
10138 { | |
10139 *attr = hl_attr(HLF_C); | |
10140 if (*attr == 0 && fill_vert == ' ') | |
10141 return '|'; | |
10142 else | |
10143 return fill_vert; | |
10144 } | |
10145 #endif | |
10146 | |
10147 /* | |
10148 * Return TRUE if redrawing should currently be done. | |
10149 */ | |
10150 int | |
10151 redrawing() | |
10152 { | |
10153 return (!RedrawingDisabled | |
10154 && !(p_lz && char_avail() && !KeyTyped && !do_redraw)); | |
10155 } | |
10156 | |
10157 /* | |
10158 * Return TRUE if printing messages should currently be done. | |
10159 */ | |
10160 int | |
10161 messaging() | |
10162 { | |
10163 return (!(p_lz && char_avail() && !KeyTyped)); | |
10164 } | |
10165 | |
10166 /* | |
10167 * Show current status info in ruler and various other places | |
10168 * If always is FALSE, only show ruler if position has changed. | |
10169 */ | |
10170 void | |
10171 showruler(always) | |
10172 int always; | |
10173 { | |
10174 if (!always && !redrawing()) | |
10175 return; | |
574 | 10176 #ifdef FEAT_INS_EXPAND |
10177 if (pum_visible()) | |
10178 { | |
639 | 10179 # ifdef FEAT_WINDOWS |
574 | 10180 /* Don't redraw right now, do it later. */ |
10181 curwin->w_redr_status = TRUE; | |
639 | 10182 # endif |
574 | 10183 return; |
10184 } | |
10185 #endif | |
7 | 10186 #if defined(FEAT_STL_OPT) && defined(FEAT_WINDOWS) |
40 | 10187 if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height) |
680 | 10188 { |
1983 | 10189 redraw_custom_statusline(curwin); |
680 | 10190 } |
7 | 10191 else |
10192 #endif | |
10193 #ifdef FEAT_CMDL_INFO | |
10194 win_redr_ruler(curwin, always); | |
10195 #endif | |
10196 | |
10197 #ifdef FEAT_TITLE | |
10198 if (need_maketitle | |
10199 # ifdef FEAT_STL_OPT | |
10200 || (p_icon && (stl_syntax & STL_IN_ICON)) | |
10201 || (p_title && (stl_syntax & STL_IN_TITLE)) | |
10202 # endif | |
10203 ) | |
10204 maketitle(); | |
10205 #endif | |
1588 | 10206 #ifdef FEAT_WINDOWS |
10207 /* Redraw the tab pages line if needed. */ | |
10208 if (redraw_tabline) | |
10209 draw_tabline(); | |
10210 #endif | |
7 | 10211 } |
10212 | |
10213 #ifdef FEAT_CMDL_INFO | |
10214 static void | |
10215 win_redr_ruler(wp, always) | |
10216 win_T *wp; | |
10217 int always; | |
10218 { | |
1869 | 10219 #define RULER_BUF_LEN 70 |
10220 char_u buffer[RULER_BUF_LEN]; | |
7 | 10221 int row; |
10222 int fillchar; | |
10223 int attr; | |
10224 int empty_line = FALSE; | |
10225 colnr_T virtcol; | |
10226 int i; | |
1869 | 10227 size_t len; |
7 | 10228 int o; |
10229 #ifdef FEAT_VERTSPLIT | |
10230 int this_ru_col; | |
10231 int off = 0; | |
10232 int width = Columns; | |
10233 # define WITH_OFF(x) x | |
10234 # define WITH_WIDTH(x) x | |
10235 #else | |
10236 # define WITH_OFF(x) 0 | |
10237 # define WITH_WIDTH(x) Columns | |
10238 # define this_ru_col ru_col | |
10239 #endif | |
10240 | |
10241 /* If 'ruler' off or redrawing disabled, don't do anything */ | |
10242 if (!p_ru) | |
10243 return; | |
10244 | |
10245 /* | |
10246 * Check if cursor.lnum is valid, since win_redr_ruler() may be called | |
10247 * after deleting lines, before cursor.lnum is corrected. | |
10248 */ | |
10249 if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count) | |
10250 return; | |
10251 | |
10252 #ifdef FEAT_INS_EXPAND | |
10253 /* Don't draw the ruler while doing insert-completion, it might overwrite | |
10254 * the (long) mode message. */ | |
10255 # ifdef FEAT_WINDOWS | |
10256 if (wp == lastwin && lastwin->w_status_height == 0) | |
10257 # endif | |
10258 if (edit_submode != NULL) | |
10259 return; | |
540 | 10260 /* Don't draw the ruler when the popup menu is visible, it may overlap. */ |
10261 if (pum_visible()) | |
10262 return; | |
7 | 10263 #endif |
10264 | |
10265 #ifdef FEAT_STL_OPT | |
10266 if (*p_ruf) | |
10267 { | |
680 | 10268 int save_called_emsg = called_emsg; |
10269 | |
10270 called_emsg = FALSE; | |
7 | 10271 win_redr_custom(wp, TRUE); |
680 | 10272 if (called_emsg) |
10273 set_string_option_direct((char_u *)"rulerformat", -1, | |
694 | 10274 (char_u *)"", OPT_FREE, SID_ERROR); |
680 | 10275 called_emsg |= save_called_emsg; |
7 | 10276 return; |
10277 } | |
10278 #endif | |
10279 | |
10280 /* | |
10281 * Check if not in Insert mode and the line is empty (will show "0-1"). | |
10282 */ | |
10283 if (!(State & INSERT) | |
10284 && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == NUL) | |
10285 empty_line = TRUE; | |
10286 | |
10287 /* | |
10288 * Only draw the ruler when something changed. | |
10289 */ | |
10290 validate_virtcol_win(wp); | |
10291 if ( redraw_cmdline | |
10292 || always | |
10293 || wp->w_cursor.lnum != wp->w_ru_cursor.lnum | |
10294 || wp->w_cursor.col != wp->w_ru_cursor.col | |
10295 || wp->w_virtcol != wp->w_ru_virtcol | |
10296 #ifdef FEAT_VIRTUALEDIT | |
10297 || wp->w_cursor.coladd != wp->w_ru_cursor.coladd | |
10298 #endif | |
10299 || wp->w_topline != wp->w_ru_topline | |
10300 || wp->w_buffer->b_ml.ml_line_count != wp->w_ru_line_count | |
10301 #ifdef FEAT_DIFF | |
10302 || wp->w_topfill != wp->w_ru_topfill | |
10303 #endif | |
10304 || empty_line != wp->w_ru_empty) | |
10305 { | |
10306 cursor_off(); | |
10307 #ifdef FEAT_WINDOWS | |
10308 if (wp->w_status_height) | |
10309 { | |
10310 row = W_WINROW(wp) + wp->w_height; | |
10311 fillchar = fillchar_status(&attr, wp == curwin); | |
10312 # ifdef FEAT_VERTSPLIT | |
10313 off = W_WINCOL(wp); | |
10314 width = W_WIDTH(wp); | |
10315 # endif | |
10316 } | |
10317 else | |
10318 #endif | |
10319 { | |
10320 row = Rows - 1; | |
10321 fillchar = ' '; | |
10322 attr = 0; | |
10323 #ifdef FEAT_VERTSPLIT | |
10324 width = Columns; | |
10325 off = 0; | |
10326 #endif | |
10327 } | |
10328 | |
10329 /* In list mode virtcol needs to be recomputed */ | |
10330 virtcol = wp->w_virtcol; | |
10331 if (wp->w_p_list && lcs_tab1 == NUL) | |
10332 { | |
10333 wp->w_p_list = FALSE; | |
10334 getvvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL); | |
10335 wp->w_p_list = TRUE; | |
10336 } | |
10337 | |
10338 /* | |
10339 * Some sprintfs return the length, some return a pointer. | |
10340 * To avoid portability problems we use strlen() here. | |
10341 */ | |
1869 | 10342 vim_snprintf((char *)buffer, RULER_BUF_LEN, "%ld,", |
7 | 10343 (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) |
10344 ? 0L | |
10345 : (long)(wp->w_cursor.lnum)); | |
1869 | 10346 len = STRLEN(buffer); |
10347 col_print(buffer + len, RULER_BUF_LEN - len, | |
7 | 10348 empty_line ? 0 : (int)wp->w_cursor.col + 1, |
10349 (int)virtcol + 1); | |
10350 | |
10351 /* | |
10352 * Add a "50%" if there is room for it. | |
10353 * On the last line, don't print in the last column (scrolls the | |
10354 * screen up on some terminals). | |
10355 */ | |
10356 i = (int)STRLEN(buffer); | |
1869 | 10357 get_rel_pos(wp, buffer + i + 1, RULER_BUF_LEN - i - 1); |
7 | 10358 o = i + vim_strsize(buffer + i + 1); |
10359 #ifdef FEAT_WINDOWS | |
10360 if (wp->w_status_height == 0) /* can't use last char of screen */ | |
10361 #endif | |
10362 ++o; | |
10363 #ifdef FEAT_VERTSPLIT | |
10364 this_ru_col = ru_col - (Columns - width); | |
10365 if (this_ru_col < 0) | |
10366 this_ru_col = 0; | |
10367 #endif | |
10368 /* Never use more than half the window/screen width, leave the other | |
10369 * half for the filename. */ | |
10370 if (this_ru_col < (WITH_WIDTH(width) + 1) / 2) | |
10371 this_ru_col = (WITH_WIDTH(width) + 1) / 2; | |
10372 if (this_ru_col + o < WITH_WIDTH(width)) | |
10373 { | |
10374 while (this_ru_col + o < WITH_WIDTH(width)) | |
10375 { | |
10376 #ifdef FEAT_MBYTE | |
10377 if (has_mbyte) | |
10378 i += (*mb_char2bytes)(fillchar, buffer + i); | |
10379 else | |
10380 #endif | |
10381 buffer[i++] = fillchar; | |
10382 ++o; | |
10383 } | |
1869 | 10384 get_rel_pos(wp, buffer + i, RULER_BUF_LEN - i); |
7 | 10385 } |
10386 /* Truncate at window boundary. */ | |
10387 #ifdef FEAT_MBYTE | |
10388 if (has_mbyte) | |
10389 { | |
10390 o = 0; | |
474 | 10391 for (i = 0; buffer[i] != NUL; i += (*mb_ptr2len)(buffer + i)) |
7 | 10392 { |
10393 o += (*mb_ptr2cells)(buffer + i); | |
10394 if (this_ru_col + o > WITH_WIDTH(width)) | |
10395 { | |
10396 buffer[i] = NUL; | |
10397 break; | |
10398 } | |
10399 } | |
10400 } | |
10401 else | |
10402 #endif | |
10403 if (this_ru_col + (int)STRLEN(buffer) > WITH_WIDTH(width)) | |
10404 buffer[WITH_WIDTH(width) - this_ru_col] = NUL; | |
10405 | |
10406 screen_puts(buffer, row, this_ru_col + WITH_OFF(off), attr); | |
10407 i = redraw_cmdline; | |
10408 screen_fill(row, row + 1, | |
10409 this_ru_col + WITH_OFF(off) + (int)STRLEN(buffer), | |
10410 (int)(WITH_OFF(off) + WITH_WIDTH(width)), | |
10411 fillchar, fillchar, attr); | |
10412 /* don't redraw the cmdline because of showing the ruler */ | |
10413 redraw_cmdline = i; | |
10414 wp->w_ru_cursor = wp->w_cursor; | |
10415 wp->w_ru_virtcol = wp->w_virtcol; | |
10416 wp->w_ru_empty = empty_line; | |
10417 wp->w_ru_topline = wp->w_topline; | |
10418 wp->w_ru_line_count = wp->w_buffer->b_ml.ml_line_count; | |
10419 #ifdef FEAT_DIFF | |
10420 wp->w_ru_topfill = wp->w_topfill; | |
10421 #endif | |
10422 } | |
10423 } | |
10424 #endif | |
13 | 10425 |
10426 #if defined(FEAT_LINEBREAK) || defined(PROTO) | |
10427 /* | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
10428 * Return the width of the 'number' and 'relativenumber' column. |
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
10429 * Caller may need to check if 'number' or 'relativenumber' is set. |
13 | 10430 * Otherwise it depends on 'numberwidth' and the line count. |
10431 */ | |
10432 int | |
10433 number_width(wp) | |
10434 win_T *wp; | |
10435 { | |
10436 int n; | |
10437 linenr_T lnum; | |
10438 | |
4736
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
10439 if (wp->w_p_rnu && !wp->w_p_nu) |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
10440 /* cursor line shows "0" */ |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
10441 lnum = wp->w_height; |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
10442 else |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
10443 /* cursor line shows absolute line number */ |
3f2319a953b3
updated for version 7.3.1115
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
10444 lnum = wp->w_buffer->b_ml.ml_line_count; |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2124
diff
changeset
|
10445 |
13 | 10446 if (lnum == wp->w_nrwidth_line_count) |
10447 return wp->w_nrwidth_width; | |
10448 wp->w_nrwidth_line_count = lnum; | |
10449 | |
10450 n = 0; | |
10451 do | |
10452 { | |
856 | 10453 lnum /= 10; |
10454 ++n; | |
13 | 10455 } while (lnum > 0); |
10456 | |
10457 /* 'numberwidth' gives the minimal width plus one */ | |
10458 if (n < wp->w_p_nuw - 1) | |
10459 n = wp->w_p_nuw - 1; | |
10460 | |
10461 wp->w_nrwidth_width = n; | |
10462 return n; | |
10463 } | |
10464 #endif | |
3986 | 10465 |
10466 /* | |
10467 * Return the current cursor column. This is the actual position on the | |
10468 * screen. First column is 0. | |
10469 */ | |
10470 int | |
10471 screen_screencol() | |
10472 { | |
10473 return screen_cur_col; | |
10474 } | |
10475 | |
10476 /* | |
10477 * Return the current cursor row. This is the actual position on the screen. | |
10478 * First row is 0. | |
10479 */ | |
10480 int | |
10481 screen_screenrow() | |
10482 { | |
10483 return screen_cur_row; | |
10484 } |