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
|
|
28 * character without composing chars ScreenLinesUC[] will be 0. When the
|
|
29 * character occupies two display cells the next byte in ScreenLines[] is 0.
|
714
|
30 * ScreenLinesC[][] contain up to 'maxcombine' composing characters
|
7
|
31 * (drawn on top of the first character). They are 0 when not used.
|
|
32 * ScreenLines2[] is only used for euc-jp to store the second byte if the
|
|
33 * first byte is 0x8e (single-width character).
|
|
34 *
|
|
35 * The screen_*() functions write to the screen and handle updating
|
|
36 * ScreenLines[].
|
|
37 *
|
|
38 * update_screen() is the function that updates all windows and status lines.
|
|
39 * It is called form the main loop when must_redraw is non-zero. It may be
|
1213
|
40 * called from other places when an immediate screen update is needed.
|
7
|
41 *
|
|
42 * The part of the buffer that is displayed in a window is set with:
|
|
43 * - w_topline (first buffer line in window)
|
|
44 * - w_topfill (filler line above the first line)
|
|
45 * - w_leftcol (leftmost window cell in window),
|
|
46 * - w_skipcol (skipped window cells of first line)
|
|
47 *
|
|
48 * Commands that only move the cursor around in a window, do not need to take
|
|
49 * action to update the display. The main loop will check if w_topline is
|
|
50 * valid and update it (scroll the window) when needed.
|
|
51 *
|
|
52 * Commands that scroll a window change w_topline and must call
|
|
53 * check_cursor() to move the cursor into the visible part of the window, and
|
|
54 * call redraw_later(VALID) to have the window displayed by update_screen()
|
|
55 * later.
|
|
56 *
|
|
57 * Commands that change text in the buffer must call changed_bytes() or
|
|
58 * changed_lines() to mark the area that changed and will require updating
|
|
59 * later. The main loop will call update_screen(), which will update each
|
|
60 * window that shows the changed buffer. This assumes text above the change
|
|
61 * can remain displayed as it is. Text after the change may need updating for
|
|
62 * scrolling, folding and syntax highlighting.
|
|
63 *
|
|
64 * Commands that change how a window is displayed (e.g., setting 'list') or
|
|
65 * invalidate the contents of a window in another way (e.g., change fold
|
|
66 * settings), must call redraw_later(NOT_VALID) to have the whole window
|
|
67 * redisplayed by update_screen() later.
|
|
68 *
|
|
69 * Commands that change how a buffer is displayed (e.g., setting 'tabstop')
|
|
70 * must call redraw_curbuf_later(NOT_VALID) to have all the windows for the
|
|
71 * buffer redisplayed by update_screen() later.
|
|
72 *
|
743
|
73 * Commands that change highlighting and possibly cause a scroll too must call
|
|
74 * redraw_later(SOME_VALID) to update the whole window but still use scrolling
|
|
75 * to avoid redrawing everything. But the length of displayed lines must not
|
|
76 * change, use NOT_VALID then.
|
|
77 *
|
7
|
78 * Commands that move the window position must call redraw_later(NOT_VALID).
|
|
79 * TODO: should minimize redrawing by scrolling when possible.
|
|
80 *
|
|
81 * Commands that change everything (e.g., resizing the screen) must call
|
|
82 * redraw_all_later(NOT_VALID) or redraw_all_later(CLEAR).
|
|
83 *
|
|
84 * Things that are handled indirectly:
|
|
85 * - When messages scroll the screen up, msg_scrolled will be set and
|
|
86 * update_screen() called to redraw.
|
|
87 */
|
|
88
|
|
89 #include "vim.h"
|
|
90
|
|
91 /*
|
|
92 * The attributes that are actually active for writing to the screen.
|
|
93 */
|
|
94 static int screen_attr = 0;
|
|
95
|
|
96 /*
|
|
97 * Positioning the cursor is reduced by remembering the last position.
|
|
98 * Mostly used by windgoto() and screen_char().
|
|
99 */
|
|
100 static int screen_cur_row, screen_cur_col; /* last known cursor position */
|
|
101
|
|
102 #ifdef FEAT_SEARCH_EXTRA
|
|
103 static match_T search_hl; /* used for 'hlsearch' highlight matching */
|
|
104 #endif
|
|
105
|
|
106 #ifdef FEAT_FOLDING
|
|
107 static foldinfo_T win_foldinfo; /* info for 'foldcolumn' */
|
|
108 #endif
|
|
109
|
|
110 /*
|
|
111 * Buffer for one screen line (characters and attributes).
|
|
112 */
|
|
113 static schar_T *current_ScreenLine;
|
|
114
|
|
115 static void win_update __ARGS((win_T *wp));
|
534
|
116 static void win_draw_end __ARGS((win_T *wp, int c1, int c2, int row, int endrow, hlf_T hl));
|
7
|
117 #ifdef FEAT_FOLDING
|
|
118 static void fold_line __ARGS((win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T lnum, int row));
|
|
119 static void fill_foldcolumn __ARGS((char_u *p, win_T *wp, int closed, linenr_T lnum));
|
|
120 static void copy_text_attr __ARGS((int off, char_u *buf, int len, int attr));
|
|
121 #endif
|
625
|
122 static int win_line __ARGS((win_T *, linenr_T, int, int, int nochange));
|
7
|
123 static int char_needs_redraw __ARGS((int off_from, int off_to, int cols));
|
|
124 #ifdef FEAT_RIGHTLEFT
|
|
125 static void screen_line __ARGS((int row, int coloff, int endcol, int clear_width, int rlflag));
|
|
126 # define SCREEN_LINE(r, o, e, c, rl) screen_line((r), (o), (e), (c), (rl))
|
|
127 #else
|
|
128 static void screen_line __ARGS((int row, int coloff, int endcol, int clear_width));
|
|
129 # define SCREEN_LINE(r, o, e, c, rl) screen_line((r), (o), (e), (c))
|
|
130 #endif
|
|
131 #ifdef FEAT_VERTSPLIT
|
|
132 static void draw_vsep_win __ARGS((win_T *wp, int row));
|
|
133 #endif
|
680
|
134 #ifdef FEAT_STL_OPT
|
|
135 static void redraw_custum_statusline __ARGS((win_T *wp));
|
|
136 #endif
|
7
|
137 #ifdef FEAT_SEARCH_EXTRA
|
1326
|
138 #define SEARCH_HL_PRIORITY 0
|
7
|
139 static void start_search_hl __ARGS((void));
|
|
140 static void end_search_hl __ARGS((void));
|
|
141 static void prepare_search_hl __ARGS((win_T *wp, linenr_T lnum));
|
|
142 static void next_search_hl __ARGS((win_T *win, match_T *shl, linenr_T lnum, colnr_T mincol));
|
|
143 #endif
|
|
144 static void screen_start_highlight __ARGS((int attr));
|
|
145 static void screen_char __ARGS((unsigned off, int row, int col));
|
|
146 #ifdef FEAT_MBYTE
|
|
147 static void screen_char_2 __ARGS((unsigned off, int row, int col));
|
|
148 #endif
|
|
149 static void screenclear2 __ARGS((void));
|
|
150 static void lineclear __ARGS((unsigned off, int width));
|
|
151 static void lineinvalid __ARGS((unsigned off, int width));
|
|
152 #ifdef FEAT_VERTSPLIT
|
|
153 static void linecopy __ARGS((int to, int from, win_T *wp));
|
|
154 static void redraw_block __ARGS((int row, int end, win_T *wp));
|
|
155 #endif
|
|
156 static int win_do_lines __ARGS((win_T *wp, int row, int line_count, int mayclear, int del));
|
|
157 static void win_rest_invalid __ARGS((win_T *wp));
|
|
158 static void msg_pos_mode __ARGS((void));
|
667
|
159 #if defined(FEAT_WINDOWS)
|
677
|
160 static void draw_tabline __ARGS((void));
|
667
|
161 #endif
|
7
|
162 #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT)
|
|
163 static int fillchar_status __ARGS((int *attr, int is_curwin));
|
|
164 #endif
|
|
165 #ifdef FEAT_VERTSPLIT
|
|
166 static int fillchar_vsep __ARGS((int *attr));
|
|
167 #endif
|
|
168 #ifdef FEAT_STL_OPT
|
574
|
169 static void win_redr_custom __ARGS((win_T *wp, int draw_ruler));
|
7
|
170 #endif
|
|
171 #ifdef FEAT_CMDL_INFO
|
|
172 static void win_redr_ruler __ARGS((win_T *wp, int always));
|
|
173 #endif
|
|
174
|
|
175 #if defined(FEAT_CLIPBOARD) || defined(FEAT_VERTSPLIT)
|
|
176 /* Ugly global: overrule attribute used by screen_char() */
|
|
177 static int screen_char_attr = 0;
|
|
178 #endif
|
|
179
|
|
180 /*
|
|
181 * Redraw the current window later, with update_screen(type).
|
|
182 * Set must_redraw only if not already set to a higher value.
|
|
183 * e.g. if must_redraw is CLEAR, type NOT_VALID will do nothing.
|
|
184 */
|
|
185 void
|
|
186 redraw_later(type)
|
|
187 int type;
|
|
188 {
|
|
189 redraw_win_later(curwin, type);
|
|
190 }
|
|
191
|
|
192 void
|
|
193 redraw_win_later(wp, type)
|
|
194 win_T *wp;
|
|
195 int type;
|
|
196 {
|
|
197 if (wp->w_redr_type < type)
|
|
198 {
|
|
199 wp->w_redr_type = type;
|
|
200 if (type >= NOT_VALID)
|
|
201 wp->w_lines_valid = 0;
|
|
202 if (must_redraw < type) /* must_redraw is the maximum of all windows */
|
|
203 must_redraw = type;
|
|
204 }
|
|
205 }
|
|
206
|
|
207 /*
|
|
208 * Force a complete redraw later. Also resets the highlighting. To be used
|
|
209 * after executing a shell command that messes up the screen.
|
|
210 */
|
|
211 void
|
|
212 redraw_later_clear()
|
|
213 {
|
|
214 redraw_all_later(CLEAR);
|
826
|
215 #ifdef FEAT_GUI
|
|
216 if (gui.in_use)
|
|
217 /* Use a code that will reset gui.highlight_mask in
|
|
218 * gui_stop_highlight(). */
|
|
219 screen_attr = HL_ALL + 1;
|
|
220 else
|
|
221 #endif
|
|
222 /* Use attributes that is very unlikely to appear in text. */
|
|
223 screen_attr = HL_BOLD | HL_UNDERLINE | HL_INVERSE;
|
7
|
224 }
|
|
225
|
|
226 /*
|
|
227 * Mark all windows to be redrawn later.
|
|
228 */
|
|
229 void
|
|
230 redraw_all_later(type)
|
|
231 int type;
|
|
232 {
|
|
233 win_T *wp;
|
|
234
|
|
235 FOR_ALL_WINDOWS(wp)
|
|
236 {
|
|
237 redraw_win_later(wp, type);
|
|
238 }
|
|
239 }
|
|
240
|
|
241 /*
|
301
|
242 * Mark all windows that are editing the current buffer to be updated later.
|
7
|
243 */
|
|
244 void
|
|
245 redraw_curbuf_later(type)
|
|
246 int type;
|
|
247 {
|
|
248 redraw_buf_later(curbuf, type);
|
|
249 }
|
|
250
|
|
251 void
|
|
252 redraw_buf_later(buf, type)
|
|
253 buf_T *buf;
|
|
254 int type;
|
|
255 {
|
|
256 win_T *wp;
|
|
257
|
|
258 FOR_ALL_WINDOWS(wp)
|
|
259 {
|
|
260 if (wp->w_buffer == buf)
|
|
261 redraw_win_later(wp, type);
|
|
262 }
|
|
263 }
|
|
264
|
|
265 /*
|
|
266 * Changed something in the current window, at buffer line "lnum", that
|
|
267 * requires that line and possibly other lines to be redrawn.
|
|
268 * Used when entering/leaving Insert mode with the cursor on a folded line.
|
|
269 * Used to remove the "$" from a change command.
|
|
270 * Note that when also inserting/deleting lines w_redraw_top and w_redraw_bot
|
|
271 * may become invalid and the whole window will have to be redrawn.
|
|
272 */
|
|
273 /*ARGSUSED*/
|
|
274 void
|
|
275 redrawWinline(lnum, invalid)
|
|
276 linenr_T lnum;
|
|
277 int invalid; /* window line height is invalid now */
|
|
278 {
|
|
279 #ifdef FEAT_FOLDING
|
|
280 int i;
|
|
281 #endif
|
|
282
|
|
283 if (curwin->w_redraw_top == 0 || curwin->w_redraw_top > lnum)
|
|
284 curwin->w_redraw_top = lnum;
|
|
285 if (curwin->w_redraw_bot == 0 || curwin->w_redraw_bot < lnum)
|
|
286 curwin->w_redraw_bot = lnum;
|
|
287 redraw_later(VALID);
|
|
288
|
|
289 #ifdef FEAT_FOLDING
|
|
290 if (invalid)
|
|
291 {
|
|
292 /* A w_lines[] entry for this lnum has become invalid. */
|
|
293 i = find_wl_entry(curwin, lnum);
|
|
294 if (i >= 0)
|
|
295 curwin->w_lines[i].wl_valid = FALSE;
|
|
296 }
|
|
297 #endif
|
|
298 }
|
|
299
|
|
300 /*
|
|
301 * update all windows that are editing the current buffer
|
|
302 */
|
|
303 void
|
|
304 update_curbuf(type)
|
|
305 int type;
|
|
306 {
|
|
307 redraw_curbuf_later(type);
|
|
308 update_screen(type);
|
|
309 }
|
|
310
|
|
311 /*
|
|
312 * update_screen()
|
|
313 *
|
|
314 * Based on the current value of curwin->w_topline, transfer a screenfull
|
|
315 * of stuff from Filemem to ScreenLines[], and update curwin->w_botline.
|
|
316 */
|
|
317 void
|
|
318 update_screen(type)
|
|
319 int type;
|
|
320 {
|
|
321 win_T *wp;
|
|
322 static int did_intro = FALSE;
|
|
323 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
|
|
324 int did_one;
|
|
325 #endif
|
|
326
|
|
327 if (!screen_valid(TRUE))
|
|
328 return;
|
|
329
|
|
330 if (must_redraw)
|
|
331 {
|
|
332 if (type < must_redraw) /* use maximal type */
|
|
333 type = must_redraw;
|
|
334 must_redraw = 0;
|
|
335 }
|
|
336
|
|
337 /* Need to update w_lines[]. */
|
|
338 if (curwin->w_lines_valid == 0 && type < NOT_VALID)
|
|
339 type = NOT_VALID;
|
|
340
|
|
341 if (!redrawing())
|
|
342 {
|
|
343 redraw_later(type); /* remember type for next time */
|
|
344 must_redraw = type;
|
|
345 if (type > INVERTED_ALL)
|
|
346 curwin->w_lines_valid = 0; /* don't use w_lines[].wl_size now */
|
|
347 return;
|
|
348 }
|
|
349
|
|
350 updating_screen = TRUE;
|
|
351 #ifdef FEAT_SYN_HL
|
|
352 ++display_tick; /* let syntax code know we're in a next round of
|
|
353 * display updating */
|
|
354 #endif
|
|
355
|
|
356 /*
|
|
357 * if the screen was scrolled up when displaying a message, scroll it down
|
|
358 */
|
|
359 if (msg_scrolled)
|
|
360 {
|
|
361 clear_cmdline = TRUE;
|
|
362 if (msg_scrolled > Rows - 5) /* clearing is faster */
|
|
363 type = CLEAR;
|
|
364 else if (type != CLEAR)
|
|
365 {
|
|
366 check_for_delay(FALSE);
|
|
367 if (screen_ins_lines(0, 0, msg_scrolled, (int)Rows, NULL) == FAIL)
|
|
368 type = CLEAR;
|
|
369 FOR_ALL_WINDOWS(wp)
|
|
370 {
|
|
371 if (W_WINROW(wp) < msg_scrolled)
|
|
372 {
|
|
373 if (W_WINROW(wp) + wp->w_height > msg_scrolled
|
|
374 && wp->w_redr_type < REDRAW_TOP
|
|
375 && wp->w_lines_valid > 0
|
|
376 && wp->w_topline == wp->w_lines[0].wl_lnum)
|
|
377 {
|
|
378 wp->w_upd_rows = msg_scrolled - W_WINROW(wp);
|
|
379 wp->w_redr_type = REDRAW_TOP;
|
|
380 }
|
|
381 else
|
|
382 {
|
|
383 wp->w_redr_type = NOT_VALID;
|
|
384 #ifdef FEAT_WINDOWS
|
|
385 if (W_WINROW(wp) + wp->w_height + W_STATUS_HEIGHT(wp)
|
|
386 <= msg_scrolled)
|
|
387 wp->w_redr_status = TRUE;
|
|
388 #endif
|
|
389 }
|
|
390 }
|
|
391 }
|
|
392 redraw_cmdline = TRUE;
|
667
|
393 #ifdef FEAT_WINDOWS
|
673
|
394 redraw_tabline = TRUE;
|
667
|
395 #endif
|
7
|
396 }
|
|
397 msg_scrolled = 0;
|
|
398 need_wait_return = FALSE;
|
|
399 }
|
|
400
|
|
401 /* reset cmdline_row now (may have been changed temporarily) */
|
|
402 compute_cmdrow();
|
|
403
|
|
404 /* Check for changed highlighting */
|
|
405 if (need_highlight_changed)
|
|
406 highlight_changed();
|
|
407
|
|
408 if (type == CLEAR) /* first clear screen */
|
|
409 {
|
|
410 screenclear(); /* will reset clear_cmdline */
|
|
411 type = NOT_VALID;
|
|
412 }
|
|
413
|
|
414 if (clear_cmdline) /* going to clear cmdline (done below) */
|
|
415 check_for_delay(FALSE);
|
|
416
|
13
|
417 #ifdef FEAT_LINEBREAK
|
|
418 /* Force redraw when width of 'number' column changes. */
|
|
419 if (curwin->w_redr_type < NOT_VALID
|
677
|
420 && curwin->w_nrwidth != (curwin->w_p_nu ? number_width(curwin) : 0))
|
13
|
421 curwin->w_redr_type = NOT_VALID;
|
|
422 #endif
|
|
423
|
7
|
424 /*
|
|
425 * Only start redrawing if there is really something to do.
|
|
426 */
|
|
427 if (type == INVERTED)
|
|
428 update_curswant();
|
|
429 if (curwin->w_redr_type < type
|
|
430 && !((type == VALID
|
|
431 && curwin->w_lines[0].wl_valid
|
|
432 #ifdef FEAT_DIFF
|
|
433 && curwin->w_topfill == curwin->w_old_topfill
|
|
434 && curwin->w_botfill == curwin->w_old_botfill
|
|
435 #endif
|
|
436 && curwin->w_topline == curwin->w_lines[0].wl_lnum)
|
|
437 #ifdef FEAT_VISUAL
|
|
438 || (type == INVERTED
|
1043
|
439 && VIsual_active
|
7
|
440 && curwin->w_old_cursor_lnum == curwin->w_cursor.lnum
|
|
441 && curwin->w_old_visual_mode == VIsual_mode
|
|
442 && (curwin->w_valid & VALID_VIRTCOL)
|
|
443 && curwin->w_old_curswant == curwin->w_curswant)
|
|
444 #endif
|
|
445 ))
|
|
446 curwin->w_redr_type = type;
|
|
447
|
849
|
448 #ifdef FEAT_WINDOWS
|
|
449 /* Redraw the tab pages line if needed. */
|
|
450 if (redraw_tabline || type >= NOT_VALID)
|
|
451 draw_tabline();
|
|
452 #endif
|
|
453
|
7
|
454 #ifdef FEAT_SYN_HL
|
|
455 /*
|
|
456 * Correct stored syntax highlighting info for changes in each displayed
|
|
457 * buffer. Each buffer must only be done once.
|
|
458 */
|
|
459 FOR_ALL_WINDOWS(wp)
|
|
460 {
|
|
461 if (wp->w_buffer->b_mod_set)
|
|
462 {
|
|
463 # ifdef FEAT_WINDOWS
|
|
464 win_T *wwp;
|
|
465
|
|
466 /* Check if we already did this buffer. */
|
|
467 for (wwp = firstwin; wwp != wp; wwp = wwp->w_next)
|
|
468 if (wwp->w_buffer == wp->w_buffer)
|
|
469 break;
|
|
470 # endif
|
|
471 if (
|
|
472 # ifdef FEAT_WINDOWS
|
|
473 wwp == wp &&
|
|
474 # endif
|
|
475 syntax_present(wp->w_buffer))
|
|
476 syn_stack_apply_changes(wp->w_buffer);
|
|
477 }
|
|
478 }
|
|
479 #endif
|
|
480
|
|
481 /*
|
|
482 * Go from top to bottom through the windows, redrawing the ones that need
|
|
483 * it.
|
|
484 */
|
|
485 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
|
|
486 did_one = FALSE;
|
|
487 #endif
|
|
488 #ifdef FEAT_SEARCH_EXTRA
|
|
489 search_hl.rm.regprog = NULL;
|
|
490 #endif
|
|
491 FOR_ALL_WINDOWS(wp)
|
|
492 {
|
|
493 if (wp->w_redr_type != 0)
|
|
494 {
|
|
495 cursor_off();
|
|
496 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
|
|
497 if (!did_one)
|
|
498 {
|
|
499 did_one = TRUE;
|
|
500 # ifdef FEAT_SEARCH_EXTRA
|
|
501 start_search_hl();
|
|
502 # endif
|
|
503 # ifdef FEAT_CLIPBOARD
|
|
504 /* When Visual area changed, may have to update selection. */
|
|
505 if (clip_star.available && clip_isautosel())
|
|
506 clip_update_selection();
|
|
507 # endif
|
|
508 #ifdef FEAT_GUI
|
|
509 /* Remove the cursor before starting to do anything, because
|
|
510 * scrolling may make it difficult to redraw the text under
|
|
511 * it. */
|
|
512 if (gui.in_use)
|
|
513 gui_undraw_cursor();
|
|
514 #endif
|
|
515 }
|
|
516 #endif
|
|
517 win_update(wp);
|
|
518 }
|
|
519
|
|
520 #ifdef FEAT_WINDOWS
|
|
521 /* redraw status line after the window to minimize cursor movement */
|
|
522 if (wp->w_redr_status)
|
|
523 {
|
|
524 cursor_off();
|
|
525 win_redr_status(wp);
|
|
526 }
|
|
527 #endif
|
|
528 }
|
|
529 #if defined(FEAT_SEARCH_EXTRA)
|
|
530 end_search_hl();
|
|
531 #endif
|
|
532
|
|
533 #ifdef FEAT_WINDOWS
|
|
534 /* Reset b_mod_set flags. Going through all windows is probably faster
|
|
535 * than going through all buffers (there could be many buffers). */
|
|
536 for (wp = firstwin; wp != NULL; wp = wp->w_next)
|
|
537 wp->w_buffer->b_mod_set = FALSE;
|
|
538 #else
|
|
539 curbuf->b_mod_set = FALSE;
|
|
540 #endif
|
|
541
|
|
542 updating_screen = FALSE;
|
|
543 #ifdef FEAT_GUI
|
|
544 gui_may_resize_shell();
|
|
545 #endif
|
|
546
|
|
547 /* Clear or redraw the command line. Done last, because scrolling may
|
|
548 * mess up the command line. */
|
|
549 if (clear_cmdline || redraw_cmdline)
|
|
550 showmode();
|
|
551
|
|
552 /* May put up an introductory message when not editing a file */
|
|
553 if (!did_intro && bufempty()
|
|
554 && curbuf->b_fname == NULL
|
|
555 #ifdef FEAT_WINDOWS
|
|
556 && firstwin->w_next == NULL
|
|
557 #endif
|
|
558 && vim_strchr(p_shm, SHM_INTRO) == NULL)
|
|
559 intro_message(FALSE);
|
|
560 did_intro = TRUE;
|
|
561
|
|
562 #ifdef FEAT_GUI
|
|
563 /* Redraw the cursor and update the scrollbars when all screen updating is
|
|
564 * done. */
|
|
565 if (gui.in_use)
|
|
566 {
|
|
567 out_flush(); /* required before updating the cursor */
|
|
568 if (did_one)
|
|
569 gui_update_cursor(FALSE, FALSE);
|
|
570 gui_update_scrollbars(FALSE);
|
|
571 }
|
|
572 #endif
|
|
573 }
|
|
574
|
|
575 #if defined(FEAT_SIGNS) || defined(FEAT_GUI)
|
|
576 static void update_prepare __ARGS((void));
|
|
577 static void update_finish __ARGS((void));
|
|
578
|
|
579 /*
|
|
580 * Prepare for updating one or more windows.
|
|
581 */
|
|
582 static void
|
|
583 update_prepare()
|
|
584 {
|
|
585 cursor_off();
|
|
586 updating_screen = TRUE;
|
|
587 #ifdef FEAT_GUI
|
|
588 /* Remove the cursor before starting to do anything, because scrolling may
|
|
589 * make it difficult to redraw the text under it. */
|
|
590 if (gui.in_use)
|
|
591 gui_undraw_cursor();
|
|
592 #endif
|
|
593 #ifdef FEAT_SEARCH_EXTRA
|
|
594 start_search_hl();
|
|
595 #endif
|
|
596 }
|
|
597
|
|
598 /*
|
|
599 * Finish updating one or more windows.
|
|
600 */
|
|
601 static void
|
|
602 update_finish()
|
|
603 {
|
|
604 if (redraw_cmdline)
|
|
605 showmode();
|
|
606
|
|
607 # ifdef FEAT_SEARCH_EXTRA
|
|
608 end_search_hl();
|
|
609 # endif
|
|
610
|
|
611 updating_screen = FALSE;
|
|
612
|
|
613 # ifdef FEAT_GUI
|
|
614 gui_may_resize_shell();
|
|
615
|
|
616 /* Redraw the cursor and update the scrollbars when all screen updating is
|
|
617 * done. */
|
|
618 if (gui.in_use)
|
|
619 {
|
|
620 out_flush(); /* required before updating the cursor */
|
|
621 gui_update_cursor(FALSE, FALSE);
|
|
622 gui_update_scrollbars(FALSE);
|
|
623 }
|
|
624 # endif
|
|
625 }
|
|
626 #endif
|
|
627
|
|
628 #if defined(FEAT_SIGNS) || defined(PROTO)
|
|
629 void
|
|
630 update_debug_sign(buf, lnum)
|
|
631 buf_T *buf;
|
|
632 linenr_T lnum;
|
|
633 {
|
|
634 win_T *wp;
|
|
635 int doit = FALSE;
|
|
636
|
|
637 # ifdef FEAT_FOLDING
|
|
638 win_foldinfo.fi_level = 0;
|
|
639 # endif
|
|
640
|
|
641 /* update/delete a specific mark */
|
|
642 FOR_ALL_WINDOWS(wp)
|
|
643 {
|
|
644 if (buf != NULL && lnum > 0)
|
|
645 {
|
|
646 if (wp->w_buffer == buf && lnum >= wp->w_topline
|
|
647 && lnum < wp->w_botline)
|
|
648 {
|
|
649 if (wp->w_redraw_top == 0 || wp->w_redraw_top > lnum)
|
|
650 wp->w_redraw_top = lnum;
|
|
651 if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < lnum)
|
|
652 wp->w_redraw_bot = lnum;
|
|
653 redraw_win_later(wp, VALID);
|
|
654 }
|
|
655 }
|
|
656 else
|
|
657 redraw_win_later(wp, VALID);
|
|
658 if (wp->w_redr_type != 0)
|
|
659 doit = TRUE;
|
|
660 }
|
|
661
|
|
662 if (!doit)
|
|
663 return;
|
|
664
|
|
665 /* update all windows that need updating */
|
|
666 update_prepare();
|
|
667
|
|
668 # ifdef FEAT_WINDOWS
|
|
669 for (wp = firstwin; wp; wp = wp->w_next)
|
|
670 {
|
|
671 if (wp->w_redr_type != 0)
|
|
672 win_update(wp);
|
|
673 if (wp->w_redr_status)
|
|
674 win_redr_status(wp);
|
|
675 }
|
|
676 # else
|
|
677 if (curwin->w_redr_type != 0)
|
|
678 win_update(curwin);
|
|
679 # endif
|
|
680
|
|
681 update_finish();
|
|
682 }
|
|
683 #endif
|
|
684
|
|
685
|
|
686 #if defined(FEAT_GUI) || defined(PROTO)
|
|
687 /*
|
|
688 * Update a single window, its status line and maybe the command line msg.
|
|
689 * Used for the GUI scrollbar.
|
|
690 */
|
|
691 void
|
|
692 updateWindow(wp)
|
|
693 win_T *wp;
|
|
694 {
|
|
695 update_prepare();
|
|
696
|
|
697 #ifdef FEAT_CLIPBOARD
|
|
698 /* When Visual area changed, may have to update selection. */
|
|
699 if (clip_star.available && clip_isautosel())
|
|
700 clip_update_selection();
|
|
701 #endif
|
670
|
702
|
7
|
703 win_update(wp);
|
670
|
704
|
7
|
705 #ifdef FEAT_WINDOWS
|
670
|
706 /* When the screen was cleared redraw the tab pages line. */
|
673
|
707 if (redraw_tabline)
|
677
|
708 draw_tabline();
|
670
|
709
|
7
|
710 if (wp->w_redr_status
|
|
711 # ifdef FEAT_CMDL_INFO
|
|
712 || p_ru
|
|
713 # endif
|
|
714 # ifdef FEAT_STL_OPT
|
40
|
715 || *p_stl != NUL || *wp->w_p_stl != NUL
|
7
|
716 # endif
|
|
717 )
|
|
718 win_redr_status(wp);
|
|
719 #endif
|
|
720
|
|
721 update_finish();
|
|
722 }
|
|
723 #endif
|
|
724
|
|
725 /*
|
|
726 * Update a single window.
|
|
727 *
|
|
728 * This may cause the windows below it also to be redrawn (when clearing the
|
|
729 * screen or scrolling lines).
|
|
730 *
|
|
731 * How the window is redrawn depends on wp->w_redr_type. Each type also
|
|
732 * implies the one below it.
|
|
733 * NOT_VALID redraw the whole window
|
743
|
734 * SOME_VALID redraw the whole window but do scroll when possible
|
7
|
735 * REDRAW_TOP redraw the top w_upd_rows window lines, otherwise like VALID
|
|
736 * INVERTED redraw the changed part of the Visual area
|
|
737 * INVERTED_ALL redraw the whole Visual area
|
|
738 * VALID 1. scroll up/down to adjust for a changed w_topline
|
|
739 * 2. update lines at the top when scrolled down
|
|
740 * 3. redraw changed text:
|
301
|
741 * - if wp->w_buffer->b_mod_set set, update lines between
|
7
|
742 * b_mod_top and b_mod_bot.
|
|
743 * - if wp->w_redraw_top non-zero, redraw lines between
|
|
744 * wp->w_redraw_top and wp->w_redr_bot.
|
|
745 * - continue redrawing when syntax status is invalid.
|
|
746 * 4. if scrolled up, update lines at the bottom.
|
|
747 * This results in three areas that may need updating:
|
|
748 * top: from first row to top_end (when scrolled down)
|
|
749 * mid: from mid_start to mid_end (update inversion or changed text)
|
|
750 * bot: from bot_start to last row (when scrolled up)
|
|
751 */
|
|
752 static void
|
|
753 win_update(wp)
|
|
754 win_T *wp;
|
|
755 {
|
|
756 buf_T *buf = wp->w_buffer;
|
|
757 int type;
|
|
758 int top_end = 0; /* Below last row of the top area that needs
|
|
759 updating. 0 when no top area updating. */
|
|
760 int mid_start = 999;/* first row of the mid area that needs
|
|
761 updating. 999 when no mid area updating. */
|
|
762 int mid_end = 0; /* Below last row of the mid area that needs
|
|
763 updating. 0 when no mid area updating. */
|
|
764 int bot_start = 999;/* first row of the bot area that needs
|
|
765 updating. 999 when no bot area updating */
|
|
766 #ifdef FEAT_VISUAL
|
|
767 int scrolled_down = FALSE; /* TRUE when scrolled down when
|
|
768 w_topline got smaller a bit */
|
|
769 #endif
|
|
770 #ifdef FEAT_SEARCH_EXTRA
|
1326
|
771 matchitem_T *cur; /* points to the match list */
|
7
|
772 int top_to_mod = FALSE; /* redraw above mod_top */
|
|
773 #endif
|
|
774
|
|
775 int row; /* current window row to display */
|
|
776 linenr_T lnum; /* current buffer lnum to display */
|
|
777 int idx; /* current index in w_lines[] */
|
|
778 int srow; /* starting row of the current line */
|
|
779
|
|
780 int eof = FALSE; /* if TRUE, we hit the end of the file */
|
|
781 int didline = FALSE; /* if TRUE, we finished the last line */
|
|
782 int i;
|
|
783 long j;
|
|
784 static int recursive = FALSE; /* being called recursively */
|
|
785 int old_botline = wp->w_botline;
|
|
786 #ifdef FEAT_FOLDING
|
|
787 long fold_count;
|
|
788 #endif
|
|
789 #ifdef FEAT_SYN_HL
|
|
790 /* remember what happened to the previous line, to know if
|
|
791 * check_visual_highlight() can be used */
|
|
792 #define DID_NONE 1 /* didn't update a line */
|
|
793 #define DID_LINE 2 /* updated a normal line */
|
|
794 #define DID_FOLD 3 /* updated a folded line */
|
|
795 int did_update = DID_NONE;
|
|
796 linenr_T syntax_last_parsed = 0; /* last parsed text line */
|
|
797 #endif
|
|
798 linenr_T mod_top = 0;
|
|
799 linenr_T mod_bot = 0;
|
|
800 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)
|
|
801 int save_got_int;
|
|
802 #endif
|
|
803
|
|
804 type = wp->w_redr_type;
|
|
805
|
|
806 if (type == NOT_VALID)
|
|
807 {
|
|
808 #ifdef FEAT_WINDOWS
|
|
809 wp->w_redr_status = TRUE;
|
|
810 #endif
|
|
811 wp->w_lines_valid = 0;
|
|
812 }
|
|
813
|
|
814 /* Window is zero-height: nothing to draw. */
|
|
815 if (wp->w_height == 0)
|
|
816 {
|
|
817 wp->w_redr_type = 0;
|
|
818 return;
|
|
819 }
|
|
820
|
|
821 #ifdef FEAT_VERTSPLIT
|
|
822 /* Window is zero-width: Only need to draw the separator. */
|
|
823 if (wp->w_width == 0)
|
|
824 {
|
|
825 /* draw the vertical separator right of this window */
|
|
826 draw_vsep_win(wp, 0);
|
|
827 wp->w_redr_type = 0;
|
|
828 return;
|
|
829 }
|
|
830 #endif
|
|
831
|
|
832 #ifdef FEAT_SEARCH_EXTRA
|
1326
|
833 /* Setup for match and 'hlsearch' highlighting. Disable any previous
|
699
|
834 * match */
|
1326
|
835 cur = wp->w_match_head;
|
|
836 while (cur != NULL)
|
|
837 {
|
|
838 cur->hl.rm = cur->match;
|
|
839 if (cur->hlg_id == 0)
|
|
840 cur->hl.attr = 0;
|
699
|
841 else
|
1326
|
842 cur->hl.attr = syn_id2attr(cur->hlg_id);
|
|
843 cur->hl.buf = buf;
|
|
844 cur->hl.lnum = 0;
|
|
845 cur->hl.first_lnum = 0;
|
|
846 cur = cur->next;
|
699
|
847 }
|
7
|
848 search_hl.buf = buf;
|
|
849 search_hl.lnum = 0;
|
|
850 search_hl.first_lnum = 0;
|
|
851 #endif
|
|
852
|
13
|
853 #ifdef FEAT_LINEBREAK
|
|
854 /* Force redraw when width of 'number' column changes. */
|
677
|
855 i = wp->w_p_nu ? number_width(wp) : 0;
|
|
856 if (wp->w_nrwidth != i)
|
13
|
857 {
|
|
858 type = NOT_VALID;
|
677
|
859 wp->w_nrwidth = i;
|
13
|
860 }
|
|
861 else
|
|
862 #endif
|
|
863
|
7
|
864 if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0)
|
|
865 {
|
|
866 /*
|
|
867 * When there are both inserted/deleted lines and specific lines to be
|
|
868 * redrawn, w_redraw_top and w_redraw_bot may be invalid, just redraw
|
|
869 * everything (only happens when redrawing is off for while).
|
|
870 */
|
|
871 type = NOT_VALID;
|
|
872 }
|
|
873 else
|
|
874 {
|
|
875 /*
|
|
876 * Set mod_top to the first line that needs displaying because of
|
|
877 * changes. Set mod_bot to the first line after the changes.
|
|
878 */
|
|
879 mod_top = wp->w_redraw_top;
|
|
880 if (wp->w_redraw_bot != 0)
|
|
881 mod_bot = wp->w_redraw_bot + 1;
|
|
882 else
|
|
883 mod_bot = 0;
|
|
884 wp->w_redraw_top = 0; /* reset for next time */
|
|
885 wp->w_redraw_bot = 0;
|
|
886 if (buf->b_mod_set)
|
|
887 {
|
|
888 if (mod_top == 0 || mod_top > buf->b_mod_top)
|
|
889 {
|
|
890 mod_top = buf->b_mod_top;
|
|
891 #ifdef FEAT_SYN_HL
|
|
892 /* Need to redraw lines above the change that may be included
|
|
893 * in a pattern match. */
|
|
894 if (syntax_present(buf))
|
|
895 {
|
|
896 mod_top -= buf->b_syn_sync_linebreaks;
|
|
897 if (mod_top < 1)
|
|
898 mod_top = 1;
|
|
899 }
|
|
900 #endif
|
|
901 }
|
|
902 if (mod_bot == 0 || mod_bot < buf->b_mod_bot)
|
|
903 mod_bot = buf->b_mod_bot;
|
|
904
|
|
905 #ifdef FEAT_SEARCH_EXTRA
|
|
906 /* When 'hlsearch' is on and using a multi-line search pattern, a
|
|
907 * change in one line may make the Search highlighting in a
|
|
908 * previous line invalid. Simple solution: redraw all visible
|
|
909 * lines above the change.
|
1326
|
910 * Same for a match pattern.
|
7
|
911 */
|
699
|
912 if (search_hl.rm.regprog != NULL
|
|
913 && re_multiline(search_hl.rm.regprog))
|
7
|
914 top_to_mod = TRUE;
|
699
|
915 else
|
1326
|
916 {
|
|
917 cur = wp->w_match_head;
|
|
918 while (cur != NULL)
|
|
919 {
|
|
920 if (cur->match.regprog != NULL
|
|
921 && re_multiline(cur->match.regprog))
|
699
|
922 {
|
|
923 top_to_mod = TRUE;
|
|
924 break;
|
|
925 }
|
1326
|
926 cur = cur->next;
|
|
927 }
|
|
928 }
|
7
|
929 #endif
|
|
930 }
|
|
931 #ifdef FEAT_FOLDING
|
|
932 if (mod_top != 0 && hasAnyFolding(wp))
|
|
933 {
|
|
934 linenr_T lnumt, lnumb;
|
|
935
|
|
936 /*
|
|
937 * A change in a line can cause lines above it to become folded or
|
|
938 * unfolded. Find the top most buffer line that may be affected.
|
|
939 * If the line was previously folded and displayed, get the first
|
|
940 * line of that fold. If the line is folded now, get the first
|
|
941 * folded line. Use the minimum of these two.
|
|
942 */
|
|
943
|
|
944 /* Find last valid w_lines[] entry above mod_top. Set lnumt to
|
|
945 * the line below it. If there is no valid entry, use w_topline.
|
|
946 * Find the first valid w_lines[] entry below mod_bot. Set lnumb
|
|
947 * to this line. If there is no valid entry, use MAXLNUM. */
|
|
948 lnumt = wp->w_topline;
|
|
949 lnumb = MAXLNUM;
|
|
950 for (i = 0; i < wp->w_lines_valid; ++i)
|
|
951 if (wp->w_lines[i].wl_valid)
|
|
952 {
|
|
953 if (wp->w_lines[i].wl_lastlnum < mod_top)
|
|
954 lnumt = wp->w_lines[i].wl_lastlnum + 1;
|
|
955 if (lnumb == MAXLNUM && wp->w_lines[i].wl_lnum >= mod_bot)
|
|
956 {
|
|
957 lnumb = wp->w_lines[i].wl_lnum;
|
|
958 /* When there is a fold column it might need updating
|
|
959 * in the next line ("J" just above an open fold). */
|
|
960 if (wp->w_p_fdc > 0)
|
|
961 ++lnumb;
|
|
962 }
|
|
963 }
|
|
964
|
|
965 (void)hasFoldingWin(wp, mod_top, &mod_top, NULL, TRUE, NULL);
|
|
966 if (mod_top > lnumt)
|
|
967 mod_top = lnumt;
|
|
968
|
|
969 /* Now do the same for the bottom line (one above mod_bot). */
|
|
970 --mod_bot;
|
|
971 (void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, TRUE, NULL);
|
|
972 ++mod_bot;
|
|
973 if (mod_bot < lnumb)
|
|
974 mod_bot = lnumb;
|
|
975 }
|
|
976 #endif
|
|
977
|
|
978 /* When a change starts above w_topline and the end is below
|
|
979 * w_topline, start redrawing at w_topline.
|
36
|
980 * If the end of the change is above w_topline: do like no change was
|
|
981 * made, but redraw the first line to find changes in syntax. */
|
7
|
982 if (mod_top != 0 && mod_top < wp->w_topline)
|
|
983 {
|
|
984 if (mod_bot > wp->w_topline)
|
|
985 mod_top = wp->w_topline;
|
|
986 #ifdef FEAT_SYN_HL
|
|
987 else if (syntax_present(buf))
|
|
988 top_end = 1;
|
|
989 #endif
|
|
990 }
|
36
|
991
|
|
992 /* When line numbers are displayed need to redraw all lines below
|
|
993 * inserted/deleted lines. */
|
|
994 if (mod_top != 0 && buf->b_mod_xlines != 0 && wp->w_p_nu)
|
|
995 mod_bot = MAXLNUM;
|
7
|
996 }
|
|
997
|
|
998 /*
|
|
999 * When only displaying the lines at the top, set top_end. Used when
|
|
1000 * window has scrolled down for msg_scrolled.
|
|
1001 */
|
|
1002 if (type == REDRAW_TOP)
|
|
1003 {
|
|
1004 j = 0;
|
|
1005 for (i = 0; i < wp->w_lines_valid; ++i)
|
|
1006 {
|
|
1007 j += wp->w_lines[i].wl_size;
|
|
1008 if (j >= wp->w_upd_rows)
|
|
1009 {
|
|
1010 top_end = j;
|
|
1011 break;
|
|
1012 }
|
|
1013 }
|
|
1014 if (top_end == 0)
|
|
1015 /* not found (cannot happen?): redraw everything */
|
|
1016 type = NOT_VALID;
|
|
1017 else
|
|
1018 /* top area defined, the rest is VALID */
|
|
1019 type = VALID;
|
|
1020 }
|
|
1021
|
|
1022 /*
|
|
1023 * If there are no changes on the screen that require a complete redraw,
|
|
1024 * handle three cases:
|
|
1025 * 1: we are off the top of the screen by a few lines: scroll down
|
|
1026 * 2: wp->w_topline is below wp->w_lines[0].wl_lnum: may scroll up
|
|
1027 * 3: wp->w_topline is wp->w_lines[0].wl_lnum: find first entry in
|
|
1028 * w_lines[] that needs updating.
|
|
1029 */
|
743
|
1030 if ((type == VALID || type == SOME_VALID
|
|
1031 || type == INVERTED || type == INVERTED_ALL)
|
7
|
1032 #ifdef FEAT_DIFF
|
|
1033 && !wp->w_botfill && !wp->w_old_botfill
|
|
1034 #endif
|
|
1035 )
|
|
1036 {
|
|
1037 if (mod_top != 0 && wp->w_topline == mod_top)
|
|
1038 {
|
|
1039 /*
|
|
1040 * w_topline is the first changed line, the scrolling will be done
|
|
1041 * further down.
|
|
1042 */
|
|
1043 }
|
|
1044 else if (wp->w_lines[0].wl_valid
|
|
1045 && (wp->w_topline < wp->w_lines[0].wl_lnum
|
|
1046 #ifdef FEAT_DIFF
|
|
1047 || (wp->w_topline == wp->w_lines[0].wl_lnum
|
|
1048 && wp->w_topfill > wp->w_old_topfill)
|
|
1049 #endif
|
|
1050 ))
|
|
1051 {
|
|
1052 /*
|
|
1053 * New topline is above old topline: May scroll down.
|
|
1054 */
|
|
1055 #ifdef FEAT_FOLDING
|
|
1056 if (hasAnyFolding(wp))
|
|
1057 {
|
|
1058 linenr_T ln;
|
|
1059
|
|
1060 /* count the number of lines we are off, counting a sequence
|
|
1061 * of folded lines as one */
|
|
1062 j = 0;
|
|
1063 for (ln = wp->w_topline; ln < wp->w_lines[0].wl_lnum; ++ln)
|
|
1064 {
|
|
1065 ++j;
|
|
1066 if (j >= wp->w_height - 2)
|
|
1067 break;
|
|
1068 (void)hasFoldingWin(wp, ln, NULL, &ln, TRUE, NULL);
|
|
1069 }
|
|
1070 }
|
|
1071 else
|
|
1072 #endif
|
|
1073 j = wp->w_lines[0].wl_lnum - wp->w_topline;
|
|
1074 if (j < wp->w_height - 2) /* not too far off */
|
|
1075 {
|
|
1076 i = plines_m_win(wp, wp->w_topline, wp->w_lines[0].wl_lnum - 1);
|
|
1077 #ifdef FEAT_DIFF
|
|
1078 /* insert extra lines for previously invisible filler lines */
|
|
1079 if (wp->w_lines[0].wl_lnum != wp->w_topline)
|
|
1080 i += diff_check_fill(wp, wp->w_lines[0].wl_lnum)
|
|
1081 - wp->w_old_topfill;
|
|
1082 #endif
|
|
1083 if (i < wp->w_height - 2) /* less than a screen off */
|
|
1084 {
|
|
1085 /*
|
|
1086 * Try to insert the correct number of lines.
|
|
1087 * If not the last window, delete the lines at the bottom.
|
|
1088 * win_ins_lines may fail when the terminal can't do it.
|
|
1089 */
|
|
1090 if (i > 0)
|
|
1091 check_for_delay(FALSE);
|
|
1092 if (win_ins_lines(wp, 0, i, FALSE, wp == firstwin) == OK)
|
|
1093 {
|
|
1094 if (wp->w_lines_valid != 0)
|
|
1095 {
|
|
1096 /* Need to update rows that are new, stop at the
|
|
1097 * first one that scrolled down. */
|
|
1098 top_end = i;
|
|
1099 #ifdef FEAT_VISUAL
|
|
1100 scrolled_down = TRUE;
|
|
1101 #endif
|
|
1102
|
|
1103 /* Move the entries that were scrolled, disable
|
|
1104 * the entries for the lines to be redrawn. */
|
|
1105 if ((wp->w_lines_valid += j) > wp->w_height)
|
|
1106 wp->w_lines_valid = wp->w_height;
|
|
1107 for (idx = wp->w_lines_valid; idx - j >= 0; idx--)
|
|
1108 wp->w_lines[idx] = wp->w_lines[idx - j];
|
|
1109 while (idx >= 0)
|
|
1110 wp->w_lines[idx--].wl_valid = FALSE;
|
|
1111 }
|
|
1112 }
|
|
1113 else
|
|
1114 mid_start = 0; /* redraw all lines */
|
|
1115 }
|
|
1116 else
|
|
1117 mid_start = 0; /* redraw all lines */
|
|
1118 }
|
|
1119 else
|
|
1120 mid_start = 0; /* redraw all lines */
|
|
1121 }
|
|
1122 else
|
|
1123 {
|
|
1124 /*
|
|
1125 * New topline is at or below old topline: May scroll up.
|
|
1126 * When topline didn't change, find first entry in w_lines[] that
|
|
1127 * needs updating.
|
|
1128 */
|
|
1129
|
|
1130 /* try to find wp->w_topline in wp->w_lines[].wl_lnum */
|
|
1131 j = -1;
|
|
1132 row = 0;
|
|
1133 for (i = 0; i < wp->w_lines_valid; i++)
|
|
1134 {
|
|
1135 if (wp->w_lines[i].wl_valid
|
|
1136 && wp->w_lines[i].wl_lnum == wp->w_topline)
|
|
1137 {
|
|
1138 j = i;
|
|
1139 break;
|
|
1140 }
|
|
1141 row += wp->w_lines[i].wl_size;
|
|
1142 }
|
|
1143 if (j == -1)
|
|
1144 {
|
|
1145 /* if wp->w_topline is not in wp->w_lines[].wl_lnum redraw all
|
|
1146 * lines */
|
|
1147 mid_start = 0;
|
|
1148 }
|
|
1149 else
|
|
1150 {
|
|
1151 /*
|
|
1152 * Try to delete the correct number of lines.
|
|
1153 * wp->w_topline is at wp->w_lines[i].wl_lnum.
|
|
1154 */
|
|
1155 #ifdef FEAT_DIFF
|
|
1156 /* If the topline didn't change, delete old filler lines,
|
|
1157 * otherwise delete filler lines of the new topline... */
|
|
1158 if (wp->w_lines[0].wl_lnum == wp->w_topline)
|
|
1159 row += wp->w_old_topfill;
|
|
1160 else
|
|
1161 row += diff_check_fill(wp, wp->w_topline);
|
|
1162 /* ... but don't delete new filler lines. */
|
|
1163 row -= wp->w_topfill;
|
|
1164 #endif
|
|
1165 if (row > 0)
|
|
1166 {
|
|
1167 check_for_delay(FALSE);
|
|
1168 if (win_del_lines(wp, 0, row, FALSE, wp == firstwin) == OK)
|
|
1169 bot_start = wp->w_height - row;
|
|
1170 else
|
|
1171 mid_start = 0; /* redraw all lines */
|
|
1172 }
|
|
1173 if ((row == 0 || bot_start < 999) && wp->w_lines_valid != 0)
|
|
1174 {
|
|
1175 /*
|
|
1176 * Skip the lines (below the deleted lines) that are still
|
|
1177 * valid and don't need redrawing. Copy their info
|
|
1178 * upwards, to compensate for the deleted lines. Set
|
|
1179 * bot_start to the first row that needs redrawing.
|
|
1180 */
|
|
1181 bot_start = 0;
|
|
1182 idx = 0;
|
|
1183 for (;;)
|
|
1184 {
|
|
1185 wp->w_lines[idx] = wp->w_lines[j];
|
|
1186 /* stop at line that didn't fit, unless it is still
|
|
1187 * valid (no lines deleted) */
|
|
1188 if (row > 0 && bot_start + row
|
|
1189 + (int)wp->w_lines[j].wl_size > wp->w_height)
|
|
1190 {
|
|
1191 wp->w_lines_valid = idx + 1;
|
|
1192 break;
|
|
1193 }
|
|
1194 bot_start += wp->w_lines[idx++].wl_size;
|
|
1195
|
|
1196 /* stop at the last valid entry in w_lines[].wl_size */
|
|
1197 if (++j >= wp->w_lines_valid)
|
|
1198 {
|
|
1199 wp->w_lines_valid = idx;
|
|
1200 break;
|
|
1201 }
|
|
1202 }
|
|
1203 #ifdef FEAT_DIFF
|
|
1204 /* Correct the first entry for filler lines at the top
|
|
1205 * when it won't get updated below. */
|
|
1206 if (wp->w_p_diff && bot_start > 0)
|
|
1207 wp->w_lines[0].wl_size =
|
|
1208 plines_win_nofill(wp, wp->w_topline, TRUE)
|
|
1209 + wp->w_topfill;
|
|
1210 #endif
|
|
1211 }
|
|
1212 }
|
|
1213 }
|
|
1214
|
|
1215 /* When starting redraw in the first line, redraw all lines. When
|
|
1216 * there is only one window it's probably faster to clear the screen
|
|
1217 * first. */
|
|
1218 if (mid_start == 0)
|
|
1219 {
|
|
1220 mid_end = wp->w_height;
|
|
1221 if (lastwin == firstwin)
|
981
|
1222 {
|
7
|
1223 screenclear();
|
981
|
1224 #ifdef FEAT_WINDOWS
|
|
1225 /* The screen was cleared, redraw the tab pages line. */
|
|
1226 if (redraw_tabline)
|
|
1227 draw_tabline();
|
|
1228 #endif
|
|
1229 }
|
7
|
1230 }
|
|
1231 }
|
|
1232 else
|
|
1233 {
|
|
1234 /* Not VALID or INVERTED: redraw all lines. */
|
|
1235 mid_start = 0;
|
|
1236 mid_end = wp->w_height;
|
|
1237 }
|
|
1238
|
743
|
1239 if (type == SOME_VALID)
|
|
1240 {
|
|
1241 /* SOME_VALID: redraw all lines. */
|
|
1242 mid_start = 0;
|
|
1243 mid_end = wp->w_height;
|
|
1244 type = NOT_VALID;
|
|
1245 }
|
|
1246
|
7
|
1247 #ifdef FEAT_VISUAL
|
|
1248 /* check if we are updating or removing the inverted part */
|
|
1249 if ((VIsual_active && buf == curwin->w_buffer)
|
|
1250 || (wp->w_old_cursor_lnum != 0 && type != NOT_VALID))
|
|
1251 {
|
|
1252 linenr_T from, to;
|
|
1253
|
|
1254 if (VIsual_active)
|
|
1255 {
|
|
1256 if (VIsual_active
|
|
1257 && (VIsual_mode != wp->w_old_visual_mode
|
|
1258 || type == INVERTED_ALL))
|
|
1259 {
|
|
1260 /*
|
|
1261 * If the type of Visual selection changed, redraw the whole
|
|
1262 * selection. Also when the ownership of the X selection is
|
|
1263 * gained or lost.
|
|
1264 */
|
|
1265 if (curwin->w_cursor.lnum < VIsual.lnum)
|
|
1266 {
|
|
1267 from = curwin->w_cursor.lnum;
|
|
1268 to = VIsual.lnum;
|
|
1269 }
|
|
1270 else
|
|
1271 {
|
|
1272 from = VIsual.lnum;
|
|
1273 to = curwin->w_cursor.lnum;
|
|
1274 }
|
|
1275 /* redraw more when the cursor moved as well */
|
|
1276 if (wp->w_old_cursor_lnum < from)
|
|
1277 from = wp->w_old_cursor_lnum;
|
|
1278 if (wp->w_old_cursor_lnum > to)
|
|
1279 to = wp->w_old_cursor_lnum;
|
|
1280 if (wp->w_old_visual_lnum < from)
|
|
1281 from = wp->w_old_visual_lnum;
|
|
1282 if (wp->w_old_visual_lnum > to)
|
|
1283 to = wp->w_old_visual_lnum;
|
|
1284 }
|
|
1285 else
|
|
1286 {
|
|
1287 /*
|
|
1288 * Find the line numbers that need to be updated: The lines
|
|
1289 * between the old cursor position and the current cursor
|
|
1290 * position. Also check if the Visual position changed.
|
|
1291 */
|
|
1292 if (curwin->w_cursor.lnum < wp->w_old_cursor_lnum)
|
|
1293 {
|
|
1294 from = curwin->w_cursor.lnum;
|
|
1295 to = wp->w_old_cursor_lnum;
|
|
1296 }
|
|
1297 else
|
|
1298 {
|
|
1299 from = wp->w_old_cursor_lnum;
|
|
1300 to = curwin->w_cursor.lnum;
|
|
1301 if (from == 0) /* Visual mode just started */
|
|
1302 from = to;
|
|
1303 }
|
|
1304
|
422
|
1305 if (VIsual.lnum != wp->w_old_visual_lnum
|
|
1306 || VIsual.col != wp->w_old_visual_col)
|
7
|
1307 {
|
|
1308 if (wp->w_old_visual_lnum < from
|
|
1309 && wp->w_old_visual_lnum != 0)
|
|
1310 from = wp->w_old_visual_lnum;
|
|
1311 if (wp->w_old_visual_lnum > to)
|
|
1312 to = wp->w_old_visual_lnum;
|
|
1313 if (VIsual.lnum < from)
|
|
1314 from = VIsual.lnum;
|
|
1315 if (VIsual.lnum > to)
|
|
1316 to = VIsual.lnum;
|
|
1317 }
|
|
1318 }
|
|
1319
|
|
1320 /*
|
|
1321 * If in block mode and changed column or curwin->w_curswant:
|
|
1322 * update all lines.
|
|
1323 * First compute the actual start and end column.
|
|
1324 */
|
|
1325 if (VIsual_mode == Ctrl_V)
|
|
1326 {
|
|
1327 colnr_T fromc, toc;
|
|
1328
|
|
1329 getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc);
|
|
1330 ++toc;
|
|
1331 if (curwin->w_curswant == MAXCOL)
|
|
1332 toc = MAXCOL;
|
|
1333
|
|
1334 if (fromc != wp->w_old_cursor_fcol
|
|
1335 || toc != wp->w_old_cursor_lcol)
|
|
1336 {
|
|
1337 if (from > VIsual.lnum)
|
|
1338 from = VIsual.lnum;
|
|
1339 if (to < VIsual.lnum)
|
|
1340 to = VIsual.lnum;
|
|
1341 }
|
|
1342 wp->w_old_cursor_fcol = fromc;
|
|
1343 wp->w_old_cursor_lcol = toc;
|
|
1344 }
|
|
1345 }
|
|
1346 else
|
|
1347 {
|
|
1348 /* Use the line numbers of the old Visual area. */
|
|
1349 if (wp->w_old_cursor_lnum < wp->w_old_visual_lnum)
|
|
1350 {
|
|
1351 from = wp->w_old_cursor_lnum;
|
|
1352 to = wp->w_old_visual_lnum;
|
|
1353 }
|
|
1354 else
|
|
1355 {
|
|
1356 from = wp->w_old_visual_lnum;
|
|
1357 to = wp->w_old_cursor_lnum;
|
|
1358 }
|
|
1359 }
|
|
1360
|
|
1361 /*
|
|
1362 * There is no need to update lines above the top of the window.
|
|
1363 */
|
|
1364 if (from < wp->w_topline)
|
|
1365 from = wp->w_topline;
|
|
1366
|
|
1367 /*
|
|
1368 * If we know the value of w_botline, use it to restrict the update to
|
|
1369 * the lines that are visible in the window.
|
|
1370 */
|
|
1371 if (wp->w_valid & VALID_BOTLINE)
|
|
1372 {
|
|
1373 if (from >= wp->w_botline)
|
|
1374 from = wp->w_botline - 1;
|
|
1375 if (to >= wp->w_botline)
|
|
1376 to = wp->w_botline - 1;
|
|
1377 }
|
|
1378
|
|
1379 /*
|
|
1380 * Find the minimal part to be updated.
|
|
1381 * Watch out for scrolling that made entries in w_lines[] invalid.
|
|
1382 * E.g., CTRL-U makes the first half of w_lines[] invalid and sets
|
|
1383 * top_end; need to redraw from top_end to the "to" line.
|
|
1384 * A middle mouse click with a Visual selection may change the text
|
|
1385 * above the Visual area and reset wl_valid, do count these for
|
|
1386 * mid_end (in srow).
|
|
1387 */
|
|
1388 if (mid_start > 0)
|
|
1389 {
|
|
1390 lnum = wp->w_topline;
|
|
1391 idx = 0;
|
|
1392 srow = 0;
|
|
1393 if (scrolled_down)
|
|
1394 mid_start = top_end;
|
|
1395 else
|
|
1396 mid_start = 0;
|
|
1397 while (lnum < from && idx < wp->w_lines_valid) /* find start */
|
|
1398 {
|
|
1399 if (wp->w_lines[idx].wl_valid)
|
|
1400 mid_start += wp->w_lines[idx].wl_size;
|
|
1401 else if (!scrolled_down)
|
|
1402 srow += wp->w_lines[idx].wl_size;
|
|
1403 ++idx;
|
|
1404 # ifdef FEAT_FOLDING
|
|
1405 if (idx < wp->w_lines_valid && wp->w_lines[idx].wl_valid)
|
|
1406 lnum = wp->w_lines[idx].wl_lnum;
|
|
1407 else
|
|
1408 # endif
|
|
1409 ++lnum;
|
|
1410 }
|
|
1411 srow += mid_start;
|
|
1412 mid_end = wp->w_height;
|
|
1413 for ( ; idx < wp->w_lines_valid; ++idx) /* find end */
|
|
1414 {
|
|
1415 if (wp->w_lines[idx].wl_valid
|
|
1416 && wp->w_lines[idx].wl_lnum >= to + 1)
|
|
1417 {
|
|
1418 /* Only update until first row of this line */
|
|
1419 mid_end = srow;
|
|
1420 break;
|
|
1421 }
|
|
1422 srow += wp->w_lines[idx].wl_size;
|
|
1423 }
|
|
1424 }
|
|
1425 }
|
|
1426
|
|
1427 if (VIsual_active && buf == curwin->w_buffer)
|
|
1428 {
|
|
1429 wp->w_old_visual_mode = VIsual_mode;
|
|
1430 wp->w_old_cursor_lnum = curwin->w_cursor.lnum;
|
|
1431 wp->w_old_visual_lnum = VIsual.lnum;
|
422
|
1432 wp->w_old_visual_col = VIsual.col;
|
7
|
1433 wp->w_old_curswant = curwin->w_curswant;
|
|
1434 }
|
|
1435 else
|
|
1436 {
|
|
1437 wp->w_old_visual_mode = 0;
|
|
1438 wp->w_old_cursor_lnum = 0;
|
|
1439 wp->w_old_visual_lnum = 0;
|
422
|
1440 wp->w_old_visual_col = 0;
|
7
|
1441 }
|
|
1442 #endif /* FEAT_VISUAL */
|
|
1443
|
|
1444 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)
|
|
1445 /* reset got_int, otherwise regexp won't work */
|
|
1446 save_got_int = got_int;
|
|
1447 got_int = 0;
|
|
1448 #endif
|
|
1449 #ifdef FEAT_FOLDING
|
|
1450 win_foldinfo.fi_level = 0;
|
|
1451 #endif
|
|
1452
|
|
1453 /*
|
|
1454 * Update all the window rows.
|
|
1455 */
|
|
1456 idx = 0; /* first entry in w_lines[].wl_size */
|
|
1457 row = 0;
|
|
1458 srow = 0;
|
|
1459 lnum = wp->w_topline; /* first line shown in window */
|
|
1460 for (;;)
|
|
1461 {
|
|
1462 /* stop updating when reached the end of the window (check for _past_
|
|
1463 * the end of the window is at the end of the loop) */
|
|
1464 if (row == wp->w_height)
|
|
1465 {
|
|
1466 didline = TRUE;
|
|
1467 break;
|
|
1468 }
|
|
1469
|
|
1470 /* stop updating when hit the end of the file */
|
|
1471 if (lnum > buf->b_ml.ml_line_count)
|
|
1472 {
|
|
1473 eof = TRUE;
|
|
1474 break;
|
|
1475 }
|
|
1476
|
|
1477 /* Remember the starting row of the line that is going to be dealt
|
|
1478 * with. It is used further down when the line doesn't fit. */
|
|
1479 srow = row;
|
|
1480
|
|
1481 /*
|
|
1482 * Update a line when it is in an area that needs updating, when it
|
|
1483 * has changes or w_lines[idx] is invalid.
|
|
1484 * bot_start may be halfway a wrapped line after using
|
|
1485 * win_del_lines(), check if the current line includes it.
|
|
1486 * When syntax folding is being used, the saved syntax states will
|
|
1487 * already have been updated, we can't see where the syntax state is
|
|
1488 * the same again, just update until the end of the window.
|
|
1489 */
|
|
1490 if (row < top_end
|
|
1491 || (row >= mid_start && row < mid_end)
|
|
1492 #ifdef FEAT_SEARCH_EXTRA
|
|
1493 || top_to_mod
|
|
1494 #endif
|
|
1495 || idx >= wp->w_lines_valid
|
|
1496 || (row + wp->w_lines[idx].wl_size > bot_start)
|
|
1497 || (mod_top != 0
|
|
1498 && (lnum == mod_top
|
|
1499 || (lnum >= mod_top
|
|
1500 && (lnum < mod_bot
|
|
1501 #ifdef FEAT_SYN_HL
|
|
1502 || did_update == DID_FOLD
|
|
1503 || (did_update == DID_LINE
|
|
1504 && syntax_present(buf)
|
|
1505 && (
|
|
1506 # ifdef FEAT_FOLDING
|
|
1507 (foldmethodIsSyntax(wp)
|
|
1508 && hasAnyFolding(wp)) ||
|
|
1509 # endif
|
|
1510 syntax_check_changed(lnum)))
|
|
1511 #endif
|
|
1512 )))))
|
|
1513 {
|
|
1514 #ifdef FEAT_SEARCH_EXTRA
|
|
1515 if (lnum == mod_top)
|
|
1516 top_to_mod = FALSE;
|
|
1517 #endif
|
|
1518
|
|
1519 /*
|
|
1520 * When at start of changed lines: May scroll following lines
|
|
1521 * up or down to minimize redrawing.
|
|
1522 * Don't do this when the change continues until the end.
|
|
1523 * Don't scroll when dollar_vcol is non-zero, keep the "$".
|
|
1524 */
|
|
1525 if (lnum == mod_top
|
|
1526 && mod_bot != MAXLNUM
|
|
1527 && !(dollar_vcol != 0 && mod_bot == mod_top + 1))
|
|
1528 {
|
|
1529 int old_rows = 0;
|
|
1530 int new_rows = 0;
|
|
1531 int xtra_rows;
|
|
1532 linenr_T l;
|
|
1533
|
|
1534 /* Count the old number of window rows, using w_lines[], which
|
|
1535 * should still contain the sizes for the lines as they are
|
|
1536 * currently displayed. */
|
|
1537 for (i = idx; i < wp->w_lines_valid; ++i)
|
|
1538 {
|
|
1539 /* Only valid lines have a meaningful wl_lnum. Invalid
|
|
1540 * lines are part of the changed area. */
|
|
1541 if (wp->w_lines[i].wl_valid
|
|
1542 && wp->w_lines[i].wl_lnum == mod_bot)
|
|
1543 break;
|
|
1544 old_rows += wp->w_lines[i].wl_size;
|
|
1545 #ifdef FEAT_FOLDING
|
|
1546 if (wp->w_lines[i].wl_valid
|
|
1547 && wp->w_lines[i].wl_lastlnum + 1 == mod_bot)
|
|
1548 {
|
|
1549 /* Must have found the last valid entry above mod_bot.
|
|
1550 * Add following invalid entries. */
|
|
1551 ++i;
|
|
1552 while (i < wp->w_lines_valid
|
|
1553 && !wp->w_lines[i].wl_valid)
|
|
1554 old_rows += wp->w_lines[i++].wl_size;
|
|
1555 break;
|
|
1556 }
|
|
1557 #endif
|
|
1558 }
|
|
1559
|
|
1560 if (i >= wp->w_lines_valid)
|
|
1561 {
|
|
1562 /* We can't find a valid line below the changed lines,
|
|
1563 * need to redraw until the end of the window.
|
|
1564 * Inserting/deleting lines has no use. */
|
|
1565 bot_start = 0;
|
|
1566 }
|
|
1567 else
|
|
1568 {
|
|
1569 /* Able to count old number of rows: Count new window
|
|
1570 * rows, and may insert/delete lines */
|
|
1571 j = idx;
|
|
1572 for (l = lnum; l < mod_bot; ++l)
|
|
1573 {
|
|
1574 #ifdef FEAT_FOLDING
|
|
1575 if (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL))
|
|
1576 ++new_rows;
|
|
1577 else
|
|
1578 #endif
|
|
1579 #ifdef FEAT_DIFF
|
|
1580 if (l == wp->w_topline)
|
|
1581 new_rows += plines_win_nofill(wp, l, TRUE)
|
|
1582 + wp->w_topfill;
|
|
1583 else
|
|
1584 #endif
|
|
1585 new_rows += plines_win(wp, l, TRUE);
|
|
1586 ++j;
|
|
1587 if (new_rows > wp->w_height - row - 2)
|
|
1588 {
|
|
1589 /* it's getting too much, must redraw the rest */
|
|
1590 new_rows = 9999;
|
|
1591 break;
|
|
1592 }
|
|
1593 }
|
|
1594 xtra_rows = new_rows - old_rows;
|
|
1595 if (xtra_rows < 0)
|
|
1596 {
|
|
1597 /* May scroll text up. If there is not enough
|
|
1598 * remaining text or scrolling fails, must redraw the
|
|
1599 * rest. If scrolling works, must redraw the text
|
|
1600 * below the scrolled text. */
|
|
1601 if (row - xtra_rows >= wp->w_height - 2)
|
|
1602 mod_bot = MAXLNUM;
|
|
1603 else
|
|
1604 {
|
|
1605 check_for_delay(FALSE);
|
|
1606 if (win_del_lines(wp, row,
|
|
1607 -xtra_rows, FALSE, FALSE) == FAIL)
|
|
1608 mod_bot = MAXLNUM;
|
|
1609 else
|
|
1610 bot_start = wp->w_height + xtra_rows;
|
|
1611 }
|
|
1612 }
|
|
1613 else if (xtra_rows > 0)
|
|
1614 {
|
|
1615 /* May scroll text down. If there is not enough
|
|
1616 * remaining text of scrolling fails, must redraw the
|
|
1617 * rest. */
|
|
1618 if (row + xtra_rows >= wp->w_height - 2)
|
|
1619 mod_bot = MAXLNUM;
|
|
1620 else
|
|
1621 {
|
|
1622 check_for_delay(FALSE);
|
|
1623 if (win_ins_lines(wp, row + old_rows,
|
|
1624 xtra_rows, FALSE, FALSE) == FAIL)
|
|
1625 mod_bot = MAXLNUM;
|
|
1626 else if (top_end > row + old_rows)
|
|
1627 /* Scrolled the part at the top that requires
|
|
1628 * updating down. */
|
|
1629 top_end += xtra_rows;
|
|
1630 }
|
|
1631 }
|
|
1632
|
|
1633 /* When not updating the rest, may need to move w_lines[]
|
|
1634 * entries. */
|
|
1635 if (mod_bot != MAXLNUM && i != j)
|
|
1636 {
|
|
1637 if (j < i)
|
|
1638 {
|
|
1639 int x = row + new_rows;
|
|
1640
|
|
1641 /* move entries in w_lines[] upwards */
|
|
1642 for (;;)
|
|
1643 {
|
|
1644 /* stop at last valid entry in w_lines[] */
|
|
1645 if (i >= wp->w_lines_valid)
|
|
1646 {
|
|
1647 wp->w_lines_valid = j;
|
|
1648 break;
|
|
1649 }
|
|
1650 wp->w_lines[j] = wp->w_lines[i];
|
|
1651 /* stop at a line that won't fit */
|
|
1652 if (x + (int)wp->w_lines[j].wl_size
|
|
1653 > wp->w_height)
|
|
1654 {
|
|
1655 wp->w_lines_valid = j + 1;
|
|
1656 break;
|
|
1657 }
|
|
1658 x += wp->w_lines[j++].wl_size;
|
|
1659 ++i;
|
|
1660 }
|
|
1661 if (bot_start > x)
|
|
1662 bot_start = x;
|
|
1663 }
|
|
1664 else /* j > i */
|
|
1665 {
|
|
1666 /* move entries in w_lines[] downwards */
|
|
1667 j -= i;
|
|
1668 wp->w_lines_valid += j;
|
|
1669 if (wp->w_lines_valid > wp->w_height)
|
|
1670 wp->w_lines_valid = wp->w_height;
|
|
1671 for (i = wp->w_lines_valid; i - j >= idx; --i)
|
|
1672 wp->w_lines[i] = wp->w_lines[i - j];
|
|
1673
|
|
1674 /* The w_lines[] entries for inserted lines are
|
|
1675 * now invalid, but wl_size may be used above.
|
|
1676 * Reset to zero. */
|
|
1677 while (i >= idx)
|
|
1678 {
|
|
1679 wp->w_lines[i].wl_size = 0;
|
|
1680 wp->w_lines[i--].wl_valid = FALSE;
|
|
1681 }
|
|
1682 }
|
|
1683 }
|
|
1684 }
|
|
1685 }
|
|
1686
|
|
1687 #ifdef FEAT_FOLDING
|
|
1688 /*
|
|
1689 * When lines are folded, display one line for all of them.
|
|
1690 * Otherwise, display normally (can be several display lines when
|
|
1691 * 'wrap' is on).
|
|
1692 */
|
|
1693 fold_count = foldedCount(wp, lnum, &win_foldinfo);
|
|
1694 if (fold_count != 0)
|
|
1695 {
|
|
1696 fold_line(wp, fold_count, &win_foldinfo, lnum, row);
|
|
1697 ++row;
|
|
1698 --fold_count;
|
|
1699 wp->w_lines[idx].wl_folded = TRUE;
|
|
1700 wp->w_lines[idx].wl_lastlnum = lnum + fold_count;
|
|
1701 # ifdef FEAT_SYN_HL
|
|
1702 did_update = DID_FOLD;
|
|
1703 # endif
|
|
1704 }
|
|
1705 else
|
|
1706 #endif
|
|
1707 if (idx < wp->w_lines_valid
|
|
1708 && wp->w_lines[idx].wl_valid
|
|
1709 && wp->w_lines[idx].wl_lnum == lnum
|
|
1710 && lnum > wp->w_topline
|
|
1711 && !(dy_flags & DY_LASTLINE)
|
|
1712 && srow + wp->w_lines[idx].wl_size > wp->w_height
|
|
1713 #ifdef FEAT_DIFF
|
|
1714 && diff_check_fill(wp, lnum) == 0
|
|
1715 #endif
|
|
1716 )
|
|
1717 {
|
|
1718 /* This line is not going to fit. Don't draw anything here,
|
|
1719 * will draw "@ " lines below. */
|
|
1720 row = wp->w_height + 1;
|
|
1721 }
|
|
1722 else
|
|
1723 {
|
|
1724 #ifdef FEAT_SEARCH_EXTRA
|
|
1725 prepare_search_hl(wp, lnum);
|
|
1726 #endif
|
|
1727 #ifdef FEAT_SYN_HL
|
|
1728 /* Let the syntax stuff know we skipped a few lines. */
|
|
1729 if (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum
|
|
1730 && syntax_present(buf))
|
|
1731 syntax_end_parsing(syntax_last_parsed + 1);
|
|
1732 #endif
|
|
1733
|
|
1734 /*
|
|
1735 * Display one line.
|
|
1736 */
|
625
|
1737 row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0);
|
7
|
1738
|
|
1739 #ifdef FEAT_FOLDING
|
|
1740 wp->w_lines[idx].wl_folded = FALSE;
|
|
1741 wp->w_lines[idx].wl_lastlnum = lnum;
|
|
1742 #endif
|
|
1743 #ifdef FEAT_SYN_HL
|
|
1744 did_update = DID_LINE;
|
|
1745 syntax_last_parsed = lnum;
|
|
1746 #endif
|
|
1747 }
|
|
1748
|
|
1749 wp->w_lines[idx].wl_lnum = lnum;
|
|
1750 wp->w_lines[idx].wl_valid = TRUE;
|
|
1751 if (row > wp->w_height) /* past end of screen */
|
|
1752 {
|
|
1753 /* we may need the size of that too long line later on */
|
|
1754 if (dollar_vcol == 0)
|
|
1755 wp->w_lines[idx].wl_size = plines_win(wp, lnum, TRUE);
|
|
1756 ++idx;
|
|
1757 break;
|
|
1758 }
|
|
1759 if (dollar_vcol == 0)
|
|
1760 wp->w_lines[idx].wl_size = row - srow;
|
|
1761 ++idx;
|
|
1762 #ifdef FEAT_FOLDING
|
|
1763 lnum += fold_count + 1;
|
|
1764 #else
|
|
1765 ++lnum;
|
|
1766 #endif
|
|
1767 }
|
|
1768 else
|
|
1769 {
|
|
1770 /* This line does not need updating, advance to the next one */
|
|
1771 row += wp->w_lines[idx++].wl_size;
|
|
1772 if (row > wp->w_height) /* past end of screen */
|
|
1773 break;
|
|
1774 #ifdef FEAT_FOLDING
|
|
1775 lnum = wp->w_lines[idx - 1].wl_lastlnum + 1;
|
|
1776 #else
|
|
1777 ++lnum;
|
|
1778 #endif
|
|
1779 #ifdef FEAT_SYN_HL
|
|
1780 did_update = DID_NONE;
|
|
1781 #endif
|
|
1782 }
|
|
1783
|
|
1784 if (lnum > buf->b_ml.ml_line_count)
|
|
1785 {
|
|
1786 eof = TRUE;
|
|
1787 break;
|
|
1788 }
|
|
1789 }
|
|
1790 /*
|
|
1791 * End of loop over all window lines.
|
|
1792 */
|
|
1793
|
|
1794
|
|
1795 if (idx > wp->w_lines_valid)
|
|
1796 wp->w_lines_valid = idx;
|
|
1797
|
|
1798 #ifdef FEAT_SYN_HL
|
|
1799 /*
|
|
1800 * Let the syntax stuff know we stop parsing here.
|
|
1801 */
|
|
1802 if (syntax_last_parsed != 0 && syntax_present(buf))
|
|
1803 syntax_end_parsing(syntax_last_parsed + 1);
|
|
1804 #endif
|
|
1805
|
|
1806 /*
|
|
1807 * If we didn't hit the end of the file, and we didn't finish the last
|
|
1808 * line we were working on, then the line didn't fit.
|
|
1809 */
|
|
1810 wp->w_empty_rows = 0;
|
|
1811 #ifdef FEAT_DIFF
|
|
1812 wp->w_filler_rows = 0;
|
|
1813 #endif
|
|
1814 if (!eof && !didline)
|
|
1815 {
|
|
1816 if (lnum == wp->w_topline)
|
|
1817 {
|
|
1818 /*
|
|
1819 * Single line that does not fit!
|
|
1820 * Don't overwrite it, it can be edited.
|
|
1821 */
|
|
1822 wp->w_botline = lnum + 1;
|
|
1823 }
|
|
1824 #ifdef FEAT_DIFF
|
|
1825 else if (diff_check_fill(wp, lnum) >= wp->w_height - srow)
|
|
1826 {
|
|
1827 /* Window ends in filler lines. */
|
|
1828 wp->w_botline = lnum;
|
|
1829 wp->w_filler_rows = wp->w_height - srow;
|
|
1830 }
|
|
1831 #endif
|
|
1832 else if (dy_flags & DY_LASTLINE) /* 'display' has "lastline" */
|
|
1833 {
|
|
1834 /*
|
|
1835 * Last line isn't finished: Display "@@@" at the end.
|
|
1836 */
|
|
1837 screen_fill(W_WINROW(wp) + wp->w_height - 1,
|
|
1838 W_WINROW(wp) + wp->w_height,
|
|
1839 (int)W_ENDCOL(wp) - 3, (int)W_ENDCOL(wp),
|
|
1840 '@', '@', hl_attr(HLF_AT));
|
|
1841 set_empty_rows(wp, srow);
|
|
1842 wp->w_botline = lnum;
|
|
1843 }
|
|
1844 else
|
|
1845 {
|
|
1846 win_draw_end(wp, '@', ' ', srow, wp->w_height, HLF_AT);
|
|
1847 wp->w_botline = lnum;
|
|
1848 }
|
|
1849 }
|
|
1850 else
|
|
1851 {
|
|
1852 #ifdef FEAT_VERTSPLIT
|
|
1853 draw_vsep_win(wp, row);
|
|
1854 #endif
|
|
1855 if (eof) /* we hit the end of the file */
|
|
1856 {
|
|
1857 wp->w_botline = buf->b_ml.ml_line_count + 1;
|
|
1858 #ifdef FEAT_DIFF
|
|
1859 j = diff_check_fill(wp, wp->w_botline);
|
|
1860 if (j > 0 && !wp->w_botfill)
|
|
1861 {
|
|
1862 /*
|
|
1863 * Display filler lines at the end of the file
|
|
1864 */
|
|
1865 if (char2cells(fill_diff) > 1)
|
|
1866 i = '-';
|
|
1867 else
|
|
1868 i = fill_diff;
|
|
1869 if (row + j > wp->w_height)
|
|
1870 j = wp->w_height - row;
|
|
1871 win_draw_end(wp, i, i, row, row + (int)j, HLF_DED);
|
|
1872 row += j;
|
|
1873 }
|
|
1874 #endif
|
|
1875 }
|
|
1876 else if (dollar_vcol == 0)
|
|
1877 wp->w_botline = lnum;
|
|
1878
|
|
1879 /* make sure the rest of the screen is blank */
|
|
1880 /* put '~'s on rows that aren't part of the file. */
|
|
1881 win_draw_end(wp, '~', ' ', row, wp->w_height, HLF_AT);
|
|
1882 }
|
|
1883
|
|
1884 /* Reset the type of redrawing required, the window has been updated. */
|
|
1885 wp->w_redr_type = 0;
|
|
1886 #ifdef FEAT_DIFF
|
|
1887 wp->w_old_topfill = wp->w_topfill;
|
|
1888 wp->w_old_botfill = wp->w_botfill;
|
|
1889 #endif
|
|
1890
|
|
1891 if (dollar_vcol == 0)
|
|
1892 {
|
|
1893 /*
|
|
1894 * There is a trick with w_botline. If we invalidate it on each
|
|
1895 * change that might modify it, this will cause a lot of expensive
|
|
1896 * calls to plines() in update_topline() each time. Therefore the
|
|
1897 * value of w_botline is often approximated, and this value is used to
|
|
1898 * compute the value of w_topline. If the value of w_botline was
|
|
1899 * wrong, check that the value of w_topline is correct (cursor is on
|
|
1900 * the visible part of the text). If it's not, we need to redraw
|
|
1901 * again. Mostly this just means scrolling up a few lines, so it
|
|
1902 * doesn't look too bad. Only do this for the current window (where
|
|
1903 * changes are relevant).
|
|
1904 */
|
|
1905 wp->w_valid |= VALID_BOTLINE;
|
|
1906 if (wp == curwin && wp->w_botline != old_botline && !recursive)
|
|
1907 {
|
|
1908 recursive = TRUE;
|
|
1909 curwin->w_valid &= ~VALID_TOPLINE;
|
|
1910 update_topline(); /* may invalidate w_botline again */
|
|
1911 if (must_redraw != 0)
|
|
1912 {
|
|
1913 /* Don't update for changes in buffer again. */
|
|
1914 i = curbuf->b_mod_set;
|
|
1915 curbuf->b_mod_set = FALSE;
|
|
1916 win_update(curwin);
|
|
1917 must_redraw = 0;
|
|
1918 curbuf->b_mod_set = i;
|
|
1919 }
|
|
1920 recursive = FALSE;
|
|
1921 }
|
|
1922 }
|
|
1923
|
|
1924 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)
|
|
1925 /* restore got_int, unless CTRL-C was hit while redrawing */
|
|
1926 if (!got_int)
|
|
1927 got_int = save_got_int;
|
|
1928 #endif
|
|
1929 }
|
|
1930
|
|
1931 #ifdef FEAT_SIGNS
|
|
1932 static int draw_signcolumn __ARGS((win_T *wp));
|
|
1933
|
|
1934 /*
|
|
1935 * Return TRUE when window "wp" has a column to draw signs in.
|
|
1936 */
|
|
1937 static int
|
|
1938 draw_signcolumn(wp)
|
|
1939 win_T *wp;
|
|
1940 {
|
|
1941 return (wp->w_buffer->b_signlist != NULL
|
|
1942 # ifdef FEAT_NETBEANS_INTG
|
|
1943 || usingNetbeans
|
|
1944 # endif
|
|
1945 );
|
|
1946 }
|
|
1947 #endif
|
|
1948
|
|
1949 /*
|
|
1950 * Clear the rest of the window and mark the unused lines with "c1". use "c2"
|
|
1951 * as the filler character.
|
|
1952 */
|
|
1953 static void
|
|
1954 win_draw_end(wp, c1, c2, row, endrow, hl)
|
|
1955 win_T *wp;
|
|
1956 int c1;
|
|
1957 int c2;
|
|
1958 int row;
|
|
1959 int endrow;
|
534
|
1960 hlf_T hl;
|
7
|
1961 {
|
|
1962 #if defined(FEAT_FOLDING) || defined(FEAT_SIGNS) || defined(FEAT_CMDWIN)
|
|
1963 int n = 0;
|
|
1964 # define FDC_OFF n
|
|
1965 #else
|
|
1966 # define FDC_OFF 0
|
|
1967 #endif
|
|
1968
|
|
1969 #ifdef FEAT_RIGHTLEFT
|
|
1970 if (wp->w_p_rl)
|
|
1971 {
|
|
1972 /* No check for cmdline window: should never be right-left. */
|
|
1973 # ifdef FEAT_FOLDING
|
|
1974 n = wp->w_p_fdc;
|
|
1975
|
|
1976 if (n > 0)
|
|
1977 {
|
|
1978 /* draw the fold column at the right */
|
119
|
1979 if (n > W_WIDTH(wp))
|
|
1980 n = W_WIDTH(wp);
|
7
|
1981 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
|
|
1982 W_ENDCOL(wp) - n, (int)W_ENDCOL(wp),
|
|
1983 ' ', ' ', hl_attr(HLF_FC));
|
|
1984 }
|
|
1985 # endif
|
|
1986 # ifdef FEAT_SIGNS
|
|
1987 if (draw_signcolumn(wp))
|
|
1988 {
|
|
1989 int nn = n + 2;
|
|
1990
|
|
1991 /* draw the sign column left of the fold column */
|
119
|
1992 if (nn > W_WIDTH(wp))
|
|
1993 nn = W_WIDTH(wp);
|
7
|
1994 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
|
|
1995 W_ENDCOL(wp) - nn, (int)W_ENDCOL(wp) - n,
|
|
1996 ' ', ' ', hl_attr(HLF_SC));
|
|
1997 n = nn;
|
|
1998 }
|
|
1999 # endif
|
|
2000 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
|
|
2001 W_WINCOL(wp), W_ENDCOL(wp) - 1 - FDC_OFF,
|
|
2002 c2, c2, hl_attr(hl));
|
|
2003 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
|
|
2004 W_ENDCOL(wp) - 1 - FDC_OFF, W_ENDCOL(wp) - FDC_OFF,
|
|
2005 c1, c2, hl_attr(hl));
|
|
2006 }
|
|
2007 else
|
|
2008 #endif
|
|
2009 {
|
|
2010 #ifdef FEAT_CMDWIN
|
|
2011 if (cmdwin_type != 0 && wp == curwin)
|
|
2012 {
|
|
2013 /* draw the cmdline character in the leftmost column */
|
|
2014 n = 1;
|
|
2015 if (n > wp->w_width)
|
|
2016 n = wp->w_width;
|
|
2017 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
|
|
2018 W_WINCOL(wp), (int)W_WINCOL(wp) + n,
|
|
2019 cmdwin_type, ' ', hl_attr(HLF_AT));
|
|
2020 }
|
|
2021 #endif
|
|
2022 #ifdef FEAT_FOLDING
|
|
2023 if (wp->w_p_fdc > 0)
|
|
2024 {
|
|
2025 int nn = n + wp->w_p_fdc;
|
|
2026
|
|
2027 /* draw the fold column at the left */
|
|
2028 if (nn > W_WIDTH(wp))
|
|
2029 nn = W_WIDTH(wp);
|
|
2030 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
|
|
2031 W_WINCOL(wp) + n, (int)W_WINCOL(wp) + nn,
|
|
2032 ' ', ' ', hl_attr(HLF_FC));
|
|
2033 n = nn;
|
|
2034 }
|
|
2035 #endif
|
|
2036 #ifdef FEAT_SIGNS
|
|
2037 if (draw_signcolumn(wp))
|
|
2038 {
|
|
2039 int nn = n + 2;
|
|
2040
|
|
2041 /* draw the sign column after the fold column */
|
|
2042 if (nn > W_WIDTH(wp))
|
|
2043 nn = W_WIDTH(wp);
|
|
2044 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
|
|
2045 W_WINCOL(wp) + n, (int)W_WINCOL(wp) + nn,
|
|
2046 ' ', ' ', hl_attr(HLF_SC));
|
|
2047 n = nn;
|
|
2048 }
|
|
2049 #endif
|
|
2050 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
|
|
2051 W_WINCOL(wp) + FDC_OFF, (int)W_ENDCOL(wp),
|
|
2052 c1, c2, hl_attr(hl));
|
|
2053 }
|
|
2054 set_empty_rows(wp, row);
|
|
2055 }
|
|
2056
|
|
2057 #ifdef FEAT_FOLDING
|
|
2058 /*
|
|
2059 * Display one folded line.
|
|
2060 */
|
|
2061 static void
|
|
2062 fold_line(wp, fold_count, foldinfo, lnum, row)
|
|
2063 win_T *wp;
|
|
2064 long fold_count;
|
|
2065 foldinfo_T *foldinfo;
|
|
2066 linenr_T lnum;
|
|
2067 int row;
|
|
2068 {
|
|
2069 char_u buf[51];
|
|
2070 pos_T *top, *bot;
|
|
2071 linenr_T lnume = lnum + fold_count - 1;
|
|
2072 int len;
|
29
|
2073 char_u *text;
|
7
|
2074 int fdc;
|
|
2075 int col;
|
|
2076 int txtcol;
|
|
2077 int off = (int)(current_ScreenLine - ScreenLines);
|
216
|
2078 int ri;
|
7
|
2079
|
|
2080 /* Build the fold line:
|
|
2081 * 1. Add the cmdwin_type for the command-line window
|
|
2082 * 2. Add the 'foldcolumn'
|
|
2083 * 3. Add the 'number' column
|
|
2084 * 4. Compose the text
|
|
2085 * 5. Add the text
|
|
2086 * 6. set highlighting for the Visual area an other text
|
|
2087 */
|
|
2088 col = 0;
|
|
2089
|
|
2090 /*
|
|
2091 * 1. Add the cmdwin_type for the command-line window
|
|
2092 * Ignores 'rightleft', this window is never right-left.
|
|
2093 */
|
|
2094 #ifdef FEAT_CMDWIN
|
|
2095 if (cmdwin_type != 0 && wp == curwin)
|
|
2096 {
|
|
2097 ScreenLines[off] = cmdwin_type;
|
|
2098 ScreenAttrs[off] = hl_attr(HLF_AT);
|
|
2099 #ifdef FEAT_MBYTE
|
|
2100 if (enc_utf8)
|
|
2101 ScreenLinesUC[off] = 0;
|
|
2102 #endif
|
|
2103 ++col;
|
|
2104 }
|
|
2105 #endif
|
|
2106
|
|
2107 /*
|
|
2108 * 2. Add the 'foldcolumn'
|
|
2109 */
|
|
2110 fdc = wp->w_p_fdc;
|
|
2111 if (fdc > W_WIDTH(wp) - col)
|
|
2112 fdc = W_WIDTH(wp) - col;
|
|
2113 if (fdc > 0)
|
|
2114 {
|
|
2115 fill_foldcolumn(buf, wp, TRUE, lnum);
|
|
2116 #ifdef FEAT_RIGHTLEFT
|
|
2117 if (wp->w_p_rl)
|
|
2118 {
|
|
2119 int i;
|
|
2120
|
|
2121 copy_text_attr(off + W_WIDTH(wp) - fdc - col, buf, fdc,
|
|
2122 hl_attr(HLF_FC));
|
|
2123 /* reverse the fold column */
|
|
2124 for (i = 0; i < fdc; ++i)
|
|
2125 ScreenLines[off + W_WIDTH(wp) - i - 1 - col] = buf[i];
|
|
2126 }
|
|
2127 else
|
|
2128 #endif
|
|
2129 copy_text_attr(off + col, buf, fdc, hl_attr(HLF_FC));
|
|
2130 col += fdc;
|
|
2131 }
|
|
2132
|
|
2133 #ifdef FEAT_RIGHTLEFT
|
216
|
2134 # define RL_MEMSET(p, v, l) if (wp->w_p_rl) \
|
|
2135 for (ri = 0; ri < l; ++ri) \
|
|
2136 ScreenAttrs[off + (W_WIDTH(wp) - (p) - (l)) + ri] = v; \
|
|
2137 else \
|
|
2138 for (ri = 0; ri < l; ++ri) \
|
|
2139 ScreenAttrs[off + (p) + ri] = v
|
7
|
2140 #else
|
216
|
2141 # define RL_MEMSET(p, v, l) for (ri = 0; ri < l; ++ri) \
|
|
2142 ScreenAttrs[off + (p) + ri] = v
|
7
|
2143 #endif
|
|
2144
|
|
2145 /* Set all attributes of the 'number' column and the text */
|
216
|
2146 RL_MEMSET(col, hl_attr(HLF_FL), W_WIDTH(wp) - col);
|
7
|
2147
|
|
2148 #ifdef FEAT_SIGNS
|
|
2149 /* If signs are being displayed, add two spaces. */
|
|
2150 if (draw_signcolumn(wp))
|
|
2151 {
|
|
2152 len = W_WIDTH(wp) - col;
|
|
2153 if (len > 0)
|
|
2154 {
|
|
2155 if (len > 2)
|
|
2156 len = 2;
|
|
2157 # ifdef FEAT_RIGHTLEFT
|
|
2158 if (wp->w_p_rl)
|
|
2159 /* the line number isn't reversed */
|
|
2160 copy_text_attr(off + W_WIDTH(wp) - len - col,
|
|
2161 (char_u *)" ", len, hl_attr(HLF_FL));
|
|
2162 else
|
|
2163 # endif
|
|
2164 copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_FL));
|
|
2165 col += len;
|
|
2166 }
|
|
2167 }
|
|
2168 #endif
|
|
2169
|
|
2170 /*
|
|
2171 * 3. Add the 'number' column
|
|
2172 */
|
|
2173 if (wp->w_p_nu)
|
|
2174 {
|
|
2175 len = W_WIDTH(wp) - col;
|
|
2176 if (len > 0)
|
|
2177 {
|
13
|
2178 int w = number_width(wp);
|
|
2179
|
|
2180 if (len > w + 1)
|
|
2181 len = w + 1;
|
|
2182 sprintf((char *)buf, "%*ld ", w, (long)lnum);
|
7
|
2183 #ifdef FEAT_RIGHTLEFT
|
|
2184 if (wp->w_p_rl)
|
|
2185 /* the line number isn't reversed */
|
|
2186 copy_text_attr(off + W_WIDTH(wp) - len - col, buf, len,
|
|
2187 hl_attr(HLF_FL));
|
|
2188 else
|
|
2189 #endif
|
|
2190 copy_text_attr(off + col, buf, len, hl_attr(HLF_FL));
|
|
2191 col += len;
|
|
2192 }
|
|
2193 }
|
|
2194
|
|
2195 /*
|
|
2196 * 4. Compose the folded-line string with 'foldtext', if set.
|
|
2197 */
|
29
|
2198 text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
|
7
|
2199
|
|
2200 txtcol = col; /* remember where text starts */
|
|
2201
|
|
2202 /*
|
|
2203 * 5. move the text to current_ScreenLine. Fill up with "fill_fold".
|
|
2204 * Right-left text is put in columns 0 - number-col, normal text is put
|
|
2205 * in columns number-col - window-width.
|
|
2206 */
|
|
2207 #ifdef FEAT_MBYTE
|
|
2208 if (has_mbyte)
|
|
2209 {
|
|
2210 int cells;
|
714
|
2211 int u8c, u8cc[MAX_MCO];
|
|
2212 int i;
|
7
|
2213 int idx;
|
|
2214 int c_len;
|
33
|
2215 char_u *p;
|
7
|
2216 # ifdef FEAT_ARABIC
|
|
2217 int prev_c = 0; /* previous Arabic character */
|
|
2218 int prev_c1 = 0; /* first composing char for prev_c */
|
|
2219 # endif
|
|
2220
|
|
2221 # ifdef FEAT_RIGHTLEFT
|
|
2222 if (wp->w_p_rl)
|
|
2223 idx = off;
|
|
2224 else
|
|
2225 # endif
|
|
2226 idx = off + col;
|
|
2227
|
|
2228 /* Store multibyte characters in ScreenLines[] et al. correctly. */
|
|
2229 for (p = text; *p != NUL; )
|
|
2230 {
|
|
2231 cells = (*mb_ptr2cells)(p);
|
474
|
2232 c_len = (*mb_ptr2len)(p);
|
7
|
2233 if (col + cells > W_WIDTH(wp)
|
|
2234 # ifdef FEAT_RIGHTLEFT
|
|
2235 - (wp->w_p_rl ? col : 0)
|
|
2236 # endif
|
|
2237 )
|
|
2238 break;
|
|
2239 ScreenLines[idx] = *p;
|
|
2240 if (enc_utf8)
|
|
2241 {
|
714
|
2242 u8c = utfc_ptr2char(p, u8cc);
|
|
2243 if (*p < 0x80 && u8cc[0] == 0)
|
7
|
2244 {
|
|
2245 ScreenLinesUC[idx] = 0;
|
|
2246 #ifdef FEAT_ARABIC
|
|
2247 prev_c = u8c;
|
|
2248 #endif
|
|
2249 }
|
|
2250 else
|
|
2251 {
|
|
2252 #ifdef FEAT_ARABIC
|
|
2253 if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))
|
|
2254 {
|
|
2255 /* Do Arabic shaping. */
|
714
|
2256 int pc, pc1, nc;
|
|
2257 int pcc[MAX_MCO];
|
7
|
2258 int firstbyte = *p;
|
|
2259
|
|
2260 /* The idea of what is the previous and next
|
|
2261 * character depends on 'rightleft'. */
|
|
2262 if (wp->w_p_rl)
|
|
2263 {
|
|
2264 pc = prev_c;
|
|
2265 pc1 = prev_c1;
|
|
2266 nc = utf_ptr2char(p + c_len);
|
714
|
2267 prev_c1 = u8cc[0];
|
7
|
2268 }
|
|
2269 else
|
|
2270 {
|
714
|
2271 pc = utfc_ptr2char(p + c_len, pcc);
|
7
|
2272 nc = prev_c;
|
714
|
2273 pc1 = pcc[0];
|
7
|
2274 }
|
|
2275 prev_c = u8c;
|
|
2276
|
714
|
2277 u8c = arabic_shape(u8c, &firstbyte, &u8cc[0],
|
7
|
2278 pc, pc1, nc);
|
|
2279 ScreenLines[idx] = firstbyte;
|
|
2280 }
|
|
2281 else
|
|
2282 prev_c = u8c;
|
|
2283 #endif
|
|
2284 /* Non-BMP character: display as ? or fullwidth ?. */
|
|
2285 if (u8c >= 0x10000)
|
|
2286 ScreenLinesUC[idx] = (cells == 2) ? 0xff1f : (int)'?';
|
|
2287 else
|
|
2288 ScreenLinesUC[idx] = u8c;
|
714
|
2289 for (i = 0; i < Screen_mco; ++i)
|
|
2290 {
|
|
2291 ScreenLinesC[i][idx] = u8cc[i];
|
|
2292 if (u8cc[i] == 0)
|
|
2293 break;
|
|
2294 }
|
7
|
2295 }
|
|
2296 if (cells > 1)
|
|
2297 ScreenLines[idx + 1] = 0;
|
|
2298 }
|
|
2299 else if (cells > 1) /* double-byte character */
|
|
2300 {
|
|
2301 if (enc_dbcs == DBCS_JPNU && *p == 0x8e)
|
|
2302 ScreenLines2[idx] = p[1];
|
|
2303 else
|
|
2304 ScreenLines[idx + 1] = p[1];
|
|
2305 }
|
|
2306 col += cells;
|
|
2307 idx += cells;
|
|
2308 p += c_len;
|
|
2309 }
|
|
2310 }
|
|
2311 else
|
|
2312 #endif
|
|
2313 {
|
|
2314 len = (int)STRLEN(text);
|
|
2315 if (len > W_WIDTH(wp) - col)
|
|
2316 len = W_WIDTH(wp) - col;
|
|
2317 if (len > 0)
|
|
2318 {
|
|
2319 #ifdef FEAT_RIGHTLEFT
|
|
2320 if (wp->w_p_rl)
|
|
2321 STRNCPY(current_ScreenLine, text, len);
|
|
2322 else
|
|
2323 #endif
|
|
2324 STRNCPY(current_ScreenLine + col, text, len);
|
|
2325 col += len;
|
|
2326 }
|
|
2327 }
|
|
2328
|
|
2329 /* Fill the rest of the line with the fold filler */
|
|
2330 #ifdef FEAT_RIGHTLEFT
|
|
2331 if (wp->w_p_rl)
|
|
2332 col -= txtcol;
|
|
2333 #endif
|
|
2334 while (col < W_WIDTH(wp)
|
|
2335 #ifdef FEAT_RIGHTLEFT
|
|
2336 - (wp->w_p_rl ? txtcol : 0)
|
|
2337 #endif
|
|
2338 )
|
|
2339 {
|
|
2340 #ifdef FEAT_MBYTE
|
|
2341 if (enc_utf8)
|
|
2342 {
|
|
2343 if (fill_fold >= 0x80)
|
|
2344 {
|
|
2345 ScreenLinesUC[off + col] = fill_fold;
|
714
|
2346 ScreenLinesC[0][off + col] = 0;
|
7
|
2347 }
|
|
2348 else
|
|
2349 ScreenLinesUC[off + col] = 0;
|
|
2350 }
|
|
2351 #endif
|
|
2352 ScreenLines[off + col++] = fill_fold;
|
|
2353 }
|
|
2354
|
|
2355 if (text != buf)
|
|
2356 vim_free(text);
|
|
2357
|
|
2358 /*
|
|
2359 * 6. set highlighting for the Visual area an other text.
|
|
2360 * If all folded lines are in the Visual area, highlight the line.
|
|
2361 */
|
|
2362 #ifdef FEAT_VISUAL
|
|
2363 if (VIsual_active && wp->w_buffer == curwin->w_buffer)
|
|
2364 {
|
|
2365 if (ltoreq(curwin->w_cursor, VIsual))
|
|
2366 {
|
|
2367 /* Visual is after curwin->w_cursor */
|
|
2368 top = &curwin->w_cursor;
|
|
2369 bot = &VIsual;
|
|
2370 }
|
|
2371 else
|
|
2372 {
|
|
2373 /* Visual is before curwin->w_cursor */
|
|
2374 top = &VIsual;
|
|
2375 bot = &curwin->w_cursor;
|
|
2376 }
|
|
2377 if (lnum >= top->lnum
|
|
2378 && lnume <= bot->lnum
|
|
2379 && (VIsual_mode != 'v'
|
|
2380 || ((lnum > top->lnum
|
|
2381 || (lnum == top->lnum
|
|
2382 && top->col == 0))
|
|
2383 && (lnume < bot->lnum
|
|
2384 || (lnume == bot->lnum
|
|
2385 && (bot->col - (*p_sel == 'e'))
|
|
2386 >= STRLEN(ml_get_buf(wp->w_buffer, lnume, FALSE)))))))
|
|
2387 {
|
|
2388 if (VIsual_mode == Ctrl_V)
|
|
2389 {
|
|
2390 /* Visual block mode: highlight the chars part of the block */
|
|
2391 if (wp->w_old_cursor_fcol + txtcol < (colnr_T)W_WIDTH(wp))
|
|
2392 {
|
|
2393 if (wp->w_old_cursor_lcol + txtcol < (colnr_T)W_WIDTH(wp))
|
|
2394 len = wp->w_old_cursor_lcol;
|
|
2395 else
|
|
2396 len = W_WIDTH(wp) - txtcol;
|
|
2397 RL_MEMSET(wp->w_old_cursor_fcol + txtcol, hl_attr(HLF_V),
|
230
|
2398 len - (int)wp->w_old_cursor_fcol);
|
7
|
2399 }
|
|
2400 }
|
|
2401 else
|
216
|
2402 {
|
7
|
2403 /* Set all attributes of the text */
|
216
|
2404 RL_MEMSET(txtcol, hl_attr(HLF_V), W_WIDTH(wp) - txtcol);
|
|
2405 }
|
7
|
2406 }
|
|
2407 }
|
|
2408 #endif
|
|
2409
|
743
|
2410 #ifdef FEAT_SYN_HL
|
|
2411 /* Show 'cursorcolumn' in the fold line. */
|
|
2412 if (wp->w_p_cuc && (int)wp->w_virtcol + txtcol < W_WIDTH(wp))
|
|
2413 ScreenAttrs[off + wp->w_virtcol + txtcol] = hl_combine_attr(
|
|
2414 ScreenAttrs[off + wp->w_virtcol + txtcol], hl_attr(HLF_CUC));
|
|
2415 #endif
|
7
|
2416
|
|
2417 SCREEN_LINE(row + W_WINROW(wp), W_WINCOL(wp), (int)W_WIDTH(wp),
|
|
2418 (int)W_WIDTH(wp), FALSE);
|
|
2419
|
|
2420 /*
|
|
2421 * Update w_cline_height and w_cline_folded if the cursor line was
|
|
2422 * updated (saves a call to plines() later).
|
|
2423 */
|
|
2424 if (wp == curwin
|
|
2425 && lnum <= curwin->w_cursor.lnum
|
|
2426 && lnume >= curwin->w_cursor.lnum)
|
|
2427 {
|
|
2428 curwin->w_cline_row = row;
|
|
2429 curwin->w_cline_height = 1;
|
|
2430 curwin->w_cline_folded = TRUE;
|
|
2431 curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW);
|
|
2432 }
|
|
2433 }
|
|
2434
|
|
2435 /*
|
|
2436 * Copy "buf[len]" to ScreenLines["off"] and set attributes to "attr".
|
|
2437 */
|
|
2438 static void
|
|
2439 copy_text_attr(off, buf, len, attr)
|
|
2440 int off;
|
|
2441 char_u *buf;
|
|
2442 int len;
|
|
2443 int attr;
|
|
2444 {
|
216
|
2445 int i;
|
|
2446
|
7
|
2447 mch_memmove(ScreenLines + off, buf, (size_t)len);
|
|
2448 # ifdef FEAT_MBYTE
|
|
2449 if (enc_utf8)
|
|
2450 vim_memset(ScreenLinesUC + off, 0, sizeof(u8char_T) * (size_t)len);
|
|
2451 # endif
|
216
|
2452 for (i = 0; i < len; ++i)
|
|
2453 ScreenAttrs[off + i] = attr;
|
7
|
2454 }
|
|
2455
|
|
2456 /*
|
|
2457 * Fill the foldcolumn at "p" for window "wp".
|
548
|
2458 * Only to be called when 'foldcolumn' > 0.
|
7
|
2459 */
|
|
2460 static void
|
|
2461 fill_foldcolumn(p, wp, closed, lnum)
|
|
2462 char_u *p;
|
|
2463 win_T *wp;
|
|
2464 int closed; /* TRUE of FALSE */
|
|
2465 linenr_T lnum; /* current line number */
|
|
2466 {
|
|
2467 int i = 0;
|
|
2468 int level;
|
|
2469 int first_level;
|
519
|
2470 int empty;
|
7
|
2471
|
|
2472 /* Init to all spaces. */
|
|
2473 copy_spaces(p, (size_t)wp->w_p_fdc);
|
|
2474
|
|
2475 level = win_foldinfo.fi_level;
|
|
2476 if (level > 0)
|
|
2477 {
|
519
|
2478 /* If there is only one column put more info in it. */
|
|
2479 empty = (wp->w_p_fdc == 1) ? 0 : 1;
|
|
2480
|
7
|
2481 /* If the column is too narrow, we start at the lowest level that
|
|
2482 * fits and use numbers to indicated the depth. */
|
519
|
2483 first_level = level - wp->w_p_fdc - closed + 1 + empty;
|
7
|
2484 if (first_level < 1)
|
|
2485 first_level = 1;
|
|
2486
|
519
|
2487 for (i = 0; i + empty < wp->w_p_fdc; ++i)
|
7
|
2488 {
|
|
2489 if (win_foldinfo.fi_lnum == lnum
|
|
2490 && first_level + i >= win_foldinfo.fi_low_level)
|
|
2491 p[i] = '-';
|
|
2492 else if (first_level == 1)
|
|
2493 p[i] = '|';
|
|
2494 else if (first_level + i <= 9)
|
|
2495 p[i] = '0' + first_level + i;
|
|
2496 else
|
|
2497 p[i] = '>';
|
|
2498 if (first_level + i == level)
|
|
2499 break;
|
|
2500 }
|
|
2501 }
|
|
2502 if (closed)
|
548
|
2503 p[i >= wp->w_p_fdc ? i - 1 : i] = '+';
|
7
|
2504 }
|
|
2505 #endif /* FEAT_FOLDING */
|
|
2506
|
|
2507 /*
|
|
2508 * Display line "lnum" of window 'wp' on the screen.
|
|
2509 * Start at row "startrow", stop when "endrow" is reached.
|
|
2510 * wp->w_virtcol needs to be valid.
|
|
2511 *
|
|
2512 * Return the number of last row the line occupies.
|
|
2513 */
|
625
|
2514 /* ARGSUSED */
|
7
|
2515 static int
|
625
|
2516 win_line(wp, lnum, startrow, endrow, nochange)
|
7
|
2517 win_T *wp;
|
|
2518 linenr_T lnum;
|
|
2519 int startrow;
|
|
2520 int endrow;
|
625
|
2521 int nochange; /* not updating for changed text */
|
7
|
2522 {
|
|
2523 int col; /* visual column on screen */
|
|
2524 unsigned off; /* offset in ScreenLines/ScreenAttrs */
|
|
2525 int c = 0; /* init for GCC */
|
|
2526 long vcol = 0; /* virtual column (for tabs) */
|
|
2527 long vcol_prev = -1; /* "vcol" of previous character */
|
|
2528 char_u *line; /* current line */
|
|
2529 char_u *ptr; /* current position in "line" */
|
|
2530 int row; /* row in the window, excl w_winrow */
|
|
2531 int screen_row; /* row on the screen, incl w_winrow */
|
|
2532
|
|
2533 char_u extra[18]; /* "%ld" and 'fdc' must fit in here */
|
|
2534 int n_extra = 0; /* number of extra chars */
|
|
2535 char_u *p_extra = NULL; /* string of extra chars */
|
|
2536 int c_extra = NUL; /* extra chars, all the same */
|
|
2537 int extra_attr = 0; /* attributes when n_extra != 0 */
|
|
2538 static char_u *at_end_str = (char_u *)""; /* used for p_extra when
|
|
2539 displaying lcs_eol at end-of-line */
|
|
2540 int lcs_eol_one = lcs_eol; /* lcs_eol until it's been used */
|
|
2541 int lcs_prec_todo = lcs_prec; /* lcs_prec until it's been used */
|
|
2542
|
|
2543 /* saved "extra" items for when draw_state becomes WL_LINE (again) */
|
|
2544 int saved_n_extra = 0;
|
|
2545 char_u *saved_p_extra = NULL;
|
|
2546 int saved_c_extra = 0;
|
|
2547 int saved_char_attr = 0;
|
|
2548
|
|
2549 int n_attr = 0; /* chars with special attr */
|
|
2550 int saved_attr2 = 0; /* char_attr saved for n_attr */
|
|
2551 int n_attr3 = 0; /* chars with overruling special attr */
|
|
2552 int saved_attr3 = 0; /* char_attr saved for n_attr3 */
|
|
2553
|
|
2554 int n_skip = 0; /* nr of chars to skip for 'nowrap' */
|
|
2555
|
|
2556 int fromcol, tocol; /* start/end of inverting */
|
|
2557 int fromcol_prev = -2; /* start of inverting after cursor */
|
|
2558 int noinvcur = FALSE; /* don't invert the cursor */
|
|
2559 #ifdef FEAT_VISUAL
|
|
2560 pos_T *top, *bot;
|
|
2561 #endif
|
|
2562 pos_T pos;
|
|
2563 long v;
|
|
2564
|
|
2565 int char_attr = 0; /* attributes for next character */
|
674
|
2566 int attr_pri = FALSE; /* char_attr has priority */
|
7
|
2567 int area_highlighting = FALSE; /* Visual or incsearch highlighting
|
|
2568 in this line */
|
|
2569 int attr = 0; /* attributes for area highlighting */
|
|
2570 int area_attr = 0; /* attributes desired by highlighting */
|
|
2571 int search_attr = 0; /* attributes desired by 'hlsearch' */
|
|
2572 #ifdef FEAT_SYN_HL
|
743
|
2573 int vcol_save_attr = 0; /* saved attr for 'cursorcolumn' */
|
7
|
2574 int syntax_attr = 0; /* attributes desired by syntax */
|
|
2575 int has_syntax = FALSE; /* this buffer has syntax highl. */
|
|
2576 int save_did_emsg;
|
743
|
2577 #endif
|
|
2578 #ifdef FEAT_SPELL
|
221
|
2579 int has_spell = FALSE; /* this buffer has spell checking */
|
348
|
2580 # define SPWORDLEN 150
|
|
2581 char_u nextline[SPWORDLEN * 2];/* text with start of the next line */
|
353
|
2582 int nextlinecol = 0; /* column where nextline[] starts */
|
|
2583 int nextline_idx = 0; /* index in nextline[] where next line
|
348
|
2584 starts */
|
221
|
2585 int spell_attr = 0; /* attributes desired by spelling */
|
|
2586 int word_end = 0; /* last byte with same spell_attr */
|
378
|
2587 static linenr_T checked_lnum = 0; /* line number for "checked_col" */
|
|
2588 static int checked_col = 0; /* column in "checked_lnum" up to which
|
348
|
2589 * there are no spell errors */
|
386
|
2590 static int cap_col = -1; /* column to check for Cap word */
|
|
2591 static linenr_T capcol_lnum = 0; /* line number where "cap_col" used */
|
348
|
2592 int cur_checked_col = 0; /* checked column for current line */
|
7
|
2593 #endif
|
|
2594 int extra_check; /* has syntax or linebreak */
|
|
2595 #ifdef FEAT_MBYTE
|
|
2596 int multi_attr = 0; /* attributes desired by multibyte */
|
|
2597 int mb_l = 1; /* multi-byte byte length */
|
|
2598 int mb_c = 0; /* decoded multi-byte character */
|
|
2599 int mb_utf8 = FALSE; /* screen char is UTF-8 char */
|
714
|
2600 int u8cc[MAX_MCO]; /* composing UTF-8 chars */
|
7
|
2601 #endif
|
|
2602 #ifdef FEAT_DIFF
|
|
2603 int filler_lines; /* nr of filler lines to be drawn */
|
|
2604 int filler_todo; /* nr of filler lines still to do + 1 */
|
534
|
2605 hlf_T diff_hlf = (hlf_T)0; /* type of diff highlighting */
|
7
|
2606 int change_start = MAXCOL; /* first col of changed area */
|
|
2607 int change_end = -1; /* last col of changed area */
|
|
2608 #endif
|
|
2609 colnr_T trailcol = MAXCOL; /* start of trailing spaces */
|
|
2610 #ifdef FEAT_LINEBREAK
|
|
2611 int need_showbreak = FALSE;
|
|
2612 #endif
|
910
|
2613 #if defined(FEAT_SIGNS) || (defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS)) \
|
|
2614 || defined(FEAT_SYN_HL) || defined(FEAT_DIFF)
|
7
|
2615 # define LINE_ATTR
|
|
2616 int line_attr = 0; /* atrribute for the whole line */
|
|
2617 #endif
|
|
2618 #ifdef FEAT_SEARCH_EXTRA
|
1326
|
2619 matchitem_T *cur; /* points to the match list */
|
|
2620 match_T *shl; /* points to search_hl or a match */
|
|
2621 int shl_flag; /* flag to indicate whether search_hl
|
|
2622 has been processed or not */
|
|
2623 int prevcol_hl_flag; /* flag to indicate whether prevcol
|
|
2624 equals startcol of search_hl or one
|
|
2625 of the matches */
|
7
|
2626 #endif
|
|
2627 #ifdef FEAT_ARABIC
|
|
2628 int prev_c = 0; /* previous Arabic character */
|
|
2629 int prev_c1 = 0; /* first composing char for prev_c */
|
|
2630 #endif
|
910
|
2631 #if defined(LINE_ATTR)
|
867
|
2632 int did_line_attr = 0;
|
|
2633 #endif
|
7
|
2634
|
|
2635 /* draw_state: items that are drawn in sequence: */
|
|
2636 #define WL_START 0 /* nothing done yet */
|
|
2637 #ifdef FEAT_CMDWIN
|
|
2638 # define WL_CMDLINE WL_START + 1 /* cmdline window column */
|
|
2639 #else
|
|
2640 # define WL_CMDLINE WL_START
|
|
2641 #endif
|
|
2642 #ifdef FEAT_FOLDING
|
|
2643 # define WL_FOLD WL_CMDLINE + 1 /* 'foldcolumn' */
|
|
2644 #else
|
|
2645 # define WL_FOLD WL_CMDLINE
|
|
2646 #endif
|
|
2647 #ifdef FEAT_SIGNS
|
|
2648 # define WL_SIGN WL_FOLD + 1 /* column for signs */
|
|
2649 #else
|
|
2650 # define WL_SIGN WL_FOLD /* column for signs */
|
|
2651 #endif
|
|
2652 #define WL_NR WL_SIGN + 1 /* line number */
|
|
2653 #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
|
|
2654 # define WL_SBR WL_NR + 1 /* 'showbreak' or 'diff' */
|
|
2655 #else
|
|
2656 # define WL_SBR WL_NR
|
|
2657 #endif
|
|
2658 #define WL_LINE WL_SBR + 1 /* text in the line */
|
|
2659 int draw_state = WL_START; /* what to draw next */
|
574
|
2660 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
|
7
|
2661 int feedback_col = 0;
|
|
2662 int feedback_old_attr = -1;
|
|
2663 #endif
|
|
2664
|
|
2665
|
|
2666 if (startrow > endrow) /* past the end already! */
|
|
2667 return startrow;
|
|
2668
|
|
2669 row = startrow;
|
|
2670 screen_row = row + W_WINROW(wp);
|
|
2671
|
|
2672 /*
|
|
2673 * To speed up the loop below, set extra_check when there is linebreak,
|
|
2674 * trailing white space and/or syntax processing to be done.
|
|
2675 */
|
|
2676 #ifdef FEAT_LINEBREAK
|
|
2677 extra_check = wp->w_p_lbr;
|
|
2678 #else
|
|
2679 extra_check = 0;
|
|
2680 #endif
|
|
2681 #ifdef FEAT_SYN_HL
|
482
|
2682 if (syntax_present(wp->w_buffer) && !wp->w_buffer->b_syn_error)
|
7
|
2683 {
|
|
2684 /* Prepare for syntax highlighting in this line. When there is an
|
|
2685 * error, stop syntax highlighting. */
|
|
2686 save_did_emsg = did_emsg;
|
|
2687 did_emsg = FALSE;
|
|
2688 syntax_start(wp, lnum);
|
|
2689 if (did_emsg)
|
482
|
2690 wp->w_buffer->b_syn_error = TRUE;
|
7
|
2691 else
|
|
2692 {
|
|
2693 did_emsg = save_did_emsg;
|
|
2694 has_syntax = TRUE;
|
|
2695 extra_check = TRUE;
|
|
2696 }
|
|
2697 }
|
743
|
2698 #endif
|
|
2699
|
|
2700 #ifdef FEAT_SPELL
|
258
|
2701 if (wp->w_p_spell
|
|
2702 && *wp->w_buffer->b_p_spl != NUL
|
|
2703 && wp->w_buffer->b_langp.ga_len > 0
|
|
2704 && *(char **)(wp->w_buffer->b_langp.ga_data) != NULL)
|
221
|
2705 {
|
|
2706 /* Prepare for spell checking. */
|
|
2707 has_spell = TRUE;
|
|
2708 extra_check = TRUE;
|
348
|
2709
|
|
2710 /* Get the start of the next line, so that words that wrap to the next
|
|
2711 * line are found too: "et<line-break>al.".
|
|
2712 * Trick: skip a few chars for C/shell/Vim comments */
|
|
2713 nextline[SPWORDLEN] = NUL;
|
|
2714 if (lnum < wp->w_buffer->b_ml.ml_line_count)
|
|
2715 {
|
|
2716 line = ml_get_buf(wp->w_buffer, lnum + 1, FALSE);
|
|
2717 spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN);
|
|
2718 }
|
|
2719
|
|
2720 /* When a word wrapped from the previous line the start of the current
|
|
2721 * line is valid. */
|
|
2722 if (lnum == checked_lnum)
|
|
2723 cur_checked_col = checked_col;
|
|
2724 checked_lnum = 0;
|
386
|
2725
|
|
2726 /* When there was a sentence end in the previous line may require a
|
|
2727 * word starting with capital in this line. In line 1 always check
|
|
2728 * the first word. */
|
|
2729 if (lnum != capcol_lnum)
|
|
2730 cap_col = -1;
|
|
2731 if (lnum == 1)
|
|
2732 cap_col = 0;
|
|
2733 capcol_lnum = 0;
|
221
|
2734 }
|
7
|
2735 #endif
|
|
2736
|
|
2737 /*
|
|
2738 * handle visual active in this window
|
|
2739 */
|
|
2740 fromcol = -10;
|
|
2741 tocol = MAXCOL;
|
|
2742 #ifdef FEAT_VISUAL
|
|
2743 if (VIsual_active && wp->w_buffer == curwin->w_buffer)
|
|
2744 {
|
|
2745 /* Visual is after curwin->w_cursor */
|
|
2746 if (ltoreq(curwin->w_cursor, VIsual))
|
|
2747 {
|
|
2748 top = &curwin->w_cursor;
|
|
2749 bot = &VIsual;
|
|
2750 }
|
|
2751 else /* Visual is before curwin->w_cursor */
|
|
2752 {
|
|
2753 top = &VIsual;
|
|
2754 bot = &curwin->w_cursor;
|
|
2755 }
|
|
2756 if (VIsual_mode == Ctrl_V) /* block mode */
|
|
2757 {
|
|
2758 if (lnum >= top->lnum && lnum <= bot->lnum)
|
|
2759 {
|
|
2760 fromcol = wp->w_old_cursor_fcol;
|
|
2761 tocol = wp->w_old_cursor_lcol;
|
|
2762 }
|
|
2763 }
|
|
2764 else /* non-block mode */
|
|
2765 {
|
|
2766 if (lnum > top->lnum && lnum <= bot->lnum)
|
|
2767 fromcol = 0;
|
|
2768 else if (lnum == top->lnum)
|
|
2769 {
|
|
2770 if (VIsual_mode == 'V') /* linewise */
|
|
2771 fromcol = 0;
|
|
2772 else
|
|
2773 {
|
|
2774 getvvcol(wp, top, (colnr_T *)&fromcol, NULL, NULL);
|
|
2775 if (gchar_pos(top) == NUL)
|
|
2776 tocol = fromcol + 1;
|
|
2777 }
|
|
2778 }
|
|
2779 if (VIsual_mode != 'V' && lnum == bot->lnum)
|
|
2780 {
|
|
2781 if (*p_sel == 'e' && bot->col == 0
|
|
2782 #ifdef FEAT_VIRTUALEDIT
|
|
2783 && bot->coladd == 0
|
|
2784 #endif
|
|
2785 )
|
|
2786 {
|
|
2787 fromcol = -10;
|
|
2788 tocol = MAXCOL;
|
|
2789 }
|
36
|
2790 else if (bot->col == MAXCOL)
|
|
2791 tocol = MAXCOL;
|
7
|
2792 else
|
|
2793 {
|
|
2794 pos = *bot;
|
|
2795 if (*p_sel == 'e')
|
|
2796 getvvcol(wp, &pos, (colnr_T *)&tocol, NULL, NULL);
|
|
2797 else
|
|
2798 {
|
|
2799 getvvcol(wp, &pos, NULL, NULL, (colnr_T *)&tocol);
|
|
2800 ++tocol;
|
|
2801 }
|
|
2802 }
|
|
2803 }
|
|
2804 }
|
|
2805
|
|
2806 #ifndef MSDOS
|
|
2807 /* Check if the character under the cursor should not be inverted */
|
|
2808 if (!highlight_match && lnum == curwin->w_cursor.lnum && wp == curwin
|
|
2809 # ifdef FEAT_GUI
|
|
2810 && !gui.in_use
|
|
2811 # endif
|
|
2812 )
|
|
2813 noinvcur = TRUE;
|
|
2814 #endif
|
|
2815
|
|
2816 /* if inverting in this line set area_highlighting */
|
|
2817 if (fromcol >= 0)
|
|
2818 {
|
|
2819 area_highlighting = TRUE;
|
|
2820 attr = hl_attr(HLF_V);
|
|
2821 #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
|
|
2822 if (clip_star.available && !clip_star.owned && clip_isautosel())
|
|
2823 attr = hl_attr(HLF_VNC);
|
|
2824 #endif
|
|
2825 }
|
|
2826 }
|
|
2827
|
|
2828 /*
|
674
|
2829 * handle 'incsearch' and ":s///c" highlighting
|
7
|
2830 */
|
|
2831 else
|
|
2832 #endif /* FEAT_VISUAL */
|
|
2833 if (highlight_match
|
|
2834 && wp == curwin
|
|
2835 && lnum >= curwin->w_cursor.lnum
|
|
2836 && lnum <= curwin->w_cursor.lnum + search_match_lines)
|
|
2837 {
|
|
2838 if (lnum == curwin->w_cursor.lnum)
|
|
2839 getvcol(curwin, &(curwin->w_cursor),
|
|
2840 (colnr_T *)&fromcol, NULL, NULL);
|
|
2841 else
|
|
2842 fromcol = 0;
|
|
2843 if (lnum == curwin->w_cursor.lnum + search_match_lines)
|
|
2844 {
|
|
2845 pos.lnum = lnum;
|
|
2846 pos.col = search_match_endcol;
|
|
2847 getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL);
|
|
2848 }
|
|
2849 else
|
|
2850 tocol = MAXCOL;
|
|
2851 if (fromcol == tocol) /* do at least one character */
|
|
2852 tocol = fromcol + 1; /* happens when past end of line */
|
|
2853 area_highlighting = TRUE;
|
|
2854 attr = hl_attr(HLF_I);
|
|
2855 }
|
|
2856
|
|
2857 #ifdef FEAT_DIFF
|
|
2858 filler_lines = diff_check(wp, lnum);
|
|
2859 if (filler_lines < 0)
|
|
2860 {
|
|
2861 if (filler_lines == -1)
|
|
2862 {
|
|
2863 if (diff_find_change(wp, lnum, &change_start, &change_end))
|
|
2864 diff_hlf = HLF_ADD; /* added line */
|
|
2865 else if (change_start == 0)
|
|
2866 diff_hlf = HLF_TXD; /* changed text */
|
|
2867 else
|
|
2868 diff_hlf = HLF_CHD; /* changed line */
|
|
2869 }
|
|
2870 else
|
|
2871 diff_hlf = HLF_ADD; /* added line */
|
|
2872 filler_lines = 0;
|
|
2873 area_highlighting = TRUE;
|
|
2874 }
|
|
2875 if (lnum == wp->w_topline)
|
|
2876 filler_lines = wp->w_topfill;
|
|
2877 filler_todo = filler_lines;
|
|
2878 #endif
|
|
2879
|
|
2880 #ifdef LINE_ATTR
|
|
2881 # ifdef FEAT_SIGNS
|
|
2882 /* If this line has a sign with line highlighting set line_attr. */
|
|
2883 v = buf_getsigntype(wp->w_buffer, lnum, SIGN_LINEHL);
|
|
2884 if (v != 0)
|
|
2885 line_attr = sign_get_attr((int)v, TRUE);
|
|
2886 # endif
|
|
2887 # if defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS)
|
|
2888 /* Highlight the current line in the quickfix window. */
|
644
|
2889 if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum)
|
7
|
2890 line_attr = hl_attr(HLF_L);
|
|
2891 # endif
|
|
2892 if (line_attr != 0)
|
|
2893 area_highlighting = TRUE;
|
|
2894 #endif
|
|
2895
|
|
2896 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
|
2897 ptr = line;
|
|
2898
|
743
|
2899 #ifdef FEAT_SPELL
|
348
|
2900 if (has_spell)
|
|
2901 {
|
386
|
2902 /* For checking first word with a capital skip white space. */
|
|
2903 if (cap_col == 0)
|
835
|
2904 cap_col = (int)(skipwhite(line) - line);
|
386
|
2905
|
348
|
2906 /* To be able to spell-check over line boundaries copy the end of the
|
|
2907 * current line into nextline[]. Above the start of the next line was
|
|
2908 * copied to nextline[SPWORDLEN]. */
|
|
2909 if (nextline[SPWORDLEN] == NUL)
|
|
2910 {
|
|
2911 /* No next line or it is empty. */
|
|
2912 nextlinecol = MAXCOL;
|
|
2913 nextline_idx = 0;
|
|
2914 }
|
|
2915 else
|
|
2916 {
|
835
|
2917 v = (long)STRLEN(line);
|
348
|
2918 if (v < SPWORDLEN)
|
|
2919 {
|
|
2920 /* Short line, use it completely and append the start of the
|
|
2921 * next line. */
|
|
2922 nextlinecol = 0;
|
|
2923 mch_memmove(nextline, line, (size_t)v);
|
|
2924 mch_memmove(nextline + v, nextline + SPWORDLEN,
|
|
2925 STRLEN(nextline + SPWORDLEN) + 1);
|
|
2926 nextline_idx = v + 1;
|
|
2927 }
|
|
2928 else
|
|
2929 {
|
|
2930 /* Long line, use only the last SPWORDLEN bytes. */
|
|
2931 nextlinecol = v - SPWORDLEN;
|
|
2932 mch_memmove(nextline, line + nextlinecol, SPWORDLEN);
|
|
2933 nextline_idx = SPWORDLEN + 1;
|
|
2934 }
|
|
2935 }
|
|
2936 }
|
|
2937 #endif
|
|
2938
|
7
|
2939 /* find start of trailing whitespace */
|
|
2940 if (wp->w_p_list && lcs_trail)
|
|
2941 {
|
|
2942 trailcol = (colnr_T)STRLEN(ptr);
|
|
2943 while (trailcol > (colnr_T)0 && vim_iswhite(ptr[trailcol - 1]))
|
|
2944 --trailcol;
|
|
2945 trailcol += (colnr_T) (ptr - line);
|
|
2946 extra_check = TRUE;
|
|
2947 }
|
|
2948
|
|
2949 /*
|
|
2950 * 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the
|
|
2951 * first character to be displayed.
|
|
2952 */
|
|
2953 if (wp->w_p_wrap)
|
|
2954 v = wp->w_skipcol;
|
|
2955 else
|
|
2956 v = wp->w_leftcol;
|
|
2957 if (v > 0)
|
|
2958 {
|
|
2959 #ifdef FEAT_MBYTE
|
|
2960 char_u *prev_ptr = ptr;
|
|
2961 #endif
|
|
2962 while (vcol < v && *ptr != NUL)
|
|
2963 {
|
|
2964 c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL);
|
|
2965 vcol += c;
|
|
2966 #ifdef FEAT_MBYTE
|
|
2967 prev_ptr = ptr;
|
39
|
2968 #endif
|
|
2969 mb_ptr_adv(ptr);
|
7
|
2970 }
|
|
2971
|
|
2972 #ifdef FEAT_VIRTUALEDIT
|
|
2973 /* When 'virtualedit' is set the end of the line may be before the
|
|
2974 * start of the displayed part. */
|
|
2975 if (vcol < v && *ptr == NUL && virtual_active())
|
|
2976 vcol = v;
|
|
2977 #endif
|
|
2978
|
|
2979 /* Handle a character that's not completely on the screen: Put ptr at
|
|
2980 * that character but skip the first few screen characters. */
|
|
2981 if (vcol > v)
|
|
2982 {
|
|
2983 vcol -= c;
|
|
2984 #ifdef FEAT_MBYTE
|
|
2985 ptr = prev_ptr;
|
|
2986 #else
|
|
2987 --ptr;
|
|
2988 #endif
|
|
2989 n_skip = v - vcol;
|
|
2990 }
|
|
2991
|
|
2992 /*
|
|
2993 * Adjust for when the inverted text is before the screen,
|
|
2994 * and when the start of the inverted text is before the screen.
|
|
2995 */
|
|
2996 if (tocol <= vcol)
|
|
2997 fromcol = 0;
|
|
2998 else if (fromcol >= 0 && fromcol < vcol)
|
|
2999 fromcol = vcol;
|
|
3000
|
|
3001 #ifdef FEAT_LINEBREAK
|
|
3002 /* When w_skipcol is non-zero, first line needs 'showbreak' */
|
|
3003 if (wp->w_p_wrap)
|
|
3004 need_showbreak = TRUE;
|
|
3005 #endif
|
743
|
3006 #ifdef FEAT_SPELL
|
499
|
3007 /* When spell checking a word we need to figure out the start of the
|
|
3008 * word and if it's badly spelled or not. */
|
|
3009 if (has_spell)
|
|
3010 {
|
|
3011 int len;
|
534
|
3012 hlf_T spell_hlf = HLF_COUNT;
|
499
|
3013
|
|
3014 pos = wp->w_cursor;
|
|
3015 wp->w_cursor.lnum = lnum;
|
835
|
3016 wp->w_cursor.col = (colnr_T)(ptr - line);
|
534
|
3017 len = spell_move_to(wp, FORWARD, TRUE, TRUE, &spell_hlf);
|
530
|
3018 if (len == 0 || (int)wp->w_cursor.col > ptr - line)
|
499
|
3019 {
|
|
3020 /* no bad word found at line start, don't check until end of a
|
|
3021 * word */
|
534
|
3022 spell_hlf = HLF_COUNT;
|
835
|
3023 word_end = (int)(spell_to_word_end(ptr, wp->w_buffer) - line + 1);
|
499
|
3024 }
|
|
3025 else
|
534
|
3026 {
|
499
|
3027 /* bad word found, use attributes until end of word */
|
|
3028 word_end = wp->w_cursor.col + len + 1;
|
|
3029
|
534
|
3030 /* Turn index into actual attributes. */
|
|
3031 if (spell_hlf != HLF_COUNT)
|
|
3032 spell_attr = highlight_attr[spell_hlf];
|
|
3033 }
|
499
|
3034 wp->w_cursor = pos;
|
501
|
3035
|
743
|
3036 # ifdef FEAT_SYN_HL
|
501
|
3037 /* Need to restart syntax highlighting for this line. */
|
|
3038 if (has_syntax)
|
|
3039 syntax_start(wp, lnum);
|
743
|
3040 # endif
|
499
|
3041 }
|
|
3042 #endif
|
7
|
3043 }
|
|
3044
|
|
3045 /*
|
|
3046 * Correct highlighting for cursor that can't be disabled.
|
|
3047 * Avoids having to check this for each character.
|
|
3048 */
|
|
3049 if (fromcol >= 0)
|
|
3050 {
|
|
3051 if (noinvcur)
|
|
3052 {
|
|
3053 if ((colnr_T)fromcol == wp->w_virtcol)
|
|
3054 {
|
|
3055 /* highlighting starts at cursor, let it start just after the
|
|
3056 * cursor */
|
|
3057 fromcol_prev = fromcol;
|
|
3058 fromcol = -1;
|
|
3059 }
|
|
3060 else if ((colnr_T)fromcol < wp->w_virtcol)
|
|
3061 /* restart highlighting after the cursor */
|
|
3062 fromcol_prev = wp->w_virtcol;
|
|
3063 }
|
|
3064 if (fromcol >= tocol)
|
|
3065 fromcol = -1;
|
|
3066 }
|
|
3067
|
|
3068 #ifdef FEAT_SEARCH_EXTRA
|
|
3069 /*
|
1326
|
3070 * Handle highlighting the last used search pattern and matches.
|
|
3071 * Do this for both search_hl and the match list.
|
7
|
3072 */
|
1326
|
3073 cur = wp->w_match_head;
|
|
3074 shl_flag = FALSE;
|
|
3075 while (cur != NULL || shl_flag == FALSE)
|
|
3076 {
|
|
3077 if (shl_flag == FALSE)
|
|
3078 {
|
|
3079 shl = &search_hl;
|
|
3080 shl_flag = TRUE;
|
|
3081 }
|
|
3082 else
|
|
3083 shl = &cur->hl;
|
36
|
3084 shl->startcol = MAXCOL;
|
|
3085 shl->endcol = MAXCOL;
|
7
|
3086 shl->attr_cur = 0;
|
|
3087 if (shl->rm.regprog != NULL)
|
|
3088 {
|
|
3089 v = (long)(ptr - line);
|
|
3090 next_search_hl(wp, shl, lnum, (colnr_T)v);
|
|
3091
|
|
3092 /* Need to get the line again, a multi-line regexp may have made it
|
|
3093 * invalid. */
|
|
3094 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
|
3095 ptr = line + v;
|
|
3096
|
|
3097 if (shl->lnum != 0 && shl->lnum <= lnum)
|
|
3098 {
|
|
3099 if (shl->lnum == lnum)
|
36
|
3100 shl->startcol = shl->rm.startpos[0].col;
|
7
|
3101 else
|
36
|
3102 shl->startcol = 0;
|
7
|
3103 if (lnum == shl->lnum + shl->rm.endpos[0].lnum
|
|
3104 - shl->rm.startpos[0].lnum)
|
36
|
3105 shl->endcol = shl->rm.endpos[0].col;
|
7
|
3106 else
|
36
|
3107 shl->endcol = MAXCOL;
|
7
|
3108 /* Highlight one character for an empty match. */
|
36
|
3109 if (shl->startcol == shl->endcol)
|
7
|
3110 {
|
|
3111 #ifdef FEAT_MBYTE
|
36
|
3112 if (has_mbyte && line[shl->endcol] != NUL)
|
474
|
3113 shl->endcol += (*mb_ptr2len)(line + shl->endcol);
|
7
|
3114 else
|
|
3115 #endif
|
36
|
3116 ++shl->endcol;
|
7
|
3117 }
|
36
|
3118 if ((long)shl->startcol < v) /* match at leftcol */
|
7
|
3119 {
|
|
3120 shl->attr_cur = shl->attr;
|
|
3121 search_attr = shl->attr;
|
|
3122 }
|
|
3123 area_highlighting = TRUE;
|
|
3124 }
|
|
3125 }
|
1326
|
3126 if (shl != &search_hl && cur != NULL)
|
|
3127 cur = cur->next;
|
7
|
3128 }
|
|
3129 #endif
|
|
3130
|
743
|
3131 #ifdef FEAT_SYN_HL
|
818
|
3132 /* Cursor line highlighting for 'cursorline'. Not when Visual mode is
|
|
3133 * active, because it's not clear what is selected then. */
|
|
3134 if (wp->w_p_cul && lnum == wp->w_cursor.lnum && !VIsual_active)
|
743
|
3135 {
|
|
3136 line_attr = hl_attr(HLF_CUL);
|
|
3137 area_highlighting = TRUE;
|
|
3138 }
|
|
3139 #endif
|
|
3140
|
504
|
3141 off = (unsigned)(current_ScreenLine - ScreenLines);
|
7
|
3142 col = 0;
|
|
3143 #ifdef FEAT_RIGHTLEFT
|
|
3144 if (wp->w_p_rl)
|
|
3145 {
|
|
3146 /* Rightleft window: process the text in the normal direction, but put
|
|
3147 * it in current_ScreenLine[] from right to left. Start at the
|
|
3148 * rightmost column of the window. */
|
|
3149 col = W_WIDTH(wp) - 1;
|
|
3150 off += col;
|
|
3151 }
|
|
3152 #endif
|
|
3153
|
|
3154 /*
|
|
3155 * Repeat for the whole displayed line.
|
|
3156 */
|
|
3157 for (;;)
|
|
3158 {
|
|
3159 /* Skip this quickly when working on the text. */
|
|
3160 if (draw_state != WL_LINE)
|
|
3161 {
|
|
3162 #ifdef FEAT_CMDWIN
|
|
3163 if (draw_state == WL_CMDLINE - 1 && n_extra == 0)
|
|
3164 {
|
|
3165 draw_state = WL_CMDLINE;
|
|
3166 if (cmdwin_type != 0 && wp == curwin)
|
|
3167 {
|
|
3168 /* Draw the cmdline character. */
|
|
3169 *extra = cmdwin_type;
|
|
3170 n_extra = 1;
|
|
3171 p_extra = extra;
|
|
3172 c_extra = NUL;
|
|
3173 char_attr = hl_attr(HLF_AT);
|
|
3174 }
|
|
3175 }
|
|
3176 #endif
|
|
3177
|
|
3178 #ifdef FEAT_FOLDING
|
|
3179 if (draw_state == WL_FOLD - 1 && n_extra == 0)
|
|
3180 {
|
|
3181 draw_state = WL_FOLD;
|
|
3182 if (wp->w_p_fdc > 0)
|
|
3183 {
|
|
3184 /* Draw the 'foldcolumn'. */
|
|
3185 fill_foldcolumn(extra, wp, FALSE, lnum);
|
|
3186 n_extra = wp->w_p_fdc;
|
|
3187 p_extra = extra;
|
|
3188 c_extra = NUL;
|
|
3189 char_attr = hl_attr(HLF_FC);
|
|
3190 }
|
|
3191 }
|
|
3192 #endif
|
|
3193
|
|
3194 #ifdef FEAT_SIGNS
|
|
3195 if (draw_state == WL_SIGN - 1 && n_extra == 0)
|
|
3196 {
|
|
3197 draw_state = WL_SIGN;
|
|
3198 /* Show the sign column when there are any signs in this
|
|
3199 * buffer or when using Netbeans. */
|
|
3200 if (draw_signcolumn(wp)
|
|
3201 # ifdef FEAT_DIFF
|
|
3202 && filler_todo <= 0
|
|
3203 # endif
|
|
3204 )
|
|
3205 {
|
|
3206 int_u text_sign;
|
|
3207 # ifdef FEAT_SIGN_ICONS
|
|
3208 int_u icon_sign;
|
|
3209 # endif
|
|
3210
|
|
3211 /* Draw two cells with the sign value or blank. */
|
|
3212 c_extra = ' ';
|
|
3213 char_attr = hl_attr(HLF_SC);
|
|
3214 n_extra = 2;
|
|
3215
|
|
3216 if (row == startrow)
|
|
3217 {
|
|
3218 text_sign = buf_getsigntype(wp->w_buffer, lnum,
|
|
3219 SIGN_TEXT);
|
|
3220 # ifdef FEAT_SIGN_ICONS
|
|
3221 icon_sign = buf_getsigntype(wp->w_buffer, lnum,
|
|
3222 SIGN_ICON);
|
|
3223 if (gui.in_use && icon_sign != 0)
|
|
3224 {
|
|
3225 /* Use the image in this position. */
|
|
3226 c_extra = SIGN_BYTE;
|
|
3227 # ifdef FEAT_NETBEANS_INTG
|
|
3228 if (buf_signcount(wp->w_buffer, lnum) > 1)
|
|
3229 c_extra = MULTISIGN_BYTE;
|
|
3230 # endif
|
|
3231 char_attr = icon_sign;
|
|
3232 }
|
|
3233 else
|
|
3234 # endif
|
|
3235 if (text_sign != 0)
|
|
3236 {
|
|
3237 p_extra = sign_get_text(text_sign);
|
|
3238 if (p_extra != NULL)
|
|
3239 {
|
|
3240 c_extra = NUL;
|
835
|
3241 n_extra = (int)STRLEN(p_extra);
|
7
|
3242 }
|
|
3243 char_attr = sign_get_attr(text_sign, FALSE);
|
|
3244 }
|
|
3245 }
|
|
3246 }
|
|
3247 }
|
|
3248 #endif
|
|
3249
|
|
3250 if (draw_state == WL_NR - 1 && n_extra == 0)
|
|
3251 {
|
|
3252 draw_state = WL_NR;
|
|
3253 /* Display the line number. After the first fill with blanks
|
|
3254 * when the 'n' flag isn't in 'cpo' */
|
|
3255 if (wp->w_p_nu
|
|
3256 && (row == startrow
|
|
3257 #ifdef FEAT_DIFF
|
|
3258 + filler_lines
|
|
3259 #endif
|
|
3260 || vim_strchr(p_cpo, CPO_NUMCOL) == NULL))
|
|
3261 {
|
|
3262 /* Draw the line number (empty space after wrapping). */
|
|
3263 if (row == startrow
|
|
3264 #ifdef FEAT_DIFF
|
|
3265 + filler_lines
|
|
3266 #endif
|
|
3267 )
|
|
3268 {
|
13
|
3269 sprintf((char *)extra, "%*ld ",
|
|
3270 number_width(wp), (long)lnum);
|
7
|
3271 if (wp->w_skipcol > 0)
|
|
3272 for (p_extra = extra; *p_extra == ' '; ++p_extra)
|
|
3273 *p_extra = '-';
|
|
3274 #ifdef FEAT_RIGHTLEFT
|
|
3275 if (wp->w_p_rl) /* reverse line numbers */
|
|
3276 rl_mirror(extra);
|
|
3277 #endif
|
|
3278 p_extra = extra;
|
|
3279 c_extra = NUL;
|
|
3280 }
|
|
3281 else
|
|
3282 c_extra = ' ';
|
13
|
3283 n_extra = number_width(wp) + 1;
|
7
|
3284 char_attr = hl_attr(HLF_N);
|
743
|
3285 #ifdef FEAT_SYN_HL
|
|
3286 /* When 'cursorline' is set highlight the line number of
|
|
3287 * the current line differently. */
|
|
3288 if (wp->w_p_cul && lnum == wp->w_cursor.lnum)
|
|
3289 char_attr = hl_combine_attr(hl_attr(HLF_CUL), char_attr);
|
|
3290 #endif
|
7
|
3291 }
|
|
3292 }
|
|
3293
|
|
3294 #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
|
|
3295 if (draw_state == WL_SBR - 1 && n_extra == 0)
|
|
3296 {
|
|
3297 draw_state = WL_SBR;
|
|
3298 # ifdef FEAT_DIFF
|
|
3299 if (filler_todo > 0)
|
|
3300 {
|
|
3301 /* Draw "deleted" diff line(s). */
|
|
3302 if (char2cells(fill_diff) > 1)
|
|
3303 c_extra = '-';
|
|
3304 else
|
|
3305 c_extra = fill_diff;
|
|
3306 # ifdef FEAT_RIGHTLEFT
|
|
3307 if (wp->w_p_rl)
|
|
3308 n_extra = col + 1;
|
|
3309 else
|
|
3310 # endif
|
|
3311 n_extra = W_WIDTH(wp) - col;
|
|
3312 char_attr = hl_attr(HLF_DED);
|
|
3313 }
|
|
3314 # endif
|
|
3315 # ifdef FEAT_LINEBREAK
|
|
3316 if (*p_sbr != NUL && need_showbreak)
|
|
3317 {
|
|
3318 /* Draw 'showbreak' at the start of each broken line. */
|
|
3319 p_extra = p_sbr;
|
|
3320 c_extra = NUL;
|
|
3321 n_extra = (int)STRLEN(p_sbr);
|
|
3322 char_attr = hl_attr(HLF_AT);
|
|
3323 need_showbreak = FALSE;
|
|
3324 /* Correct end of highlighted area for 'showbreak',
|
|
3325 * required when 'linebreak' is also set. */
|
|
3326 if (tocol == vcol)
|
|
3327 tocol += n_extra;
|
|
3328 }
|
|
3329 # endif
|
|
3330 }
|
|
3331 #endif
|
|
3332
|
|
3333 if (draw_state == WL_LINE - 1 && n_extra == 0)
|
|
3334 {
|
|
3335 draw_state = WL_LINE;
|
|
3336 if (saved_n_extra)
|
|
3337 {
|
|
3338 /* Continue item from end of wrapped line. */
|
|
3339 n_extra = saved_n_extra;
|
|
3340 c_extra = saved_c_extra;
|
|
3341 p_extra = saved_p_extra;
|
|
3342 char_attr = saved_char_attr;
|
|
3343 }
|
|
3344 else
|
|
3345 char_attr = 0;
|
|
3346 }
|
|
3347 }
|
|
3348
|
|
3349 /* When still displaying '$' of change command, stop at cursor */
|
819
|
3350 if (dollar_vcol != 0 && wp == curwin
|
|
3351 && lnum == wp->w_cursor.lnum && vcol >= (long)wp->w_virtcol
|
7
|
3352 #ifdef FEAT_DIFF
|
|
3353 && filler_todo <= 0
|
|
3354 #endif
|
|
3355 )
|
|
3356 {
|
|
3357 SCREEN_LINE(screen_row, W_WINCOL(wp), col, -(int)W_WIDTH(wp),
|
|
3358 wp->w_p_rl);
|
819
|
3359 /* Pretend we have finished updating the window. Except when
|
|
3360 * 'cursorcolumn' is set. */
|
|
3361 #ifdef FEAT_SYN_HL
|
|
3362 if (wp->w_p_cuc)
|
|
3363 row = wp->w_cline_row + wp->w_cline_height;
|
|
3364 else
|
|
3365 #endif
|
|
3366 row = wp->w_height;
|
7
|
3367 break;
|
|
3368 }
|
|
3369
|
|
3370 if (draw_state == WL_LINE && area_highlighting)
|
|
3371 {
|
|
3372 /* handle Visual or match highlighting in this line */
|
|
3373 if (vcol == fromcol
|
|
3374 #ifdef FEAT_MBYTE
|
|
3375 || (has_mbyte && vcol + 1 == fromcol && n_extra == 0
|
|
3376 && (*mb_ptr2cells)(ptr) > 1)
|
|
3377 #endif
|
|
3378 || ((int)vcol_prev == fromcol_prev
|
|
3379 && vcol < tocol))
|
|
3380 area_attr = attr; /* start highlighting */
|
|
3381 else if (area_attr != 0
|
|
3382 && (vcol == tocol
|
|
3383 || (noinvcur && (colnr_T)vcol == wp->w_virtcol)))
|
|
3384 area_attr = 0; /* stop highlighting */
|
|
3385
|
|
3386 #ifdef FEAT_SEARCH_EXTRA
|
|
3387 if (!n_extra)
|
|
3388 {
|
|
3389 /*
|
|
3390 * Check for start/end of search pattern match.
|
|
3391 * After end, check for start/end of next match.
|
|
3392 * When another match, have to check for start again.
|
|
3393 * Watch out for matching an empty string!
|
1326
|
3394 * Do this for 'search_hl' and the match list (ordered by
|
|
3395 * priority).
|
7
|
3396 */
|
36
|
3397 v = (long)(ptr - line);
|
1326
|
3398 cur = wp->w_match_head;
|
|
3399 shl_flag = FALSE;
|
|
3400 while (cur != NULL || shl_flag == FALSE)
|
|
3401 {
|
|
3402 if (shl_flag == FALSE
|
|
3403 && ((cur != NULL
|
|
3404 && cur->priority > SEARCH_HL_PRIORITY)
|
|
3405 || cur == NULL))
|
|
3406 {
|
|
3407 shl = &search_hl;
|
|
3408 shl_flag = TRUE;
|
|
3409 }
|
|
3410 else
|
|
3411 shl = &cur->hl;
|
7
|
3412 while (shl->rm.regprog != NULL)
|
|
3413 {
|
36
|
3414 if (shl->startcol != MAXCOL
|
|
3415 && v >= (long)shl->startcol
|
|
3416 && v < (long)shl->endcol)
|
7
|
3417 {
|
|
3418 shl->attr_cur = shl->attr;
|
|
3419 }
|
36
|
3420 else if (v == (long)shl->endcol)
|
7
|
3421 {
|
|
3422 shl->attr_cur = 0;
|
|
3423
|
|
3424 next_search_hl(wp, shl, lnum, (colnr_T)v);
|
|
3425
|
|
3426 /* Need to get the line again, a multi-line regexp
|
|
3427 * may have made it invalid. */
|
|
3428 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
|
3429 ptr = line + v;
|
|
3430
|
|
3431 if (shl->lnum == lnum)
|
|
3432 {
|
36
|
3433 shl->startcol = shl->rm.startpos[0].col;
|
7
|
3434 if (shl->rm.endpos[0].lnum == 0)
|
36
|
3435 shl->endcol = shl->rm.endpos[0].col;
|
7
|
3436 else
|
36
|
3437 shl->endcol = MAXCOL;
|
|
3438
|
|
3439 if (shl->startcol == shl->endcol)
|
7
|
3440 {
|
|
3441 /* highlight empty match, try again after
|
|
3442 * it */
|
|
3443 #ifdef FEAT_MBYTE
|
|
3444 if (has_mbyte)
|
474
|
3445 shl->endcol += (*mb_ptr2len)(line
|
36
|
3446 + shl->endcol);
|
7
|
3447 else
|
|
3448 #endif
|
36
|
3449 ++shl->endcol;
|
7
|
3450 }
|
|
3451
|
|
3452 /* Loop to check if the match starts at the
|
|
3453 * current position */
|
|
3454 continue;
|
|
3455 }
|
|
3456 }
|
|
3457 break;
|
|
3458 }
|
1326
|
3459 if (shl != &search_hl && cur != NULL)
|
|
3460 cur = cur->next;
|
|
3461 }
|
|
3462
|
|
3463 /* Use attributes from match with highest priority among
|
|
3464 * 'search_hl' and the match list. */
|
|
3465 search_attr = search_hl.attr_cur;
|
|
3466 cur = wp->w_match_head;
|
|
3467 shl_flag = FALSE;
|
|
3468 while (cur != NULL || shl_flag == FALSE)
|
|
3469 {
|
|
3470 if (shl_flag == FALSE
|
|
3471 && ((cur != NULL
|
|
3472 && cur->priority > SEARCH_HL_PRIORITY)
|
|
3473 || cur == NULL))
|
699
|
3474 {
|
1326
|
3475 shl = &search_hl;
|
|
3476 shl_flag = TRUE;
|
699
|
3477 }
|
1326
|
3478 else
|
|
3479 shl = &cur->hl;
|
|
3480 if (shl->attr_cur != 0)
|
|
3481 search_attr = shl->attr_cur;
|
|
3482 if (shl != &search_hl && cur != NULL)
|
|
3483 cur = cur->next;
|
|
3484 }
|
7
|
3485 }
|
|
3486 #endif
|
|
3487
|
|
3488 #ifdef FEAT_DIFF
|
674
|
3489 if (diff_hlf != (hlf_T)0)
|
7
|
3490 {
|
1295
|
3491 if (diff_hlf == HLF_CHD && ptr - line >= change_start
|
|
3492 && n_extra == 0)
|
7
|
3493 diff_hlf = HLF_TXD; /* changed text */
|
1295
|
3494 if (diff_hlf == HLF_TXD && ptr - line > change_end
|
|
3495 && n_extra == 0)
|
7
|
3496 diff_hlf = HLF_CHD; /* changed line */
|
674
|
3497 line_attr = hl_attr(diff_hlf);
|
|
3498 }
|
|
3499 #endif
|
|
3500
|
|
3501 /* Decide which of the highlight attributes to use. */
|
|
3502 attr_pri = TRUE;
|
|
3503 if (area_attr != 0)
|
|
3504 char_attr = area_attr;
|
|
3505 else if (search_attr != 0)
|
|
3506 char_attr = search_attr;
|
|
3507 #ifdef LINE_ATTR
|
|
3508 /* Use line_attr when not in the Visual or 'incsearch' area
|
|
3509 * (area_attr may be 0 when "noinvcur" is set). */
|
|
3510 else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL)
|
|
3511 || (vcol < fromcol || vcol >= tocol)))
|
|
3512 char_attr = line_attr;
|
|
3513 #endif
|
|
3514 else
|
|
3515 {
|
|
3516 attr_pri = FALSE;
|
|
3517 #ifdef FEAT_SYN_HL
|
|
3518 if (has_syntax)
|
|
3519 char_attr = syntax_attr;
|
|
3520 else
|
|
3521 #endif
|
|
3522 char_attr = 0;
|
|
3523 }
|
7
|
3524 }
|
|
3525
|
|
3526 /*
|
|
3527 * Get the next character to put on the screen.
|
|
3528 */
|
|
3529 /*
|
|
3530 * The 'extra' array contains the extra stuff that is inserted to
|
|
3531 * represent special characters (non-printable stuff). When all
|
|
3532 * characters are the same, c_extra is used.
|
|
3533 * For the '$' of the 'list' option, n_extra == 1, p_extra == "".
|
|
3534 */
|
|
3535 if (n_extra > 0)
|
|
3536 {
|
|
3537 if (c_extra != NUL)
|
|
3538 {
|
|
3539 c = c_extra;
|
|
3540 #ifdef FEAT_MBYTE
|
|
3541 mb_c = c; /* doesn't handle non-utf-8 multi-byte! */
|
|
3542 if (enc_utf8 && (*mb_char2len)(c) > 1)
|
|
3543 {
|
|
3544 mb_utf8 = TRUE;
|
714
|
3545 u8cc[0] = 0;
|
819
|
3546 c = 0xc0;
|
7
|
3547 }
|
|
3548 else
|
|
3549 mb_utf8 = FALSE;
|
|
3550 #endif
|
|
3551 }
|
|
3552 else
|
|
3553 {
|
|
3554 c = *p_extra;
|
|
3555 #ifdef FEAT_MBYTE
|
|
3556 if (has_mbyte)
|
|
3557 {
|
|
3558 mb_c = c;
|
|
3559 if (enc_utf8)
|
|
3560 {
|
|
3561 /* If the UTF-8 character is more than one byte:
|
|
3562 * Decode it into "mb_c". */
|
474
|
3563 mb_l = (*mb_ptr2len)(p_extra);
|
7
|
3564 mb_utf8 = FALSE;
|
|
3565 if (mb_l > n_extra)
|
|
3566 mb_l = 1;
|
|
3567 else if (mb_l > 1)
|
|
3568 {
|
714
|
3569 mb_c = utfc_ptr2char(p_extra, u8cc);
|
7
|
3570 mb_utf8 = TRUE;
|
819
|
3571 c = 0xc0;
|
7
|
3572 }
|
|
3573 }
|
|
3574 else
|
|
3575 {
|
|
3576 /* if this is a DBCS character, put it in "mb_c" */
|
|
3577 mb_l = MB_BYTE2LEN(c);
|
|
3578 if (mb_l >= n_extra)
|
|
3579 mb_l = 1;
|
|
3580 else if (mb_l > 1)
|
|
3581 mb_c = (c << 8) + p_extra[1];
|
|
3582 }
|
504
|
3583 if (mb_l == 0) /* at the NUL at end-of-line */
|
|
3584 mb_l = 1;
|
|
3585
|
7
|
3586 /* If a double-width char doesn't fit display a '>' in the
|
|
3587 * last column. */
|
504
|
3588 if ((
|
7
|
3589 # ifdef FEAT_RIGHTLEFT
|
|
3590 wp->w_p_rl ? (col <= 0) :
|
|
3591 # endif
|
504
|
3592 (col >= W_WIDTH(wp) - 1))
|
7
|
3593 && (*mb_char2cells)(mb_c) == 2)
|
|
3594 {
|
|
3595 c = '>';
|
|
3596 mb_c = c;
|
|
3597 mb_l = 1;
|
|
3598 mb_utf8 = FALSE;
|
|
3599 multi_attr = hl_attr(HLF_AT);
|
|
3600 /* put the pointer back to output the double-width
|
|
3601 * character at the start of the next line. */
|
|
3602 ++n_extra;
|
|
3603 --p_extra;
|
|
3604 }
|
|
3605 else
|
|
3606 {
|
|
3607 n_extra -= mb_l - 1;
|
|
3608 p_extra += mb_l - 1;
|
|
3609 }
|
|
3610 }
|
|
3611 #endif
|
|
3612 ++p_extra;
|
|
3613 }
|
|
3614 --n_extra;
|
|
3615 }
|
|
3616 else
|
|
3617 {
|
|
3618 /*
|
|
3619 * Get a character from the line itself.
|
|
3620 */
|
|
3621 c = *ptr;
|
|
3622 #ifdef FEAT_MBYTE
|
|
3623 if (has_mbyte)
|
|
3624 {
|
|
3625 mb_c = c;
|
|
3626 if (enc_utf8)
|
|
3627 {
|
|
3628 /* If the UTF-8 character is more than one byte: Decode it
|
|
3629 * into "mb_c". */
|
474
|
3630 mb_l = (*mb_ptr2len)(ptr);
|
7
|
3631 mb_utf8 = FALSE;
|
|
3632 if (mb_l > 1)
|
|
3633 {
|
714
|
3634 mb_c = utfc_ptr2char(ptr, u8cc);
|
7
|
3635 /* Overlong encoded ASCII or ASCII with composing char
|
|
3636 * is displayed normally, except a NUL. */
|
|
3637 if (mb_c < 0x80)
|
|
3638 c = mb_c;
|
|
3639 mb_utf8 = TRUE;
|
507
|
3640
|
|
3641 /* At start of the line we can have a composing char.
|
|
3642 * Draw it as a space with a composing char. */
|
|
3643 if (utf_iscomposing(mb_c))
|
|
3644 {
|
1326
|
3645 int i;
|
|
3646
|
714
|
3647 for (i = Screen_mco - 1; i > 0; --i)
|
|
3648 u8cc[i] = u8cc[i - 1];
|
|
3649 u8cc[0] = mb_c;
|
507
|
3650 mb_c = ' ';
|
|
3651 }
|
7
|
3652 }
|
|
3653
|
|
3654 if ((mb_l == 1 && c >= 0x80)
|
|
3655 || (mb_l >= 1 && mb_c == 0)
|
|
3656 || (mb_l > 1 && (!vim_isprintc(mb_c)
|
|
3657 || mb_c >= 0x10000)))
|
|
3658 {
|
|
3659 /*
|
|
3660 * Illegal UTF-8 byte: display as <xx>.
|
|
3661 * Non-BMP character : display as ? or fullwidth ?.
|
|
3662 */
|
|
3663 if (mb_c < 0x10000)
|
|
3664 {
|
|
3665 transchar_hex(extra, mb_c);
|
714
|
3666 # ifdef FEAT_RIGHTLEFT
|
7
|
3667 if (wp->w_p_rl) /* reverse */
|
|
3668 rl_mirror(extra);
|
714
|
3669 # endif
|
7
|
3670 }
|
|
3671 else if (utf_char2cells(mb_c) != 2)
|
|
3672 STRCPY(extra, "?");
|
|
3673 else
|
|
3674 /* 0xff1f in UTF-8: full-width '?' */
|
|
3675 STRCPY(extra, "\357\274\237");
|
|
3676
|
|
3677 p_extra = extra;
|
|
3678 c = *p_extra;
|
|
3679 mb_c = mb_ptr2char_adv(&p_extra);
|
|
3680 mb_utf8 = (c >= 0x80);
|
|
3681 n_extra = (int)STRLEN(p_extra);
|
|
3682 c_extra = NUL;
|
|
3683 if (area_attr == 0 && search_attr == 0)
|
|
3684 {
|
|
3685 n_attr = n_extra + 1;
|
|
3686 extra_attr = hl_attr(HLF_8);
|
|
3687 saved_attr2 = char_attr; /* save current attr */
|
|
3688 }
|
|
3689 }
|
|
3690 else if (mb_l == 0) /* at the NUL at end-of-line */
|
|
3691 mb_l = 1;
|
|
3692 #ifdef FEAT_ARABIC
|
|
3693 else if (p_arshape && !p_tbidi && ARABIC_CHAR(mb_c))
|
|
3694 {
|
|
3695 /* Do Arabic shaping. */
|
714
|
3696 int pc, pc1, nc;
|
|
3697 int pcc[MAX_MCO];
|
7
|
3698
|
|
3699 /* The idea of what is the previous and next
|
|
3700 * character depends on 'rightleft'. */
|
|
3701 if (wp->w_p_rl)
|
|
3702 {
|
|
3703 pc = prev_c;
|
|
3704 pc1 = prev_c1;
|
|
3705 nc = utf_ptr2char(ptr + mb_l);
|
714
|
3706 prev_c1 = u8cc[0];
|
7
|
3707 }
|
|
3708 else
|
|
3709 {
|
714
|
3710 pc = utfc_ptr2char(ptr + mb_l, pcc);
|
7
|
3711 nc = prev_c;
|
714
|
3712 pc1 = pcc[0];
|
7
|
3713 }
|
|
3714 prev_c = mb_c;
|
|
3715
|
714
|
3716 mb_c = arabic_shape(mb_c, &c, &u8cc[0], pc, pc1, nc);
|
7
|
3717 }
|
|
3718 else
|
|
3719 prev_c = mb_c;
|
|
3720 #endif
|
|
3721 }
|
|
3722 else /* enc_dbcs */
|
|
3723 {
|
|
3724 mb_l = MB_BYTE2LEN(c);
|
|
3725 if (mb_l == 0) /* at the NUL at end-of-line */
|
|
3726 mb_l = 1;
|
|
3727 else if (mb_l > 1)
|
|
3728 {
|
|
3729 /* We assume a second byte below 32 is illegal.
|
|
3730 * Hopefully this is OK for all double-byte encodings!
|
|
3731 */
|
|
3732 if (ptr[1] >= 32)
|
|
3733 mb_c = (c << 8) + ptr[1];
|
|
3734 else
|
|
3735 {
|
|
3736 if (ptr[1] == NUL)
|
|
3737 {
|
|
3738 /* head byte at end of line */
|
|
3739 mb_l = 1;
|
|
3740 transchar_nonprint(extra, c);
|
|
3741 }
|
|
3742 else
|
|
3743 {
|
|
3744 /* illegal tail byte */
|
|
3745 mb_l = 2;
|
|
3746 STRCPY(extra, "XX");
|
|
3747 }
|
|
3748 p_extra = extra;
|
|
3749 n_extra = (int)STRLEN(extra) - 1;
|
|
3750 c_extra = NUL;
|
|
3751 c = *p_extra++;
|
|
3752 if (area_attr == 0 && search_attr == 0)
|
|
3753 {
|
|
3754 n_attr = n_extra + 1;
|
|
3755 extra_attr = hl_attr(HLF_8);
|
|
3756 saved_attr2 = char_attr; /* save current attr */
|
|
3757 }
|
|
3758 mb_c = c;
|
|
3759 }
|
|
3760 }
|
|
3761 }
|
|
3762 /* If a double-width char doesn't fit display a '>' in the
|
|
3763 * last column; the character is displayed at the start of the
|
|
3764 * next line. */
|
|
3765 if ((
|
|
3766 # ifdef FEAT_RIGHTLEFT
|
|
3767 wp->w_p_rl ? (col <= 0) :
|
|
3768 # endif
|
|
3769 (col >= W_WIDTH(wp) - 1))
|
|
3770 && (*mb_char2cells)(mb_c) == 2)
|
|
3771 {
|
|
3772 c = '>';
|
|
3773 mb_c = c;
|
|
3774 mb_utf8 = FALSE;
|
|
3775 mb_l = 1;
|
|
3776 multi_attr = hl_attr(HLF_AT);
|
|
3777 /* Put pointer back so that the character will be
|
|
3778 * displayed at the start of the next line. */
|
|
3779 --ptr;
|
|
3780 }
|
|
3781 else if (*ptr != NUL)
|
|
3782 ptr += mb_l - 1;
|
|
3783
|
|
3784 /* If a double-width char doesn't fit at the left side display
|
|
3785 * a '<' in the first column. */
|
|
3786 if (n_skip > 0 && mb_l > 1)
|
|
3787 {
|
|
3788 extra[0] = '<';
|
|
3789 p_extra = extra;
|
|
3790 n_extra = 1;
|
|
3791 c_extra = NUL;
|
|
3792 c = ' ';
|
|
3793 if (area_attr == 0 && search_attr == 0)
|
|
3794 {
|
|
3795 n_attr = n_extra + 1;
|
|
3796 extra_attr = hl_attr(HLF_AT);
|
|
3797 saved_attr2 = char_attr; /* save current attr */
|
|
3798 }
|
|
3799 mb_c = c;
|
|
3800 mb_utf8 = FALSE;
|
|
3801 mb_l = 1;
|
|
3802 }
|
|
3803
|
|
3804 }
|
|
3805 #endif
|
|
3806 ++ptr;
|
|
3807
|
12
|
3808 /* 'list' : change char 160 to lcs_nbsp. */
|
819
|
3809 if (wp->w_p_list && (c == 160
|
|
3810 #ifdef FEAT_MBYTE
|
|
3811 || (mb_utf8 && mb_c == 160)
|
|
3812 #endif
|
|
3813 ) && lcs_nbsp)
|
12
|
3814 {
|
|
3815 c = lcs_nbsp;
|
|
3816 if (area_attr == 0 && search_attr == 0)
|
|
3817 {
|
|
3818 n_attr = 1;
|
|
3819 extra_attr = hl_attr(HLF_8);
|
|
3820 saved_attr2 = char_attr; /* save current attr */
|
|
3821 }
|
|
3822 #ifdef FEAT_MBYTE
|
|
3823 mb_c = c;
|
|
3824 if (enc_utf8 && (*mb_char2len)(c) > 1)
|
|
3825 {
|
|
3826 mb_utf8 = TRUE;
|
714
|
3827 u8cc[0] = 0;
|
819
|
3828 c = 0xc0;
|
12
|
3829 }
|
|
3830 else
|
|
3831 mb_utf8 = FALSE;
|
|
3832 #endif
|
|
3833 }
|
|
3834
|
7
|
3835 if (extra_check)
|
|
3836 {
|
743
|
3837 #ifdef FEAT_SPELL
|
221
|
3838 int can_spell = TRUE;
|
743
|
3839 #endif
|
|
3840
|
|
3841 #ifdef FEAT_SYN_HL
|
7
|
3842 /* Get syntax attribute, unless still at the start of the line
|
|
3843 * (double-wide char that doesn't fit). */
|
221
|
3844 v = (long)(ptr - line);
|
|
3845 if (has_syntax && v > 0)
|
7
|
3846 {
|
|
3847 /* Get the syntax attribute for the character. If there
|
|
3848 * is an error, disable syntax highlighting. */
|
|
3849 save_did_emsg = did_emsg;
|
|
3850 did_emsg = FALSE;
|
|
3851
|
221
|
3852 syntax_attr = get_syntax_attr((colnr_T)v - 1,
|
743
|
3853 # ifdef FEAT_SPELL
|
|
3854 has_spell ? &can_spell :
|
|
3855 # endif
|
|
3856 NULL);
|
7
|
3857
|
|
3858 if (did_emsg)
|
482
|
3859 {
|
|
3860 wp->w_buffer->b_syn_error = TRUE;
|
|
3861 has_syntax = FALSE;
|
|
3862 }
|
7
|
3863 else
|
|
3864 did_emsg = save_did_emsg;
|
|
3865
|
|
3866 /* Need to get the line again, a multi-line regexp may
|
|
3867 * have made it invalid. */
|
|
3868 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
|
3869 ptr = line + v;
|
|
3870
|
674
|
3871 if (!attr_pri)
|
7
|
3872 char_attr = syntax_attr;
|
301
|
3873 else
|
303
|
3874 char_attr = hl_combine_attr(syntax_attr, char_attr);
|
7
|
3875 }
|
743
|
3876 #endif
|
|
3877
|
|
3878 #ifdef FEAT_SPELL
|
301
|
3879 /* Check spelling (unless at the end of the line).
|
319
|
3880 * Only do this when there is no syntax highlighting, the
|
|
3881 * @Spell cluster is not used or the current syntax item
|
|
3882 * contains the @Spell cluster. */
|
348
|
3883 if (has_spell && v >= word_end && v > cur_checked_col)
|
221
|
3884 {
|
230
|
3885 spell_attr = 0;
|
743
|
3886 # ifdef FEAT_SYN_HL
|
674
|
3887 if (!attr_pri)
|
230
|
3888 char_attr = syntax_attr;
|
743
|
3889 # endif
|
|
3890 if (c != 0 && (
|
|
3891 # ifdef FEAT_SYN_HL
|
|
3892 !has_syntax ||
|
|
3893 # endif
|
|
3894 can_spell))
|
221
|
3895 {
|
348
|
3896 char_u *prev_ptr, *p;
|
|
3897 int len;
|
534
|
3898 hlf_T spell_hlf = HLF_COUNT;
|
221
|
3899 # ifdef FEAT_MBYTE
|
336
|
3900 if (has_mbyte)
|
|
3901 {
|
|
3902 prev_ptr = ptr - mb_l;
|
|
3903 v -= mb_l - 1;
|
|
3904 }
|
|
3905 else
|
221
|
3906 # endif
|
336
|
3907 prev_ptr = ptr - 1;
|
348
|
3908
|
|
3909 /* Use nextline[] if possible, it has the start of the
|
|
3910 * next line concatenated. */
|
|
3911 if ((prev_ptr - line) - nextlinecol >= 0)
|
|
3912 p = nextline + (prev_ptr - line) - nextlinecol;
|
|
3913 else
|
|
3914 p = prev_ptr;
|
835
|
3915 cap_col -= (int)(prev_ptr - line);
|
625
|
3916 len = spell_check(wp, p, &spell_hlf, &cap_col,
|
|
3917 nochange);
|
348
|
3918 word_end = v + len;
|
301
|
3919
|
|
3920 /* In Insert mode only highlight a word that
|
|
3921 * doesn't touch the cursor. */
|
534
|
3922 if (spell_hlf != HLF_COUNT
|
301
|
3923 && (State & INSERT) != 0
|
|
3924 && wp->w_cursor.lnum == lnum
|
|
3925 && wp->w_cursor.col >=
|
|
3926 (colnr_T)(prev_ptr - line)
|
|
3927 && wp->w_cursor.col < (colnr_T)word_end)
|
221
|
3928 {
|
534
|
3929 spell_hlf = HLF_COUNT;
|
301
|
3930 spell_redraw_lnum = lnum;
|
221
|
3931 }
|
348
|
3932
|
534
|
3933 if (spell_hlf == HLF_COUNT && p != prev_ptr
|
348
|
3934 && (p - nextline) + len > nextline_idx)
|
|
3935 {
|
|
3936 /* Remember that the good word continues at the
|
|
3937 * start of the next line. */
|
|
3938 checked_lnum = lnum + 1;
|
835
|
3939 checked_col = (int)((p - nextline) + len - nextline_idx);
|
348
|
3940 }
|
386
|
3941
|
534
|
3942 /* Turn index into actual attributes. */
|
|
3943 if (spell_hlf != HLF_COUNT)
|
|
3944 spell_attr = highlight_attr[spell_hlf];
|
|
3945
|
386
|
3946 if (cap_col > 0)
|
|
3947 {
|
|
3948 if (p != prev_ptr
|
|
3949 && (p - nextline) + cap_col >= nextline_idx)
|
|
3950 {
|
|
3951 /* Remember that the word in the next line
|
|
3952 * must start with a capital. */
|
|
3953 capcol_lnum = lnum + 1;
|
835
|
3954 cap_col = (int)((p - nextline) + cap_col
|
|
3955 - nextline_idx);
|
386
|
3956 }
|
|
3957 else
|
|
3958 /* Compute the actual column. */
|
835
|
3959 cap_col += (int)(prev_ptr - line);
|
386
|
3960 }
|
221
|
3961 }
|
|
3962 }
|
|
3963 if (spell_attr != 0)
|
348
|
3964 {
|
674
|
3965 if (!attr_pri)
|
348
|
3966 char_attr = hl_combine_attr(char_attr, spell_attr);
|
|
3967 else
|
|
3968 char_attr = hl_combine_attr(spell_attr, char_attr);
|
|
3969 }
|
7
|
3970 #endif
|
|
3971 #ifdef FEAT_LINEBREAK
|
|
3972 /*
|
221
|
3973 * Found last space before word: check for line break.
|
7
|
3974 */
|
|
3975 if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)
|
819
|
3976 && !wp->w_p_list)
|
7
|
3977 {
|
|
3978 n_extra = win_lbr_chartabsize(wp, ptr - (
|
|
3979 # ifdef FEAT_MBYTE
|
|
3980 has_mbyte ? mb_l :
|
|
3981 # endif
|
|
3982 1), (colnr_T)vcol, NULL) - 1;
|
|
3983 c_extra = ' ';
|
|
3984 if (vim_iswhite(c))
|
|
3985 c = ' ';
|
|
3986 }
|
|
3987 #endif
|
|
3988
|
|
3989 if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
|
|
3990 {
|
|
3991 c = lcs_trail;
|
674
|
3992 if (!attr_pri)
|
7
|
3993 {
|
|
3994 n_attr = 1;
|
|
3995 extra_attr = hl_attr(HLF_8);
|
|
3996 saved_attr2 = char_attr; /* save current attr */
|
|
3997 }
|
|
3998 #ifdef FEAT_MBYTE
|
|
3999 mb_c = c;
|
|
4000 if (enc_utf8 && (*mb_char2len)(c) > 1)
|
|
4001 {
|
|
4002 mb_utf8 = TRUE;
|
714
|
4003 u8cc[0] = 0;
|
819
|
4004 c = 0xc0;
|
7
|
4005 }
|
|
4006 else
|
|
4007 mb_utf8 = FALSE;
|
|
4008 #endif
|
|
4009 }
|
|
4010 }
|
|
4011
|
|
4012 /*
|
|
4013 * Handling of non-printable characters.
|
|
4014 */
|
819
|
4015 if (!(chartab[c & 0xff] & CT_PRINT_CHAR))
|
7
|
4016 {
|
|
4017 /*
|
|
4018 * when getting a character from the file, we may have to
|
|
4019 * turn it into something else on the way to putting it
|
|
4020 * into "ScreenLines".
|
|
4021 */
|
|
4022 if (c == TAB && (!wp->w_p_list || lcs_tab1))
|
|
4023 {
|
|
4024 /* tab amount depends on current column */
|
|
4025 n_extra = (int)wp->w_buffer->b_p_ts
|
|
4026 - vcol % (int)wp->w_buffer->b_p_ts - 1;
|
|
4027 #ifdef FEAT_MBYTE
|
|
4028 mb_utf8 = FALSE; /* don't draw as UTF-8 */
|
|
4029 #endif
|
|
4030 if (wp->w_p_list)
|
|
4031 {
|
|
4032 c = lcs_tab1;
|
|
4033 c_extra = lcs_tab2;
|
|
4034 n_attr = n_extra + 1;
|
|
4035 extra_attr = hl_attr(HLF_8);
|
|
4036 saved_attr2 = char_attr; /* save current attr */
|
|
4037 #ifdef FEAT_MBYTE
|
|
4038 mb_c = c;
|
|
4039 if (enc_utf8 && (*mb_char2len)(c) > 1)
|
|
4040 {
|
|
4041 mb_utf8 = TRUE;
|
714
|
4042 u8cc[0] = 0;
|
819
|
4043 c = 0xc0;
|
7
|
4044 }
|
|
4045 #endif
|
|
4046 }
|
|
4047 else
|
|
4048 {
|
|
4049 c_extra = ' ';
|
|
4050 c = ' ';
|
|
4051 }
|
|
4052 }
|
36
|
4053 else if (c == NUL
|
|
4054 && ((wp->w_p_list && lcs_eol > 0)
|
|
4055 || ((fromcol >= 0 || fromcol_prev >= 0)
|
|
4056 && tocol > vcol
|
39
|
4057 #ifdef FEAT_VISUAL
|
36
|
4058 && VIsual_mode != Ctrl_V
|
39
|
4059 #endif
|
36
|
4060 && (
|
|
4061 # ifdef FEAT_RIGHTLEFT
|
|
4062 wp->w_p_rl ? (col >= 0) :
|
|
4063 # endif
|
|
4064 (col < W_WIDTH(wp)))
|
|
4065 && !(noinvcur
|
|
4066 && (colnr_T)vcol == wp->w_virtcol)))
|
|
4067 && lcs_eol_one >= 0)
|
7
|
4068 {
|
36
|
4069 /* Display a '$' after the line or highlight an extra
|
|
4070 * character if the line break is included. */
|
7
|
4071 #if defined(FEAT_DIFF) || defined(LINE_ATTR)
|
|
4072 /* For a diff line the highlighting continues after the
|
|
4073 * "$". */
|
|
4074 if (
|
|
4075 # ifdef FEAT_DIFF
|
534
|
4076 diff_hlf == (hlf_T)0
|
7
|
4077 # ifdef LINE_ATTR
|
|
4078 &&
|
|
4079 # endif
|
|
4080 # endif
|
|
4081 # ifdef LINE_ATTR
|
|
4082 line_attr == 0
|
|
4083 # endif
|
|
4084 )
|
|
4085 #endif
|
|
4086 {
|
|
4087 #ifdef FEAT_VIRTUALEDIT
|
|
4088 /* In virtualedit, visual selections may extend
|
|
4089 * beyond end of line. */
|
|
4090 if (area_highlighting && virtual_active()
|
|
4091 && tocol != MAXCOL && vcol < tocol)
|
|
4092 n_extra = 0;
|
|
4093 else
|
|
4094 #endif
|
|
4095 {
|
|
4096 p_extra = at_end_str;
|
|
4097 n_extra = 1;
|
|
4098 c_extra = NUL;
|
|
4099 }
|
|
4100 }
|
36
|
4101 if (wp->w_p_list)
|
|
4102 c = lcs_eol;
|
|
4103 else
|
|
4104 c = ' ';
|
7
|
4105 lcs_eol_one = -1;
|
|
4106 --ptr; /* put it back at the NUL */
|
674
|
4107 if (!attr_pri)
|
7
|
4108 {
|
|
4109 extra_attr = hl_attr(HLF_AT);
|
|
4110 n_attr = 1;
|
|
4111 }
|
|
4112 #ifdef FEAT_MBYTE
|
|
4113 mb_c = c;
|
|
4114 if (enc_utf8 && (*mb_char2len)(c) > 1)
|
|
4115 {
|
|
4116 mb_utf8 = TRUE;
|
714
|
4117 u8cc[0] = 0;
|
819
|
4118 c = 0xc0;
|
7
|
4119 }
|
|
4120 else
|
|
4121 mb_utf8 = FALSE; /* don't draw as UTF-8 */
|
|
4122 #endif
|
|
4123 }
|
|
4124 else if (c != NUL)
|
|
4125 {
|
|
4126 p_extra = transchar(c);
|
|
4127 #ifdef FEAT_RIGHTLEFT
|
|
4128 if ((dy_flags & DY_UHEX) && wp->w_p_rl)
|
|
4129 rl_mirror(p_extra); /* reverse "<12>" */
|
|
4130 #endif
|
|
4131 n_extra = byte2cells(c) - 1;
|
|
4132 c_extra = NUL;
|
|
4133 c = *p_extra++;
|
674
|
4134 if (!attr_pri)
|
7
|
4135 {
|
|
4136 n_attr = n_extra + 1;
|
|
4137 extra_attr = hl_attr(HLF_8);
|
|
4138 saved_attr2 = char_attr; /* save current attr */
|
|
4139 }
|
|
4140 #ifdef FEAT_MBYTE
|
|
4141 mb_utf8 = FALSE; /* don't draw as UTF-8 */
|
|
4142 #endif
|
|
4143 }
|
|
4144 #ifdef FEAT_VIRTUALEDIT
|
|
4145 else if (VIsual_active
|
|
4146 && (VIsual_mode == Ctrl_V
|
|
4147 || VIsual_mode == 'v')
|
|
4148 && virtual_active()
|
|
4149 && tocol != MAXCOL
|
|
4150 && vcol < tocol
|
|
4151 && (
|
|
4152 # ifdef FEAT_RIGHTLEFT
|
|
4153 wp->w_p_rl ? (col >= 0) :
|
|
4154 # endif
|
|
4155 (col < W_WIDTH(wp))))
|
|
4156 {
|
|
4157 c = ' ';
|
|
4158 --ptr; /* put it back at the NUL */
|
|
4159 }
|
|
4160 #endif
|
910
|
4161 #if defined(LINE_ATTR)
|
7
|
4162 else if ((
|
|
4163 # ifdef FEAT_DIFF
|
910
|
4164 diff_hlf != (hlf_T)0 ||
|
7
|
4165 # endif
|
|
4166 line_attr != 0
|
|
4167 ) && (
|
|
4168 # ifdef FEAT_RIGHTLEFT
|
|
4169 wp->w_p_rl ? (col >= 0) :
|
|
4170 # endif
|
|
4171 (col < W_WIDTH(wp))))
|
|
4172 {
|
|
4173 /* Highlight until the right side of the window */
|
|
4174 c = ' ';
|
|
4175 --ptr; /* put it back at the NUL */
|
867
|
4176
|
|
4177 /* Remember we do the char for line highlighting. */
|
|
4178 ++did_line_attr;
|
|
4179
|
|
4180 /* don't do search HL for the rest of the line */
|
|
4181 if (line_attr != 0 && char_attr == search_attr && col > 0)
|
|
4182 char_attr = line_attr;
|
7
|
4183 # ifdef FEAT_DIFF
|
|
4184 if (diff_hlf == HLF_TXD)
|
|
4185 {
|
|
4186 diff_hlf = HLF_CHD;
|
|
4187 if (attr == 0 || char_attr != attr)
|
|
4188 char_attr = hl_attr(diff_hlf);
|
|
4189 }
|
|
4190 # endif
|
|
4191 }
|
|
4192 #endif
|
|
4193 }
|
|
4194 }
|
|
4195
|
|
4196 /* Don't override visual selection highlighting. */
|
|
4197 if (n_attr > 0
|
|
4198 && draw_state == WL_LINE
|
674
|
4199 && !attr_pri)
|
7
|
4200 char_attr = extra_attr;
|
|
4201
|
42
|
4202 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
|
7
|
4203 /* XIM don't send preedit_start and preedit_end, but they send
|
|
4204 * preedit_changed and commit. Thus Vim can't set "im_is_active", use
|
|
4205 * im_is_preediting() here. */
|
|
4206 if (xic != NULL
|
|
4207 && lnum == curwin->w_cursor.lnum
|
|
4208 && (State & INSERT)
|
|
4209 && !p_imdisable
|
|
4210 && im_is_preediting()
|
|
4211 && draw_state == WL_LINE)
|
|
4212 {
|
|
4213 colnr_T tcol;
|
|
4214
|
|
4215 if (preedit_end_col == MAXCOL)
|
|
4216 getvcol(curwin, &(curwin->w_cursor), &tcol, NULL, NULL);
|
|
4217 else
|
|
4218 tcol = preedit_end_col;
|
|
4219 if ((long)preedit_start_col <= vcol && vcol < (long)tcol)
|
|
4220 {
|
|
4221 if (feedback_old_attr < 0)
|
|
4222 {
|
|
4223 feedback_col = 0;
|
|
4224 feedback_old_attr = char_attr;
|
|
4225 }
|
|
4226 char_attr = im_get_feedback_attr(feedback_col);
|
|
4227 if (char_attr < 0)
|
|
4228 char_attr = feedback_old_attr;
|
|
4229 feedback_col++;
|
|
4230 }
|
|
4231 else if (feedback_old_attr >= 0)
|
|
4232 {
|
|
4233 char_attr = feedback_old_attr;
|
|
4234 feedback_old_attr = -1;
|
|
4235 feedback_col = 0;
|
|
4236 }
|
|
4237 }
|
|
4238 #endif
|
|
4239 /*
|
|
4240 * Handle the case where we are in column 0 but not on the first
|
|
4241 * character of the line and the user wants us to show us a
|
|
4242 * special character (via 'listchars' option "precedes:<char>".
|
|
4243 */
|
|
4244 if (lcs_prec_todo != NUL
|
|
4245 && (wp->w_p_wrap ? wp->w_skipcol > 0 : wp->w_leftcol > 0)
|
|
4246 #ifdef FEAT_DIFF
|
|
4247 && filler_todo <= 0
|
|
4248 #endif
|
|
4249 && draw_state > WL_NR
|
|
4250 && c != NUL)
|
|
4251 {
|
|
4252 c = lcs_prec;
|
|
4253 lcs_prec_todo = NUL;
|
|
4254 #ifdef FEAT_MBYTE
|
|
4255 mb_c = c;
|
|
4256 if (enc_utf8 && (*mb_char2len)(c) > 1)
|
|
4257 {
|
|
4258 mb_utf8 = TRUE;
|
714
|
4259 u8cc[0] = 0;
|
819
|
4260 c = 0xc0;
|
7
|
4261 }
|
|
4262 else
|
|
4263 mb_utf8 = FALSE; /* don't draw as UTF-8 */
|
|
4264 #endif
|
674
|
4265 if (!attr_pri)
|
7
|
4266 {
|
|
4267 saved_attr3 = char_attr; /* save current attr */
|
|
4268 char_attr = hl_attr(HLF_AT); /* later copied to char_attr */
|
|
4269 n_attr3 = 1;
|
|
4270 }
|
|
4271 }
|
|
4272
|
|
4273 /*
|
867
|
4274 * At end of the text line or just after the last character.
|
7
|
4275 */
|
867
|
4276 if (c == NUL
|
910
|
4277 #if defined(LINE_ATTR)
|
867
|
4278 || did_line_attr == 1
|
|
4279 #endif
|
|
4280 )
|
|
4281 {
|
|
4282 #ifdef FEAT_SEARCH_EXTRA
|
|
4283 long prevcol = (long)(ptr - line) - (c == NUL);
|
|
4284 #endif
|
|
4285
|
7
|
4286 /* invert at least one char, used for Visual and empty line or
|
|
4287 * highlight match at end of line. If it's beyond the last
|
|
4288 * char on the screen, just overwrite that one (tricky!) Not
|
|
4289 * needed when a '$' was displayed for 'list'. */
|
1326
|
4290 #ifdef FEAT_SEARCH_EXTRA
|
|
4291 prevcol_hl_flag = FALSE;
|
|
4292 if (prevcol == (long)search_hl.startcol)
|
|
4293 prevcol_hl_flag = TRUE;
|
|
4294 else
|
|
4295 {
|
|
4296 cur = wp->w_match_head;
|
|
4297 while (cur != NULL)
|
|
4298 {
|
|
4299 if (prevcol == (long)cur->hl.startcol)
|
|
4300 {
|
|
4301 prevcol_hl_flag = TRUE;
|
|
4302 break;
|
|
4303 }
|
|
4304 cur = cur->next;
|
|
4305 }
|
|
4306 }
|
|
4307 #endif
|
7
|
4308 if (lcs_eol == lcs_eol_one
|
867
|
4309 && ((area_attr != 0 && vcol == fromcol && c == NUL)
|
7
|
4310 #ifdef FEAT_SEARCH_EXTRA
|
|
4311 /* highlight 'hlsearch' match at end of line */
|
1326
|
4312 || (prevcol_hl_flag == TRUE
|
910
|
4313 # if defined(LINE_ATTR)
|
867
|
4314 && did_line_attr <= 1
|
|
4315 # endif
|
|
4316 )
|
7
|
4317 #endif
|
|
4318 ))
|
|
4319 {
|
|
4320 int n = 0;
|
|
4321
|
|
4322 #ifdef FEAT_RIGHTLEFT
|
|
4323 if (wp->w_p_rl)
|
|
4324 {
|
|
4325 if (col < 0)
|
|
4326 n = 1;
|
|
4327 }
|
|
4328 else
|
|
4329 #endif
|
|
4330 {
|
|
4331 if (col >= W_WIDTH(wp))
|
|
4332 n = -1;
|
|
4333 }
|
|
4334 if (n != 0)
|
|
4335 {
|
|
4336 /* At the window boundary, highlight the last character
|
|
4337 * instead (better than nothing). */
|
|
4338 off += n;
|
|
4339 col += n;
|
|
4340 }
|
|
4341 else
|
|
4342 {
|
|
4343 /* Add a blank character to highlight. */
|
|
4344 ScreenLines[off] = ' ';
|
|
4345 #ifdef FEAT_MBYTE
|
|
4346 if (enc_utf8)
|
|
4347 ScreenLinesUC[off] = 0;
|
|
4348 #endif
|
|
4349 }
|
|
4350 #ifdef FEAT_SEARCH_EXTRA
|
|
4351 if (area_attr == 0)
|
|
4352 {
|
1326
|
4353 /* Use attributes from match with highest priority among
|
|
4354 * 'search_hl' and the match list. */
|
|
4355 char_attr = search_hl.attr;
|
|
4356 cur = wp->w_match_head;
|
|
4357 shl_flag = FALSE;
|
|
4358 while (cur != NULL || shl_flag == FALSE)
|
699
|
4359 {
|
1326
|
4360 if (shl_flag == FALSE
|
|
4361 && ((cur != NULL
|
|
4362 && cur->priority > SEARCH_HL_PRIORITY)
|
|
4363 || cur == NULL))
|
699
|
4364 {
|
1326
|
4365 shl = &search_hl;
|
|
4366 shl_flag = TRUE;
|
699
|
4367 }
|
1326
|
4368 else
|
|
4369 shl = &cur->hl;
|
|
4370 if ((ptr - line) - 1 == (long)shl->startcol)
|
|
4371 char_attr = shl->attr;
|
|
4372 if (shl != &search_hl && cur != NULL)
|
|
4373 cur = cur->next;
|
699
|
4374 }
|
7
|
4375 }
|
|
4376 #endif
|
|
4377 ScreenAttrs[off] = char_attr;
|
|
4378 #ifdef FEAT_RIGHTLEFT
|
|
4379 if (wp->w_p_rl)
|
|
4380 --col;
|
|
4381 else
|
|
4382 #endif
|
|
4383 ++col;
|
743
|
4384 ++vcol;
|
|
4385 }
|
867
|
4386 }
|
|
4387
|
|
4388 /*
|
|
4389 * At end of the text line.
|
|
4390 */
|
|
4391 if (c == NUL)
|
|
4392 {
|
743
|
4393 #ifdef FEAT_SYN_HL
|
|
4394 /* Highlight 'cursorcolumn' past end of the line. */
|
758
|
4395 if (wp->w_p_wrap)
|
|
4396 v = wp->w_skipcol;
|
|
4397 else
|
|
4398 v = wp->w_leftcol;
|
820
|
4399 /* check if line ends before left margin */
|
|
4400 if (vcol < v + col - win_col_off(wp))
|
|
4401
|
|
4402 vcol = v + col - win_col_off(wp);
|
743
|
4403 if (wp->w_p_cuc
|
|
4404 && (int)wp->w_virtcol >= vcol
|
819
|
4405 && (int)wp->w_virtcol < W_WIDTH(wp) * (row - startrow + 1)
|
|
4406 + v
|
743
|
4407 && lnum != wp->w_cursor.lnum
|
|
4408 # ifdef FEAT_RIGHTLEFT
|
|
4409 && !wp->w_p_rl
|
|
4410 # endif
|
|
4411 )
|
|
4412 {
|
|
4413 while (col < W_WIDTH(wp))
|
|
4414 {
|
|
4415 ScreenLines[off] = ' ';
|
|
4416 #ifdef FEAT_MBYTE
|
|
4417 if (enc_utf8)
|
|
4418 ScreenLinesUC[off] = 0;
|
|
4419 #endif
|
|
4420 ++col;
|
777
|
4421 if (vcol == (long)wp->w_virtcol)
|
743
|
4422 {
|
|
4423 ScreenAttrs[off] = hl_attr(HLF_CUC);
|
|
4424 break;
|
|
4425 }
|
|
4426 ScreenAttrs[off++] = 0;
|
|
4427 ++vcol;
|
|
4428 }
|
|
4429 }
|
|
4430 #endif
|
7
|
4431
|
|
4432 SCREEN_LINE(screen_row, W_WINCOL(wp), col, (int)W_WIDTH(wp),
|
|
4433 wp->w_p_rl);
|
|
4434 row++;
|
|
4435
|
|
4436 /*
|
|
4437 * Update w_cline_height and w_cline_folded if the cursor line was
|
|
4438 * updated (saves a call to plines() later).
|
|
4439 */
|
|
4440 if (wp == curwin && lnum == curwin->w_cursor.lnum)
|
|
4441 {
|
|
4442 curwin->w_cline_row = startrow;
|
|
4443 curwin->w_cline_height = row - startrow;
|
|
4444 #ifdef FEAT_FOLDING
|
|
4445 curwin->w_cline_folded = FALSE;
|
|
4446 #endif
|
|
4447 curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW);
|
|
4448 }
|
|
4449
|
|
4450 break;
|
|
4451 }
|
|
4452
|
|
4453 /* line continues beyond line end */
|
|
4454 if (lcs_ext
|
|
4455 && !wp->w_p_wrap
|
|
4456 #ifdef FEAT_DIFF
|
|
4457 && filler_todo <= 0
|
|
4458 #endif
|
|
4459 && (
|
|
4460 #ifdef FEAT_RIGHTLEFT
|
|
4461 wp->w_p_rl ? col == 0 :
|
|
4462 #endif
|
|
4463 col == W_WIDTH(wp) - 1)
|
|
4464 && (*ptr != NUL
|
|
4465 || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str)
|
|
4466 || (n_extra && (c_extra != NUL || *p_extra != NUL))))
|
|
4467 {
|
|
4468 c = lcs_ext;
|
|
4469 char_attr = hl_attr(HLF_AT);
|
|
4470 #ifdef FEAT_MBYTE
|
|
4471 mb_c = c;
|
|
4472 if (enc_utf8 && (*mb_char2len)(c) > 1)
|
|
4473 {
|
|
4474 mb_utf8 = TRUE;
|
714
|
4475 u8cc[0] = 0;
|
819
|
4476 c = 0xc0;
|
7
|
4477 }
|
|
4478 else
|
|
4479 mb_utf8 = FALSE;
|
|
4480 #endif
|
|
4481 }
|
|
4482
|
743
|
4483 #ifdef FEAT_SYN_HL
|
|
4484 /* Highlight the cursor column if 'cursorcolumn' is set. But don't
|
|
4485 * highlight the cursor position itself. */
|
777
|
4486 if (wp->w_p_cuc && vcol == (long)wp->w_virtcol
|
743
|
4487 && lnum != wp->w_cursor.lnum
|
|
4488 && draw_state == WL_LINE)
|
|
4489 {
|
|
4490 vcol_save_attr = char_attr;
|
|
4491 char_attr = hl_combine_attr(char_attr, hl_attr(HLF_CUC));
|
|
4492 }
|
|
4493 else
|
|
4494 vcol_save_attr = -1;
|
|
4495 #endif
|
|
4496
|
7
|
4497 /*
|
|
4498 * Store character to be displayed.
|
|
4499 * Skip characters that are left of the screen for 'nowrap'.
|
|
4500 */
|
|
4501 vcol_prev = vcol;
|
|
4502 if (draw_state < WL_LINE || n_skip <= 0)
|
|
4503 {
|
|
4504 /*
|
|
4505 * Store the character.
|
|
4506 */
|
|
4507 #if defined(FEAT_RIGHTLEFT) && defined(FEAT_MBYTE)
|
|
4508 if (has_mbyte && wp->w_p_rl && (*mb_char2cells)(mb_c) > 1)
|
|
4509 {
|
|
4510 /* A double-wide character is: put first halve in left cell. */
|
|
4511 --off;
|
|
4512 --col;
|
|
4513 }
|
|
4514 #endif
|
|
4515 ScreenLines[off] = c;
|
|
4516 #ifdef FEAT_MBYTE
|
|
4517 if (enc_dbcs == DBCS_JPNU)
|
|
4518 ScreenLines2[off] = mb_c & 0xff;
|
|
4519 else if (enc_utf8)
|
|
4520 {
|
|
4521 if (mb_utf8)
|
|
4522 {
|
1326
|
4523 int i;
|
|
4524
|
7
|
4525 ScreenLinesUC[off] = mb_c;
|
819
|
4526 if ((c & 0xff) == 0)
|
|
4527 ScreenLines[off] = 0x80; /* avoid storing zero */
|
714
|
4528 for (i = 0; i < Screen_mco; ++i)
|
|
4529 {
|
|
4530 ScreenLinesC[i][off] = u8cc[i];
|
|
4531 if (u8cc[i] == 0)
|
|
4532 break;
|
|
4533 }
|
7
|
4534 }
|
|
4535 else
|
|
4536 ScreenLinesUC[off] = 0;
|
|
4537 }
|
|
4538 if (multi_attr)
|
|
4539 {
|
|
4540 ScreenAttrs[off] = multi_attr;
|
|
4541 multi_attr = 0;
|
|
4542 }
|
|
4543 else
|
|
4544 #endif
|
|
4545 ScreenAttrs[off] = char_attr;
|
|
4546
|
|
4547 #ifdef FEAT_MBYTE
|
|
4548 if (has_mbyte && (*mb_char2cells)(mb_c) > 1)
|
|
4549 {
|
|
4550 /* Need to fill two screen columns. */
|
|
4551 ++off;
|
|
4552 ++col;
|
|
4553 if (enc_utf8)
|
|
4554 /* UTF-8: Put a 0 in the second screen char. */
|
|
4555 ScreenLines[off] = 0;
|
|
4556 else
|
|
4557 /* DBCS: Put second byte in the second screen char. */
|
|
4558 ScreenLines[off] = mb_c & 0xff;
|
|
4559 ++vcol;
|
|
4560 /* When "tocol" is halfway a character, set it to the end of
|
|
4561 * the character, otherwise highlighting won't stop. */
|
|
4562 if (tocol == vcol)
|
|
4563 ++tocol;
|
|
4564 #ifdef FEAT_RIGHTLEFT
|
|
4565 if (wp->w_p_rl)
|
|
4566 {
|
|
4567 /* now it's time to backup one cell */
|
|
4568 --off;
|
|
4569 --col;
|
|
4570 }
|
|
4571 #endif
|
|
4572 }
|
|
4573 #endif
|
|
4574 #ifdef FEAT_RIGHTLEFT
|
|
4575 if (wp->w_p_rl)
|
|
4576 {
|
|
4577 --off;
|
|
4578 --col;
|
|
4579 }
|
|
4580 else
|
|
4581 #endif
|
|
4582 {
|
|
4583 ++off;
|
|
4584 ++col;
|
|
4585 }
|
|
4586 }
|
|
4587 else
|
|
4588 --n_skip;
|
|
4589
|
|
4590 /* Only advance the "vcol" when after the 'number' column. */
|
|
4591 if (draw_state >= WL_SBR
|
|
4592 #ifdef FEAT_DIFF
|
|
4593 && filler_todo <= 0
|
|
4594 #endif
|
|
4595 )
|
|
4596 ++vcol;
|
|
4597
|
743
|
4598 #ifdef FEAT_SYN_HL
|
|
4599 if (vcol_save_attr >= 0)
|
|
4600 char_attr = vcol_save_attr;
|
|
4601 #endif
|
|
4602
|
7
|
4603 /* restore attributes after "predeces" in 'listchars' */
|
|
4604 if (draw_state > WL_NR && n_attr3 > 0 && --n_attr3 == 0)
|
|
4605 char_attr = saved_attr3;
|
|
4606
|
|
4607 /* restore attributes after last 'listchars' or 'number' char */
|
|
4608 if (n_attr > 0 && draw_state == WL_LINE && --n_attr == 0)
|
|
4609 char_attr = saved_attr2;
|
|
4610
|
|
4611 /*
|
|
4612 * At end of screen line and there is more to come: Display the line
|
|
4613 * so far. If there is no more to display it is catched above.
|
|
4614 */
|
|
4615 if ((
|
|
4616 #ifdef FEAT_RIGHTLEFT
|
|
4617 wp->w_p_rl ? (col < 0) :
|
|
4618 #endif
|
|
4619 (col >= W_WIDTH(wp)))
|
|
4620 && (*ptr != NUL
|
|
4621 #ifdef FEAT_DIFF
|
|
4622 || filler_todo > 0
|
|
4623 #endif
|
|
4624 || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str)
|
|
4625 || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL)))
|
|
4626 )
|
|
4627 {
|
|
4628 SCREEN_LINE(screen_row, W_WINCOL(wp), col, (int)W_WIDTH(wp),
|
|
4629 wp->w_p_rl);
|
|
4630 ++row;
|
|
4631 ++screen_row;
|
|
4632
|
|
4633 /* When not wrapping and finished diff lines, or when displayed
|
|
4634 * '$' and highlighting until last column, break here. */
|
|
4635 if ((!wp->w_p_wrap
|
|
4636 #ifdef FEAT_DIFF
|
|
4637 && filler_todo <= 0
|
|
4638 #endif
|
|
4639 ) || lcs_eol_one == -1)
|
|
4640 break;
|
|
4641
|
|
4642 /* When the window is too narrow draw all "@" lines. */
|
|
4643 if (draw_state != WL_LINE
|
|
4644 #ifdef FEAT_DIFF
|
|
4645 && filler_todo <= 0
|
|
4646 #endif
|
|
4647 )
|
|
4648 {
|
|
4649 win_draw_end(wp, '@', ' ', row, wp->w_height, HLF_AT);
|
|
4650 #ifdef FEAT_VERTSPLIT
|
|
4651 draw_vsep_win(wp, row);
|
|
4652 #endif
|
|
4653 row = endrow;
|
|
4654 }
|
|
4655
|
|
4656 /* When line got too long for screen break here. */
|
|
4657 if (row == endrow)
|
|
4658 {
|
|
4659 ++row;
|
|
4660 break;
|
|
4661 }
|
|
4662
|
|
4663 if (screen_cur_row == screen_row - 1
|
|
4664 #ifdef FEAT_DIFF
|
|
4665 && filler_todo <= 0
|
|
4666 #endif
|
|
4667 && W_WIDTH(wp) == Columns)
|
|
4668 {
|
|
4669 /* Remember that the line wraps, used for modeless copy. */
|
|
4670 LineWraps[screen_row - 1] = TRUE;
|
|
4671
|
|
4672 /*
|
|
4673 * Special trick to make copy/paste of wrapped lines work with
|
|
4674 * xterm/screen: write an extra character beyond the end of
|
|
4675 * the line. This will work with all terminal types
|
|
4676 * (regardless of the xn,am settings).
|
|
4677 * Only do this on a fast tty.
|
|
4678 * Only do this if the cursor is on the current line
|
|
4679 * (something has been written in it).
|
|
4680 * Don't do this for the GUI.
|
|
4681 * Don't do this for double-width characters.
|
|
4682 * Don't do this for a window not at the right screen border.
|
|
4683 */
|
|
4684 if (p_tf
|
|
4685 #ifdef FEAT_GUI
|
|
4686 && !gui.in_use
|
|
4687 #endif
|
|
4688 #ifdef FEAT_MBYTE
|
|
4689 && !(has_mbyte
|
|
4690 && ((*mb_off2cells)(LineOffset[screen_row]) == 2
|
|
4691 || (*mb_off2cells)(LineOffset[screen_row - 1]
|
|
4692 + (int)Columns - 2) == 2))
|
|
4693 #endif
|
|
4694 )
|
|
4695 {
|
|
4696 /* First make sure we are at the end of the screen line,
|
|
4697 * then output the same character again to let the
|
|
4698 * terminal know about the wrap. If the terminal doesn't
|
|
4699 * auto-wrap, we overwrite the character. */
|
|
4700 if (screen_cur_col != W_WIDTH(wp))
|
|
4701 screen_char(LineOffset[screen_row - 1]
|
|
4702 + (unsigned)Columns - 1,
|
|
4703 screen_row - 1, (int)(Columns - 1));
|
|
4704
|
|
4705 #ifdef FEAT_MBYTE
|
|
4706 /* When there is a multi-byte character, just output a
|
|
4707 * space to keep it simple. */
|
148
|
4708 if (has_mbyte && MB_BYTE2LEN(ScreenLines[LineOffset[
|
|
4709 screen_row - 1] + (Columns - 1)]) > 1)
|
7
|
4710 out_char(' ');
|
|
4711 else
|
|
4712 #endif
|
|
4713 out_char(ScreenLines[LineOffset[screen_row - 1]
|
|
4714 + (Columns - 1)]);
|
|
4715 /* force a redraw of the first char on the next line */
|
|
4716 ScreenAttrs[LineOffset[screen_row]] = (sattr_T)-1;
|
|
4717 screen_start(); /* don't know where cursor is now */
|
|
4718 }
|
|
4719 }
|
|
4720
|
|
4721 col = 0;
|
|
4722 off = (unsigned)(current_ScreenLine - ScreenLines);
|
|
4723 #ifdef FEAT_RIGHTLEFT
|
|
4724 if (wp->w_p_rl)
|
|
4725 {
|
|
4726 col = W_WIDTH(wp) - 1; /* col is not used if breaking! */
|
|
4727 off += col;
|
|
4728 }
|
|
4729 #endif
|
|
4730
|
|
4731 /* reset the drawing state for the start of a wrapped line */
|
|
4732 draw_state = WL_START;
|
|
4733 saved_n_extra = n_extra;
|
|
4734 saved_p_extra = p_extra;
|
|
4735 saved_c_extra = c_extra;
|
|
4736 saved_char_attr = char_attr;
|
|
4737 n_extra = 0;
|
|
4738 lcs_prec_todo = lcs_prec;
|
|
4739 #ifdef FEAT_LINEBREAK
|
|
4740 # ifdef FEAT_DIFF
|
|
4741 if (filler_todo <= 0)
|
|
4742 # endif
|
|
4743 need_showbreak = TRUE;
|
|
4744 #endif
|
|
4745 #ifdef FEAT_DIFF
|
|
4746 --filler_todo;
|
|
4747 /* When the filler lines are actually below the last line of the
|
|
4748 * file, don't draw the line itself, break here. */
|
|
4749 if (filler_todo == 0 && wp->w_botfill)
|
|
4750 break;
|
|
4751 #endif
|
|
4752 }
|
|
4753
|
|
4754 } /* for every character in the line */
|
|
4755
|
743
|
4756 #ifdef FEAT_SPELL
|
386
|
4757 /* After an empty line check first word for capital. */
|
|
4758 if (*skipwhite(line) == NUL)
|
|
4759 {
|
|
4760 capcol_lnum = lnum + 1;
|
|
4761 cap_col = 0;
|
|
4762 }
|
|
4763 #endif
|
|
4764
|
7
|
4765 return row;
|
|
4766 }
|
|
4767
|
714
|
4768 #ifdef FEAT_MBYTE
|
|
4769 static int comp_char_differs __ARGS((int, int));
|
|
4770
|
|
4771 /*
|
|
4772 * Return if the composing characters at "off_from" and "off_to" differ.
|
|
4773 */
|
|
4774 static int
|
|
4775 comp_char_differs(off_from, off_to)
|
|
4776 int off_from;
|
|
4777 int off_to;
|
|
4778 {
|
|
4779 int i;
|
|
4780
|
|
4781 for (i = 0; i < Screen_mco; ++i)
|
|
4782 {
|
|
4783 if (ScreenLinesC[i][off_from] != ScreenLinesC[i][off_to])
|
|
4784 return TRUE;
|
|
4785 if (ScreenLinesC[i][off_from] == 0)
|
|
4786 break;
|
|
4787 }
|
|
4788 return FALSE;
|
|
4789 }
|
|
4790 #endif
|
|
4791
|
7
|
4792 /*
|
|
4793 * Check whether the given character needs redrawing:
|
|
4794 * - the (first byte of the) character is different
|
|
4795 * - the attributes are different
|
|
4796 * - the character is multi-byte and the next byte is different
|
|
4797 */
|
|
4798 static int
|
|
4799 char_needs_redraw(off_from, off_to, cols)
|
|
4800 int off_from;
|
|
4801 int off_to;
|
|
4802 int cols;
|
|
4803 {
|
|
4804 if (cols > 0
|
|
4805 && ((ScreenLines[off_from] != ScreenLines[off_to]
|
|
4806 || ScreenAttrs[off_from] != ScreenAttrs[off_to])
|
|
4807
|
|
4808 #ifdef FEAT_MBYTE
|
|
4809 || (enc_dbcs != 0
|
|
4810 && MB_BYTE2LEN(ScreenLines[off_from]) > 1
|
|
4811 && (enc_dbcs == DBCS_JPNU && ScreenLines[off_from] == 0x8e
|
|
4812 ? ScreenLines2[off_from] != ScreenLines2[off_to]
|
|
4813 : (cols > 1 && ScreenLines[off_from + 1]
|
|
4814 != ScreenLines[off_to + 1])))
|
|
4815 || (enc_utf8
|
|
4816 && (ScreenLinesUC[off_from] != ScreenLinesUC[off_to]
|
|
4817 || (ScreenLinesUC[off_from] != 0
|
714
|
4818 && comp_char_differs(off_from, off_to))))
|
7
|
4819 #endif
|
|
4820 ))
|
|
4821 return TRUE;
|
|
4822 return FALSE;
|
|
4823 }
|
|
4824
|
|
4825 /*
|
|
4826 * Move one "cooked" screen line to the screen, but only the characters that
|
|
4827 * have actually changed. Handle insert/delete character.
|
|
4828 * "coloff" gives the first column on the screen for this line.
|
|
4829 * "endcol" gives the columns where valid characters are.
|
|
4830 * "clear_width" is the width of the window. It's > 0 if the rest of the line
|
|
4831 * needs to be cleared, negative otherwise.
|
|
4832 * "rlflag" is TRUE in a rightleft window:
|
|
4833 * When TRUE and "clear_width" > 0, clear columns 0 to "endcol"
|
|
4834 * When FALSE and "clear_width" > 0, clear columns "endcol" to "clear_width"
|
|
4835 */
|
|
4836 static void
|
|
4837 screen_line(row, coloff, endcol, clear_width
|
|
4838 #ifdef FEAT_RIGHTLEFT
|
|
4839 , rlflag
|
|
4840 #endif
|
|
4841 )
|
|
4842 int row;
|
|
4843 int coloff;
|
|
4844 int endcol;
|
|
4845 int clear_width;
|
|
4846 #ifdef FEAT_RIGHTLEFT
|
|
4847 int rlflag;
|
|
4848 #endif
|
|
4849 {
|
|
4850 unsigned off_from;
|
|
4851 unsigned off_to;
|
|
4852 int col = 0;
|
|
4853 #if defined(FEAT_GUI) || defined(UNIX) || defined(FEAT_VERTSPLIT)
|
|
4854 int hl;
|
|
4855 #endif
|
|
4856 int force = FALSE; /* force update rest of the line */
|
|
4857 int redraw_this /* bool: does character need redraw? */
|
|
4858 #ifdef FEAT_GUI
|
|
4859 = TRUE /* For GUI when while-loop empty */
|
|
4860 #endif
|
|
4861 ;
|
|
4862 int redraw_next; /* redraw_this for next character */
|
|
4863 #ifdef FEAT_MBYTE
|
|
4864 int clear_next = FALSE;
|
|
4865 int char_cells; /* 1: normal char */
|
|
4866 /* 2: occupies two display cells */
|
|
4867 # define CHAR_CELLS char_cells
|
|
4868 #else
|
|
4869 # define CHAR_CELLS 1
|
|
4870 #endif
|
|
4871
|
|
4872 # ifdef FEAT_CLIPBOARD
|
|
4873 clip_may_clear_selection(row, row);
|
|
4874 # endif
|
|
4875
|
|
4876 off_from = (unsigned)(current_ScreenLine - ScreenLines);
|
|
4877 off_to = LineOffset[row] + coloff;
|
|
4878
|
|
4879 #ifdef FEAT_RIGHTLEFT
|
|
4880 if (rlflag)
|
|
4881 {
|
|
4882 /* Clear rest first, because it's left of the text. */
|
|
4883 if (clear_width > 0)
|
|
4884 {
|
|
4885 while (col <= endcol && ScreenLines[off_to] == ' '
|
|
4886 && ScreenAttrs[off_to] == 0
|
|
4887 # ifdef FEAT_MBYTE
|
|
4888 && (!enc_utf8 || ScreenLinesUC[off_to] == 0)
|
|
4889 # endif
|
|
4890 )
|
|
4891 {
|
|
4892 ++off_to;
|
|
4893 ++col;
|
|
4894 }
|
|
4895 if (col <= endcol)
|
|
4896 screen_fill(row, row + 1, col + coloff,
|
|
4897 endcol + coloff + 1, ' ', ' ', 0);
|
|
4898 }
|
|
4899 col = endcol + 1;
|
|
4900 off_to = LineOffset[row] + col + coloff;
|
|
4901 off_from += col;
|
|
4902 endcol = (clear_width > 0 ? clear_width : -clear_width);
|
|
4903 }
|
|
4904 #endif /* FEAT_RIGHTLEFT */
|
|
4905
|
|
4906 redraw_next = char_needs_redraw(off_from, off_to, endcol - col);
|
|
4907
|
|
4908 while (col < endcol)
|
|
4909 {
|
|
4910 #ifdef FEAT_MBYTE
|
|
4911 if (has_mbyte && (col + 1 < endcol))
|
|
4912 char_cells = (*mb_off2cells)(off_from);
|
|
4913 else
|
|
4914 char_cells = 1;
|
|
4915 #endif
|
|
4916
|
|
4917 redraw_this = redraw_next;
|
|
4918 redraw_next = force || char_needs_redraw(off_from + CHAR_CELLS,
|
|
4919 off_to + CHAR_CELLS, endcol - col - CHAR_CELLS);
|
|
4920
|
|
4921 #ifdef FEAT_GUI
|
|
4922 /* If the next character was bold, then redraw the current character to
|
|
4923 * remove any pixels that might have spilt over into us. This only
|
|
4924 * happens in the GUI.
|
|
4925 */
|
|
4926 if (redraw_next && gui.in_use)
|
|
4927 {
|
|
4928 hl = ScreenAttrs[off_to + CHAR_CELLS];
|
743
|
4929 if (hl > HL_ALL)
|
|
4930 hl = syn_attr2attr(hl);
|
|
4931 if (hl & HL_BOLD)
|
7
|
4932 redraw_this = TRUE;
|
|
4933 }
|
|
4934 #endif
|
|
4935
|
|
4936 if (redraw_this)
|
|
4937 {
|
|
4938 /*
|
|
4939 * Special handling when 'xs' termcap flag set (hpterm):
|
|
4940 * Attributes for characters are stored at the position where the
|
|
4941 * cursor is when writing the highlighting code. The
|
|
4942 * start-highlighting code must be written with the cursor on the
|
|
4943 * first highlighted character. The stop-highlighting code must
|
|
4944 * be written with the cursor just after the last highlighted
|
|
4945 * character.
|
|
4946 * Overwriting a character doesn't remove it's highlighting. Need
|
|
4947 * to clear the rest of the line, and force redrawing it
|
|
4948 * completely.
|
|
4949 */
|
|
4950 if ( p_wiv
|
|
4951 && !force
|
|
4952 #ifdef FEAT_GUI
|
|
4953 && !gui.in_use
|
|
4954 #endif
|
|
4955 && ScreenAttrs[off_to] != 0
|
|
4956 && ScreenAttrs[off_from] != ScreenAttrs[off_to])
|
|
4957 {
|
|
4958 /*
|
|
4959 * Need to remove highlighting attributes here.
|
|
4960 */
|
|
4961 windgoto(row, col + coloff);
|
|
4962 out_str(T_CE); /* clear rest of this screen line */
|
|
4963 screen_start(); /* don't know where cursor is now */
|
|
4964 force = TRUE; /* force redraw of rest of the line */
|
|
4965 redraw_next = TRUE; /* or else next char would miss out */
|
|
4966
|
|
4967 /*
|
|
4968 * If the previous character was highlighted, need to stop
|
|
4969 * highlighting at this character.
|
|
4970 */
|
|
4971 if (col + coloff > 0 && ScreenAttrs[off_to - 1] != 0)
|
|
4972 {
|
|
4973 screen_attr = ScreenAttrs[off_to - 1];
|
|
4974 term_windgoto(row, col + coloff);
|
|
4975 screen_stop_highlight();
|
|
4976 }
|
|
4977 else
|
|
4978 screen_attr = 0; /* highlighting has stopped */
|
|
4979 }
|
|
4980 #ifdef FEAT_MBYTE
|
|
4981 if (enc_dbcs != 0)
|
|
4982 {
|
|
4983 /* Check if overwriting a double-byte with a single-byte or
|
|
4984 * the other way around requires another character to be
|
|
4985 * redrawn. For UTF-8 this isn't needed, because comparing
|
|
4986 * ScreenLinesUC[] is sufficient. */
|
|
4987 if (char_cells == 1
|
|
4988 && col + 1 < endcol
|
|
4989 && (*mb_off2cells)(off_to) > 1)
|
|
4990 {
|
|
4991 /* Writing a single-cell character over a double-cell
|
|
4992 * character: need to redraw the next cell. */
|
|
4993 ScreenLines[off_to + 1] = 0;
|
|
4994 redraw_next = TRUE;
|
|
4995 }
|
|
4996 else if (char_cells == 2
|
|
4997 && col + 2 < endcol
|
|
4998 && (*mb_off2cells)(off_to) == 1
|
|
4999 && (*mb_off2cells)(off_to + 1) > 1)
|
|
5000 {
|
|
5001 /* Writing the second half of a double-cell character over
|
|
5002 * a double-cell character: need to redraw the second
|
|
5003 * cell. */
|
|
5004 ScreenLines[off_to + 2] = 0;
|
|
5005 redraw_next = TRUE;
|
|
5006 }
|
|
5007
|
|
5008 if (enc_dbcs == DBCS_JPNU)
|
|
5009 ScreenLines2[off_to] = ScreenLines2[off_from];
|
|
5010 }
|
|
5011 /* When writing a single-width character over a double-width
|
|
5012 * character and at the end of the redrawn text, need to clear out
|
|
5013 * the right halve of the old character.
|
|
5014 * Also required when writing the right halve of a double-width
|
|
5015 * char over the left halve of an existing one. */
|
|
5016 if (has_mbyte && col + char_cells == endcol
|
|
5017 && ((char_cells == 1
|
|
5018 && (*mb_off2cells)(off_to) > 1)
|
|
5019 || (char_cells == 2
|
|
5020 && (*mb_off2cells)(off_to) == 1
|
|
5021 && (*mb_off2cells)(off_to + 1) > 1)))
|
|
5022 clear_next = TRUE;
|
|
5023 #endif
|
|
5024
|
|
5025 ScreenLines[off_to] = ScreenLines[off_from];
|
|
5026 #ifdef FEAT_MBYTE
|
|
5027 if (enc_utf8)
|
|
5028 {
|
|
5029 ScreenLinesUC[off_to] = ScreenLinesUC[off_from];
|
|
5030 if (ScreenLinesUC[off_from] != 0)
|
|
5031 {
|
714
|
5032 int i;
|
|
5033
|
|
5034 for (i = 0; i < Screen_mco; ++i)
|
|
5035 ScreenLinesC[i][off_to] = ScreenLinesC[i][off_from];
|
7
|
5036 }
|
|
5037 }
|
|
5038 if (char_cells == 2)
|
|
5039 ScreenLines[off_to + 1] = ScreenLines[off_from + 1];
|
|
5040 #endif
|
|
5041
|
|
5042 #if defined(FEAT_GUI) || defined(UNIX)
|
|
5043 /* The bold trick makes a single row of pixels appear in the next
|
|
5044 * character. When a bold character is removed, the next
|
|
5045 * character should be redrawn too. This happens for our own GUI
|
|
5046 * and for some xterms. */
|
|
5047 if (
|
|
5048 # ifdef FEAT_GUI
|
|
5049 gui.in_use
|
|
5050 # endif
|
|
5051 # if defined(FEAT_GUI) && defined(UNIX)
|
|
5052 ||
|
|
5053 # endif
|
|
5054 # ifdef UNIX
|
|
5055 term_is_xterm
|
|
5056 # endif
|
|
5057 )
|
|
5058 {
|
|
5059 hl = ScreenAttrs[off_to];
|
743
|
5060 if (hl > HL_ALL)
|
|
5061 hl = syn_attr2attr(hl);
|
|
5062 if (hl & HL_BOLD)
|
7
|
5063 redraw_next = TRUE;
|
|
5064 }
|
|
5065 #endif
|
|
5066 ScreenAttrs[off_to] = ScreenAttrs[off_from];
|
|
5067 #ifdef FEAT_MBYTE
|
819
|
5068 /* For simplicity set the attributes of second half of a
|
|
5069 * double-wide character equal to the first half. */
|
|
5070 if (char_cells == 2)
|
|
5071 ScreenAttrs[off_to + 1] = ScreenAttrs[off_from];
|
|
5072
|
7
|
5073 if (enc_dbcs != 0 && char_cells == 2)
|
|
5074 screen_char_2(off_to, row, col + coloff);
|
|
5075 else
|
|
5076 #endif
|
|
5077 screen_char(off_to, row, col + coloff);
|
|
5078 }
|
|
5079 else if ( p_wiv
|
|
5080 #ifdef FEAT_GUI
|
|
5081 && !gui.in_use
|
|
5082 #endif
|
|
5083 && col + coloff > 0)
|
|
5084 {
|
|
5085 if (ScreenAttrs[off_to] == ScreenAttrs[off_to - 1])
|
|
5086 {
|
|
5087 /*
|
|
5088 * Don't output stop-highlight when moving the cursor, it will
|
|
5089 * stop the highlighting when it should continue.
|
|
5090 */
|
|
5091 screen_attr = 0;
|
|
5092 }
|
|
5093 else if (screen_attr != 0)
|
|
5094 screen_stop_highlight();
|
|
5095 }
|
|
5096
|
|
5097 off_to += CHAR_CELLS;
|
|
5098 off_from += CHAR_CELLS;
|
|
5099 col += CHAR_CELLS;
|
|
5100 }
|
|
5101
|
|
5102 #ifdef FEAT_MBYTE
|
|
5103 if (clear_next)
|
|
5104 {
|
|
5105 /* Clear the second half of a double-wide character of which the left
|
|
5106 * half was overwritten with a single-wide character. */
|
|
5107 ScreenLines[off_to] = ' ';
|
|
5108 if (enc_utf8)
|
|
5109 ScreenLinesUC[off_to] = 0;
|
|
5110 screen_char(off_to, row, col + coloff);
|
|
5111 }
|
|
5112 #endif
|
|
5113
|
|
5114 if (clear_width > 0
|
|
5115 #ifdef FEAT_RIGHTLEFT
|
|
5116 && !rlflag
|
|
5117 #endif
|
|
5118 )
|
|
5119 {
|
|
5120 #ifdef FEAT_GUI
|
|
5121 int startCol = col;
|
|
5122 #endif
|
|
5123
|
|
5124 /* blank out the rest of the line */
|
|
5125 while (col < clear_width && ScreenLines[off_to] == ' '
|
|
5126 && ScreenAttrs[off_to] == 0
|
|
5127 #ifdef FEAT_MBYTE
|
|
5128 && (!enc_utf8 || ScreenLinesUC[off_to] == 0)
|
|
5129 #endif
|
|
5130 )
|
|
5131 {
|
|
5132 ++off_to;
|
|
5133 ++col;
|
|
5134 }
|
|
5135 if (col < clear_width)
|
|
5136 {
|
|
5137 #ifdef FEAT_GUI
|
|
5138 /*
|
|
5139 * In the GUI, clearing the rest of the line may leave pixels
|
|
5140 * behind if the first character cleared was bold. Some bold
|
|
5141 * fonts spill over the left. In this case we redraw the previous
|
|
5142 * character too. If we didn't skip any blanks above, then we
|
|
5143 * only redraw if the character wasn't already redrawn anyway.
|
|
5144 */
|
996
|
5145 if (gui.in_use && (col > startCol || !redraw_this))
|
7
|
5146 {
|
|
5147 hl = ScreenAttrs[off_to];
|
|
5148 if (hl > HL_ALL || (hl & HL_BOLD))
|
996
|
5149 {
|
|
5150 int prev_cells = 1;
|
|
5151 # ifdef FEAT_MBYTE
|
|
5152 if (enc_utf8)
|
|
5153 /* for utf-8, ScreenLines[char_offset + 1] == 0 means
|
|
5154 * that its width is 2. */
|
|
5155 prev_cells = ScreenLines[off_to - 1] == 0 ? 2 : 1;
|
|
5156 else if (enc_dbcs != 0)
|
|
5157 {
|
|
5158 /* find previous character by counting from first
|
|
5159 * column and get its width. */
|
|
5160 unsigned off = LineOffset[row];
|
|
5161
|
|
5162 while (off < off_to)
|
|
5163 {
|
|
5164 prev_cells = (*mb_off2cells)(off);
|
|
5165 off += prev_cells;
|
|
5166 }
|
|
5167 }
|
|
5168
|
|
5169 if (enc_dbcs != 0 && prev_cells > 1)
|
|
5170 screen_char_2(off_to - prev_cells, row,
|
|
5171 col + coloff - prev_cells);
|
|
5172 else
|
|
5173 # endif
|
|
5174 screen_char(off_to - prev_cells, row,
|
|
5175 col + coloff - prev_cells);
|
|
5176 }
|
7
|
5177 }
|
|
5178 #endif
|
|
5179 screen_fill(row, row + 1, col + coloff, clear_width + coloff,
|
|
5180 ' ', ' ', 0);
|
|
5181 #ifdef FEAT_VERTSPLIT
|
|
5182 off_to += clear_width - col;
|
|
5183 col = clear_width;
|
|
5184 #endif
|
|
5185 }
|
|
5186 }
|
|
5187
|
|
5188 if (clear_width > 0)
|
|
5189 {
|
|
5190 #ifdef FEAT_VERTSPLIT
|
|
5191 /* For a window that's left of another, draw the separator char. */
|
|
5192 if (col + coloff < Columns)
|
|
5193 {
|
|
5194 int c;
|
|
5195
|
|
5196 c = fillchar_vsep(&hl);
|
|
5197 if (ScreenLines[off_to] != c
|
|
5198 # ifdef FEAT_MBYTE
|
714
|
5199 || (enc_utf8 && (int)ScreenLinesUC[off_to]
|
|
5200 != (c >= 0x80 ? c : 0))
|
7
|
5201 # endif
|
|
5202 || ScreenAttrs[off_to] != hl)
|
|
5203 {
|
|
5204 ScreenLines[off_to] = c;
|
|
5205 ScreenAttrs[off_to] = hl;
|
|
5206 # ifdef FEAT_MBYTE
|
|
5207 if (enc_utf8)
|
|
5208 {
|
|
5209 if (c >= 0x80)
|
|
5210 {
|
|
5211 ScreenLinesUC[off_to] = c;
|
714
|
5212 ScreenLinesC[0][off_to] = 0;
|
7
|
5213 }
|
|
5214 else
|
|
5215 ScreenLinesUC[off_to] = 0;
|
|
5216 }
|
|
5217 # endif
|
|
5218 screen_char(off_to, row, col + coloff);
|
|
5219 }
|
|
5220 }
|
|
5221 else
|
|
5222 #endif
|
|
5223 LineWraps[row] = FALSE;
|
|
5224 }
|
|
5225 }
|
|
5226
|
474
|
5227 #if defined(FEAT_RIGHTLEFT) || defined(PROTO)
|
7
|
5228 /*
|
474
|
5229 * Mirror text "str" for right-left displaying.
|
|
5230 * Only works for single-byte characters (e.g., numbers).
|
7
|
5231 */
|
474
|
5232 void
|
7
|
5233 rl_mirror(str)
|
|
5234 char_u *str;
|
|
5235 {
|
|
5236 char_u *p1, *p2;
|
|
5237 int t;
|
|
5238
|
|
5239 for (p1 = str, p2 = str + STRLEN(str) - 1; p1 < p2; ++p1, --p2)
|
|
5240 {
|
|
5241 t = *p1;
|
|
5242 *p1 = *p2;
|
|
5243 *p2 = t;
|
|
5244 }
|
|
5245 }
|
|
5246 #endif
|
|
5247
|
|
5248 #if defined(FEAT_WINDOWS) || defined(PROTO)
|
|
5249 /*
|
|
5250 * mark all status lines for redraw; used after first :cd
|
|
5251 */
|
|
5252 void
|
|
5253 status_redraw_all()
|
|
5254 {
|
|
5255 win_T *wp;
|
|
5256
|
|
5257 for (wp = firstwin; wp; wp = wp->w_next)
|
|
5258 if (wp->w_status_height)
|
|
5259 {
|
|
5260 wp->w_redr_status = TRUE;
|
|
5261 redraw_later(VALID);
|
|
5262 }
|
|
5263 }
|
|
5264
|
|
5265 /*
|
|
5266 * mark all status lines of the current buffer for redraw
|
|
5267 */
|
|
5268 void
|
|
5269 status_redraw_curbuf()
|
|
5270 {
|
|
5271 win_T *wp;
|
|
5272
|
|
5273 for (wp = firstwin; wp; wp = wp->w_next)
|
|
5274 if (wp->w_status_height != 0 && wp->w_buffer == curbuf)
|
|
5275 {
|
|
5276 wp->w_redr_status = TRUE;
|
|
5277 redraw_later(VALID);
|
|
5278 }
|
|
5279 }
|
|
5280
|
|
5281 /*
|
|
5282 * Redraw all status lines that need to be redrawn.
|
|
5283 */
|
|
5284 void
|
|
5285 redraw_statuslines()
|
|
5286 {
|
|
5287 win_T *wp;
|
|
5288
|
|
5289 for (wp = firstwin; wp; wp = wp->w_next)
|
|
5290 if (wp->w_redr_status)
|
|
5291 win_redr_status(wp);
|
673
|
5292 if (redraw_tabline)
|
677
|
5293 draw_tabline();
|
7
|
5294 }
|
|
5295 #endif
|
|
5296
|
|
5297 #if (defined(FEAT_WILDMENU) && defined(FEAT_VERTSPLIT)) || defined(PROTO)
|
|
5298 /*
|
|
5299 * Redraw all status lines at the bottom of frame "frp".
|
|
5300 */
|
|
5301 void
|
|
5302 win_redraw_last_status(frp)
|
|
5303 frame_T *frp;
|
|
5304 {
|
|
5305 if (frp->fr_layout == FR_LEAF)
|
|
5306 frp->fr_win->w_redr_status = TRUE;
|
|
5307 else if (frp->fr_layout == FR_ROW)
|
|
5308 {
|
|
5309 for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next)
|
|
5310 win_redraw_last_status(frp);
|
|
5311 }
|
|
5312 else /* frp->fr_layout == FR_COL */
|
|
5313 {
|
|
5314 frp = frp->fr_child;
|
|
5315 while (frp->fr_next != NULL)
|
|
5316 frp = frp->fr_next;
|
|
5317 win_redraw_last_status(frp);
|
|
5318 }
|
|
5319 }
|
|
5320 #endif
|
|
5321
|
|
5322 #ifdef FEAT_VERTSPLIT
|
|
5323 /*
|
|
5324 * Draw the verticap separator right of window "wp" starting with line "row".
|
|
5325 */
|
|
5326 static void
|
|
5327 draw_vsep_win(wp, row)
|
|
5328 win_T *wp;
|
|
5329 int row;
|
|
5330 {
|
|
5331 int hl;
|
|
5332 int c;
|
|
5333
|
|
5334 if (wp->w_vsep_width)
|
|
5335 {
|
|
5336 /* draw the vertical separator right of this window */
|
|
5337 c = fillchar_vsep(&hl);
|
|
5338 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
|
|
5339 W_ENDCOL(wp), W_ENDCOL(wp) + 1,
|
|
5340 c, ' ', hl);
|
|
5341 }
|
|
5342 }
|
|
5343 #endif
|
|
5344
|
|
5345 #ifdef FEAT_WILDMENU
|
|
5346 static int status_match_len __ARGS((expand_T *xp, char_u *s));
|
277
|
5347 static int skip_status_match_char __ARGS((expand_T *xp, char_u *s));
|
7
|
5348
|
|
5349 /*
|
|
5350 * Get the lenght of an item as it will be shown in the status line.
|
|
5351 */
|
|
5352 static int
|
|
5353 status_match_len(xp, s)
|
|
5354 expand_T *xp;
|
|
5355 char_u *s;
|
|
5356 {
|
|
5357 int len = 0;
|
|
5358
|
|
5359 #ifdef FEAT_MENU
|
|
5360 int emenu = (xp->xp_context == EXPAND_MENUS
|
|
5361 || xp->xp_context == EXPAND_MENUNAMES);
|
|
5362
|
|
5363 /* Check for menu separators - replace with '|'. */
|
|
5364 if (emenu && menu_is_separator(s))
|
|
5365 return 1;
|
|
5366 #endif
|
|
5367
|
|
5368 while (*s != NUL)
|
|
5369 {
|
277
|
5370 if (skip_status_match_char(xp, s))
|
7
|
5371 ++s;
|
42
|
5372 len += ptr2cells(s);
|
39
|
5373 mb_ptr_adv(s);
|
7
|
5374 }
|
|
5375
|
|
5376 return len;
|
|
5377 }
|
|
5378
|
|
5379 /*
|
277
|
5380 * Return TRUE for characters that are not displayed in a status match.
|
|
5381 * These are backslashes used for escaping. Do show backslashes in help tags.
|
|
5382 */
|
|
5383 static int
|
|
5384 skip_status_match_char(xp, s)
|
|
5385 expand_T *xp;
|
|
5386 char_u *s;
|
|
5387 {
|
|
5388 return ((rem_backslash(s) && xp->xp_context != EXPAND_HELP)
|
|
5389 #ifdef FEAT_MENU
|
|
5390 || ((xp->xp_context == EXPAND_MENUS
|
|
5391 || xp->xp_context == EXPAND_MENUNAMES)
|
|
5392 && (s[0] == '\t' || (s[0] == '\\' && s[1] != NUL)))
|
|
5393 #endif
|
|
5394 );
|
|
5395 }
|
|
5396
|
|
5397 /*
|
7
|
5398 * Show wildchar matches in the status line.
|
|
5399 * Show at least the "match" item.
|
|
5400 * We start at item 'first_match' in the list and show all matches that fit.
|
|
5401 *
|
|
5402 * If inversion is possible we use it. Else '=' characters are used.
|
|
5403 */
|
|
5404 void
|
|
5405 win_redr_status_matches(xp, num_matches, matches, match, showtail)
|
|
5406 expand_T *xp;
|
|
5407 int num_matches;
|
|
5408 char_u **matches; /* list of matches */
|
|
5409 int match;
|
|
5410 int showtail;
|
|
5411 {
|
|
5412 #define L_MATCH(m) (showtail ? sm_gettail(matches[m]) : matches[m])
|
|
5413 int row;
|
|
5414 char_u *buf;
|
|
5415 int len;
|
|
5416 int clen; /* lenght in screen cells */
|
|
5417 int fillchar;
|
|
5418 int attr;
|
|
5419 int i;
|
|
5420 int highlight = TRUE;
|
|
5421 char_u *selstart = NULL;
|
|
5422 int selstart_col = 0;
|
|
5423 char_u *selend = NULL;
|
|
5424 static int first_match = 0;
|
|
5425 int add_left = FALSE;
|
|
5426 char_u *s;
|
|
5427 #ifdef FEAT_MENU
|
|
5428 int emenu;
|
|
5429 #endif
|
|
5430 #if defined(FEAT_MBYTE) || defined(FEAT_MENU)
|
|
5431 int l;
|
|
5432 #endif
|
|
5433
|
|
5434 if (matches == NULL) /* interrupted completion? */
|
|
5435 return;
|
|
5436
|
39
|
5437 #ifdef FEAT_MBYTE
|
|
5438 if (has_mbyte)
|
|
5439 buf = alloc((unsigned)Columns * MB_MAXBYTES + 1);
|
|
5440 else
|
|
5441 #endif
|
|
5442 buf = alloc((unsigned)Columns + 1);
|
7
|
5443 if (buf == NULL)
|
|
5444 return;
|
|
5445
|
|
5446 if (match == -1) /* don't show match but original text */
|
|
5447 {
|
|
5448 match = 0;
|
|
5449 highlight = FALSE;
|
|
5450 }
|
|
5451 /* count 1 for the ending ">" */
|
|
5452 clen = status_match_len(xp, L_MATCH(match)) + 3;
|
|
5453 if (match == 0)
|
|
5454 first_match = 0;
|
|
5455 else if (match < first_match)
|
|
5456 {
|
|
5457 /* jumping left, as far as we can go */
|
|
5458 first_match = match;
|
|
5459 add_left = TRUE;
|
|
5460 }
|
|
5461 else
|
|
5462 {
|
|
5463 /* check if match fits on the screen */
|
|
5464 for (i = first_match; i < match; ++i)
|
|
5465 clen += status_match_len(xp, L_MATCH(i)) + 2;
|
|
5466 if (first_match > 0)
|
|
5467 clen += 2;
|
|
5468 /* jumping right, put match at the left */
|
|
5469 if ((long)clen > Columns)
|
|
5470 {
|
|
5471 first_match = match;
|
|
5472 /* if showing the last match, we can add some on the left */
|
|
5473 clen = 2;
|
|
5474 for (i = match; i < num_matches; ++i)
|
|
5475 {
|
|
5476 clen += status_match_len(xp, L_MATCH(i)) + 2;
|
|
5477 if ((long)clen >= Columns)
|
|
5478 break;
|
|
5479 }
|
|
5480 if (i == num_matches)
|
|
5481 add_left = TRUE;
|
|
5482 }
|
|
5483 }
|
|
5484 if (add_left)
|
|
5485 while (first_match > 0)
|
|
5486 {
|
|
5487 clen += status_match_len(xp, L_MATCH(first_match - 1)) + 2;
|
|
5488 if ((long)clen >= Columns)
|
|
5489 break;
|
|
5490 --first_match;
|
|
5491 }
|
|
5492
|
|
5493 fillchar = fillchar_status(&attr, TRUE);
|
|
5494
|
|
5495 if (first_match == 0)
|
|
5496 {
|
|
5497 *buf = NUL;
|
|
5498 len = 0;
|
|
5499 }
|
|
5500 else
|
|
5501 {
|
|
5502 STRCPY(buf, "< ");
|
|
5503 len = 2;
|
|
5504 }
|
|
5505 clen = len;
|
|
5506
|
|
5507 i = first_match;
|
|
5508 while ((long)(clen + status_match_len(xp, L_MATCH(i)) + 2) < Columns)
|
|
5509 {
|
|
5510 if (i == match)
|
|
5511 {
|
|
5512 selstart = buf + len;
|
|
5513 selstart_col = clen;
|
|
5514 }
|
|
5515
|
|
5516 s = L_MATCH(i);
|
|
5517 /* Check for menu separators - replace with '|' */
|
|
5518 #ifdef FEAT_MENU
|
|
5519 emenu = (xp->xp_context == EXPAND_MENUS
|
|
5520 || xp->xp_context == EXPAND_MENUNAMES);
|
|
5521 if (emenu && menu_is_separator(s))
|
|
5522 {
|
|
5523 STRCPY(buf + len, transchar('|'));
|
|
5524 l = (int)STRLEN(buf + len);
|
|
5525 len += l;
|
|
5526 clen += l;
|
|
5527 }
|
|
5528 else
|
|
5529 #endif
|
|
5530 for ( ; *s != NUL; ++s)
|
|
5531 {
|
277
|
5532 if (skip_status_match_char(xp, s))
|
7
|
5533 ++s;
|
|
5534 clen += ptr2cells(s);
|
|
5535 #ifdef FEAT_MBYTE
|
474
|
5536 if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1)
|
7
|
5537 {
|
|
5538 STRNCPY(buf + len, s, l);
|
|
5539 s += l - 1;
|
|
5540 len += l;
|
|
5541 }
|
|
5542 else
|
|
5543 #endif
|
|
5544 {
|
|
5545 STRCPY(buf + len, transchar_byte(*s));
|
|
5546 len += (int)STRLEN(buf + len);
|
|
5547 }
|
|
5548 }
|
|
5549 if (i == match)
|
|
5550 selend = buf + len;
|
|
5551
|
|
5552 *(buf + len++) = ' ';
|
|
5553 *(buf + len++) = ' ';
|
|
5554 clen += 2;
|
|
5555 if (++i == num_matches)
|
|
5556 break;
|
|
5557 }
|
|
5558
|
|
5559 if (i != num_matches)
|
|
5560 {
|
|
5561 *(buf + len++) = '>';
|
|
5562 ++clen;
|
|
5563 }
|
|
5564
|
|
5565 buf[len] = NUL;
|
|
5566
|
|
5567 row = cmdline_row - 1;
|
|
5568 if (row >= 0)
|
|
5569 {
|
|
5570 if (wild_menu_showing == 0)
|
|
5571 {
|
|
5572 if (msg_scrolled > 0)
|
|
5573 {
|
|
5574 /* Put the wildmenu just above the command line. If there is
|
|
5575 * no room, scroll the screen one line up. */
|
|
5576 if (cmdline_row == Rows - 1)
|
|
5577 {
|
|
5578 screen_del_lines(0, 0, 1, (int)Rows, TRUE, NULL);
|
|
5579 ++msg_scrolled;
|
|
5580 }
|
|
5581 else
|
|
5582 {
|
|
5583 ++cmdline_row;
|
|
5584 ++row;
|
|
5585 }
|
|
5586 wild_menu_showing = WM_SCROLLED;
|
|
5587 }
|
|
5588 else
|
|
5589 {
|
|
5590 /* Create status line if needed by setting 'laststatus' to 2.
|
|
5591 * Set 'winminheight' to zero to avoid that the window is
|
|
5592 * resized. */
|
|
5593 if (lastwin->w_status_height == 0)
|
|
5594 {
|
|
5595 save_p_ls = p_ls;
|
|
5596 save_p_wmh = p_wmh;
|
|
5597 p_ls = 2;
|
|
5598 p_wmh = 0;
|
|
5599 last_status(FALSE);
|
|
5600 }
|
|
5601 wild_menu_showing = WM_SHOWN;
|
|
5602 }
|
|
5603 }
|
|
5604
|
|
5605 screen_puts(buf, row, 0, attr);
|
|
5606 if (selstart != NULL && highlight)
|
|
5607 {
|
|
5608 *selend = NUL;
|
|
5609 screen_puts(selstart, row, selstart_col, hl_attr(HLF_WM));
|
|
5610 }
|
|
5611
|
|
5612 screen_fill(row, row + 1, clen, (int)Columns, fillchar, fillchar, attr);
|
|
5613 }
|
|
5614
|
|
5615 #ifdef FEAT_VERTSPLIT
|
|
5616 win_redraw_last_status(topframe);
|
|
5617 #else
|
|
5618 lastwin->w_redr_status = TRUE;
|
|
5619 #endif
|
|
5620 vim_free(buf);
|
|
5621 }
|
|
5622 #endif
|
|
5623
|
|
5624 #if defined(FEAT_WINDOWS) || defined(PROTO)
|
|
5625 /*
|
|
5626 * Redraw the status line of window wp.
|
|
5627 *
|
|
5628 * If inversion is possible we use it. Else '=' characters are used.
|
|
5629 */
|
|
5630 void
|
|
5631 win_redr_status(wp)
|
|
5632 win_T *wp;
|
|
5633 {
|
|
5634 int row;
|
|
5635 char_u *p;
|
|
5636 int len;
|
|
5637 int fillchar;
|
|
5638 int attr;
|
|
5639 int this_ru_col;
|
|
5640
|
|
5641 wp->w_redr_status = FALSE;
|
|
5642 if (wp->w_status_height == 0)
|
|
5643 {
|
|
5644 /* no status line, can only be last window */
|
|
5645 redraw_cmdline = TRUE;
|
|
5646 }
|
540
|
5647 else if (!redrawing()
|
|
5648 #ifdef FEAT_INS_EXPAND
|
|
5649 /* don't update status line when popup menu is visible and may be
|
|
5650 * drawn over it */
|
|
5651 || pum_visible()
|
|
5652 #endif
|
|
5653 )
|
7
|
5654 {
|
|
5655 /* Don't redraw right now, do it later. */
|
|
5656 wp->w_redr_status = TRUE;
|
|
5657 }
|
|
5658 #ifdef FEAT_STL_OPT
|
40
|
5659 else if (*p_stl != NUL || *wp->w_p_stl != NUL)
|
7
|
5660 {
|
|
5661 /* redraw custom status line */
|
680
|
5662 redraw_custum_statusline(wp);
|
7
|
5663 }
|
|
5664 #endif
|
|
5665 else
|
|
5666 {
|
|
5667 fillchar = fillchar_status(&attr, wp == curwin);
|
|
5668
|
685
|
5669 get_trans_bufname(wp->w_buffer);
|
7
|
5670 p = NameBuff;
|
|
5671 len = (int)STRLEN(p);
|
|
5672
|
|
5673 if (wp->w_buffer->b_help
|
|
5674 #ifdef FEAT_QUICKFIX
|
|
5675 || wp->w_p_pvw
|
|
5676 #endif
|
|
5677 || bufIsChanged(wp->w_buffer)
|
|
5678 || wp->w_buffer->b_p_ro)
|
|
5679 *(p + len++) = ' ';
|
|
5680 if (wp->w_buffer->b_help)
|
|
5681 {
|
809
|
5682 STRCPY(p + len, _("[Help]"));
|
7
|
5683 len += (int)STRLEN(p + len);
|
|
5684 }
|
|
5685 #ifdef FEAT_QUICKFIX
|
|
5686 if (wp->w_p_pvw)
|
|
5687 {
|
|
5688 STRCPY(p + len, _("[Preview]"));
|
|
5689 len += (int)STRLEN(p + len);
|
|
5690 }
|
|
5691 #endif
|
|
5692 if (bufIsChanged(wp->w_buffer))
|
|
5693 {
|
|
5694 STRCPY(p + len, "[+]");
|
|
5695 len += 3;
|
|
5696 }
|
|
5697 if (wp->w_buffer->b_p_ro)
|
|
5698 {
|
|
5699 STRCPY(p + len, "[RO]");
|
|
5700 len += 4;
|
|
5701 }
|
|
5702
|
|
5703 #ifndef FEAT_VERTSPLIT
|
|
5704 this_ru_col = ru_col;
|
|
5705 if (this_ru_col < (Columns + 1) / 2)
|
|
5706 this_ru_col = (Columns + 1) / 2;
|
|
5707 #else
|
|
5708 this_ru_col = ru_col - (Columns - W_WIDTH(wp));
|
|
5709 if (this_ru_col < (W_WIDTH(wp) + 1) / 2)
|
|
5710 this_ru_col = (W_WIDTH(wp) + 1) / 2;
|
|
5711 if (this_ru_col <= 1)
|
|
5712 {
|
|
5713 p = (char_u *)"<"; /* No room for file name! */
|
|
5714 len = 1;
|
|
5715 }
|
|
5716 else
|
|
5717 #endif
|
|
5718 #ifdef FEAT_MBYTE
|
|
5719 if (has_mbyte)
|
|
5720 {
|
|
5721 int clen = 0, i;
|
|
5722
|
|
5723 /* Count total number of display cells. */
|
474
|
5724 for (i = 0; p[i] != NUL; i += (*mb_ptr2len)(p + i))
|
7
|
5725 clen += (*mb_ptr2cells)(p + i);
|
|
5726 /* Find first character that will fit.
|
|
5727 * Going from start to end is much faster for DBCS. */
|
|
5728 for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;
|
474
|
5729 i += (*mb_ptr2len)(p + i))
|
7
|
5730 clen -= (*mb_ptr2cells)(p + i);
|
|
5731 len = clen;
|
|
5732 if (i > 0)
|
|
5733 {
|
|
5734 p = p + i - 1;
|
|
5735 *p = '<';
|
|
5736 ++len;
|
|
5737 }
|
|
5738
|
|
5739 }
|
|
5740 else
|
|
5741 #endif
|
|
5742 if (len > this_ru_col - 1)
|
|
5743 {
|
|
5744 p += len - (this_ru_col - 1);
|
|
5745 *p = '<';
|
|
5746 len = this_ru_col - 1;
|
|
5747 }
|
|
5748
|
|
5749 row = W_WINROW(wp) + wp->w_height;
|
|
5750 screen_puts(p, row, W_WINCOL(wp), attr);
|
|
5751 screen_fill(row, row + 1, len + W_WINCOL(wp),
|
|
5752 this_ru_col + W_WINCOL(wp), fillchar, fillchar, attr);
|
|
5753
|
|
5754 if (get_keymap_str(wp, NameBuff, MAXPATHL)
|
|
5755 && (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))
|
|
5756 screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff)
|
|
5757 - 1 + W_WINCOL(wp)), attr);
|
|
5758
|
|
5759 #ifdef FEAT_CMDL_INFO
|
|
5760 win_redr_ruler(wp, TRUE);
|
|
5761 #endif
|
|
5762 }
|
|
5763
|
|
5764 #ifdef FEAT_VERTSPLIT
|
|
5765 /*
|
|
5766 * May need to draw the character below the vertical separator.
|
|
5767 */
|
|
5768 if (wp->w_vsep_width != 0 && wp->w_status_height != 0 && redrawing())
|
|
5769 {
|
|
5770 if (stl_connected(wp))
|
|
5771 fillchar = fillchar_status(&attr, wp == curwin);
|
|
5772 else
|
|
5773 fillchar = fillchar_vsep(&attr);
|
|
5774 screen_putchar(fillchar, W_WINROW(wp) + wp->w_height, W_ENDCOL(wp),
|
|
5775 attr);
|
|
5776 }
|
|
5777 #endif
|
|
5778 }
|
|
5779
|
680
|
5780 #ifdef FEAT_STL_OPT
|
|
5781 /*
|
|
5782 * Redraw the status line according to 'statusline' and take care of any
|
|
5783 * errors encountered.
|
|
5784 */
|
|
5785 static void
|
|
5786 redraw_custum_statusline(wp)
|
|
5787 win_T *wp;
|
|
5788 {
|
|
5789 int save_called_emsg = called_emsg;
|
|
5790
|
|
5791 called_emsg = FALSE;
|
|
5792 win_redr_custom(wp, FALSE);
|
|
5793 if (called_emsg)
|
|
5794 set_string_option_direct((char_u *)"statusline", -1,
|
|
5795 (char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL
|
694
|
5796 ? OPT_LOCAL : OPT_GLOBAL), SID_ERROR);
|
680
|
5797 called_emsg |= save_called_emsg;
|
|
5798 }
|
|
5799 #endif
|
|
5800
|
7
|
5801 # ifdef FEAT_VERTSPLIT
|
|
5802 /*
|
|
5803 * Return TRUE if the status line of window "wp" is connected to the status
|
|
5804 * line of the window right of it. If not, then it's a vertical separator.
|
|
5805 * Only call if (wp->w_vsep_width != 0).
|
|
5806 */
|
|
5807 int
|
|
5808 stl_connected(wp)
|
|
5809 win_T *wp;
|
|
5810 {
|
|
5811 frame_T *fr;
|
|
5812
|
|
5813 fr = wp->w_frame;
|
|
5814 while (fr->fr_parent != NULL)
|
|
5815 {
|
|
5816 if (fr->fr_parent->fr_layout == FR_COL)
|
|
5817 {
|
|
5818 if (fr->fr_next != NULL)
|
|
5819 break;
|
|
5820 }
|
|
5821 else
|
|
5822 {
|
|
5823 if (fr->fr_next != NULL)
|
|
5824 return TRUE;
|
|
5825 }
|
|
5826 fr = fr->fr_parent;
|
|
5827 }
|
|
5828 return FALSE;
|
|
5829 }
|
|
5830 # endif
|
|
5831
|
|
5832 #endif /* FEAT_WINDOWS */
|
|
5833
|
|
5834 #if defined(FEAT_WINDOWS) || defined(FEAT_STL_OPT) || defined(PROTO)
|
|
5835 /*
|
|
5836 * Get the value to show for the language mappings, active 'keymap'.
|
|
5837 */
|
|
5838 int
|
|
5839 get_keymap_str(wp, buf, len)
|
|
5840 win_T *wp;
|
|
5841 char_u *buf; /* buffer for the result */
|
|
5842 int len; /* length of buffer */
|
|
5843 {
|
|
5844 char_u *p;
|
|
5845
|
|
5846 if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP)
|
|
5847 return FALSE;
|
|
5848
|
|
5849 {
|
|
5850 #ifdef FEAT_EVAL
|
|
5851 buf_T *old_curbuf = curbuf;
|
|
5852 win_T *old_curwin = curwin;
|
|
5853 char_u *s;
|
|
5854
|
|
5855 curbuf = wp->w_buffer;
|
|
5856 curwin = wp;
|
|
5857 STRCPY(buf, "b:keymap_name"); /* must be writable */
|
|
5858 ++emsg_skip;
|
714
|
5859 s = p = eval_to_string(buf, NULL, FALSE);
|
7
|
5860 --emsg_skip;
|
|
5861 curbuf = old_curbuf;
|
|
5862 curwin = old_curwin;
|
|
5863 if (p == NULL || *p == NUL)
|
|
5864 #endif
|
|
5865 {
|
|
5866 #ifdef FEAT_KEYMAP
|
|
5867 if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED)
|
|
5868 p = wp->w_buffer->b_p_keymap;
|
|
5869 else
|
|
5870 #endif
|
|
5871 p = (char_u *)"lang";
|
|
5872 }
|
|
5873 if ((int)(STRLEN(p) + 3) < len)
|
|
5874 sprintf((char *)buf, "<%s>", p);
|
|
5875 else
|
|
5876 buf[0] = NUL;
|
|
5877 #ifdef FEAT_EVAL
|
|
5878 vim_free(s);
|
|
5879 #endif
|
|
5880 }
|
|
5881 return buf[0] != NUL;
|
|
5882 }
|
|
5883 #endif
|
|
5884
|
|
5885 #if defined(FEAT_STL_OPT) || defined(PROTO)
|
|
5886 /*
|
677
|
5887 * Redraw the status line or ruler of window "wp".
|
|
5888 * When "wp" is NULL redraw the tab pages line from 'tabline'.
|
7
|
5889 */
|
|
5890 static void
|
574
|
5891 win_redr_custom(wp, draw_ruler)
|
7
|
5892 win_T *wp;
|
574
|
5893 int draw_ruler; /* TRUE or FALSE */
|
7
|
5894 {
|
|
5895 int attr;
|
|
5896 int curattr;
|
|
5897 int row;
|
|
5898 int col = 0;
|
|
5899 int maxwidth;
|
|
5900 int width;
|
|
5901 int n;
|
|
5902 int len;
|
|
5903 int fillchar;
|
|
5904 char_u buf[MAXPATHL];
|
|
5905 char_u *p;
|
681
|
5906 struct stl_hlrec hltab[STL_MAX_ITEM];
|
|
5907 struct stl_hlrec tabtab[STL_MAX_ITEM];
|
677
|
5908 int use_sandbox = FALSE;
|
7
|
5909
|
|
5910 /* setup environment for the task at hand */
|
677
|
5911 if (wp == NULL)
|
|
5912 {
|
|
5913 /* Use 'tabline'. Always at the first line of the screen. */
|
|
5914 p = p_tal;
|
|
5915 row = 0;
|
707
|
5916 fillchar = ' ';
|
677
|
5917 attr = hl_attr(HLF_TPF);
|
|
5918 maxwidth = Columns;
|
|
5919 # ifdef FEAT_EVAL
|
681
|
5920 use_sandbox = was_set_insecurely((char_u *)"tabline", 0);
|
677
|
5921 # endif
|
|
5922 }
|
40
|
5923 else
|
677
|
5924 {
|
|
5925 row = W_WINROW(wp) + wp->w_height;
|
|
5926 fillchar = fillchar_status(&attr, wp == curwin);
|
|
5927 maxwidth = W_WIDTH(wp);
|
|
5928
|
|
5929 if (draw_ruler)
|
|
5930 {
|
|
5931 p = p_ruf;
|
|
5932 /* advance past any leading group spec - implicit in ru_col */
|
|
5933 if (*p == '%')
|
|
5934 {
|
|
5935 if (*++p == '-')
|
7
|
5936 p++;
|
677
|
5937 if (atoi((char *) p))
|
|
5938 while (VIM_ISDIGIT(*p))
|
|
5939 p++;
|
|
5940 if (*p++ != '(')
|
|
5941 p = p_ruf;
|
|
5942 }
|
7
|
5943 #ifdef FEAT_VERTSPLIT
|
677
|
5944 col = ru_col - (Columns - W_WIDTH(wp));
|
|
5945 if (col < (W_WIDTH(wp) + 1) / 2)
|
|
5946 col = (W_WIDTH(wp) + 1) / 2;
|
7
|
5947 #else
|
677
|
5948 col = ru_col;
|
|
5949 if (col > (Columns + 1) / 2)
|
|
5950 col = (Columns + 1) / 2;
|
|
5951 #endif
|
|
5952 maxwidth = W_WIDTH(wp) - col;
|
7
|
5953 #ifdef FEAT_WINDOWS
|
677
|
5954 if (!wp->w_status_height)
|
|
5955 #endif
|
|
5956 {
|
|
5957 row = Rows - 1;
|
|
5958 --maxwidth; /* writing in last column may cause scrolling */
|
|
5959 fillchar = ' ';
|
|
5960 attr = 0;
|
|
5961 }
|
|
5962
|
|
5963 # ifdef FEAT_EVAL
|
681
|
5964 use_sandbox = was_set_insecurely((char_u *)"rulerformat", 0);
|
677
|
5965 # endif
|
|
5966 }
|
|
5967 else
|
|
5968 {
|
|
5969 if (*wp->w_p_stl != NUL)
|
|
5970 p = wp->w_p_stl;
|
|
5971 else
|
|
5972 p = p_stl;
|
|
5973 # ifdef FEAT_EVAL
|
681
|
5974 use_sandbox = was_set_insecurely((char_u *)"statusline",
|
|
5975 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
|
677
|
5976 # endif
|
|
5977 }
|
|
5978
|
|
5979 #ifdef FEAT_VERTSPLIT
|
|
5980 col += W_WINCOL(wp);
|
|
5981 #endif
|
|
5982 }
|
|
5983
|
7
|
5984 if (maxwidth <= 0)
|
|
5985 return;
|
677
|
5986
|
|
5987 width = build_stl_str_hl(wp == NULL ? curwin : wp,
|
|
5988 buf, sizeof(buf),
|
|
5989 p, use_sandbox,
|
681
|
5990 fillchar, maxwidth, hltab, tabtab);
|
835
|
5991 len = (int)STRLEN(buf);
|
7
|
5992
|
|
5993 while (width < maxwidth && len < sizeof(buf) - 1)
|
|
5994 {
|
|
5995 #ifdef FEAT_MBYTE
|
|
5996 len += (*mb_char2bytes)(fillchar, buf + len);
|
|
5997 #else
|
|
5998 buf[len++] = fillchar;
|
|
5999 #endif
|
|
6000 ++width;
|
|
6001 }
|
|
6002 buf[len] = NUL;
|
|
6003
|
681
|
6004 /*
|
|
6005 * Draw each snippet with the specified highlighting.
|
|
6006 */
|
7
|
6007 curattr = attr;
|
|
6008 p = buf;
|
681
|
6009 for (n = 0; hltab[n].start != NULL; n++)
|
|
6010 {
|
|
6011 len = (int)(hltab[n].start - p);
|
7
|
6012 screen_puts_len(p, len, row, col, curattr);
|
|
6013 col += vim_strnsize(p, len);
|
681
|
6014 p = hltab[n].start;
|
|
6015
|
|
6016 if (hltab[n].userhl == 0)
|
7
|
6017 curattr = attr;
|
681
|
6018 else if (hltab[n].userhl < 0)
|
|
6019 curattr = syn_id2attr(-hltab[n].userhl);
|
7
|
6020 #ifdef FEAT_WINDOWS
|
680
|
6021 else if (wp != NULL && wp != curwin && wp->w_status_height != 0)
|
681
|
6022 curattr = highlight_stlnc[hltab[n].userhl - 1];
|
7
|
6023 #endif
|
|
6024 else
|
681
|
6025 curattr = highlight_user[hltab[n].userhl - 1];
|
7
|
6026 }
|
|
6027 screen_puts(p, row, col, curattr);
|
681
|
6028
|
|
6029 if (wp == NULL)
|
|
6030 {
|
|
6031 /* Fill the TabPageIdxs[] array for clicking in the tab pagesline. */
|
|
6032 col = 0;
|
|
6033 len = 0;
|
|
6034 p = buf;
|
|
6035 fillchar = 0;
|
|
6036 for (n = 0; tabtab[n].start != NULL; n++)
|
|
6037 {
|
|
6038 len += vim_strnsize(p, (int)(tabtab[n].start - p));
|
|
6039 while (col < len)
|
|
6040 TabPageIdxs[col++] = fillchar;
|
|
6041 p = tabtab[n].start;
|
|
6042 fillchar = tabtab[n].userhl;
|
|
6043 }
|
|
6044 while (col < Columns)
|
|
6045 TabPageIdxs[col++] = fillchar;
|
|
6046 }
|
7
|
6047 }
|
|
6048
|
|
6049 #endif /* FEAT_STL_OPT */
|
|
6050
|
|
6051 /*
|
|
6052 * Output a single character directly to the screen and update ScreenLines.
|
|
6053 */
|
|
6054 void
|
|
6055 screen_putchar(c, row, col, attr)
|
|
6056 int c;
|
|
6057 int row, col;
|
|
6058 int attr;
|
|
6059 {
|
|
6060 #ifdef FEAT_MBYTE
|
|
6061 char_u buf[MB_MAXBYTES + 1];
|
|
6062
|
|
6063 buf[(*mb_char2bytes)(c, buf)] = NUL;
|
|
6064 #else
|
|
6065 char_u buf[2];
|
|
6066
|
|
6067 buf[0] = c;
|
|
6068 buf[1] = NUL;
|
|
6069 #endif
|
|
6070 screen_puts(buf, row, col, attr);
|
|
6071 }
|
|
6072
|
|
6073 /*
|
|
6074 * Get a single character directly from ScreenLines into "bytes[]".
|
|
6075 * Also return its attribute in *attrp;
|
|
6076 */
|
|
6077 void
|
|
6078 screen_getbytes(row, col, bytes, attrp)
|
|
6079 int row, col;
|
|
6080 char_u *bytes;
|
|
6081 int *attrp;
|
|
6082 {
|
|
6083 unsigned off;
|
|
6084
|
|
6085 /* safety check */
|
|
6086 if (ScreenLines != NULL && row < screen_Rows && col < screen_Columns)
|
|
6087 {
|
|
6088 off = LineOffset[row] + col;
|
|
6089 *attrp = ScreenAttrs[off];
|
|
6090 bytes[0] = ScreenLines[off];
|
|
6091 bytes[1] = NUL;
|
|
6092
|
|
6093 #ifdef FEAT_MBYTE
|
|
6094 if (enc_utf8 && ScreenLinesUC[off] != 0)
|
|
6095 bytes[utfc_char2bytes(off, bytes)] = NUL;
|
|
6096 else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
|
|
6097 {
|
|
6098 bytes[0] = ScreenLines[off];
|
|
6099 bytes[1] = ScreenLines2[off];
|
|
6100 bytes[2] = NUL;
|
|
6101 }
|
|
6102 else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1)
|
|
6103 {
|
|
6104 bytes[1] = ScreenLines[off + 1];
|
|
6105 bytes[2] = NUL;
|
|
6106 }
|
|
6107 #endif
|
|
6108 }
|
|
6109 }
|
|
6110
|
714
|
6111 #ifdef FEAT_MBYTE
|
|
6112 static int screen_comp_differs __ARGS((int, int*));
|
|
6113
|
|
6114 /*
|
|
6115 * Return TRUE if composing characters for screen posn "off" differs from
|
|
6116 * composing characters in "u8cc".
|
|
6117 */
|
|
6118 static int
|
|
6119 screen_comp_differs(off, u8cc)
|
|
6120 int off;
|
|
6121 int *u8cc;
|
|
6122 {
|
|
6123 int i;
|
|
6124
|
|
6125 for (i = 0; i < Screen_mco; ++i)
|
|
6126 {
|
|
6127 if (ScreenLinesC[i][off] != (u8char_T)u8cc[i])
|
|
6128 return TRUE;
|
|
6129 if (u8cc[i] == 0)
|
|
6130 break;
|
|
6131 }
|
|
6132 return FALSE;
|
|
6133 }
|
|
6134 #endif
|
|
6135
|
7
|
6136 /*
|
|
6137 * Put string '*text' on the screen at position 'row' and 'col', with
|
|
6138 * attributes 'attr', and update ScreenLines[] and ScreenAttrs[].
|
|
6139 * Note: only outputs within one row, message is truncated at screen boundary!
|
|
6140 * Note: if ScreenLines[], row and/or col is invalid, nothing is done.
|
|
6141 */
|
|
6142 void
|
|
6143 screen_puts(text, row, col, attr)
|
|
6144 char_u *text;
|
|
6145 int row;
|
|
6146 int col;
|
|
6147 int attr;
|
|
6148 {
|
|
6149 screen_puts_len(text, -1, row, col, attr);
|
|
6150 }
|
|
6151
|
|
6152 /*
|
|
6153 * Like screen_puts(), but output "text[len]". When "len" is -1 output up to
|
|
6154 * a NUL.
|
|
6155 */
|
|
6156 void
|
|
6157 screen_puts_len(text, len, row, col, attr)
|
|
6158 char_u *text;
|
|
6159 int len;
|
|
6160 int row;
|
|
6161 int col;
|
|
6162 int attr;
|
|
6163 {
|
|
6164 unsigned off;
|
|
6165 char_u *ptr = text;
|
|
6166 int c;
|
|
6167 #ifdef FEAT_MBYTE
|
|
6168 int mbyte_blen = 1;
|
|
6169 int mbyte_cells = 1;
|
|
6170 int u8c = 0;
|
714
|
6171 int u8cc[MAX_MCO];
|
7
|
6172 int clear_next_cell = FALSE;
|
|
6173 # ifdef FEAT_ARABIC
|
|
6174 int prev_c = 0; /* previous Arabic character */
|
714
|
6175 int pc, nc, nc1;
|
|
6176 int pcc[MAX_MCO];
|
7
|
6177 # endif
|
|
6178 #endif
|
|
6179
|
|
6180 if (ScreenLines == NULL || row >= screen_Rows) /* safety check */
|
|
6181 return;
|
|
6182
|
|
6183 off = LineOffset[row] + col;
|
|
6184 while (*ptr != NUL && col < screen_Columns
|
|
6185 && (len < 0 || (int)(ptr - text) < len))
|
|
6186 {
|
|
6187 c = *ptr;
|
|
6188 #ifdef FEAT_MBYTE
|
|
6189 /* check if this is the first byte of a multibyte */
|
|
6190 if (has_mbyte)
|
|
6191 {
|
|
6192 if (enc_utf8 && len > 0)
|
474
|
6193 mbyte_blen = utfc_ptr2len_len(ptr, (int)((text + len) - ptr));
|
7
|
6194 else
|
474
|
6195 mbyte_blen = (*mb_ptr2len)(ptr);
|
7
|
6196 if (enc_dbcs == DBCS_JPNU && c == 0x8e)
|
|
6197 mbyte_cells = 1;
|
|
6198 else if (enc_dbcs != 0)
|
|
6199 mbyte_cells = mbyte_blen;
|
|
6200 else /* enc_utf8 */
|
|
6201 {
|
|
6202 if (len >= 0)
|
714
|
6203 u8c = utfc_ptr2char_len(ptr, u8cc,
|
7
|
6204 (int)((text + len) - ptr));
|
|
6205 else
|
714
|
6206 u8c = utfc_ptr2char(ptr, u8cc);
|
7
|
6207 mbyte_cells = utf_char2cells(u8c);
|
|
6208 /* Non-BMP character: display as ? or fullwidth ?. */
|
|
6209 if (u8c >= 0x10000)
|
|
6210 {
|
|
6211 u8c = (mbyte_cells == 2) ? 0xff1f : (int)'?';
|
|
6212 if (attr == 0)
|
|
6213 attr = hl_attr(HLF_8);
|
|
6214 }
|
|
6215 # ifdef FEAT_ARABIC
|
|
6216 if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))
|
|
6217 {
|
|
6218 /* Do Arabic shaping. */
|
|
6219 if (len >= 0 && (int)(ptr - text) + mbyte_blen >= len)
|
|
6220 {
|
|
6221 /* Past end of string to be displayed. */
|
|
6222 nc = NUL;
|
|
6223 nc1 = NUL;
|
|
6224 }
|
|
6225 else
|
714
|
6226 {
|
|
6227 nc = utfc_ptr2char(ptr + mbyte_blen, pcc);
|
|
6228 nc1 = pcc[0];
|
|
6229 }
|
7
|
6230 pc = prev_c;
|
|
6231 prev_c = u8c;
|
714
|
6232 u8c = arabic_shape(u8c, &c, &u8cc[0], nc, nc1, pc);
|
7
|
6233 }
|
|
6234 else
|
|
6235 prev_c = u8c;
|
|
6236 # endif
|
|
6237 }
|
|
6238 }
|
|
6239 #endif
|
|
6240
|
|
6241 if (ScreenLines[off] != c
|
|
6242 #ifdef FEAT_MBYTE
|
|
6243 || (mbyte_cells == 2
|
|
6244 && ScreenLines[off + 1] != (enc_dbcs ? ptr[1] : 0))
|
|
6245 || (enc_dbcs == DBCS_JPNU
|
|
6246 && c == 0x8e
|
|
6247 && ScreenLines2[off] != ptr[1])
|
|
6248 || (enc_utf8
|
714
|
6249 && (ScreenLinesUC[off] != (u8char_T)u8c
|
|
6250 || screen_comp_differs(off, u8cc)))
|
7
|
6251 #endif
|
|
6252 || ScreenAttrs[off] != attr
|
|
6253 || exmode_active
|
|
6254 )
|
|
6255 {
|
|
6256 #if defined(FEAT_GUI) || defined(UNIX)
|
|
6257 /* The bold trick makes a single row of pixels appear in the next
|
|
6258 * character. When a bold character is removed, the next
|
|
6259 * character should be redrawn too. This happens for our own GUI
|
|
6260 * and for some xterms.
|
|
6261 * Force the redraw by setting the attribute to a different value
|
|
6262 * than "attr", the contents of ScreenLines[] may be needed by
|
|
6263 * mb_off2cells() further on.
|
|
6264 * Don't do this for the last drawn character, because the next
|
|
6265 * character may not be redrawn. */
|
|
6266 if (
|
|
6267 # ifdef FEAT_GUI
|
|
6268 gui.in_use
|
|
6269 # endif
|
|
6270 # if defined(FEAT_GUI) && defined(UNIX)
|
|
6271 ||
|
|
6272 # endif
|
|
6273 # ifdef UNIX
|
|
6274 term_is_xterm
|
|
6275 # endif
|
|
6276 )
|
|
6277 {
|
|
6278 int n;
|
|
6279
|
|
6280 n = ScreenAttrs[off];
|
|
6281 # ifdef FEAT_MBYTE
|
|
6282 if (col + mbyte_cells < screen_Columns
|
|
6283 && (n > HL_ALL || (n & HL_BOLD))
|
|
6284 && (len < 0 ? ptr[mbyte_blen] != NUL
|
|
6285 : ptr + mbyte_blen < text + len))
|
|
6286 ScreenAttrs[off + mbyte_cells] = attr + 1;
|
|
6287 # else
|
|
6288 if (col + 1 < screen_Columns
|
|
6289 && (n > HL_ALL || (n & HL_BOLD))
|
|
6290 && (len < 0 ? ptr[1] != NUL : ptr + 1 < text + len))
|
|
6291 ScreenLines[off + 1] = 0;
|
|
6292 # endif
|
|
6293 }
|
|
6294 #endif
|
|
6295 #ifdef FEAT_MBYTE
|
|
6296 /* When at the end of the text and overwriting a two-cell
|
|
6297 * character with a one-cell character, need to clear the next
|
|
6298 * cell. Also when overwriting the left halve of a two-cell char
|
|
6299 * with the right halve of a two-cell char. Do this only once
|
|
6300 * (mb_off2cells() may return 2 on the right halve). */
|
|
6301 if (clear_next_cell)
|
|
6302 clear_next_cell = FALSE;
|
|
6303 else if (has_mbyte
|
|
6304 && (len < 0 ? ptr[mbyte_blen] == NUL
|
|
6305 : ptr + mbyte_blen >= text + len)
|
|
6306 && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
|
|
6307 || (mbyte_cells == 2
|
|
6308 && (*mb_off2cells)(off) == 1
|
|
6309 && (*mb_off2cells)(off + 1) > 1)))
|
|
6310 clear_next_cell = TRUE;
|
|
6311
|
|
6312 /* Make sure we never leave a second byte of a double-byte behind,
|
|
6313 * it confuses mb_off2cells(). */
|
|
6314 if (enc_dbcs
|
|
6315 && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
|
|
6316 || (mbyte_cells == 2
|
|
6317 && (*mb_off2cells)(off) == 1
|
|
6318 && (*mb_off2cells)(off + 1) > 1)))
|
|
6319 ScreenLines[off + mbyte_blen] = 0;
|
|
6320 #endif
|
|
6321 ScreenLines[off] = c;
|
|
6322 ScreenAttrs[off] = attr;
|
|
6323 #ifdef FEAT_MBYTE
|
|
6324 if (enc_utf8)
|
|
6325 {
|
714
|
6326 if (c < 0x80 && u8cc[0] == 0)
|
7
|
6327 ScreenLinesUC[off] = 0;
|
|
6328 else
|
|
6329 {
|
714
|
6330 int i;
|
|
6331
|
7
|
6332 ScreenLinesUC[off] = u8c;
|
714
|
6333 for (i = 0; i < Screen_mco; ++i)
|
|
6334 {
|
|
6335 ScreenLinesC[i][off] = u8cc[i];
|
|
6336 if (u8cc[i] == 0)
|
|
6337 break;
|
|
6338 }
|
7
|
6339 }
|
|
6340 if (mbyte_cells == 2)
|
|
6341 {
|
|
6342 ScreenLines[off + 1] = 0;
|
|
6343 ScreenAttrs[off + 1] = attr;
|
|
6344 }
|
|
6345 screen_char(off, row, col);
|
|
6346 }
|
|
6347 else if (mbyte_cells == 2)
|
|
6348 {
|
|
6349 ScreenLines[off + 1] = ptr[1];
|
|
6350 ScreenAttrs[off + 1] = attr;
|
|
6351 screen_char_2(off, row, col);
|
|
6352 }
|
|
6353 else if (enc_dbcs == DBCS_JPNU && c == 0x8e)
|
|
6354 {
|
|
6355 ScreenLines2[off] = ptr[1];
|
|
6356 screen_char(off, row, col);
|
|
6357 }
|
|
6358 else
|
|
6359 #endif
|
|
6360 screen_char(off, row, col);
|
|
6361 }
|
|
6362 #ifdef FEAT_MBYTE
|
|
6363 if (has_mbyte)
|
|
6364 {
|
|
6365 off += mbyte_cells;
|
|
6366 col += mbyte_cells;
|
|
6367 ptr += mbyte_blen;
|
|
6368 if (clear_next_cell)
|
|
6369 ptr = (char_u *)" ";
|
|
6370 }
|
|
6371 else
|
|
6372 #endif
|
|
6373 {
|
|
6374 ++off;
|
|
6375 ++col;
|
|
6376 ++ptr;
|
|
6377 }
|
|
6378 }
|
|
6379 }
|
|
6380
|
|
6381 #ifdef FEAT_SEARCH_EXTRA
|
|
6382 /*
|
1326
|
6383 * Prepare for 'hlsearch' highlighting.
|
7
|
6384 */
|
|
6385 static void
|
|
6386 start_search_hl()
|
|
6387 {
|
|
6388 if (p_hls && !no_hlsearch)
|
|
6389 {
|
|
6390 last_pat_prog(&search_hl.rm);
|
|
6391 search_hl.attr = hl_attr(HLF_L);
|
|
6392 }
|
|
6393 }
|
|
6394
|
|
6395 /*
|
1326
|
6396 * Clean up for 'hlsearch' highlighting.
|
7
|
6397 */
|
|
6398 static void
|
|
6399 end_search_hl()
|
|
6400 {
|
|
6401 if (search_hl.rm.regprog != NULL)
|
|
6402 {
|
|
6403 vim_free(search_hl.rm.regprog);
|
|
6404 search_hl.rm.regprog = NULL;
|
|
6405 }
|
|
6406 }
|
|
6407
|
|
6408 /*
|
|
6409 * Advance to the match in window "wp" line "lnum" or past it.
|
|
6410 */
|
|
6411 static void
|
|
6412 prepare_search_hl(wp, lnum)
|
|
6413 win_T *wp;
|
|
6414 linenr_T lnum;
|
|
6415 {
|
1326
|
6416 matchitem_T *cur; /* points to the match list */
|
|
6417 match_T *shl; /* points to search_hl or a match */
|
|
6418 int shl_flag; /* flag to indicate whether search_hl
|
|
6419 has been processed or not */
|
7
|
6420 int n;
|
|
6421
|
|
6422 /*
|
|
6423 * When using a multi-line pattern, start searching at the top
|
|
6424 * of the window or just after a closed fold.
|
1326
|
6425 * Do this both for search_hl and the match list.
|
7
|
6426 */
|
1326
|
6427 cur = wp->w_match_head;
|
|
6428 shl_flag = FALSE;
|
|
6429 while (cur != NULL || shl_flag == FALSE)
|
|
6430 {
|
|
6431 if (shl_flag == FALSE)
|
|
6432 {
|
|
6433 shl = &search_hl;
|
|
6434 shl_flag = TRUE;
|
|
6435 }
|
|
6436 else
|
|
6437 shl = &cur->hl;
|
7
|
6438 if (shl->rm.regprog != NULL
|
|
6439 && shl->lnum == 0
|
|
6440 && re_multiline(shl->rm.regprog))
|
|
6441 {
|
|
6442 if (shl->first_lnum == 0)
|
|
6443 {
|
|
6444 # ifdef FEAT_FOLDING
|
|
6445 for (shl->first_lnum = lnum;
|
|
6446 shl->first_lnum > wp->w_topline; --shl->first_lnum)
|
|
6447 if (hasFoldingWin(wp, shl->first_lnum - 1,
|
|
6448 NULL, NULL, TRUE, NULL))
|
|
6449 break;
|
|
6450 # else
|
|
6451 shl->first_lnum = wp->w_topline;
|
|
6452 # endif
|
|
6453 }
|
|
6454 n = 0;
|
|
6455 while (shl->first_lnum < lnum && shl->rm.regprog != NULL)
|
|
6456 {
|
|
6457 next_search_hl(wp, shl, shl->first_lnum, (colnr_T)n);
|
|
6458 if (shl->lnum != 0)
|
|
6459 {
|
|
6460 shl->first_lnum = shl->lnum
|
|
6461 + shl->rm.endpos[0].lnum
|
|
6462 - shl->rm.startpos[0].lnum;
|
|
6463 n = shl->rm.endpos[0].col;
|
|
6464 }
|
|
6465 else
|
|
6466 {
|
|
6467 ++shl->first_lnum;
|
|
6468 n = 0;
|
|
6469 }
|
|
6470 }
|
|
6471 }
|
1326
|
6472 if (shl != &search_hl && cur != NULL)
|
|
6473 cur = cur->next;
|
7
|
6474 }
|
|
6475 }
|
|
6476
|
|
6477 /*
|
1326
|
6478 * Search for a next 'hlsearch' or match.
|
7
|
6479 * Uses shl->buf.
|
|
6480 * Sets shl->lnum and shl->rm contents.
|
|
6481 * Note: Assumes a previous match is always before "lnum", unless
|
|
6482 * shl->lnum is zero.
|
|
6483 * Careful: Any pointers for buffer lines will become invalid.
|
|
6484 */
|
|
6485 static void
|
|
6486 next_search_hl(win, shl, lnum, mincol)
|
|
6487 win_T *win;
|
1326
|
6488 match_T *shl; /* points to search_hl or a match */
|
7
|
6489 linenr_T lnum;
|
|
6490 colnr_T mincol; /* minimal column for a match */
|
|
6491 {
|
|
6492 linenr_T l;
|
|
6493 colnr_T matchcol;
|
|
6494 long nmatched;
|
|
6495
|
|
6496 if (shl->lnum != 0)
|
|
6497 {
|
|
6498 /* Check for three situations:
|
|
6499 * 1. If the "lnum" is below a previous match, start a new search.
|
|
6500 * 2. If the previous match includes "mincol", use it.
|
|
6501 * 3. Continue after the previous match.
|
|
6502 */
|
|
6503 l = shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
|
|
6504 if (lnum > l)
|
|
6505 shl->lnum = 0;
|
|
6506 else if (lnum < l || shl->rm.endpos[0].col > mincol)
|
|
6507 return;
|
|
6508 }
|
|
6509
|
|
6510 /*
|
|
6511 * Repeat searching for a match until one is found that includes "mincol"
|
|
6512 * or none is found in this line.
|
|
6513 */
|
|
6514 called_emsg = FALSE;
|
|
6515 for (;;)
|
|
6516 {
|
|
6517 /* Three situations:
|
|
6518 * 1. No useful previous match: search from start of line.
|
|
6519 * 2. Not Vi compatible or empty match: continue at next character.
|
|
6520 * Break the loop if this is beyond the end of the line.
|
|
6521 * 3. Vi compatible searching: continue at end of previous match.
|
|
6522 */
|
|
6523 if (shl->lnum == 0)
|
|
6524 matchcol = 0;
|
|
6525 else if (vim_strchr(p_cpo, CPO_SEARCH) == NULL
|
|
6526 || (shl->rm.endpos[0].lnum == 0
|
685
|
6527 && shl->rm.endpos[0].col <= shl->rm.startpos[0].col))
|
|
6528 {
|
688
|
6529 char_u *ml;
|
685
|
6530
|
|
6531 matchcol = shl->rm.startpos[0].col;
|
688
|
6532 ml = ml_get_buf(shl->buf, lnum, FALSE) + matchcol;
|
685
|
6533 if (*ml == NUL)
|
|
6534 {
|
|
6535 ++matchcol;
|
7
|
6536 shl->lnum = 0;
|
|
6537 break;
|
|
6538 }
|
685
|
6539 #ifdef FEAT_MBYTE
|
|
6540 if (has_mbyte)
|
|
6541 matchcol += mb_ptr2len(ml);
|
|
6542 else
|
|
6543 #endif
|
|
6544 ++matchcol;
|
7
|
6545 }
|
|
6546 else
|
|
6547 matchcol = shl->rm.endpos[0].col;
|
|
6548
|
|
6549 shl->lnum = lnum;
|
|
6550 nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum, matchcol);
|
|
6551 if (called_emsg)
|
|
6552 {
|
|
6553 /* Error while handling regexp: stop using this regexp. */
|
1112
|
6554 if (shl == &search_hl)
|
|
6555 {
|
1326
|
6556 /* don't free regprog in the match list, it's a copy */
|
1112
|
6557 vim_free(shl->rm.regprog);
|
|
6558 no_hlsearch = TRUE;
|
|
6559 }
|
7
|
6560 shl->rm.regprog = NULL;
|
1112
|
6561 shl->lnum = 0;
|
|
6562 got_int = FALSE; /* avoid the "Type :quit to exit Vim" message */
|
7
|
6563 break;
|
|
6564 }
|
|
6565 if (nmatched == 0)
|
|
6566 {
|
|
6567 shl->lnum = 0; /* no match found */
|
|
6568 break;
|
|
6569 }
|
|
6570 if (shl->rm.startpos[0].lnum > 0
|
|
6571 || shl->rm.startpos[0].col >= mincol
|
|
6572 || nmatched > 1
|
|
6573 || shl->rm.endpos[0].col > mincol)
|
|
6574 {
|
|
6575 shl->lnum += shl->rm.startpos[0].lnum;
|
|
6576 break; /* useful match found */
|
|
6577 }
|
|
6578 }
|
|
6579 }
|
|
6580 #endif
|
|
6581
|
|
6582 static void
|
|
6583 screen_start_highlight(attr)
|
|
6584 int attr;
|
|
6585 {
|
|
6586 attrentry_T *aep = NULL;
|
|
6587
|
|
6588 screen_attr = attr;
|
|
6589 if (full_screen
|
|
6590 #ifdef WIN3264
|
|
6591 && termcap_active
|
|
6592 #endif
|
|
6593 )
|
|
6594 {
|
|
6595 #ifdef FEAT_GUI
|
|
6596 if (gui.in_use)
|
|
6597 {
|
|
6598 char buf[20];
|
|
6599
|
681
|
6600 /* The GUI handles this internally. */
|
|
6601 sprintf(buf, IF_EB("\033|%dh", ESC_STR "|%dh"), attr);
|
7
|
6602 OUT_STR(buf);
|
|
6603 }
|
|
6604 else
|
|
6605 #endif
|
|
6606 {
|
|
6607 if (attr > HL_ALL) /* special HL attr. */
|
|
6608 {
|
|
6609 if (t_colors > 1)
|
|
6610 aep = syn_cterm_attr2entry(attr);
|
|
6611 else
|
|
6612 aep = syn_term_attr2entry(attr);
|
|
6613 if (aep == NULL) /* did ":syntax clear" */
|
|
6614 attr = 0;
|
|
6615 else
|
|
6616 attr = aep->ae_attr;
|
|
6617 }
|
|
6618 if ((attr & HL_BOLD) && T_MD != NULL) /* bold */
|
|
6619 out_str(T_MD);
|
681
|
6620 else if (aep != NULL && t_colors > 1 && aep->ae_u.cterm.fg_color
|
|
6621 && cterm_normal_fg_bold)
|
|
6622 /* If the Normal FG color has BOLD attribute and the new HL
|
|
6623 * has a FG color defined, clear BOLD. */
|
|
6624 out_str(T_ME);
|
7
|
6625 if ((attr & HL_STANDOUT) && T_SO != NULL) /* standout */
|
|
6626 out_str(T_SO);
|
205
|
6627 if ((attr & (HL_UNDERLINE | HL_UNDERCURL)) && T_US != NULL)
|
|
6628 /* underline or undercurl */
|
7
|
6629 out_str(T_US);
|
|
6630 if ((attr & HL_ITALIC) && T_CZH != NULL) /* italic */
|
|
6631 out_str(T_CZH);
|
|
6632 if ((attr & HL_INVERSE) && T_MR != NULL) /* inverse (reverse) */
|
|
6633 out_str(T_MR);
|
|
6634
|
|
6635 /*
|
|
6636 * Output the color or start string after bold etc., in case the
|
|
6637 * bold etc. override the color setting.
|
|
6638 */
|
|
6639 if (aep != NULL)
|
|
6640 {
|
|
6641 if (t_colors > 1)
|
|
6642 {
|
|
6643 if (aep->ae_u.cterm.fg_color)
|
|
6644 term_fg_color(aep->ae_u.cterm.fg_color - 1);
|
|
6645 if (aep->ae_u.cterm.bg_color)
|
|
6646 term_bg_color(aep->ae_u.cterm.bg_color - 1);
|
|
6647 }
|
|
6648 else
|
|
6649 {
|
|
6650 if (aep->ae_u.term.start != NULL)
|
|
6651 out_str(aep->ae_u.term.start);
|
|
6652 }
|
|
6653 }
|
|
6654 }
|
|
6655 }
|
|
6656 }
|
|
6657
|
|
6658 void
|
|
6659 screen_stop_highlight()
|
|
6660 {
|
|
6661 int do_ME = FALSE; /* output T_ME code */
|
|
6662
|
|
6663 if (screen_attr != 0
|
|
6664 #ifdef WIN3264
|
|
6665 && termcap_active
|
|
6666 #endif
|
|
6667 )
|
|
6668 {
|
|
6669 #ifdef FEAT_GUI
|
|
6670 if (gui.in_use)
|
|
6671 {
|
|
6672 char buf[20];
|
|
6673
|
|
6674 /* use internal GUI code */
|
|
6675 sprintf(buf, IF_EB("\033|%dH", ESC_STR "|%dH"), screen_attr);
|
|
6676 OUT_STR(buf);
|
|
6677 }
|
|
6678 else
|
|
6679 #endif
|
|
6680 {
|
|
6681 if (screen_attr > HL_ALL) /* special HL attr. */
|
|
6682 {
|
|
6683 attrentry_T *aep;
|
|
6684
|
|
6685 if (t_colors > 1)
|
|
6686 {
|
|
6687 /*
|
|
6688 * Assume that t_me restores the original colors!
|
|
6689 */
|
|
6690 aep = syn_cterm_attr2entry(screen_attr);
|
|
6691 if (aep != NULL && (aep->ae_u.cterm.fg_color
|
|
6692 || aep->ae_u.cterm.bg_color))
|
|
6693 do_ME = TRUE;
|
|
6694 }
|
|
6695 else
|
|
6696 {
|
|
6697 aep = syn_term_attr2entry(screen_attr);
|
|
6698 if (aep != NULL && aep->ae_u.term.stop != NULL)
|
|
6699 {
|
|
6700 if (STRCMP(aep->ae_u.term.stop, T_ME) == 0)
|
|
6701 do_ME = TRUE;
|
|
6702 else
|
|
6703 out_str(aep->ae_u.term.stop);
|
|
6704 }
|
|
6705 }
|
|
6706 if (aep == NULL) /* did ":syntax clear" */
|
|
6707 screen_attr = 0;
|
|
6708 else
|
|
6709 screen_attr = aep->ae_attr;
|
|
6710 }
|
|
6711
|
|
6712 /*
|
|
6713 * Often all ending-codes are equal to T_ME. Avoid outputting the
|
|
6714 * same sequence several times.
|
|
6715 */
|
|
6716 if (screen_attr & HL_STANDOUT)
|
|
6717 {
|
|
6718 if (STRCMP(T_SE, T_ME) == 0)
|
|
6719 do_ME = TRUE;
|
|
6720 else
|
|
6721 out_str(T_SE);
|
|
6722 }
|
205
|
6723 if (screen_attr & (HL_UNDERLINE | HL_UNDERCURL))
|
7
|
6724 {
|
|
6725 if (STRCMP(T_UE, T_ME) == 0)
|
|
6726 do_ME = TRUE;
|
|
6727 else
|
|
6728 out_str(T_UE);
|
|
6729 }
|
|
6730 if (screen_attr & HL_ITALIC)
|
|
6731 {
|
|
6732 if (STRCMP(T_CZR, T_ME) == 0)
|
|
6733 do_ME = TRUE;
|
|
6734 else
|
|
6735 out_str(T_CZR);
|
|
6736 }
|
|
6737 if (do_ME || (screen_attr & (HL_BOLD | HL_INVERSE)))
|
|
6738 out_str(T_ME);
|
|
6739
|
|
6740 if (t_colors > 1)
|
|
6741 {
|
|
6742 /* set Normal cterm colors */
|
|
6743 if (cterm_normal_fg_color != 0)
|
|
6744 term_fg_color(cterm_normal_fg_color - 1);
|
|
6745 if (cterm_normal_bg_color != 0)
|
|
6746 term_bg_color(cterm_normal_bg_color - 1);
|
|
6747 if (cterm_normal_fg_bold)
|
|
6748 out_str(T_MD);
|
|
6749 }
|
|
6750 }
|
|
6751 }
|
|
6752 screen_attr = 0;
|
|
6753 }
|
|
6754
|
|
6755 /*
|
|
6756 * Reset the colors for a cterm. Used when leaving Vim.
|
|
6757 * The machine specific code may override this again.
|
|
6758 */
|
|
6759 void
|
|
6760 reset_cterm_colors()
|
|
6761 {
|
|
6762 if (t_colors > 1)
|
|
6763 {
|
|
6764 /* set Normal cterm colors */
|
|
6765 if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0)
|
|
6766 {
|
|
6767 out_str(T_OP);
|
|
6768 screen_attr = -1;
|
|
6769 }
|
|
6770 if (cterm_normal_fg_bold)
|
|
6771 {
|
|
6772 out_str(T_ME);
|
|
6773 screen_attr = -1;
|
|
6774 }
|
|
6775 }
|
|
6776 }
|
|
6777
|
|
6778 /*
|
|
6779 * Put character ScreenLines["off"] on the screen at position "row" and "col",
|
|
6780 * using the attributes from ScreenAttrs["off"].
|
|
6781 */
|
|
6782 static void
|
|
6783 screen_char(off, row, col)
|
|
6784 unsigned off;
|
|
6785 int row;
|
|
6786 int col;
|
|
6787 {
|
|
6788 int attr;
|
|
6789
|
|
6790 /* Check for illegal values, just in case (could happen just after
|
|
6791 * resizing). */
|
|
6792 if (row >= screen_Rows || col >= screen_Columns)
|
|
6793 return;
|
|
6794
|
|
6795 /* Outputting the last character on the screen may scrollup the screen.
|
|
6796 * Don't to it! Mark the character invalid (update it when scrolled up) */
|
|
6797 if (row == screen_Rows - 1 && col == screen_Columns - 1
|
|
6798 #ifdef FEAT_RIGHTLEFT
|
|
6799 /* account for first command-line character in rightleft mode */
|
|
6800 && !cmdmsg_rl
|
|
6801 #endif
|
|
6802 )
|
|
6803 {
|
|
6804 ScreenAttrs[off] = (sattr_T)-1;
|
|
6805 return;
|
|
6806 }
|
|
6807
|
|
6808 /*
|
|
6809 * Stop highlighting first, so it's easier to move the cursor.
|
|
6810 */
|
|
6811 #if defined(FEAT_CLIPBOARD) || defined(FEAT_VERTSPLIT)
|
|
6812 if (screen_char_attr != 0)
|
|
6813 attr = screen_char_attr;
|
|
6814 else
|
|
6815 #endif
|
|
6816 attr = ScreenAttrs[off];
|
|
6817 if (screen_attr != attr)
|
|
6818 screen_stop_highlight();
|
|
6819
|
|
6820 windgoto(row, col);
|
|
6821
|
|
6822 if (screen_attr != attr)
|
|
6823 screen_start_highlight(attr);
|
|
6824
|
|
6825 #ifdef FEAT_MBYTE
|
|
6826 if (enc_utf8 && ScreenLinesUC[off] != 0)
|
|
6827 {
|
|
6828 char_u buf[MB_MAXBYTES + 1];
|
|
6829
|
|
6830 /* Convert UTF-8 character to bytes and write it. */
|
|
6831
|
|
6832 buf[utfc_char2bytes(off, buf)] = NUL;
|
|
6833
|
|
6834 out_str(buf);
|
|
6835 if (utf_char2cells(ScreenLinesUC[off]) > 1)
|
|
6836 ++screen_cur_col;
|
|
6837 }
|
|
6838 else
|
|
6839 #endif
|
|
6840 {
|
|
6841 #ifdef FEAT_MBYTE
|
|
6842 out_flush_check();
|
|
6843 #endif
|
|
6844 out_char(ScreenLines[off]);
|
|
6845 #ifdef FEAT_MBYTE
|
|
6846 /* double-byte character in single-width cell */
|
|
6847 if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
|
|
6848 out_char(ScreenLines2[off]);
|
|
6849 #endif
|
|
6850 }
|
|
6851
|
|
6852 screen_cur_col++;
|
|
6853 }
|
|
6854
|
|
6855 #ifdef FEAT_MBYTE
|
|
6856
|
|
6857 /*
|
|
6858 * Used for enc_dbcs only: Put one double-wide character at ScreenLines["off"]
|
|
6859 * on the screen at position 'row' and 'col'.
|
|
6860 * The attributes of the first byte is used for all. This is required to
|
|
6861 * output the two bytes of a double-byte character with nothing in between.
|
|
6862 */
|
|
6863 static void
|
|
6864 screen_char_2(off, row, col)
|
|
6865 unsigned off;
|
|
6866 int row;
|
|
6867 int col;
|
|
6868 {
|
|
6869 /* Check for illegal values (could be wrong when screen was resized). */
|
|
6870 if (off + 1 >= (unsigned)(screen_Rows * screen_Columns))
|
|
6871 return;
|
|
6872
|
|
6873 /* Outputting the last character on the screen may scrollup the screen.
|
|
6874 * Don't to it! Mark the character invalid (update it when scrolled up) */
|
|
6875 if (row == screen_Rows - 1 && col >= screen_Columns - 2)
|
|
6876 {
|
|
6877 ScreenAttrs[off] = (sattr_T)-1;
|
|
6878 return;
|
|
6879 }
|
|
6880
|
|
6881 /* Output the first byte normally (positions the cursor), then write the
|
|
6882 * second byte directly. */
|
|
6883 screen_char(off, row, col);
|
|
6884 out_char(ScreenLines[off + 1]);
|
|
6885 ++screen_cur_col;
|
|
6886 }
|
|
6887 #endif
|
|
6888
|
|
6889 #if defined(FEAT_CLIPBOARD) || defined(FEAT_VERTSPLIT) || defined(PROTO)
|
|
6890 /*
|
|
6891 * Draw a rectangle of the screen, inverted when "invert" is TRUE.
|
|
6892 * This uses the contents of ScreenLines[] and doesn't change it.
|
|
6893 */
|
|
6894 void
|
|
6895 screen_draw_rectangle(row, col, height, width, invert)
|
|
6896 int row;
|
|
6897 int col;
|
|
6898 int height;
|
|
6899 int width;
|
|
6900 int invert;
|
|
6901 {
|
|
6902 int r, c;
|
|
6903 int off;
|
|
6904
|
534
|
6905 /* Can't use ScreenLines unless initialized */
|
|
6906 if (ScreenLines == NULL)
|
|
6907 return;
|
|
6908
|
7
|
6909 if (invert)
|
|
6910 screen_char_attr = HL_INVERSE;
|
|
6911 for (r = row; r < row + height; ++r)
|
|
6912 {
|
|
6913 off = LineOffset[r];
|
|
6914 for (c = col; c < col + width; ++c)
|
|
6915 {
|
|
6916 #ifdef FEAT_MBYTE
|
|
6917 if (enc_dbcs != 0 && dbcs_off2cells(off + c) > 1)
|
|
6918 {
|
|
6919 screen_char_2(off + c, r, c);
|
|
6920 ++c;
|
|
6921 }
|
|
6922 else
|
|
6923 #endif
|
|
6924 {
|
|
6925 screen_char(off + c, r, c);
|
|
6926 #ifdef FEAT_MBYTE
|
|
6927 if (utf_off2cells(off + c) > 1)
|
|
6928 ++c;
|
|
6929 #endif
|
|
6930 }
|
|
6931 }
|
|
6932 }
|
|
6933 screen_char_attr = 0;
|
|
6934 }
|
|
6935 #endif
|
|
6936
|
|
6937 #ifdef FEAT_VERTSPLIT
|
|
6938 /*
|
|
6939 * Redraw the characters for a vertically split window.
|
|
6940 */
|
|
6941 static void
|
|
6942 redraw_block(row, end, wp)
|
|
6943 int row;
|
|
6944 int end;
|
|
6945 win_T *wp;
|
|
6946 {
|
|
6947 int col;
|
|
6948 int width;
|
|
6949
|
|
6950 # ifdef FEAT_CLIPBOARD
|
|
6951 clip_may_clear_selection(row, end - 1);
|
|
6952 # endif
|
|
6953
|
|
6954 if (wp == NULL)
|
|
6955 {
|
|
6956 col = 0;
|
|
6957 width = Columns;
|
|
6958 }
|
|
6959 else
|
|
6960 {
|
|
6961 col = wp->w_wincol;
|
|
6962 width = wp->w_width;
|
|
6963 }
|
|
6964 screen_draw_rectangle(row, col, end - row, width, FALSE);
|
|
6965 }
|
|
6966 #endif
|
|
6967
|
|
6968 /*
|
|
6969 * Fill the screen from 'start_row' to 'end_row', from 'start_col' to 'end_col'
|
|
6970 * with character 'c1' in first column followed by 'c2' in the other columns.
|
|
6971 * Use attributes 'attr'.
|
|
6972 */
|
|
6973 void
|
|
6974 screen_fill(start_row, end_row, start_col, end_col, c1, c2, attr)
|
|
6975 int start_row, end_row;
|
|
6976 int start_col, end_col;
|
|
6977 int c1, c2;
|
|
6978 int attr;
|
|
6979 {
|
|
6980 int row;
|
|
6981 int col;
|
|
6982 int off;
|
|
6983 int end_off;
|
|
6984 int did_delete;
|
|
6985 int c;
|
|
6986 int norm_term;
|
|
6987 #if defined(FEAT_GUI) || defined(UNIX)
|
|
6988 int force_next = FALSE;
|
|
6989 #endif
|
|
6990
|
|
6991 if (end_row > screen_Rows) /* safety check */
|
|
6992 end_row = screen_Rows;
|
|
6993 if (end_col > screen_Columns) /* safety check */
|
|
6994 end_col = screen_Columns;
|
|
6995 if (ScreenLines == NULL
|
|
6996 || start_row >= end_row
|
|
6997 || start_col >= end_col) /* nothing to do */
|
|
6998 return;
|
|
6999
|
|
7000 /* it's a "normal" terminal when not in a GUI or cterm */
|
|
7001 norm_term = (
|
|
7002 #ifdef FEAT_GUI
|
|
7003 !gui.in_use &&
|
|
7004 #endif
|
|
7005 t_colors <= 1);
|
|
7006 for (row = start_row; row < end_row; ++row)
|
|
7007 {
|
|
7008 /*
|
|
7009 * Try to use delete-line termcap code, when no attributes or in a
|
|
7010 * "normal" terminal, where a bold/italic space is just a
|
|
7011 * space.
|
|
7012 */
|
|
7013 did_delete = FALSE;
|
|
7014 if (c2 == ' '
|
|
7015 && end_col == Columns
|
|
7016 && can_clear(T_CE)
|
|
7017 && (attr == 0
|
|
7018 || (norm_term
|
|
7019 && attr <= HL_ALL
|
|
7020 && ((attr & ~(HL_BOLD | HL_ITALIC)) == 0))))
|
|
7021 {
|
|
7022 /*
|
|
7023 * check if we really need to clear something
|
|
7024 */
|
|
7025 col = start_col;
|
|
7026 if (c1 != ' ') /* don't clear first char */
|
|
7027 ++col;
|
|
7028
|
|
7029 off = LineOffset[row] + col;
|
|
7030 end_off = LineOffset[row] + end_col;
|
|
7031
|
|
7032 /* skip blanks (used often, keep it fast!) */
|
|
7033 #ifdef FEAT_MBYTE
|
|
7034 if (enc_utf8)
|
|
7035 while (off < end_off && ScreenLines[off] == ' '
|
|
7036 && ScreenAttrs[off] == 0 && ScreenLinesUC[off] == 0)
|
|
7037 ++off;
|
|
7038 else
|
|
7039 #endif
|
|
7040 while (off < end_off && ScreenLines[off] == ' '
|
|
7041 && ScreenAttrs[off] == 0)
|
|
7042 ++off;
|
|
7043 if (off < end_off) /* something to be cleared */
|
|
7044 {
|
|
7045 col = off - LineOffset[row];
|
|
7046 screen_stop_highlight();
|
|
7047 term_windgoto(row, col);/* clear rest of this screen line */
|
|
7048 out_str(T_CE);
|
|
7049 screen_start(); /* don't know where cursor is now */
|
|
7050 col = end_col - col;
|
|
7051 while (col--) /* clear chars in ScreenLines */
|
|
7052 {
|
|
7053 ScreenLines[off] = ' ';
|
|
7054 #ifdef FEAT_MBYTE
|
|
7055 if (enc_utf8)
|
|
7056 ScreenLinesUC[off] = 0;
|
|
7057 #endif
|
|
7058 ScreenAttrs[off] = 0;
|
|
7059 ++off;
|
|
7060 }
|
|
7061 }
|
|
7062 did_delete = TRUE; /* the chars are cleared now */
|
|
7063 }
|
|
7064
|
|
7065 off = LineOffset[row] + start_col;
|
|
7066 c = c1;
|
|
7067 for (col = start_col; col < end_col; ++col)
|
|
7068 {
|
|
7069 if (ScreenLines[off] != c
|
|
7070 #ifdef FEAT_MBYTE
|
714
|
7071 || (enc_utf8 && (int)ScreenLinesUC[off]
|
|
7072 != (c >= 0x80 ? c : 0))
|
7
|
7073 #endif
|
|
7074 || ScreenAttrs[off] != attr
|
|
7075 #if defined(FEAT_GUI) || defined(UNIX)
|
|
7076 || force_next
|
|
7077 #endif
|
|
7078 )
|
|
7079 {
|
|
7080 #if defined(FEAT_GUI) || defined(UNIX)
|
|
7081 /* The bold trick may make a single row of pixels appear in
|
|
7082 * the next character. When a bold character is removed, the
|
|
7083 * next character should be redrawn too. This happens for our
|
|
7084 * own GUI and for some xterms. */
|
|
7085 if (
|
|
7086 # ifdef FEAT_GUI
|
|
7087 gui.in_use
|
|
7088 # endif
|
|
7089 # if defined(FEAT_GUI) && defined(UNIX)
|
|
7090 ||
|
|
7091 # endif
|
|
7092 # ifdef UNIX
|
|
7093 term_is_xterm
|
|
7094 # endif
|
|
7095 )
|
|
7096 {
|
|
7097 if (ScreenLines[off] != ' '
|
|
7098 && (ScreenAttrs[off] > HL_ALL
|
|
7099 || ScreenAttrs[off] & HL_BOLD))
|
|
7100 force_next = TRUE;
|
|
7101 else
|
|
7102 force_next = FALSE;
|
|
7103 }
|
|
7104 #endif
|
|
7105 ScreenLines[off] = c;
|
|
7106 #ifdef FEAT_MBYTE
|
|
7107 if (enc_utf8)
|
|
7108 {
|
|
7109 if (c >= 0x80)
|
|
7110 {
|
|
7111 ScreenLinesUC[off] = c;
|
714
|
7112 ScreenLinesC[0][off] = 0;
|
7
|
7113 }
|
|
7114 else
|
|
7115 ScreenLinesUC[off] = 0;
|
|
7116 }
|
|
7117 #endif
|
|
7118 ScreenAttrs[off] = attr;
|
|
7119 if (!did_delete || c != ' ')
|
|
7120 screen_char(off, row, col);
|
|
7121 }
|
|
7122 ++off;
|
|
7123 if (col == start_col)
|
|
7124 {
|
|
7125 if (did_delete)
|
|
7126 break;
|
|
7127 c = c2;
|
|
7128 }
|
|
7129 }
|
|
7130 if (end_col == Columns)
|
|
7131 LineWraps[row] = FALSE;
|
|
7132 if (row == Rows - 1) /* overwritten the command line */
|
|
7133 {
|
|
7134 redraw_cmdline = TRUE;
|
|
7135 if (c1 == ' ' && c2 == ' ')
|
|
7136 clear_cmdline = FALSE; /* command line has been cleared */
|
644
|
7137 if (start_col == 0)
|
|
7138 mode_displayed = FALSE; /* mode cleared or overwritten */
|
7
|
7139 }
|
|
7140 }
|
|
7141 }
|
|
7142
|
|
7143 /*
|
|
7144 * Check if there should be a delay. Used before clearing or redrawing the
|
|
7145 * screen or the command line.
|
|
7146 */
|
|
7147 void
|
|
7148 check_for_delay(check_msg_scroll)
|
|
7149 int check_msg_scroll;
|
|
7150 {
|
|
7151 if ((emsg_on_display || (check_msg_scroll && msg_scroll))
|
|
7152 && !did_wait_return
|
|
7153 && emsg_silent == 0)
|
|
7154 {
|
|
7155 out_flush();
|
|
7156 ui_delay(1000L, TRUE);
|
|
7157 emsg_on_display = FALSE;
|
|
7158 if (check_msg_scroll)
|
|
7159 msg_scroll = FALSE;
|
|
7160 }
|
|
7161 }
|
|
7162
|
|
7163 /*
|
|
7164 * screen_valid - allocate screen buffers if size changed
|
|
7165 * If "clear" is TRUE: clear screen if it has been resized.
|
|
7166 * Returns TRUE if there is a valid screen to write to.
|
|
7167 * Returns FALSE when starting up and screen not initialized yet.
|
|
7168 */
|
|
7169 int
|
|
7170 screen_valid(clear)
|
|
7171 int clear;
|
|
7172 {
|
|
7173 screenalloc(clear); /* allocate screen buffers if size changed */
|
|
7174 return (ScreenLines != NULL);
|
|
7175 }
|
|
7176
|
|
7177 /*
|
|
7178 * Resize the shell to Rows and Columns.
|
|
7179 * Allocate ScreenLines[] and associated items.
|
|
7180 *
|
|
7181 * There may be some time between setting Rows and Columns and (re)allocating
|
|
7182 * ScreenLines[]. This happens when starting up and when (manually) changing
|
|
7183 * the shell size. Always use screen_Rows and screen_Columns to access items
|
|
7184 * in ScreenLines[]. Use Rows and Columns for positioning text etc. where the
|
|
7185 * final size of the shell is needed.
|
|
7186 */
|
|
7187 void
|
|
7188 screenalloc(clear)
|
|
7189 int clear;
|
|
7190 {
|
|
7191 int new_row, old_row;
|
|
7192 #ifdef FEAT_GUI
|
|
7193 int old_Rows;
|
|
7194 #endif
|
|
7195 win_T *wp;
|
|
7196 int outofmem = FALSE;
|
|
7197 int len;
|
|
7198 schar_T *new_ScreenLines;
|
|
7199 #ifdef FEAT_MBYTE
|
|
7200 u8char_T *new_ScreenLinesUC = NULL;
|
714
|
7201 u8char_T *new_ScreenLinesC[MAX_MCO];
|
7
|
7202 schar_T *new_ScreenLines2 = NULL;
|
714
|
7203 int i;
|
7
|
7204 #endif
|
|
7205 sattr_T *new_ScreenAttrs;
|
|
7206 unsigned *new_LineOffset;
|
|
7207 char_u *new_LineWraps;
|
671
|
7208 #ifdef FEAT_WINDOWS
|
681
|
7209 short *new_TabPageIdxs;
|
671
|
7210 tabpage_T *tp;
|
|
7211 #endif
|
7
|
7212 static int entered = FALSE; /* avoid recursiveness */
|
944
|
7213 static int done_outofmem_msg = FALSE; /* did outofmem message */
|
7
|
7214
|
|
7215 /*
|
|
7216 * Allocation of the screen buffers is done only when the size changes and
|
|
7217 * when Rows and Columns have been set and we have started doing full
|
|
7218 * screen stuff.
|
|
7219 */
|
|
7220 if ((ScreenLines != NULL
|
|
7221 && Rows == screen_Rows
|
|
7222 && Columns == screen_Columns
|
|
7223 #ifdef FEAT_MBYTE
|
|
7224 && enc_utf8 == (ScreenLinesUC != NULL)
|
|
7225 && (enc_dbcs == DBCS_JPNU) == (ScreenLines2 != NULL)
|
714
|
7226 && p_mco == Screen_mco
|
7
|
7227 #endif
|
|
7228 )
|
|
7229 || Rows == 0
|
|
7230 || Columns == 0
|
|
7231 || (!full_screen && ScreenLines == NULL))
|
|
7232 return;
|
|
7233
|
|
7234 /*
|
|
7235 * It's possible that we produce an out-of-memory message below, which
|
|
7236 * will cause this function to be called again. To break the loop, just
|
|
7237 * return here.
|
|
7238 */
|
|
7239 if (entered)
|
|
7240 return;
|
|
7241 entered = TRUE;
|
|
7242
|
911
|
7243 /*
|
|
7244 * Note that the window sizes are updated before reallocating the arrays,
|
|
7245 * thus we must not redraw here!
|
|
7246 */
|
|
7247 ++RedrawingDisabled;
|
|
7248
|
7
|
7249 win_new_shellsize(); /* fit the windows in the new sized shell */
|
|
7250
|
|
7251 comp_col(); /* recompute columns for shown command and ruler */
|
|
7252
|
|
7253 /*
|
|
7254 * We're changing the size of the screen.
|
|
7255 * - Allocate new arrays for ScreenLines and ScreenAttrs.
|
|
7256 * - Move lines from the old arrays into the new arrays, clear extra
|
|
7257 * lines (unless the screen is going to be cleared).
|
|
7258 * - Free the old arrays.
|
|
7259 *
|
|
7260 * If anything fails, make ScreenLines NULL, so we don't do anything!
|
|
7261 * Continuing with the old ScreenLines may result in a crash, because the
|
|
7262 * size is wrong.
|
|
7263 */
|
671
|
7264 FOR_ALL_TAB_WINDOWS(tp, wp)
|
7
|
7265 win_free_lsize(wp);
|
|
7266
|
|
7267 new_ScreenLines = (schar_T *)lalloc((long_u)(
|
|
7268 (Rows + 1) * Columns * sizeof(schar_T)), FALSE);
|
|
7269 #ifdef FEAT_MBYTE
|
714
|
7270 vim_memset(new_ScreenLinesC, 0, sizeof(u8char_T) * MAX_MCO);
|
7
|
7271 if (enc_utf8)
|
|
7272 {
|
|
7273 new_ScreenLinesUC = (u8char_T *)lalloc((long_u)(
|
|
7274 (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
|
714
|
7275 for (i = 0; i < p_mco; ++i)
|
|
7276 new_ScreenLinesC[i] = (u8char_T *)lalloc((long_u)(
|
7
|
7277 (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
|
|
7278 }
|
|
7279 if (enc_dbcs == DBCS_JPNU)
|
|
7280 new_ScreenLines2 = (schar_T *)lalloc((long_u)(
|
|
7281 (Rows + 1) * Columns * sizeof(schar_T)), FALSE);
|
|
7282 #endif
|
|
7283 new_ScreenAttrs = (sattr_T *)lalloc((long_u)(
|
|
7284 (Rows + 1) * Columns * sizeof(sattr_T)), FALSE);
|
|
7285 new_LineOffset = (unsigned *)lalloc((long_u)(
|
|
7286 Rows * sizeof(unsigned)), FALSE);
|
|
7287 new_LineWraps = (char_u *)lalloc((long_u)(Rows * sizeof(char_u)), FALSE);
|
671
|
7288 #ifdef FEAT_WINDOWS
|
681
|
7289 new_TabPageIdxs = (short *)lalloc((long_u)(Columns * sizeof(short)), FALSE);
|
671
|
7290 #endif
|
7
|
7291
|
677
|
7292 FOR_ALL_TAB_WINDOWS(tp, wp)
|
7
|
7293 {
|
|
7294 if (win_alloc_lines(wp) == FAIL)
|
|
7295 {
|
|
7296 outofmem = TRUE;
|
|
7297 #ifdef FEAT_WINDOWS
|
|
7298 break;
|
|
7299 #endif
|
|
7300 }
|
|
7301 }
|
|
7302
|
714
|
7303 #ifdef FEAT_MBYTE
|
|
7304 for (i = 0; i < p_mco; ++i)
|
|
7305 if (new_ScreenLinesC[i] == NULL)
|
|
7306 break;
|
|
7307 #endif
|
7
|
7308 if (new_ScreenLines == NULL
|
|
7309 #ifdef FEAT_MBYTE
|
714
|
7310 || (enc_utf8 && (new_ScreenLinesUC == NULL || i != p_mco))
|
7
|
7311 || (enc_dbcs == DBCS_JPNU && new_ScreenLines2 == NULL)
|
|
7312 #endif
|
|
7313 || new_ScreenAttrs == NULL
|
|
7314 || new_LineOffset == NULL
|
|
7315 || new_LineWraps == NULL
|
671
|
7316 #ifdef FEAT_WINDOWS
|
|
7317 || new_TabPageIdxs == NULL
|
|
7318 #endif
|
7
|
7319 || outofmem)
|
|
7320 {
|
944
|
7321 if (ScreenLines != NULL || !done_outofmem_msg)
|
534
|
7322 {
|
|
7323 /* guess the size */
|
|
7324 do_outofmem_msg((long_u)((Rows + 1) * Columns));
|
|
7325
|
|
7326 /* Remember we did this to avoid getting outofmem messages over
|
|
7327 * and over again. */
|
944
|
7328 done_outofmem_msg = TRUE;
|
534
|
7329 }
|
7
|
7330 vim_free(new_ScreenLines);
|
|
7331 new_ScreenLines = NULL;
|
|
7332 #ifdef FEAT_MBYTE
|
|
7333 vim_free(new_ScreenLinesUC);
|
|
7334 new_ScreenLinesUC = NULL;
|
714
|
7335 for (i = 0; i < p_mco; ++i)
|
|
7336 {
|
|
7337 vim_free(new_ScreenLinesC[i]);
|
|
7338 new_ScreenLinesC[i] = NULL;
|
|
7339 }
|
7
|
7340 vim_free(new_ScreenLines2);
|
|
7341 new_ScreenLines2 = NULL;
|
|
7342 #endif
|
|
7343 vim_free(new_ScreenAttrs);
|
|
7344 new_ScreenAttrs = NULL;
|
|
7345 vim_free(new_LineOffset);
|
|
7346 new_LineOffset = NULL;
|
|
7347 vim_free(new_LineWraps);
|
|
7348 new_LineWraps = NULL;
|
671
|
7349 #ifdef FEAT_WINDOWS
|
|
7350 vim_free(new_TabPageIdxs);
|
|
7351 new_TabPageIdxs = NULL;
|
|
7352 #endif
|
7
|
7353 }
|
|
7354 else
|
|
7355 {
|
944
|
7356 done_outofmem_msg = FALSE;
|
534
|
7357
|
7
|
7358 for (new_row = 0; new_row < Rows; ++new_row)
|
|
7359 {
|
|
7360 new_LineOffset[new_row] = new_row * Columns;
|
|
7361 new_LineWraps[new_row] = FALSE;
|
|
7362
|
|
7363 /*
|
|
7364 * If the screen is not going to be cleared, copy as much as
|
|
7365 * possible from the old screen to the new one and clear the rest
|
|
7366 * (used when resizing the window at the "--more--" prompt or when
|
|
7367 * executing an external command, for the GUI).
|
|
7368 */
|
|
7369 if (!clear)
|
|
7370 {
|
|
7371 (void)vim_memset(new_ScreenLines + new_row * Columns,
|
|
7372 ' ', (size_t)Columns * sizeof(schar_T));
|
|
7373 #ifdef FEAT_MBYTE
|
|
7374 if (enc_utf8)
|
|
7375 {
|
|
7376 (void)vim_memset(new_ScreenLinesUC + new_row * Columns,
|
|
7377 0, (size_t)Columns * sizeof(u8char_T));
|
714
|
7378 for (i = 0; i < p_mco; ++i)
|
|
7379 (void)vim_memset(new_ScreenLinesC[i]
|
|
7380 + new_row * Columns,
|
7
|
7381 0, (size_t)Columns * sizeof(u8char_T));
|
|
7382 }
|
|
7383 if (enc_dbcs == DBCS_JPNU)
|
|
7384 (void)vim_memset(new_ScreenLines2 + new_row * Columns,
|
|
7385 0, (size_t)Columns * sizeof(schar_T));
|
|
7386 #endif
|
|
7387 (void)vim_memset(new_ScreenAttrs + new_row * Columns,
|
|
7388 0, (size_t)Columns * sizeof(sattr_T));
|
|
7389 old_row = new_row + (screen_Rows - Rows);
|
534
|
7390 if (old_row >= 0 && ScreenLines != NULL)
|
7
|
7391 {
|
|
7392 if (screen_Columns < Columns)
|
|
7393 len = screen_Columns;
|
|
7394 else
|
|
7395 len = Columns;
|
26
|
7396 #ifdef FEAT_MBYTE
|
571
|
7397 /* When switching to utf-8 don't copy characters, they
|
714
|
7398 * may be invalid now. Also when p_mco changes. */
|
|
7399 if (!(enc_utf8 && ScreenLinesUC == NULL)
|
|
7400 && p_mco == Screen_mco)
|
26
|
7401 #endif
|
|
7402 mch_memmove(new_ScreenLines + new_LineOffset[new_row],
|
|
7403 ScreenLines + LineOffset[old_row],
|
|
7404 (size_t)len * sizeof(schar_T));
|
7
|
7405 #ifdef FEAT_MBYTE
|
714
|
7406 if (enc_utf8 && ScreenLinesUC != NULL
|
|
7407 && p_mco == Screen_mco)
|
7
|
7408 {
|
|
7409 mch_memmove(new_ScreenLinesUC + new_LineOffset[new_row],
|
|
7410 ScreenLinesUC + LineOffset[old_row],
|
|
7411 (size_t)len * sizeof(u8char_T));
|
714
|
7412 for (i = 0; i < p_mco; ++i)
|
|
7413 mch_memmove(new_ScreenLinesC[i]
|
|
7414 + new_LineOffset[new_row],
|
|
7415 ScreenLinesC[i] + LineOffset[old_row],
|
7
|
7416 (size_t)len * sizeof(u8char_T));
|
|
7417 }
|
|
7418 if (enc_dbcs == DBCS_JPNU && ScreenLines2 != NULL)
|
|
7419 mch_memmove(new_ScreenLines2 + new_LineOffset[new_row],
|
|
7420 ScreenLines2 + LineOffset[old_row],
|
|
7421 (size_t)len * sizeof(schar_T));
|
|
7422 #endif
|
|
7423 mch_memmove(new_ScreenAttrs + new_LineOffset[new_row],
|
|
7424 ScreenAttrs + LineOffset[old_row],
|
|
7425 (size_t)len * sizeof(sattr_T));
|
|
7426 }
|
|
7427 }
|
|
7428 }
|
|
7429 /* Use the last line of the screen for the current line. */
|
|
7430 current_ScreenLine = new_ScreenLines + Rows * Columns;
|
|
7431 }
|
|
7432
|
356
|
7433 free_screenlines();
|
|
7434
|
7
|
7435 ScreenLines = new_ScreenLines;
|
|
7436 #ifdef FEAT_MBYTE
|
|
7437 ScreenLinesUC = new_ScreenLinesUC;
|
714
|
7438 for (i = 0; i < p_mco; ++i)
|
|
7439 ScreenLinesC[i] = new_ScreenLinesC[i];
|
|
7440 Screen_mco = p_mco;
|
7
|
7441 ScreenLines2 = new_ScreenLines2;
|
|
7442 #endif
|
|
7443 ScreenAttrs = new_ScreenAttrs;
|
|
7444 LineOffset = new_LineOffset;
|
|
7445 LineWraps = new_LineWraps;
|
671
|
7446 #ifdef FEAT_WINDOWS
|
|
7447 TabPageIdxs = new_TabPageIdxs;
|
|
7448 #endif
|
7
|
7449
|
|
7450 /* It's important that screen_Rows and screen_Columns reflect the actual
|
|
7451 * size of ScreenLines[]. Set them before calling anything. */
|
|
7452 #ifdef FEAT_GUI
|
|
7453 old_Rows = screen_Rows;
|
|
7454 #endif
|
|
7455 screen_Rows = Rows;
|
|
7456 screen_Columns = Columns;
|
|
7457
|
|
7458 must_redraw = CLEAR; /* need to clear the screen later */
|
|
7459 if (clear)
|
|
7460 screenclear2();
|
|
7461
|
|
7462 #ifdef FEAT_GUI
|
|
7463 else if (gui.in_use
|
|
7464 && !gui.starting
|
|
7465 && ScreenLines != NULL
|
|
7466 && old_Rows != Rows)
|
|
7467 {
|
|
7468 (void)gui_redraw_block(0, 0, (int)Rows - 1, (int)Columns - 1, 0);
|
|
7469 /*
|
|
7470 * Adjust the position of the cursor, for when executing an external
|
|
7471 * command.
|
|
7472 */
|
|
7473 if (msg_row >= Rows) /* Rows got smaller */
|
|
7474 msg_row = Rows - 1; /* put cursor at last row */
|
|
7475 else if (Rows > old_Rows) /* Rows got bigger */
|
|
7476 msg_row += Rows - old_Rows; /* put cursor in same place */
|
|
7477 if (msg_col >= Columns) /* Columns got smaller */
|
|
7478 msg_col = Columns - 1; /* put cursor at last column */
|
|
7479 }
|
|
7480 #endif
|
|
7481
|
|
7482 entered = FALSE;
|
911
|
7483 --RedrawingDisabled;
|
766
|
7484
|
|
7485 #ifdef FEAT_AUTOCMD
|
|
7486 if (starting == 0)
|
|
7487 apply_autocmds(EVENT_VIMRESIZED, NULL, NULL, FALSE, curbuf);
|
|
7488 #endif
|
7
|
7489 }
|
|
7490
|
|
7491 void
|
356
|
7492 free_screenlines()
|
|
7493 {
|
|
7494 #ifdef FEAT_MBYTE
|
714
|
7495 int i;
|
|
7496
|
356
|
7497 vim_free(ScreenLinesUC);
|
714
|
7498 for (i = 0; i < Screen_mco; ++i)
|
|
7499 vim_free(ScreenLinesC[i]);
|
356
|
7500 vim_free(ScreenLines2);
|
|
7501 #endif
|
714
|
7502 vim_free(ScreenLines);
|
356
|
7503 vim_free(ScreenAttrs);
|
|
7504 vim_free(LineOffset);
|
|
7505 vim_free(LineWraps);
|
671
|
7506 #ifdef FEAT_WINDOWS
|
|
7507 vim_free(TabPageIdxs);
|
|
7508 #endif
|
356
|
7509 }
|
|
7510
|
|
7511 void
|
7
|
7512 screenclear()
|
|
7513 {
|
|
7514 check_for_delay(FALSE);
|
|
7515 screenalloc(FALSE); /* allocate screen buffers if size changed */
|
|
7516 screenclear2(); /* clear the screen */
|
|
7517 }
|
|
7518
|
|
7519 static void
|
|
7520 screenclear2()
|
|
7521 {
|
|
7522 int i;
|
|
7523
|
|
7524 if (starting == NO_SCREEN || ScreenLines == NULL
|
|
7525 #ifdef FEAT_GUI
|
|
7526 || (gui.in_use && gui.starting)
|
|
7527 #endif
|
|
7528 )
|
|
7529 return;
|
|
7530
|
|
7531 #ifdef FEAT_GUI
|
|
7532 if (!gui.in_use)
|
|
7533 #endif
|
|
7534 screen_attr = -1; /* force setting the Normal colors */
|
|
7535 screen_stop_highlight(); /* don't want highlighting here */
|
|
7536
|
|
7537 #ifdef FEAT_CLIPBOARD
|
|
7538 /* disable selection without redrawing it */
|
|
7539 clip_scroll_selection(9999);
|
|
7540 #endif
|
|
7541
|
|
7542 /* blank out ScreenLines */
|
|
7543 for (i = 0; i < Rows; ++i)
|
|
7544 {
|
|
7545 lineclear(LineOffset[i], (int)Columns);
|
|
7546 LineWraps[i] = FALSE;
|
|
7547 }
|
|
7548
|
|
7549 if (can_clear(T_CL))
|
|
7550 {
|
|
7551 out_str(T_CL); /* clear the display */
|
|
7552 clear_cmdline = FALSE;
|
644
|
7553 mode_displayed = FALSE;
|
7
|
7554 }
|
|
7555 else
|
|
7556 {
|
|
7557 /* can't clear the screen, mark all chars with invalid attributes */
|
|
7558 for (i = 0; i < Rows; ++i)
|
|
7559 lineinvalid(LineOffset[i], (int)Columns);
|
|
7560 clear_cmdline = TRUE;
|
|
7561 }
|
|
7562
|
|
7563 screen_cleared = TRUE; /* can use contents of ScreenLines now */
|
|
7564
|
|
7565 win_rest_invalid(firstwin);
|
|
7566 redraw_cmdline = TRUE;
|
670
|
7567 #ifdef FEAT_WINDOWS
|
673
|
7568 redraw_tabline = TRUE;
|
670
|
7569 #endif
|
7
|
7570 if (must_redraw == CLEAR) /* no need to clear again */
|
|
7571 must_redraw = NOT_VALID;
|
|
7572 compute_cmdrow();
|
|
7573 msg_row = cmdline_row; /* put cursor on last line for messages */
|
|
7574 msg_col = 0;
|
|
7575 screen_start(); /* don't know where cursor is now */
|
|
7576 msg_scrolled = 0; /* can't scroll back */
|
|
7577 msg_didany = FALSE;
|
|
7578 msg_didout = FALSE;
|
|
7579 }
|
|
7580
|
|
7581 /*
|
|
7582 * Clear one line in ScreenLines.
|
|
7583 */
|
|
7584 static void
|
|
7585 lineclear(off, width)
|
|
7586 unsigned off;
|
|
7587 int width;
|
|
7588 {
|
|
7589 (void)vim_memset(ScreenLines + off, ' ', (size_t)width * sizeof(schar_T));
|
|
7590 #ifdef FEAT_MBYTE
|
|
7591 if (enc_utf8)
|
|
7592 (void)vim_memset(ScreenLinesUC + off, 0,
|
|
7593 (size_t)width * sizeof(u8char_T));
|
|
7594 #endif
|
|
7595 (void)vim_memset(ScreenAttrs + off, 0, (size_t)width * sizeof(sattr_T));
|
|
7596 }
|
|
7597
|
|
7598 /*
|
|
7599 * Mark one line in ScreenLines invalid by setting the attributes to an
|
|
7600 * invalid value.
|
|
7601 */
|
|
7602 static void
|
|
7603 lineinvalid(off, width)
|
|
7604 unsigned off;
|
|
7605 int width;
|
|
7606 {
|
|
7607 (void)vim_memset(ScreenAttrs + off, -1, (size_t)width * sizeof(sattr_T));
|
|
7608 }
|
|
7609
|
|
7610 #ifdef FEAT_VERTSPLIT
|
|
7611 /*
|
|
7612 * Copy part of a Screenline for vertically split window "wp".
|
|
7613 */
|
|
7614 static void
|
|
7615 linecopy(to, from, wp)
|
|
7616 int to;
|
|
7617 int from;
|
|
7618 win_T *wp;
|
|
7619 {
|
|
7620 unsigned off_to = LineOffset[to] + wp->w_wincol;
|
|
7621 unsigned off_from = LineOffset[from] + wp->w_wincol;
|
|
7622
|
|
7623 mch_memmove(ScreenLines + off_to, ScreenLines + off_from,
|
|
7624 wp->w_width * sizeof(schar_T));
|
|
7625 # ifdef FEAT_MBYTE
|
|
7626 if (enc_utf8)
|
|
7627 {
|
714
|
7628 int i;
|
|
7629
|
7
|
7630 mch_memmove(ScreenLinesUC + off_to, ScreenLinesUC + off_from,
|
|
7631 wp->w_width * sizeof(u8char_T));
|
714
|
7632 for (i = 0; i < p_mco; ++i)
|
|
7633 mch_memmove(ScreenLinesC[i] + off_to, ScreenLinesC[i] + off_from,
|
|
7634 wp->w_width * sizeof(u8char_T));
|
7
|
7635 }
|
|
7636 if (enc_dbcs == DBCS_JPNU)
|
|
7637 mch_memmove(ScreenLines2 + off_to, ScreenLines2 + off_from,
|
|
7638 wp->w_width * sizeof(schar_T));
|
|
7639 # endif
|
|
7640 mch_memmove(ScreenAttrs + off_to, ScreenAttrs + off_from,
|
|
7641 wp->w_width * sizeof(sattr_T));
|
|
7642 }
|
|
7643 #endif
|
|
7644
|
|
7645 /*
|
|
7646 * Return TRUE if clearing with term string "p" would work.
|
|
7647 * It can't work when the string is empty or it won't set the right background.
|
|
7648 */
|
|
7649 int
|
|
7650 can_clear(p)
|
|
7651 char_u *p;
|
|
7652 {
|
|
7653 return (*p != NUL && (t_colors <= 1
|
|
7654 #ifdef FEAT_GUI
|
|
7655 || gui.in_use
|
|
7656 #endif
|
|
7657 || cterm_normal_bg_color == 0 || *T_UT != NUL));
|
|
7658 }
|
|
7659
|
|
7660 /*
|
|
7661 * Reset cursor position. Use whenever cursor was moved because of outputting
|
|
7662 * something directly to the screen (shell commands) or a terminal control
|
|
7663 * code.
|
|
7664 */
|
|
7665 void
|
|
7666 screen_start()
|
|
7667 {
|
|
7668 screen_cur_row = screen_cur_col = 9999;
|
|
7669 }
|
|
7670
|
|
7671 /*
|
|
7672 * Move the cursor to position "row","col" in the screen.
|
|
7673 * This tries to find the most efficient way to move, minimizing the number of
|
|
7674 * characters sent to the terminal.
|
|
7675 */
|
|
7676 void
|
|
7677 windgoto(row, col)
|
|
7678 int row;
|
|
7679 int col;
|
|
7680 {
|
205
|
7681 sattr_T *p;
|
7
|
7682 int i;
|
|
7683 int plan;
|
|
7684 int cost;
|
|
7685 int wouldbe_col;
|
|
7686 int noinvcurs;
|
|
7687 char_u *bs;
|
|
7688 int goto_cost;
|
|
7689 int attr;
|
|
7690
|
1213
|
7691 #define GOTO_COST 7 /* assume a term_windgoto() takes about 7 chars */
|
7
|
7692 #define HIGHL_COST 5 /* assume unhighlight takes 5 chars */
|
|
7693
|
|
7694 #define PLAN_LE 1
|
|
7695 #define PLAN_CR 2
|
|
7696 #define PLAN_NL 3
|
|
7697 #define PLAN_WRITE 4
|
|
7698 /* Can't use ScreenLines unless initialized */
|
|
7699 if (ScreenLines == NULL)
|
|
7700 return;
|
|
7701
|
|
7702 if (col != screen_cur_col || row != screen_cur_row)
|
|
7703 {
|
|
7704 /* Check for valid position. */
|
|
7705 if (row < 0) /* window without text lines? */
|
|
7706 row = 0;
|
|
7707 if (row >= screen_Rows)
|
|
7708 row = screen_Rows - 1;
|
|
7709 if (col >= screen_Columns)
|
|
7710 col = screen_Columns - 1;
|
|
7711
|
|
7712 /* check if no cursor movement is allowed in highlight mode */
|
|
7713 if (screen_attr && *T_MS == NUL)
|
|
7714 noinvcurs = HIGHL_COST;
|
|
7715 else
|
|
7716 noinvcurs = 0;
|
|
7717 goto_cost = GOTO_COST + noinvcurs;
|
|
7718
|
|
7719 /*
|
|
7720 * Plan how to do the positioning:
|
|
7721 * 1. Use CR to move it to column 0, same row.
|
|
7722 * 2. Use T_LE to move it a few columns to the left.
|
|
7723 * 3. Use NL to move a few lines down, column 0.
|
|
7724 * 4. Move a few columns to the right with T_ND or by writing chars.
|
|
7725 *
|
|
7726 * Don't do this if the cursor went beyond the last column, the cursor
|
|
7727 * position is unknown then (some terminals wrap, some don't )
|
|
7728 *
|
1213
|
7729 * First check if the highlighting attributes allow us to write
|
7
|
7730 * characters to move the cursor to the right.
|
|
7731 */
|
|
7732 if (row >= screen_cur_row && screen_cur_col < Columns)
|
|
7733 {
|
|
7734 /*
|
|
7735 * If the cursor is in the same row, bigger col, we can use CR
|
|
7736 * or T_LE.
|
|
7737 */
|
|
7738 bs = NULL; /* init for GCC */
|
|
7739 attr = screen_attr;
|
|
7740 if (row == screen_cur_row && col < screen_cur_col)
|
|
7741 {
|
|
7742 /* "le" is preferred over "bc", because "bc" is obsolete */
|
|
7743 if (*T_LE)
|
|
7744 bs = T_LE; /* "cursor left" */
|
|
7745 else
|
|
7746 bs = T_BC; /* "backspace character (old) */
|
|
7747 if (*bs)
|
|
7748 cost = (screen_cur_col - col) * (int)STRLEN(bs);
|
|
7749 else
|
|
7750 cost = 999;
|
|
7751 if (col + 1 < cost) /* using CR is less characters */
|
|
7752 {
|
|
7753 plan = PLAN_CR;
|
|
7754 wouldbe_col = 0;
|
|
7755 cost = 1; /* CR is just one character */
|
|
7756 }
|
|
7757 else
|
|
7758 {
|
|
7759 plan = PLAN_LE;
|
|
7760 wouldbe_col = col;
|
|
7761 }
|
|
7762 if (noinvcurs) /* will stop highlighting */
|
|
7763 {
|
|
7764 cost += noinvcurs;
|
|
7765 attr = 0;
|
|
7766 }
|
|
7767 }
|
|
7768
|
|
7769 /*
|
|
7770 * If the cursor is above where we want to be, we can use CR LF.
|
|
7771 */
|
|
7772 else if (row > screen_cur_row)
|
|
7773 {
|
|
7774 plan = PLAN_NL;
|
|
7775 wouldbe_col = 0;
|
|
7776 cost = (row - screen_cur_row) * 2; /* CR LF */
|
|
7777 if (noinvcurs) /* will stop highlighting */
|
|
7778 {
|
|
7779 cost += noinvcurs;
|
|
7780 attr = 0;
|
|
7781 }
|
|
7782 }
|
|
7783
|
|
7784 /*
|
|
7785 * If the cursor is in the same row, smaller col, just use write.
|
|
7786 */
|
|
7787 else
|
|
7788 {
|
|
7789 plan = PLAN_WRITE;
|
|
7790 wouldbe_col = screen_cur_col;
|
|
7791 cost = 0;
|
|
7792 }
|
|
7793
|
|
7794 /*
|
|
7795 * Check if any characters that need to be written have the
|
|
7796 * correct attributes. Also avoid UTF-8 characters.
|
|
7797 */
|
|
7798 i = col - wouldbe_col;
|
|
7799 if (i > 0)
|
|
7800 cost += i;
|
|
7801 if (cost < goto_cost && i > 0)
|
|
7802 {
|
|
7803 /*
|
|
7804 * Check if the attributes are correct without additionally
|
|
7805 * stopping highlighting.
|
|
7806 */
|
|
7807 p = ScreenAttrs + LineOffset[row] + wouldbe_col;
|
|
7808 while (i && *p++ == attr)
|
|
7809 --i;
|
|
7810 if (i != 0)
|
|
7811 {
|
|
7812 /*
|
|
7813 * Try if it works when highlighting is stopped here.
|
|
7814 */
|
|
7815 if (*--p == 0)
|
|
7816 {
|
|
7817 cost += noinvcurs;
|
|
7818 while (i && *p++ == 0)
|
|
7819 --i;
|
|
7820 }
|
|
7821 if (i != 0)
|
|
7822 cost = 999; /* different attributes, don't do it */
|
|
7823 }
|
|
7824 #ifdef FEAT_MBYTE
|
|
7825 if (enc_utf8)
|
|
7826 {
|
|
7827 /* Don't use an UTF-8 char for positioning, it's slow. */
|
|
7828 for (i = wouldbe_col; i < col; ++i)
|
|
7829 if (ScreenLinesUC[LineOffset[row] + i] != 0)
|
|
7830 {
|
|
7831 cost = 999;
|
|
7832 break;
|
|
7833 }
|
|
7834 }
|
|
7835 #endif
|
|
7836 }
|
|
7837
|
|
7838 /*
|
|
7839 * We can do it without term_windgoto()!
|
|
7840 */
|
|
7841 if (cost < goto_cost)
|
|
7842 {
|
|
7843 if (plan == PLAN_LE)
|
|
7844 {
|
|
7845 if (noinvcurs)
|
|
7846 screen_stop_highlight();
|
|
7847 while (screen_cur_col > col)
|
|
7848 {
|
|
7849 out_str(bs);
|
|
7850 --screen_cur_col;
|
|
7851 }
|
|
7852 }
|
|
7853 else if (plan == PLAN_CR)
|
|
7854 {
|
|
7855 if (noinvcurs)
|
|
7856 screen_stop_highlight();
|
|
7857 out_char('\r');
|
|
7858 screen_cur_col = 0;
|
|
7859 }
|
|
7860 else if (plan == PLAN_NL)
|
|
7861 {
|
|
7862 if (noinvcurs)
|
|
7863 screen_stop_highlight();
|
|
7864 while (screen_cur_row < row)
|
|
7865 {
|
|
7866 out_char('\n');
|
|
7867 ++screen_cur_row;
|
|
7868 }
|
|
7869 screen_cur_col = 0;
|
|
7870 }
|
|
7871
|
|
7872 i = col - screen_cur_col;
|
|
7873 if (i > 0)
|
|
7874 {
|
|
7875 /*
|
|
7876 * Use cursor-right if it's one character only. Avoids
|
|
7877 * removing a line of pixels from the last bold char, when
|
|
7878 * using the bold trick in the GUI.
|
|
7879 */
|
|
7880 if (T_ND[0] != NUL && T_ND[1] == NUL)
|
|
7881 {
|
|
7882 while (i-- > 0)
|
|
7883 out_char(*T_ND);
|
|
7884 }
|
|
7885 else
|
|
7886 {
|
|
7887 int off;
|
|
7888
|
|
7889 off = LineOffset[row] + screen_cur_col;
|
|
7890 while (i-- > 0)
|
|
7891 {
|
|
7892 if (ScreenAttrs[off] != screen_attr)
|
|
7893 screen_stop_highlight();
|
|
7894 #ifdef FEAT_MBYTE
|
|
7895 out_flush_check();
|
|
7896 #endif
|
|
7897 out_char(ScreenLines[off]);
|
|
7898 #ifdef FEAT_MBYTE
|
|
7899 if (enc_dbcs == DBCS_JPNU
|
|
7900 && ScreenLines[off] == 0x8e)
|
|
7901 out_char(ScreenLines2[off]);
|
|
7902 #endif
|
|
7903 ++off;
|
|
7904 }
|
|
7905 }
|
|
7906 }
|
|
7907 }
|
|
7908 }
|
|
7909 else
|
|
7910 cost = 999;
|
|
7911
|
|
7912 if (cost >= goto_cost)
|
|
7913 {
|
|
7914 if (noinvcurs)
|
|
7915 screen_stop_highlight();
|
|
7916 if (row == screen_cur_row && (col > screen_cur_col) &&
|
|
7917 *T_CRI != NUL)
|
|
7918 term_cursor_right(col - screen_cur_col);
|
|
7919 else
|
|
7920 term_windgoto(row, col);
|
|
7921 }
|
|
7922 screen_cur_row = row;
|
|
7923 screen_cur_col = col;
|
|
7924 }
|
|
7925 }
|
|
7926
|
|
7927 /*
|
|
7928 * Set cursor to its position in the current window.
|
|
7929 */
|
|
7930 void
|
|
7931 setcursor()
|
|
7932 {
|
|
7933 if (redrawing())
|
|
7934 {
|
|
7935 validate_cursor();
|
|
7936 windgoto(W_WINROW(curwin) + curwin->w_wrow,
|
|
7937 W_WINCOL(curwin) + (
|
|
7938 #ifdef FEAT_RIGHTLEFT
|
|
7939 curwin->w_p_rl ? ((int)W_WIDTH(curwin) - curwin->w_wcol - (
|
|
7940 # ifdef FEAT_MBYTE
|
|
7941 has_mbyte ? (*mb_ptr2cells)(ml_get_cursor()) :
|
|
7942 # endif
|
|
7943 1)) :
|
|
7944 #endif
|
|
7945 curwin->w_wcol));
|
|
7946 }
|
|
7947 }
|
|
7948
|
|
7949
|
|
7950 /*
|
|
7951 * insert 'line_count' lines at 'row' in window 'wp'
|
|
7952 * if 'invalid' is TRUE the wp->w_lines[].wl_lnum is invalidated.
|
|
7953 * if 'mayclear' is TRUE the screen will be cleared if it is faster than
|
|
7954 * scrolling.
|
|
7955 * Returns FAIL if the lines are not inserted, OK for success.
|
|
7956 */
|
|
7957 int
|
|
7958 win_ins_lines(wp, row, line_count, invalid, mayclear)
|
|
7959 win_T *wp;
|
|
7960 int row;
|
|
7961 int line_count;
|
|
7962 int invalid;
|
|
7963 int mayclear;
|
|
7964 {
|
|
7965 int did_delete;
|
|
7966 int nextrow;
|
|
7967 int lastrow;
|
|
7968 int retval;
|
|
7969
|
|
7970 if (invalid)
|
|
7971 wp->w_lines_valid = 0;
|
|
7972
|
|
7973 if (wp->w_height < 5)
|
|
7974 return FAIL;
|
|
7975
|
|
7976 if (line_count > wp->w_height - row)
|
|
7977 line_count = wp->w_height - row;
|
|
7978
|
|
7979 retval = win_do_lines(wp, row, line_count, mayclear, FALSE);
|
|
7980 if (retval != MAYBE)
|
|
7981 return retval;
|
|
7982
|
|
7983 /*
|
|
7984 * If there is a next window or a status line, we first try to delete the
|
|
7985 * lines at the bottom to avoid messing what is after the window.
|
|
7986 * If this fails and there are following windows, don't do anything to avoid
|
|
7987 * messing up those windows, better just redraw.
|
|
7988 */
|
|
7989 did_delete = FALSE;
|
|
7990 #ifdef FEAT_WINDOWS
|
|
7991 if (wp->w_next != NULL || wp->w_status_height)
|
|
7992 {
|
|
7993 if (screen_del_lines(0, W_WINROW(wp) + wp->w_height - line_count,
|
|
7994 line_count, (int)Rows, FALSE, NULL) == OK)
|
|
7995 did_delete = TRUE;
|
|
7996 else if (wp->w_next)
|
|
7997 return FAIL;
|
|
7998 }
|
|
7999 #endif
|
|
8000 /*
|
|
8001 * if no lines deleted, blank the lines that will end up below the window
|
|
8002 */
|
|
8003 if (!did_delete)
|
|
8004 {
|
|
8005 #ifdef FEAT_WINDOWS
|
|
8006 wp->w_redr_status = TRUE;
|
|
8007 #endif
|
|
8008 redraw_cmdline = TRUE;
|
|
8009 nextrow = W_WINROW(wp) + wp->w_height + W_STATUS_HEIGHT(wp);
|
|
8010 lastrow = nextrow + line_count;
|
|
8011 if (lastrow > Rows)
|
|
8012 lastrow = Rows;
|
|
8013 screen_fill(nextrow - line_count, lastrow - line_count,
|
|
8014 W_WINCOL(wp), (int)W_ENDCOL(wp),
|
|
8015 ' ', ' ', 0);
|
|
8016 }
|
|
8017
|
|
8018 if (screen_ins_lines(0, W_WINROW(wp) + row, line_count, (int)Rows, NULL)
|
|
8019 == FAIL)
|
|
8020 {
|
|
8021 /* deletion will have messed up other windows */
|
|
8022 if (did_delete)
|
|
8023 {
|
|
8024 #ifdef FEAT_WINDOWS
|
|
8025 wp->w_redr_status = TRUE;
|
|
8026 #endif
|
|
8027 win_rest_invalid(W_NEXT(wp));
|
|
8028 }
|
|
8029 return FAIL;
|
|
8030 }
|
|
8031
|
|
8032 return OK;
|
|
8033 }
|
|
8034
|
|
8035 /*
|
|
8036 * delete "line_count" window lines at "row" in window "wp"
|
|
8037 * If "invalid" is TRUE curwin->w_lines[] is invalidated.
|
|
8038 * If "mayclear" is TRUE the screen will be cleared if it is faster than
|
|
8039 * scrolling
|
|
8040 * Return OK for success, FAIL if the lines are not deleted.
|
|
8041 */
|
|
8042 int
|
|
8043 win_del_lines(wp, row, line_count, invalid, mayclear)
|
|
8044 win_T *wp;
|
|
8045 int row;
|
|
8046 int line_count;
|
|
8047 int invalid;
|
|
8048 int mayclear;
|
|
8049 {
|
|
8050 int retval;
|
|
8051
|
|
8052 if (invalid)
|
|
8053 wp->w_lines_valid = 0;
|
|
8054
|
|
8055 if (line_count > wp->w_height - row)
|
|
8056 line_count = wp->w_height - row;
|
|
8057
|
|
8058 retval = win_do_lines(wp, row, line_count, mayclear, TRUE);
|
|
8059 if (retval != MAYBE)
|
|
8060 return retval;
|
|
8061
|
|
8062 if (screen_del_lines(0, W_WINROW(wp) + row, line_count,
|
|
8063 (int)Rows, FALSE, NULL) == FAIL)
|
|
8064 return FAIL;
|
|
8065
|
|
8066 #ifdef FEAT_WINDOWS
|
|
8067 /*
|
|
8068 * If there are windows or status lines below, try to put them at the
|
|
8069 * correct place. If we can't do that, they have to be redrawn.
|
|
8070 */
|
|
8071 if (wp->w_next || wp->w_status_height || cmdline_row < Rows - 1)
|
|
8072 {
|
|
8073 if (screen_ins_lines(0, W_WINROW(wp) + wp->w_height - line_count,
|
|
8074 line_count, (int)Rows, NULL) == FAIL)
|
|
8075 {
|
|
8076 wp->w_redr_status = TRUE;
|
|
8077 win_rest_invalid(wp->w_next);
|
|
8078 }
|
|
8079 }
|
|
8080 /*
|
|
8081 * If this is the last window and there is no status line, redraw the
|
|
8082 * command line later.
|
|
8083 */
|
|
8084 else
|
|
8085 #endif
|
|
8086 redraw_cmdline = TRUE;
|
|
8087 return OK;
|
|
8088 }
|
|
8089
|
|
8090 /*
|
|
8091 * Common code for win_ins_lines() and win_del_lines().
|
|
8092 * Returns OK or FAIL when the work has been done.
|
|
8093 * Returns MAYBE when not finished yet.
|
|
8094 */
|
|
8095 static int
|
|
8096 win_do_lines(wp, row, line_count, mayclear, del)
|
|
8097 win_T *wp;
|
|
8098 int row;
|
|
8099 int line_count;
|
|
8100 int mayclear;
|
|
8101 int del;
|
|
8102 {
|
|
8103 int retval;
|
|
8104
|
|
8105 if (!redrawing() || line_count <= 0)
|
|
8106 return FAIL;
|
|
8107
|
|
8108 /* only a few lines left: redraw is faster */
|
|
8109 if (mayclear && Rows - line_count < 5
|
|
8110 #ifdef FEAT_VERTSPLIT
|
|
8111 && wp->w_width == Columns
|
|
8112 #endif
|
|
8113 )
|
|
8114 {
|
|
8115 screenclear(); /* will set wp->w_lines_valid to 0 */
|
|
8116 return FAIL;
|
|
8117 }
|
|
8118
|
|
8119 /*
|
|
8120 * Delete all remaining lines
|
|
8121 */
|
|
8122 if (row + line_count >= wp->w_height)
|
|
8123 {
|
|
8124 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
|
|
8125 W_WINCOL(wp), (int)W_ENDCOL(wp),
|
|
8126 ' ', ' ', 0);
|
|
8127 return OK;
|
|
8128 }
|
|
8129
|
|
8130 /*
|
|
8131 * when scrolling, the message on the command line should be cleared,
|
|
8132 * otherwise it will stay there forever.
|
|
8133 */
|
|
8134 clear_cmdline = TRUE;
|
|
8135
|
|
8136 /*
|
|
8137 * If the terminal can set a scroll region, use that.
|
|
8138 * Always do this in a vertically split window. This will redraw from
|
|
8139 * ScreenLines[] when t_CV isn't defined. That's faster than using
|
|
8140 * win_line().
|
|
8141 * Don't use a scroll region when we are going to redraw the text, writing
|
|
8142 * a character in the lower right corner of the scroll region causes a
|
|
8143 * scroll-up in the DJGPP version.
|
|
8144 */
|
|
8145 if (scroll_region
|
|
8146 #ifdef FEAT_VERTSPLIT
|
|
8147 || W_WIDTH(wp) != Columns
|
|
8148 #endif
|
|
8149 )
|
|
8150 {
|
|
8151 #ifdef FEAT_VERTSPLIT
|
|
8152 if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL))
|
|
8153 #endif
|
|
8154 scroll_region_set(wp, row);
|
|
8155 if (del)
|
|
8156 retval = screen_del_lines(W_WINROW(wp) + row, 0, line_count,
|
|
8157 wp->w_height - row, FALSE, wp);
|
|
8158 else
|
|
8159 retval = screen_ins_lines(W_WINROW(wp) + row, 0, line_count,
|
|
8160 wp->w_height - row, wp);
|
|
8161 #ifdef FEAT_VERTSPLIT
|
|
8162 if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL))
|
|
8163 #endif
|
|
8164 scroll_region_reset();
|
|
8165 return retval;
|
|
8166 }
|
|
8167
|
|
8168 #ifdef FEAT_WINDOWS
|
|
8169 if (wp->w_next != NULL && p_tf) /* don't delete/insert on fast terminal */
|
|
8170 return FAIL;
|
|
8171 #endif
|
|
8172
|
|
8173 return MAYBE;
|
|
8174 }
|
|
8175
|
|
8176 /*
|
|
8177 * window 'wp' and everything after it is messed up, mark it for redraw
|
|
8178 */
|
|
8179 static void
|
|
8180 win_rest_invalid(wp)
|
|
8181 win_T *wp;
|
|
8182 {
|
|
8183 #ifdef FEAT_WINDOWS
|
|
8184 while (wp != NULL)
|
|
8185 #else
|
|
8186 if (wp != NULL)
|
|
8187 #endif
|
|
8188 {
|
|
8189 redraw_win_later(wp, NOT_VALID);
|
|
8190 #ifdef FEAT_WINDOWS
|
|
8191 wp->w_redr_status = TRUE;
|
|
8192 wp = wp->w_next;
|
|
8193 #endif
|
|
8194 }
|
|
8195 redraw_cmdline = TRUE;
|
|
8196 }
|
|
8197
|
|
8198 /*
|
|
8199 * The rest of the routines in this file perform screen manipulations. The
|
|
8200 * given operation is performed physically on the screen. The corresponding
|
|
8201 * change is also made to the internal screen image. In this way, the editor
|
|
8202 * anticipates the effect of editing changes on the appearance of the screen.
|
|
8203 * That way, when we call screenupdate a complete redraw isn't usually
|
|
8204 * necessary. Another advantage is that we can keep adding code to anticipate
|
|
8205 * screen changes, and in the meantime, everything still works.
|
|
8206 */
|
|
8207
|
|
8208 /*
|
|
8209 * types for inserting or deleting lines
|
|
8210 */
|
|
8211 #define USE_T_CAL 1
|
|
8212 #define USE_T_CDL 2
|
|
8213 #define USE_T_AL 3
|
|
8214 #define USE_T_CE 4
|
|
8215 #define USE_T_DL 5
|
|
8216 #define USE_T_SR 6
|
|
8217 #define USE_NL 7
|
|
8218 #define USE_T_CD 8
|
|
8219 #define USE_REDRAW 9
|
|
8220
|
|
8221 /*
|
|
8222 * insert lines on the screen and update ScreenLines[]
|
|
8223 * 'end' is the line after the scrolled part. Normally it is Rows.
|
|
8224 * When scrolling region used 'off' is the offset from the top for the region.
|
|
8225 * 'row' and 'end' are relative to the start of the region.
|
|
8226 *
|
|
8227 * return FAIL for failure, OK for success.
|
|
8228 */
|
446
|
8229 int
|
7
|
8230 screen_ins_lines(off, row, line_count, end, wp)
|
|
8231 int off;
|
|
8232 int row;
|
|
8233 int line_count;
|
|
8234 int end;
|
|
8235 win_T *wp; /* NULL or window to use width from */
|
|
8236 {
|
|
8237 int i;
|
|
8238 int j;
|
|
8239 unsigned temp;
|
|
8240 int cursor_row;
|
|
8241 int type;
|
|
8242 int result_empty;
|
|
8243 int can_ce = can_clear(T_CE);
|
|
8244
|
|
8245 /*
|
|
8246 * FAIL if
|
|
8247 * - there is no valid screen
|
|
8248 * - the screen has to be redrawn completely
|
|
8249 * - the line count is less than one
|
|
8250 * - the line count is more than 'ttyscroll'
|
|
8251 */
|
|
8252 if (!screen_valid(TRUE) || line_count <= 0 || line_count > p_ttyscroll)
|
|
8253 return FAIL;
|
|
8254
|
|
8255 /*
|
|
8256 * There are seven ways to insert lines:
|
|
8257 * 0. When in a vertically split window and t_CV isn't set, redraw the
|
|
8258 * characters from ScreenLines[].
|
|
8259 * 1. Use T_CD (clear to end of display) if it exists and the result of
|
|
8260 * the insert is just empty lines
|
|
8261 * 2. Use T_CAL (insert multiple lines) if it exists and T_AL is not
|
|
8262 * present or line_count > 1. It looks better if we do all the inserts
|
|
8263 * at once.
|
|
8264 * 3. Use T_CDL (delete multiple lines) if it exists and the result of the
|
|
8265 * insert is just empty lines and T_CE is not present or line_count >
|
|
8266 * 1.
|
|
8267 * 4. Use T_AL (insert line) if it exists.
|
|
8268 * 5. Use T_CE (erase line) if it exists and the result of the insert is
|
|
8269 * just empty lines.
|
|
8270 * 6. Use T_DL (delete line) if it exists and the result of the insert is
|
|
8271 * just empty lines.
|
|
8272 * 7. Use T_SR (scroll reverse) if it exists and inserting at row 0 and
|
|
8273 * the 'da' flag is not set or we have clear line capability.
|
|
8274 * 8. redraw the characters from ScreenLines[].
|
|
8275 *
|
|
8276 * Careful: In a hpterm scroll reverse doesn't work as expected, it moves
|
|
8277 * the scrollbar for the window. It does have insert line, use that if it
|
|
8278 * exists.
|
|
8279 */
|
|
8280 result_empty = (row + line_count >= end);
|
|
8281 #ifdef FEAT_VERTSPLIT
|
|
8282 if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL)
|
|
8283 type = USE_REDRAW;
|
|
8284 else
|
|
8285 #endif
|
|
8286 if (can_clear(T_CD) && result_empty)
|
|
8287 type = USE_T_CD;
|
|
8288 else if (*T_CAL != NUL && (line_count > 1 || *T_AL == NUL))
|
|
8289 type = USE_T_CAL;
|
|
8290 else if (*T_CDL != NUL && result_empty && (line_count > 1 || !can_ce))
|
|
8291 type = USE_T_CDL;
|
|
8292 else if (*T_AL != NUL)
|
|
8293 type = USE_T_AL;
|
|
8294 else if (can_ce && result_empty)
|
|
8295 type = USE_T_CE;
|
|
8296 else if (*T_DL != NUL && result_empty)
|
|
8297 type = USE_T_DL;
|
|
8298 else if (*T_SR != NUL && row == 0 && (*T_DA == NUL || can_ce))
|
|
8299 type = USE_T_SR;
|
|
8300 else
|
|
8301 return FAIL;
|
|
8302
|
|
8303 /*
|
|
8304 * For clearing the lines screen_del_lines() is used. This will also take
|
|
8305 * care of t_db if necessary.
|
|
8306 */
|
|
8307 if (type == USE_T_CD || type == USE_T_CDL ||
|
|
8308 type == USE_T_CE || type == USE_T_DL)
|
|
8309 return screen_del_lines(off, row, line_count, end, FALSE, wp);
|
|
8310
|
|
8311 /*
|
|
8312 * If text is retained below the screen, first clear or delete as many
|
|
8313 * lines at the bottom of the window as are about to be inserted so that
|
|
8314 * the deleted lines won't later surface during a screen_del_lines.
|
|
8315 */
|
|
8316 if (*T_DB)
|
|
8317 screen_del_lines(off, end - line_count, line_count, end, FALSE, wp);
|
|
8318
|
|
8319 #ifdef FEAT_CLIPBOARD
|
|
8320 /* Remove a modeless selection when inserting lines halfway the screen
|
|
8321 * or not the full width of the screen. */
|
|
8322 if (off + row > 0
|
|
8323 # ifdef FEAT_VERTSPLIT
|
|
8324 || (wp != NULL && wp->w_width != Columns)
|
|
8325 # endif
|
|
8326 )
|
|
8327 clip_clear_selection();
|
|
8328 else
|
|
8329 clip_scroll_selection(-line_count);
|
|
8330 #endif
|
|
8331
|
|
8332 #ifdef FEAT_GUI
|
|
8333 /* Don't update the GUI cursor here, ScreenLines[] is invalid until the
|
|
8334 * scrolling is actually carried out. */
|
|
8335 gui_dont_update_cursor();
|
|
8336 #endif
|
|
8337
|
|
8338 if (*T_CCS != NUL) /* cursor relative to region */
|
|
8339 cursor_row = row;
|
|
8340 else
|
|
8341 cursor_row = row + off;
|
|
8342
|
|
8343 /*
|
|
8344 * Shift LineOffset[] line_count down to reflect the inserted lines.
|
|
8345 * Clear the inserted lines in ScreenLines[].
|
|
8346 */
|
|
8347 row += off;
|
|
8348 end += off;
|
|
8349 for (i = 0; i < line_count; ++i)
|
|
8350 {
|
|
8351 #ifdef FEAT_VERTSPLIT
|
|
8352 if (wp != NULL && wp->w_width != Columns)
|
|
8353 {
|
|
8354 /* need to copy part of a line */
|
|
8355 j = end - 1 - i;
|
|
8356 while ((j -= line_count) >= row)
|
|
8357 linecopy(j + line_count, j, wp);
|
|
8358 j += line_count;
|
|
8359 if (can_clear((char_u *)" "))
|
|
8360 lineclear(LineOffset[j] + wp->w_wincol, wp->w_width);
|
|
8361 else
|
|
8362 lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
|
|
8363 LineWraps[j] = FALSE;
|
|
8364 }
|
|
8365 else
|
|
8366 #endif
|
|
8367 {
|
|
8368 j = end - 1 - i;
|
|
8369 temp = LineOffset[j];
|
|
8370 while ((j -= line_count) >= row)
|
|
8371 {
|
|
8372 LineOffset[j + line_count] = LineOffset[j];
|
|
8373 LineWraps[j + line_count] = LineWraps[j];
|
|
8374 }
|
|
8375 LineOffset[j + line_count] = temp;
|
|
8376 LineWraps[j + line_count] = FALSE;
|
|
8377 if (can_clear((char_u *)" "))
|
|
8378 lineclear(temp, (int)Columns);
|
|
8379 else
|
|
8380 lineinvalid(temp, (int)Columns);
|
|
8381 }
|
|
8382 }
|
|
8383
|
|
8384 screen_stop_highlight();
|
|
8385 windgoto(cursor_row, 0);
|
|
8386
|
|
8387 #ifdef FEAT_VERTSPLIT
|
|
8388 /* redraw the characters */
|
|
8389 if (type == USE_REDRAW)
|
|
8390 redraw_block(row, end, wp);
|
|
8391 else
|
|
8392 #endif
|
|
8393 if (type == USE_T_CAL)
|
|
8394 {
|
|
8395 term_append_lines(line_count);
|
|
8396 screen_start(); /* don't know where cursor is now */
|
|
8397 }
|
|
8398 else
|
|
8399 {
|
|
8400 for (i = 0; i < line_count; i++)
|
|
8401 {
|
|
8402 if (type == USE_T_AL)
|
|
8403 {
|
|
8404 if (i && cursor_row != 0)
|
|
8405 windgoto(cursor_row, 0);
|
|
8406 out_str(T_AL);
|
|
8407 }
|
|
8408 else /* type == USE_T_SR */
|
|
8409 out_str(T_SR);
|
|
8410 screen_start(); /* don't know where cursor is now */
|
|
8411 }
|
|
8412 }
|
|
8413
|
|
8414 /*
|
|
8415 * With scroll-reverse and 'da' flag set we need to clear the lines that
|
|
8416 * have been scrolled down into the region.
|
|
8417 */
|
|
8418 if (type == USE_T_SR && *T_DA)
|
|
8419 {
|
|
8420 for (i = 0; i < line_count; ++i)
|
|
8421 {
|
|
8422 windgoto(off + i, 0);
|
|
8423 out_str(T_CE);
|
|
8424 screen_start(); /* don't know where cursor is now */
|
|
8425 }
|
|
8426 }
|
|
8427
|
|
8428 #ifdef FEAT_GUI
|
|
8429 gui_can_update_cursor();
|
|
8430 if (gui.in_use)
|
|
8431 out_flush(); /* always flush after a scroll */
|
|
8432 #endif
|
|
8433 return OK;
|
|
8434 }
|
|
8435
|
|
8436 /*
|
|
8437 * delete lines on the screen and update ScreenLines[]
|
|
8438 * 'end' is the line after the scrolled part. Normally it is Rows.
|
|
8439 * When scrolling region used 'off' is the offset from the top for the region.
|
|
8440 * 'row' and 'end' are relative to the start of the region.
|
|
8441 *
|
|
8442 * Return OK for success, FAIL if the lines are not deleted.
|
|
8443 */
|
|
8444 /*ARGSUSED*/
|
|
8445 int
|
|
8446 screen_del_lines(off, row, line_count, end, force, wp)
|
|
8447 int off;
|
|
8448 int row;
|
|
8449 int line_count;
|
|
8450 int end;
|
|
8451 int force; /* even when line_count > p_ttyscroll */
|
|
8452 win_T *wp; /* NULL or window to use width from */
|
|
8453 {
|
|
8454 int j;
|
|
8455 int i;
|
|
8456 unsigned temp;
|
|
8457 int cursor_row;
|
|
8458 int cursor_end;
|
|
8459 int result_empty; /* result is empty until end of region */
|
|
8460 int can_delete; /* deleting line codes can be used */
|
|
8461 int type;
|
|
8462
|
|
8463 /*
|
|
8464 * FAIL if
|
|
8465 * - there is no valid screen
|
|
8466 * - the screen has to be redrawn completely
|
|
8467 * - the line count is less than one
|
|
8468 * - the line count is more than 'ttyscroll'
|
|
8469 */
|
|
8470 if (!screen_valid(TRUE) || line_count <= 0 ||
|
|
8471 (!force && line_count > p_ttyscroll))
|
|
8472 return FAIL;
|
|
8473
|
|
8474 /*
|
|
8475 * Check if the rest of the current region will become empty.
|
|
8476 */
|
|
8477 result_empty = row + line_count >= end;
|
|
8478
|
|
8479 /*
|
|
8480 * We can delete lines only when 'db' flag not set or when 'ce' option
|
|
8481 * available.
|
|
8482 */
|
|
8483 can_delete = (*T_DB == NUL || can_clear(T_CE));
|
|
8484
|
|
8485 /*
|
|
8486 * There are six ways to delete lines:
|
|
8487 * 0. When in a vertically split window and t_CV isn't set, redraw the
|
|
8488 * characters from ScreenLines[].
|
|
8489 * 1. Use T_CD if it exists and the result is empty.
|
|
8490 * 2. Use newlines if row == 0 and count == 1 or T_CDL does not exist.
|
|
8491 * 3. Use T_CDL (delete multiple lines) if it exists and line_count > 1 or
|
|
8492 * none of the other ways work.
|
|
8493 * 4. Use T_CE (erase line) if the result is empty.
|
|
8494 * 5. Use T_DL (delete line) if it exists.
|
|
8495 * 6. redraw the characters from ScreenLines[].
|
|
8496 */
|
|
8497 #ifdef FEAT_VERTSPLIT
|
|
8498 if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL)
|
|
8499 type = USE_REDRAW;
|
|
8500 else
|
|
8501 #endif
|
|
8502 if (can_clear(T_CD) && result_empty)
|
|
8503 type = USE_T_CD;
|
|
8504 #if defined(__BEOS__) && defined(BEOS_DR8)
|
|
8505 /*
|
|
8506 * USE_NL does not seem to work in Terminal of DR8 so we set T_DB="" in
|
|
8507 * its internal termcap... this works okay for tests which test *T_DB !=
|
|
8508 * NUL. It has the disadvantage that the user cannot use any :set t_*
|
|
8509 * command to get T_DB (back) to empty_option, only :set term=... will do
|
|
8510 * the trick...
|
|
8511 * Anyway, this hack will hopefully go away with the next OS release.
|
|
8512 * (Olaf Seibert)
|
|
8513 */
|
|
8514 else if (row == 0 && T_DB == empty_option
|
|
8515 && (line_count == 1 || *T_CDL == NUL))
|
|
8516 #else
|
|
8517 else if (row == 0 && (
|
|
8518 #ifndef AMIGA
|
|
8519 /* On the Amiga, somehow '\n' on the last line doesn't always scroll
|
|
8520 * up, so use delete-line command */
|
|
8521 line_count == 1 ||
|
|
8522 #endif
|
|
8523 *T_CDL == NUL))
|
|
8524 #endif
|
|
8525 type = USE_NL;
|
|
8526 else if (*T_CDL != NUL && line_count > 1 && can_delete)
|
|
8527 type = USE_T_CDL;
|
|
8528 else if (can_clear(T_CE) && result_empty
|
|
8529 #ifdef FEAT_VERTSPLIT
|
|
8530 && (wp == NULL || wp->w_width == Columns)
|
|
8531 #endif
|
|
8532 )
|
|
8533 type = USE_T_CE;
|
|
8534 else if (*T_DL != NUL && can_delete)
|
|
8535 type = USE_T_DL;
|
|
8536 else if (*T_CDL != NUL && can_delete)
|
|
8537 type = USE_T_CDL;
|
|
8538 else
|
|
8539 return FAIL;
|
|
8540
|
|
8541 #ifdef FEAT_CLIPBOARD
|
|
8542 /* Remove a modeless selection when deleting lines halfway the screen or
|
|
8543 * not the full width of the screen. */
|
|
8544 if (off + row > 0
|
|
8545 # ifdef FEAT_VERTSPLIT
|
|
8546 || (wp != NULL && wp->w_width != Columns)
|
|
8547 # endif
|
|
8548 )
|
|
8549 clip_clear_selection();
|
|
8550 else
|
|
8551 clip_scroll_selection(line_count);
|
|
8552 #endif
|
|
8553
|
|
8554 #ifdef FEAT_GUI
|
|
8555 /* Don't update the GUI cursor here, ScreenLines[] is invalid until the
|
|
8556 * scrolling is actually carried out. */
|
|
8557 gui_dont_update_cursor();
|
|
8558 #endif
|
|
8559
|
|
8560 if (*T_CCS != NUL) /* cursor relative to region */
|
|
8561 {
|
|
8562 cursor_row = row;
|
|
8563 cursor_end = end;
|
|
8564 }
|
|
8565 else
|
|
8566 {
|
|
8567 cursor_row = row + off;
|
|
8568 cursor_end = end + off;
|
|
8569 }
|
|
8570
|
|
8571 /*
|
|
8572 * Now shift LineOffset[] line_count up to reflect the deleted lines.
|
|
8573 * Clear the inserted lines in ScreenLines[].
|
|
8574 */
|
|
8575 row += off;
|
|
8576 end += off;
|
|
8577 for (i = 0; i < line_count; ++i)
|
|
8578 {
|
|
8579 #ifdef FEAT_VERTSPLIT
|
|
8580 if (wp != NULL && wp->w_width != Columns)
|
|
8581 {
|
|
8582 /* need to copy part of a line */
|
|
8583 j = row + i;
|
|
8584 while ((j += line_count) <= end - 1)
|
|
8585 linecopy(j - line_count, j, wp);
|
|
8586 j -= line_count;
|
|
8587 if (can_clear((char_u *)" "))
|
|
8588 lineclear(LineOffset[j] + wp->w_wincol, wp->w_width);
|
|
8589 else
|
|
8590 lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
|
|
8591 LineWraps[j] = FALSE;
|
|
8592 }
|
|
8593 else
|
|
8594 #endif
|
|
8595 {
|
|
8596 /* whole width, moving the line pointers is faster */
|
|
8597 j = row + i;
|
|
8598 temp = LineOffset[j];
|
|
8599 while ((j += line_count) <= end - 1)
|
|
8600 {
|
|
8601 LineOffset[j - line_count] = LineOffset[j];
|
|
8602 LineWraps[j - line_count] = LineWraps[j];
|
|
8603 }
|
|
8604 LineOffset[j - line_count] = temp;
|
|
8605 LineWraps[j - line_count] = FALSE;
|
|
8606 if (can_clear((char_u *)" "))
|
|
8607 lineclear(temp, (int)Columns);
|
|
8608 else
|
|
8609 lineinvalid(temp, (int)Columns);
|
|
8610 }
|
|
8611 }
|
|
8612
|
|
8613 screen_stop_highlight();
|
|
8614
|
|
8615 #ifdef FEAT_VERTSPLIT
|
|
8616 /* redraw the characters */
|
|
8617 if (type == USE_REDRAW)
|
|
8618 redraw_block(row, end, wp);
|
|
8619 else
|
|
8620 #endif
|
|
8621 if (type == USE_T_CD) /* delete the lines */
|
|
8622 {
|
|
8623 windgoto(cursor_row, 0);
|
|
8624 out_str(T_CD);
|
|
8625 screen_start(); /* don't know where cursor is now */
|
|
8626 }
|
|
8627 else if (type == USE_T_CDL)
|
|
8628 {
|
|
8629 windgoto(cursor_row, 0);
|
|
8630 term_delete_lines(line_count);
|
|
8631 screen_start(); /* don't know where cursor is now */
|
|
8632 }
|
|
8633 /*
|
|
8634 * Deleting lines at top of the screen or scroll region: Just scroll
|
|
8635 * the whole screen (scroll region) up by outputting newlines on the
|
|
8636 * last line.
|
|
8637 */
|
|
8638 else if (type == USE_NL)
|
|
8639 {
|
|
8640 windgoto(cursor_end - 1, 0);
|
|
8641 for (i = line_count; --i >= 0; )
|
|
8642 out_char('\n'); /* cursor will remain on same line */
|
|
8643 }
|
|
8644 else
|
|
8645 {
|
|
8646 for (i = line_count; --i >= 0; )
|
|
8647 {
|
|
8648 if (type == USE_T_DL)
|
|
8649 {
|
|
8650 windgoto(cursor_row, 0);
|
|
8651 out_str(T_DL); /* delete a line */
|
|
8652 }
|
|
8653 else /* type == USE_T_CE */
|
|
8654 {
|
|
8655 windgoto(cursor_row + i, 0);
|
|
8656 out_str(T_CE); /* erase a line */
|
|
8657 }
|
|
8658 screen_start(); /* don't know where cursor is now */
|
|
8659 }
|
|
8660 }
|
|
8661
|
|
8662 /*
|
|
8663 * If the 'db' flag is set, we need to clear the lines that have been
|
|
8664 * scrolled up at the bottom of the region.
|
|
8665 */
|
|
8666 if (*T_DB && (type == USE_T_DL || type == USE_T_CDL))
|
|
8667 {
|
|
8668 for (i = line_count; i > 0; --i)
|
|
8669 {
|
|
8670 windgoto(cursor_end - i, 0);
|
|
8671 out_str(T_CE); /* erase a line */
|
|
8672 screen_start(); /* don't know where cursor is now */
|
|
8673 }
|
|
8674 }
|
|
8675
|
|
8676 #ifdef FEAT_GUI
|
|
8677 gui_can_update_cursor();
|
|
8678 if (gui.in_use)
|
|
8679 out_flush(); /* always flush after a scroll */
|
|
8680 #endif
|
|
8681
|
|
8682 return OK;
|
|
8683 }
|
|
8684
|
|
8685 /*
|
|
8686 * show the current mode and ruler
|
|
8687 *
|
|
8688 * If clear_cmdline is TRUE, clear the rest of the cmdline.
|
|
8689 * If clear_cmdline is FALSE there may be a message there that needs to be
|
|
8690 * cleared only if a mode is shown.
|
|
8691 * Return the length of the message (0 if no message).
|
|
8692 */
|
|
8693 int
|
|
8694 showmode()
|
|
8695 {
|
|
8696 int need_clear;
|
|
8697 int length = 0;
|
|
8698 int do_mode;
|
|
8699 int attr;
|
|
8700 int nwr_save;
|
|
8701 #ifdef FEAT_INS_EXPAND
|
|
8702 int sub_attr;
|
|
8703 #endif
|
|
8704
|
642
|
8705 do_mode = ((p_smd && msg_silent == 0)
|
|
8706 && ((State & INSERT)
|
|
8707 || restart_edit
|
7
|
8708 #ifdef FEAT_VISUAL
|
|
8709 || VIsual_active
|
|
8710 #endif
|
|
8711 ));
|
|
8712 if (do_mode || Recording)
|
|
8713 {
|
|
8714 /*
|
|
8715 * Don't show mode right now, when not redrawing or inside a mapping.
|
|
8716 * Call char_avail() only when we are going to show something, because
|
|
8717 * it takes a bit of time.
|
|
8718 */
|
|
8719 if (!redrawing() || (char_avail() && !KeyTyped) || msg_silent != 0)
|
|
8720 {
|
|
8721 redraw_cmdline = TRUE; /* show mode later */
|
|
8722 return 0;
|
|
8723 }
|
|
8724
|
|
8725 nwr_save = need_wait_return;
|
|
8726
|
|
8727 /* wait a bit before overwriting an important message */
|
|
8728 check_for_delay(FALSE);
|
|
8729
|
|
8730 /* if the cmdline is more than one line high, erase top lines */
|
|
8731 need_clear = clear_cmdline;
|
|
8732 if (clear_cmdline && cmdline_row < Rows - 1)
|
|
8733 msg_clr_cmdline(); /* will reset clear_cmdline */
|
|
8734
|
|
8735 /* Position on the last line in the window, column 0 */
|
|
8736 msg_pos_mode();
|
|
8737 cursor_off();
|
|
8738 attr = hl_attr(HLF_CM); /* Highlight mode */
|
|
8739 if (do_mode)
|
|
8740 {
|
|
8741 MSG_PUTS_ATTR("--", attr);
|
|
8742 #if defined(FEAT_XIM)
|
|
8743 if (xic != NULL && im_get_status() && !p_imdisable
|
|
8744 && curbuf->b_p_iminsert == B_IMODE_IM)
|
|
8745 # ifdef HAVE_GTK2 /* most of the time, it's not XIM being used */
|
|
8746 MSG_PUTS_ATTR(" IM", attr);
|
|
8747 # else
|
|
8748 MSG_PUTS_ATTR(" XIM", attr);
|
|
8749 # endif
|
|
8750 #endif
|
|
8751 #if defined(FEAT_HANGULIN) && defined(FEAT_GUI)
|
|
8752 if (gui.in_use)
|
|
8753 {
|
|
8754 if (hangul_input_state_get())
|
236
|
8755 MSG_PUTS_ATTR(" \307\321\261\333", attr); /* HANGUL */
|
7
|
8756 }
|
|
8757 #endif
|
|
8758 #ifdef FEAT_INS_EXPAND
|
|
8759 if (edit_submode != NULL) /* CTRL-X in Insert mode */
|
|
8760 {
|
|
8761 /* These messages can get long, avoid a wrap in a narrow
|
|
8762 * window. Prefer showing edit_submode_extra. */
|
|
8763 length = (Rows - msg_row) * Columns - 3;
|
|
8764 if (edit_submode_extra != NULL)
|
|
8765 length -= vim_strsize(edit_submode_extra);
|
|
8766 if (length > 0)
|
|
8767 {
|
|
8768 if (edit_submode_pre != NULL)
|
|
8769 length -= vim_strsize(edit_submode_pre);
|
|
8770 if (length - vim_strsize(edit_submode) > 0)
|
|
8771 {
|
|
8772 if (edit_submode_pre != NULL)
|
|
8773 msg_puts_attr(edit_submode_pre, attr);
|
|
8774 msg_puts_attr(edit_submode, attr);
|
|
8775 }
|
|
8776 if (edit_submode_extra != NULL)
|
|
8777 {
|
|
8778 MSG_PUTS_ATTR(" ", attr); /* add a space in between */
|
|
8779 if ((int)edit_submode_highl < (int)HLF_COUNT)
|
|
8780 sub_attr = hl_attr(edit_submode_highl);
|
|
8781 else
|
|
8782 sub_attr = attr;
|
|
8783 msg_puts_attr(edit_submode_extra, sub_attr);
|
|
8784 }
|
|
8785 }
|
|
8786 length = 0;
|
|
8787 }
|
|
8788 else
|
|
8789 #endif
|
|
8790 {
|
|
8791 #ifdef FEAT_VREPLACE
|
|
8792 if (State & VREPLACE_FLAG)
|
|
8793 MSG_PUTS_ATTR(_(" VREPLACE"), attr);
|
|
8794 else
|
|
8795 #endif
|
|
8796 if (State & REPLACE_FLAG)
|
|
8797 MSG_PUTS_ATTR(_(" REPLACE"), attr);
|
|
8798 else if (State & INSERT)
|
|
8799 {
|
|
8800 #ifdef FEAT_RIGHTLEFT
|
|
8801 if (p_ri)
|
|
8802 MSG_PUTS_ATTR(_(" REVERSE"), attr);
|
|
8803 #endif
|
|
8804 MSG_PUTS_ATTR(_(" INSERT"), attr);
|
|
8805 }
|
|
8806 else if (restart_edit == 'I')
|
|
8807 MSG_PUTS_ATTR(_(" (insert)"), attr);
|
|
8808 else if (restart_edit == 'R')
|
|
8809 MSG_PUTS_ATTR(_(" (replace)"), attr);
|
|
8810 else if (restart_edit == 'V')
|
|
8811 MSG_PUTS_ATTR(_(" (vreplace)"), attr);
|
|
8812 #ifdef FEAT_RIGHTLEFT
|
|
8813 if (p_hkmap)
|
|
8814 MSG_PUTS_ATTR(_(" Hebrew"), attr);
|
|
8815 # ifdef FEAT_FKMAP
|
|
8816 if (p_fkmap)
|
|
8817 MSG_PUTS_ATTR(farsi_text_5, attr);
|
|
8818 # endif
|
|
8819 #endif
|
|
8820 #ifdef FEAT_KEYMAP
|
|
8821 if (State & LANGMAP)
|
|
8822 {
|
|
8823 # ifdef FEAT_ARABIC
|
|
8824 if (curwin->w_p_arab)
|
|
8825 MSG_PUTS_ATTR(_(" Arabic"), attr);
|
|
8826 else
|
|
8827 # endif
|
|
8828 MSG_PUTS_ATTR(_(" (lang)"), attr);
|
|
8829 }
|
|
8830 #endif
|
|
8831 if ((State & INSERT) && p_paste)
|
|
8832 MSG_PUTS_ATTR(_(" (paste)"), attr);
|
|
8833
|
|
8834 #ifdef FEAT_VISUAL
|
|
8835 if (VIsual_active)
|
|
8836 {
|
|
8837 char *p;
|
|
8838
|
|
8839 /* Don't concatenate separate words to avoid translation
|
|
8840 * problems. */
|
|
8841 switch ((VIsual_select ? 4 : 0)
|
|
8842 + (VIsual_mode == Ctrl_V) * 2
|
|
8843 + (VIsual_mode == 'V'))
|
|
8844 {
|
|
8845 case 0: p = N_(" VISUAL"); break;
|
|
8846 case 1: p = N_(" VISUAL LINE"); break;
|
|
8847 case 2: p = N_(" VISUAL BLOCK"); break;
|
|
8848 case 4: p = N_(" SELECT"); break;
|
|
8849 case 5: p = N_(" SELECT LINE"); break;
|
|
8850 default: p = N_(" SELECT BLOCK"); break;
|
|
8851 }
|
|
8852 MSG_PUTS_ATTR(_(p), attr);
|
|
8853 }
|
|
8854 #endif
|
|
8855 MSG_PUTS_ATTR(" --", attr);
|
|
8856 }
|
644
|
8857
|
7
|
8858 need_clear = TRUE;
|
|
8859 }
|
|
8860 if (Recording
|
|
8861 #ifdef FEAT_INS_EXPAND
|
|
8862 && edit_submode == NULL /* otherwise it gets too long */
|
|
8863 #endif
|
|
8864 )
|
|
8865 {
|
|
8866 MSG_PUTS_ATTR(_("recording"), attr);
|
|
8867 need_clear = TRUE;
|
|
8868 }
|
644
|
8869
|
|
8870 mode_displayed = TRUE;
|
7
|
8871 if (need_clear || clear_cmdline)
|
|
8872 msg_clr_eos();
|
|
8873 msg_didout = FALSE; /* overwrite this message */
|
|
8874 length = msg_col;
|
|
8875 msg_col = 0;
|
|
8876 need_wait_return = nwr_save; /* never ask for hit-return for this */
|
|
8877 }
|
|
8878 else if (clear_cmdline && msg_silent == 0)
|
|
8879 /* Clear the whole command line. Will reset "clear_cmdline". */
|
|
8880 msg_clr_cmdline();
|
|
8881
|
|
8882 #ifdef FEAT_CMDL_INFO
|
|
8883 # ifdef FEAT_VISUAL
|
|
8884 /* In Visual mode the size of the selected area must be redrawn. */
|
|
8885 if (VIsual_active)
|
|
8886 clear_showcmd();
|
|
8887 # endif
|
|
8888
|
|
8889 /* If the last window has no status line, the ruler is after the mode
|
|
8890 * message and must be redrawn */
|
|
8891 if (redrawing()
|
|
8892 # ifdef FEAT_WINDOWS
|
|
8893 && lastwin->w_status_height == 0
|
|
8894 # endif
|
|
8895 )
|
|
8896 win_redr_ruler(lastwin, TRUE);
|
|
8897 #endif
|
|
8898 redraw_cmdline = FALSE;
|
|
8899 clear_cmdline = FALSE;
|
|
8900
|
|
8901 return length;
|
|
8902 }
|
|
8903
|
|
8904 /*
|
|
8905 * Position for a mode message.
|
|
8906 */
|
|
8907 static void
|
|
8908 msg_pos_mode()
|
|
8909 {
|
|
8910 msg_col = 0;
|
|
8911 msg_row = Rows - 1;
|
|
8912 }
|
|
8913
|
|
8914 /*
|
|
8915 * Delete mode message. Used when ESC is typed which is expected to end
|
|
8916 * Insert mode (but Insert mode didn't end yet!).
|
644
|
8917 * Caller should check "mode_displayed".
|
7
|
8918 */
|
|
8919 void
|
|
8920 unshowmode(force)
|
|
8921 int force;
|
|
8922 {
|
|
8923 /*
|
|
8924 * Don't delete it right now, when not redrawing or insided a mapping.
|
|
8925 */
|
|
8926 if (!redrawing() || (!force && char_avail() && !KeyTyped))
|
|
8927 redraw_cmdline = TRUE; /* delete mode later */
|
|
8928 else
|
|
8929 {
|
|
8930 msg_pos_mode();
|
|
8931 if (Recording)
|
|
8932 MSG_PUTS_ATTR(_("recording"), hl_attr(HLF_CM));
|
|
8933 msg_clr_eos();
|
|
8934 }
|
|
8935 }
|
|
8936
|
667
|
8937 #if defined(FEAT_WINDOWS)
|
|
8938 /*
|
|
8939 * Draw the tab pages line at the top of the Vim window.
|
|
8940 */
|
|
8941 static void
|
677
|
8942 draw_tabline()
|
667
|
8943 {
|
|
8944 int tabcount = 0;
|
|
8945 tabpage_T *tp;
|
|
8946 int tabwidth;
|
|
8947 int col = 0;
|
673
|
8948 int scol = 0;
|
667
|
8949 int attr;
|
|
8950 win_T *wp;
|
671
|
8951 win_T *cwp;
|
|
8952 int wincount;
|
|
8953 int modified;
|
667
|
8954 int c;
|
|
8955 int len;
|
|
8956 int attr_sel = hl_attr(HLF_TPS);
|
|
8957 int attr_nosel = hl_attr(HLF_TP);
|
|
8958 int attr_fill = hl_attr(HLF_TPF);
|
673
|
8959 char_u *p;
|
677
|
8960 int room;
|
|
8961 int use_sep_chars = (t_colors < 8
|
|
8962 #ifdef FEAT_GUI
|
|
8963 && !gui.in_use
|
|
8964 #endif
|
|
8965 );
|
673
|
8966
|
|
8967 redraw_tabline = FALSE;
|
667
|
8968
|
685
|
8969 #ifdef FEAT_GUI_TABLINE
|
798
|
8970 /* Take care of a GUI tabline. */
|
685
|
8971 if (gui_use_tabline())
|
|
8972 {
|
|
8973 gui_update_tabline();
|
|
8974 return;
|
|
8975 }
|
|
8976 #endif
|
|
8977
|
|
8978 if (tabline_height() < 1)
|
667
|
8979 return;
|
|
8980
|
677
|
8981 #if defined(FEAT_STL_OPT)
|
681
|
8982
|
|
8983 /* Init TabPageIdxs[] to zero: Clicking outside of tabs has no effect. */
|
|
8984 for (scol = 0; scol < Columns; ++scol)
|
|
8985 TabPageIdxs[scol] = 0;
|
|
8986
|
677
|
8987 /* Use the 'tabline' option if it's set. */
|
|
8988 if (*p_tal != NUL)
|
|
8989 {
|
680
|
8990 int save_called_emsg = called_emsg;
|
|
8991
|
|
8992 /* Check for an error. If there is one we would loop in redrawing the
|
|
8993 * screen. Avoid that by making 'tabline' empty. */
|
|
8994 called_emsg = FALSE;
|
677
|
8995 win_redr_custom(NULL, FALSE);
|
680
|
8996 if (called_emsg)
|
|
8997 set_string_option_direct((char_u *)"tabline", -1,
|
694
|
8998 (char_u *)"", OPT_FREE, SID_ERROR);
|
680
|
8999 called_emsg |= save_called_emsg;
|
|
9000 }
|
|
9001 else
|
|
9002 #endif
|
|
9003 {
|
|
9004 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
|
|
9005 ++tabcount;
|
|
9006
|
|
9007 tabwidth = (Columns - 1 + tabcount / 2) / tabcount;
|
|
9008 if (tabwidth < 6)
|
|
9009 tabwidth = 6;
|
|
9010
|
|
9011 attr = attr_nosel;
|
|
9012 tabcount = 0;
|
681
|
9013 scol = 0;
|
699
|
9014 for (tp = first_tabpage; tp != NULL && col < Columns - 4;
|
|
9015 tp = tp->tp_next)
|
680
|
9016 {
|
|
9017 scol = col;
|
|
9018
|
|
9019 if (tp->tp_topframe == topframe)
|
|
9020 attr = attr_sel;
|
|
9021 if (use_sep_chars && col > 0)
|
|
9022 screen_putchar('|', 0, col++, attr);
|
|
9023
|
|
9024 if (tp->tp_topframe != topframe)
|
|
9025 attr = attr_nosel;
|
|
9026
|
|
9027 screen_putchar(' ', 0, col++, attr);
|
|
9028
|
|
9029 if (tp == curtab)
|
|
9030 {
|
|
9031 cwp = curwin;
|
|
9032 wp = firstwin;
|
|
9033 }
|
|
9034 else
|
|
9035 {
|
|
9036 cwp = tp->tp_curwin;
|
|
9037 wp = tp->tp_firstwin;
|
|
9038 }
|
|
9039
|
|
9040 modified = FALSE;
|
|
9041 for (wincount = 0; wp != NULL; wp = wp->w_next, ++wincount)
|
|
9042 if (bufIsChanged(wp->w_buffer))
|
|
9043 modified = TRUE;
|
|
9044 if (modified || wincount > 1)
|
|
9045 {
|
|
9046 if (wincount > 1)
|
|
9047 {
|
|
9048 vim_snprintf((char *)NameBuff, MAXPATHL, "%d", wincount);
|
835
|
9049 len = (int)STRLEN(NameBuff);
|
699
|
9050 if (col + len >= Columns - 3)
|
|
9051 break;
|
680
|
9052 screen_puts_len(NameBuff, len, 0, col,
|
677
|
9053 #if defined(FEAT_SYN_HL)
|
680
|
9054 hl_combine_attr(attr, hl_attr(HLF_T))
|
677
|
9055 #else
|
680
|
9056 attr
|
|
9057 #endif
|
|
9058 );
|
|
9059 col += len;
|
|
9060 }
|
|
9061 if (modified)
|
|
9062 screen_puts_len((char_u *)"+", 1, 0, col++, attr);
|
|
9063 screen_putchar(' ', 0, col++, attr);
|
|
9064 }
|
|
9065
|
|
9066 room = scol - col + tabwidth - 1;
|
|
9067 if (room > 0)
|
|
9068 {
|
685
|
9069 /* Get buffer name in NameBuff[] */
|
|
9070 get_trans_bufname(cwp->w_buffer);
|
819
|
9071 shorten_dir(NameBuff);
|
680
|
9072 len = vim_strsize(NameBuff);
|
|
9073 p = NameBuff;
|
677
|
9074 #ifdef FEAT_MBYTE
|
680
|
9075 if (has_mbyte)
|
|
9076 while (len > room)
|
|
9077 {
|
|
9078 len -= ptr2cells(p);
|
|
9079 mb_ptr_adv(p);
|
|
9080 }
|
|
9081 else
|
|
9082 #endif
|
|
9083 if (len > room)
|
677
|
9084 {
|
680
|
9085 p += len - room;
|
|
9086 len = room;
|
677
|
9087 }
|
699
|
9088 if (len > Columns - col - 1)
|
|
9089 len = Columns - col - 1;
|
680
|
9090
|
835
|
9091 screen_puts_len(p, (int)STRLEN(p), 0, col, attr);
|
680
|
9092 col += len;
|
|
9093 }
|
|
9094 screen_putchar(' ', 0, col++, attr);
|
|
9095
|
|
9096 /* Store the tab page number in TabPageIdxs[], so that
|
|
9097 * jump_to_mouse() knows where each one is. */
|
|
9098 ++tabcount;
|
|
9099 while (scol < col)
|
|
9100 TabPageIdxs[scol++] = tabcount;
|
|
9101 }
|
|
9102
|
|
9103 if (use_sep_chars)
|
|
9104 c = '_';
|
|
9105 else
|
|
9106 c = ' ';
|
|
9107 screen_fill(0, 1, col, (int)Columns, c, c, attr_fill);
|
681
|
9108
|
|
9109 /* Put an "X" for closing the current tab if there are several. */
|
|
9110 if (first_tabpage->tp_next != NULL)
|
|
9111 {
|
|
9112 screen_putchar('X', 0, (int)Columns - 1, attr_nosel);
|
|
9113 TabPageIdxs[Columns - 1] = -999;
|
|
9114 }
|
|
9115 }
|
834
|
9116
|
|
9117 /* Reset the flag here again, in case evaluating 'tabline' causes it to be
|
|
9118 * set. */
|
|
9119 redraw_tabline = FALSE;
|
667
|
9120 }
|
685
|
9121
|
|
9122 /*
|
|
9123 * Get buffer name for "buf" into NameBuff[].
|
|
9124 * Takes care of special buffer names and translates special characters.
|
|
9125 */
|
|
9126 void
|
|
9127 get_trans_bufname(buf)
|
|
9128 buf_T *buf;
|
|
9129 {
|
|
9130 if (buf_spname(buf) != NULL)
|
|
9131 STRCPY(NameBuff, buf_spname(buf));
|
|
9132 else
|
|
9133 home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
|
|
9134 trans_characters(NameBuff, MAXPATHL);
|
|
9135 }
|
667
|
9136 #endif
|
|
9137
|
7
|
9138 #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT)
|
|
9139 /*
|
|
9140 * Get the character to use in a status line. Get its attributes in "*attr".
|
|
9141 */
|
|
9142 static int
|
|
9143 fillchar_status(attr, is_curwin)
|
|
9144 int *attr;
|
|
9145 int is_curwin;
|
|
9146 {
|
|
9147 int fill;
|
|
9148 if (is_curwin)
|
|
9149 {
|
|
9150 *attr = hl_attr(HLF_S);
|
|
9151 fill = fill_stl;
|
|
9152 }
|
|
9153 else
|
|
9154 {
|
|
9155 *attr = hl_attr(HLF_SNC);
|
|
9156 fill = fill_stlnc;
|
|
9157 }
|
|
9158 /* Use fill when there is highlighting, and highlighting of current
|
|
9159 * window differs, or the fillchars differ, or this is not the
|
|
9160 * current window */
|
|
9161 if (*attr != 0 && ((hl_attr(HLF_S) != hl_attr(HLF_SNC)
|
|
9162 || !is_curwin || firstwin == lastwin)
|
|
9163 || (fill_stl != fill_stlnc)))
|
|
9164 return fill;
|
|
9165 if (is_curwin)
|
|
9166 return '^';
|
|
9167 return '=';
|
|
9168 }
|
|
9169 #endif
|
|
9170
|
|
9171 #ifdef FEAT_VERTSPLIT
|
|
9172 /*
|
|
9173 * Get the character to use in a separator between vertically split windows.
|
|
9174 * Get its attributes in "*attr".
|
|
9175 */
|
|
9176 static int
|
|
9177 fillchar_vsep(attr)
|
|
9178 int *attr;
|
|
9179 {
|
|
9180 *attr = hl_attr(HLF_C);
|
|
9181 if (*attr == 0 && fill_vert == ' ')
|
|
9182 return '|';
|
|
9183 else
|
|
9184 return fill_vert;
|
|
9185 }
|
|
9186 #endif
|
|
9187
|
|
9188 /*
|
|
9189 * Return TRUE if redrawing should currently be done.
|
|
9190 */
|
|
9191 int
|
|
9192 redrawing()
|
|
9193 {
|
|
9194 return (!RedrawingDisabled
|
|
9195 && !(p_lz && char_avail() && !KeyTyped && !do_redraw));
|
|
9196 }
|
|
9197
|
|
9198 /*
|
|
9199 * Return TRUE if printing messages should currently be done.
|
|
9200 */
|
|
9201 int
|
|
9202 messaging()
|
|
9203 {
|
|
9204 return (!(p_lz && char_avail() && !KeyTyped));
|
|
9205 }
|
|
9206
|
|
9207 /*
|
|
9208 * Show current status info in ruler and various other places
|
|
9209 * If always is FALSE, only show ruler if position has changed.
|
|
9210 */
|
|
9211 void
|
|
9212 showruler(always)
|
|
9213 int always;
|
|
9214 {
|
|
9215 if (!always && !redrawing())
|
|
9216 return;
|
574
|
9217 #ifdef FEAT_INS_EXPAND
|
|
9218 if (pum_visible())
|
|
9219 {
|
639
|
9220 # ifdef FEAT_WINDOWS
|
574
|
9221 /* Don't redraw right now, do it later. */
|
|
9222 curwin->w_redr_status = TRUE;
|
639
|
9223 # endif
|
574
|
9224 return;
|
|
9225 }
|
|
9226 #endif
|
7
|
9227 #if defined(FEAT_STL_OPT) && defined(FEAT_WINDOWS)
|
40
|
9228 if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)
|
680
|
9229 {
|
|
9230 redraw_custum_statusline(curwin);
|
|
9231 }
|
7
|
9232 else
|
|
9233 #endif
|
|
9234 #ifdef FEAT_CMDL_INFO
|
|
9235 win_redr_ruler(curwin, always);
|
|
9236 #endif
|
|
9237
|
|
9238 #ifdef FEAT_TITLE
|
|
9239 if (need_maketitle
|
|
9240 # ifdef FEAT_STL_OPT
|
|
9241 || (p_icon && (stl_syntax & STL_IN_ICON))
|
|
9242 || (p_title && (stl_syntax & STL_IN_TITLE))
|
|
9243 # endif
|
|
9244 )
|
|
9245 maketitle();
|
|
9246 #endif
|
|
9247 }
|
|
9248
|
|
9249 #ifdef FEAT_CMDL_INFO
|
|
9250 static void
|
|
9251 win_redr_ruler(wp, always)
|
|
9252 win_T *wp;
|
|
9253 int always;
|
|
9254 {
|
|
9255 char_u buffer[70];
|
|
9256 int row;
|
|
9257 int fillchar;
|
|
9258 int attr;
|
|
9259 int empty_line = FALSE;
|
|
9260 colnr_T virtcol;
|
|
9261 int i;
|
|
9262 int o;
|
|
9263 #ifdef FEAT_VERTSPLIT
|
|
9264 int this_ru_col;
|
|
9265 int off = 0;
|
|
9266 int width = Columns;
|
|
9267 # define WITH_OFF(x) x
|
|
9268 # define WITH_WIDTH(x) x
|
|
9269 #else
|
|
9270 # define WITH_OFF(x) 0
|
|
9271 # define WITH_WIDTH(x) Columns
|
|
9272 # define this_ru_col ru_col
|
|
9273 #endif
|
|
9274
|
|
9275 /* If 'ruler' off or redrawing disabled, don't do anything */
|
|
9276 if (!p_ru)
|
|
9277 return;
|
|
9278
|
|
9279 /*
|
|
9280 * Check if cursor.lnum is valid, since win_redr_ruler() may be called
|
|
9281 * after deleting lines, before cursor.lnum is corrected.
|
|
9282 */
|
|
9283 if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count)
|
|
9284 return;
|
|
9285
|
|
9286 #ifdef FEAT_INS_EXPAND
|
|
9287 /* Don't draw the ruler while doing insert-completion, it might overwrite
|
|
9288 * the (long) mode message. */
|
|
9289 # ifdef FEAT_WINDOWS
|
|
9290 if (wp == lastwin && lastwin->w_status_height == 0)
|
|
9291 # endif
|
|
9292 if (edit_submode != NULL)
|
|
9293 return;
|
540
|
9294 /* Don't draw the ruler when the popup menu is visible, it may overlap. */
|
|
9295 if (pum_visible())
|
|
9296 return;
|
7
|
9297 #endif
|
|
9298
|
|
9299 #ifdef FEAT_STL_OPT
|
|
9300 if (*p_ruf)
|
|
9301 {
|
680
|
9302 int save_called_emsg = called_emsg;
|
|
9303
|
|
9304 called_emsg = FALSE;
|
7
|
9305 win_redr_custom(wp, TRUE);
|
680
|
9306 if (called_emsg)
|
|
9307 set_string_option_direct((char_u *)"rulerformat", -1,
|
694
|
9308 (char_u *)"", OPT_FREE, SID_ERROR);
|
680
|
9309 called_emsg |= save_called_emsg;
|
7
|
9310 return;
|
|
9311 }
|
|
9312 #endif
|
|
9313
|
|
9314 /*
|
|
9315 * Check if not in Insert mode and the line is empty (will show "0-1").
|
|
9316 */
|
|
9317 if (!(State & INSERT)
|
|
9318 && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == NUL)
|
|
9319 empty_line = TRUE;
|
|
9320
|
|
9321 /*
|
|
9322 * Only draw the ruler when something changed.
|
|
9323 */
|
|
9324 validate_virtcol_win(wp);
|
|
9325 if ( redraw_cmdline
|
|
9326 || always
|
|
9327 || wp->w_cursor.lnum != wp->w_ru_cursor.lnum
|
|
9328 || wp->w_cursor.col != wp->w_ru_cursor.col
|
|
9329 || wp->w_virtcol != wp->w_ru_virtcol
|
|
9330 #ifdef FEAT_VIRTUALEDIT
|
|
9331 || wp->w_cursor.coladd != wp->w_ru_cursor.coladd
|
|
9332 #endif
|
|
9333 || wp->w_topline != wp->w_ru_topline
|
|
9334 || wp->w_buffer->b_ml.ml_line_count != wp->w_ru_line_count
|
|
9335 #ifdef FEAT_DIFF
|
|
9336 || wp->w_topfill != wp->w_ru_topfill
|
|
9337 #endif
|
|
9338 || empty_line != wp->w_ru_empty)
|
|
9339 {
|
|
9340 cursor_off();
|
|
9341 #ifdef FEAT_WINDOWS
|
|
9342 if (wp->w_status_height)
|
|
9343 {
|
|
9344 row = W_WINROW(wp) + wp->w_height;
|
|
9345 fillchar = fillchar_status(&attr, wp == curwin);
|
|
9346 # ifdef FEAT_VERTSPLIT
|
|
9347 off = W_WINCOL(wp);
|
|
9348 width = W_WIDTH(wp);
|
|
9349 # endif
|
|
9350 }
|
|
9351 else
|
|
9352 #endif
|
|
9353 {
|
|
9354 row = Rows - 1;
|
|
9355 fillchar = ' ';
|
|
9356 attr = 0;
|
|
9357 #ifdef FEAT_VERTSPLIT
|
|
9358 width = Columns;
|
|
9359 off = 0;
|
|
9360 #endif
|
|
9361 }
|
|
9362
|
|
9363 /* In list mode virtcol needs to be recomputed */
|
|
9364 virtcol = wp->w_virtcol;
|
|
9365 if (wp->w_p_list && lcs_tab1 == NUL)
|
|
9366 {
|
|
9367 wp->w_p_list = FALSE;
|
|
9368 getvvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL);
|
|
9369 wp->w_p_list = TRUE;
|
|
9370 }
|
|
9371
|
|
9372 /*
|
|
9373 * Some sprintfs return the length, some return a pointer.
|
|
9374 * To avoid portability problems we use strlen() here.
|
|
9375 */
|
|
9376 sprintf((char *)buffer, "%ld,",
|
|
9377 (wp->w_buffer->b_ml.ml_flags & ML_EMPTY)
|
|
9378 ? 0L
|
|
9379 : (long)(wp->w_cursor.lnum));
|
|
9380 col_print(buffer + STRLEN(buffer),
|
|
9381 empty_line ? 0 : (int)wp->w_cursor.col + 1,
|
|
9382 (int)virtcol + 1);
|
|
9383
|
|
9384 /*
|
|
9385 * Add a "50%" if there is room for it.
|
|
9386 * On the last line, don't print in the last column (scrolls the
|
|
9387 * screen up on some terminals).
|
|
9388 */
|
|
9389 i = (int)STRLEN(buffer);
|
|
9390 get_rel_pos(wp, buffer + i + 1);
|
|
9391 o = i + vim_strsize(buffer + i + 1);
|
|
9392 #ifdef FEAT_WINDOWS
|
|
9393 if (wp->w_status_height == 0) /* can't use last char of screen */
|
|
9394 #endif
|
|
9395 ++o;
|
|
9396 #ifdef FEAT_VERTSPLIT
|
|
9397 this_ru_col = ru_col - (Columns - width);
|
|
9398 if (this_ru_col < 0)
|
|
9399 this_ru_col = 0;
|
|
9400 #endif
|
|
9401 /* Never use more than half the window/screen width, leave the other
|
|
9402 * half for the filename. */
|
|
9403 if (this_ru_col < (WITH_WIDTH(width) + 1) / 2)
|
|
9404 this_ru_col = (WITH_WIDTH(width) + 1) / 2;
|
|
9405 if (this_ru_col + o < WITH_WIDTH(width))
|
|
9406 {
|
|
9407 while (this_ru_col + o < WITH_WIDTH(width))
|
|
9408 {
|
|
9409 #ifdef FEAT_MBYTE
|
|
9410 if (has_mbyte)
|
|
9411 i += (*mb_char2bytes)(fillchar, buffer + i);
|
|
9412 else
|
|
9413 #endif
|
|
9414 buffer[i++] = fillchar;
|
|
9415 ++o;
|
|
9416 }
|
|
9417 get_rel_pos(wp, buffer + i);
|
|
9418 }
|
|
9419 /* Truncate at window boundary. */
|
|
9420 #ifdef FEAT_MBYTE
|
|
9421 if (has_mbyte)
|
|
9422 {
|
|
9423 o = 0;
|
474
|
9424 for (i = 0; buffer[i] != NUL; i += (*mb_ptr2len)(buffer + i))
|
7
|
9425 {
|
|
9426 o += (*mb_ptr2cells)(buffer + i);
|
|
9427 if (this_ru_col + o > WITH_WIDTH(width))
|
|
9428 {
|
|
9429 buffer[i] = NUL;
|
|
9430 break;
|
|
9431 }
|
|
9432 }
|
|
9433 }
|
|
9434 else
|
|
9435 #endif
|
|
9436 if (this_ru_col + (int)STRLEN(buffer) > WITH_WIDTH(width))
|
|
9437 buffer[WITH_WIDTH(width) - this_ru_col] = NUL;
|
|
9438
|
|
9439 screen_puts(buffer, row, this_ru_col + WITH_OFF(off), attr);
|
|
9440 i = redraw_cmdline;
|
|
9441 screen_fill(row, row + 1,
|
|
9442 this_ru_col + WITH_OFF(off) + (int)STRLEN(buffer),
|
|
9443 (int)(WITH_OFF(off) + WITH_WIDTH(width)),
|
|
9444 fillchar, fillchar, attr);
|
|
9445 /* don't redraw the cmdline because of showing the ruler */
|
|
9446 redraw_cmdline = i;
|
|
9447 wp->w_ru_cursor = wp->w_cursor;
|
|
9448 wp->w_ru_virtcol = wp->w_virtcol;
|
|
9449 wp->w_ru_empty = empty_line;
|
|
9450 wp->w_ru_topline = wp->w_topline;
|
|
9451 wp->w_ru_line_count = wp->w_buffer->b_ml.ml_line_count;
|
|
9452 #ifdef FEAT_DIFF
|
|
9453 wp->w_ru_topfill = wp->w_topfill;
|
|
9454 #endif
|
|
9455 }
|
|
9456 }
|
|
9457 #endif
|
13
|
9458
|
|
9459 #if defined(FEAT_LINEBREAK) || defined(PROTO)
|
|
9460 /*
|
|
9461 * Return the width of the 'number' column.
|
677
|
9462 * Caller may need to check if 'number' is set.
|
13
|
9463 * Otherwise it depends on 'numberwidth' and the line count.
|
|
9464 */
|
|
9465 int
|
|
9466 number_width(wp)
|
|
9467 win_T *wp;
|
|
9468 {
|
|
9469 int n;
|
|
9470 linenr_T lnum;
|
|
9471
|
|
9472 lnum = wp->w_buffer->b_ml.ml_line_count;
|
|
9473 if (lnum == wp->w_nrwidth_line_count)
|
|
9474 return wp->w_nrwidth_width;
|
|
9475 wp->w_nrwidth_line_count = lnum;
|
|
9476
|
|
9477 n = 0;
|
|
9478 do
|
|
9479 {
|
856
|
9480 lnum /= 10;
|
|
9481 ++n;
|
13
|
9482 } while (lnum > 0);
|
|
9483
|
|
9484 /* 'numberwidth' gives the minimal width plus one */
|
|
9485 if (n < wp->w_p_nuw - 1)
|
|
9486 n = wp->w_p_nuw - 1;
|
|
9487
|
|
9488 wp->w_nrwidth_width = n;
|
|
9489 return n;
|
|
9490 }
|
|
9491 #endif
|