blob: 6b9cbc628718ecbc902332a4982b0413c7f3dba0 [file] [log] [blame]
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001/* vi:set ts=8 sts=4 sw=4 noet:
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 * drawline.c: Functions for drawing window lines on the screen.
12 * This is the middle level, drawscreen. is the higher level and screen.c the
13 * lower level.
14 */
15
16#include "vim.h"
17
18#ifdef FEAT_SYN_HL
19/*
20 * Advance **color_cols and return TRUE when there are columns to draw.
21 */
22 static int
23advance_color_col(int vcol, int **color_cols)
24{
25 while (**color_cols >= 0 && vcol > **color_cols)
26 ++*color_cols;
27 return (**color_cols >= 0);
28}
29#endif
30
31#ifdef FEAT_SYN_HL
32/*
33 * Used when 'cursorlineopt' contains "screenline": compute the margins between
34 * which the highlighting is used.
35 */
36 static void
37margin_columns_win(win_T *wp, int *left_col, int *right_col)
38{
39 // cache previous calculations depending on w_virtcol
40 static int saved_w_virtcol;
41 static win_T *prev_wp;
42 static int prev_left_col;
43 static int prev_right_col;
44 static int prev_col_off;
45
46 int cur_col_off = win_col_off(wp);
47 int width1;
48 int width2;
49
50 if (saved_w_virtcol == wp->w_virtcol
51 && prev_wp == wp && prev_col_off == cur_col_off)
52 {
53 *right_col = prev_right_col;
54 *left_col = prev_left_col;
55 return;
56 }
57
58 width1 = wp->w_width - cur_col_off;
59 width2 = width1 + win_col_off2(wp);
60
61 *left_col = 0;
62 *right_col = width1;
63
64 if (wp->w_virtcol >= (colnr_T)width1)
65 *right_col = width1 + ((wp->w_virtcol - width1) / width2 + 1) * width2;
66 if (wp->w_virtcol >= (colnr_T)width1 && width2 > 0)
67 *left_col = (wp->w_virtcol - width1) / width2 * width2 + width1;
68
69 // cache values
70 prev_left_col = *left_col;
71 prev_right_col = *right_col;
72 prev_wp = wp;
73 saved_w_virtcol = wp->w_virtcol;
74 prev_col_off = cur_col_off;
75}
76#endif
77
78#ifdef FEAT_SIGNS
79/*
80 * Get information needed to display the sign in line 'lnum' in window 'wp'.
81 * If 'nrcol' is TRUE, the sign is going to be displayed in the number column.
82 * Otherwise the sign is going to be displayed in the sign column.
83 */
84 static void
85get_sign_display_info(
86 int nrcol,
87 win_T *wp,
88 linenr_T lnum UNUSED,
89 sign_attrs_T *sattr,
90 int wcr_attr,
91 int row,
92 int startrow,
93 int filler_lines UNUSED,
94 int filler_todo UNUSED,
95 int *c_extrap,
96 int *c_finalp,
97 char_u *extra,
98 char_u **pp_extra,
99 int *n_extrap,
100 int *char_attrp)
101{
102 int text_sign;
103# ifdef FEAT_SIGN_ICONS
104 int icon_sign;
105# endif
106
107 // Draw two cells with the sign value or blank.
108 *c_extrap = ' ';
109 *c_finalp = NUL;
110 if (nrcol)
111 *n_extrap = number_width(wp) + 1;
112 else
113 {
114 *char_attrp = hl_combine_attr(wcr_attr, HL_ATTR(HLF_SC));
115 *n_extrap = 2;
116 }
117
118 if (row == startrow
119#ifdef FEAT_DIFF
120 + filler_lines && filler_todo <= 0
121#endif
122 )
123 {
Bram Moolenaar6656c2e2019-10-24 15:00:04 +0200124 text_sign = (sattr->sat_text != NULL) ? sattr->sat_typenr : 0;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200125# ifdef FEAT_SIGN_ICONS
Bram Moolenaar6656c2e2019-10-24 15:00:04 +0200126 icon_sign = (sattr->sat_icon != NULL) ? sattr->sat_typenr : 0;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200127 if (gui.in_use && icon_sign != 0)
128 {
129 // Use the image in this position.
130 if (nrcol)
131 {
132 *c_extrap = NUL;
133 sprintf((char *)extra, "%-*c ", number_width(wp), SIGN_BYTE);
134 *pp_extra = extra;
135 *n_extrap = (int)STRLEN(*pp_extra);
136 }
137 else
138 *c_extrap = SIGN_BYTE;
139# ifdef FEAT_NETBEANS_INTG
140 if (netbeans_active() && (buf_signcount(wp->w_buffer, lnum) > 1))
141 {
142 if (nrcol)
143 {
144 *c_extrap = NUL;
145 sprintf((char *)extra, "%-*c ", number_width(wp),
146 MULTISIGN_BYTE);
147 *pp_extra = extra;
148 *n_extrap = (int)STRLEN(*pp_extra);
149 }
150 else
151 *c_extrap = MULTISIGN_BYTE;
152 }
153# endif
154 *c_finalp = NUL;
155 *char_attrp = icon_sign;
156 }
157 else
158# endif
159 if (text_sign != 0)
160 {
Bram Moolenaar6656c2e2019-10-24 15:00:04 +0200161 *pp_extra = sattr->sat_text;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200162 if (*pp_extra != NULL)
163 {
164 if (nrcol)
165 {
166 int n, width = number_width(wp) - 2;
167
168 for (n = 0; n < width; n++)
169 extra[n] = ' ';
170 extra[n] = 0;
171 STRCAT(extra, *pp_extra);
172 STRCAT(extra, " ");
173 *pp_extra = extra;
174 }
175 *c_extrap = NUL;
176 *c_finalp = NUL;
177 *n_extrap = (int)STRLEN(*pp_extra);
178 }
Bram Moolenaar6656c2e2019-10-24 15:00:04 +0200179 *char_attrp = sattr->sat_texthl;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200180 }
181 }
182}
183#endif
184
Bram Moolenaar05ad5ff2019-11-30 22:48:27 +0100185#ifdef FEAT_PROP_POPUP
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200186static textprop_T *current_text_props = NULL;
187static buf_T *current_buf = NULL;
188
189 static int
190text_prop_compare(const void *s1, const void *s2)
191{
192 int idx1, idx2;
193 proptype_T *pt1, *pt2;
194 colnr_T col1, col2;
195
196 idx1 = *(int *)s1;
197 idx2 = *(int *)s2;
198 pt1 = text_prop_type_by_id(current_buf, current_text_props[idx1].tp_type);
199 pt2 = text_prop_type_by_id(current_buf, current_text_props[idx2].tp_type);
200 if (pt1 == pt2)
201 return 0;
202 if (pt1 == NULL)
203 return -1;
204 if (pt2 == NULL)
205 return 1;
206 if (pt1->pt_priority != pt2->pt_priority)
207 return pt1->pt_priority > pt2->pt_priority ? 1 : -1;
208 col1 = current_text_props[idx1].tp_col;
209 col2 = current_text_props[idx2].tp_col;
210 return col1 == col2 ? 0 : col1 > col2 ? 1 : -1;
211}
212#endif
213
214/*
215 * Display line "lnum" of window 'wp' on the screen.
216 * Start at row "startrow", stop when "endrow" is reached.
217 * wp->w_virtcol needs to be valid.
218 *
219 * Return the number of last row the line occupies.
220 */
221 int
222win_line(
223 win_T *wp,
224 linenr_T lnum,
225 int startrow,
226 int endrow,
227 int nochange UNUSED, // not updating for changed text
228 int number_only) // only update the number column
229{
230 int col = 0; // visual column on screen
231 unsigned off; // offset in ScreenLines/ScreenAttrs
232 int c = 0; // init for GCC
233 long vcol = 0; // virtual column (for tabs)
234#ifdef FEAT_LINEBREAK
235 long vcol_sbr = -1; // virtual column after showbreak
236#endif
237 long vcol_prev = -1; // "vcol" of previous character
238 char_u *line; // current line
239 char_u *ptr; // current position in "line"
240 int row; // row in the window, excl w_winrow
241 int screen_row; // row on the screen, incl w_winrow
242
243 char_u extra[21]; // "%ld " and 'fdc' must fit in here
244 int n_extra = 0; // number of extra chars
245 char_u *p_extra = NULL; // string of extra chars, plus NUL
246 char_u *p_extra_free = NULL; // p_extra needs to be freed
247 int c_extra = NUL; // extra chars, all the same
248 int c_final = NUL; // final char, mandatory if set
249 int extra_attr = 0; // attributes when n_extra != 0
250 static char_u *at_end_str = (char_u *)""; // used for p_extra when
251 // displaying lcs_eol at end-of-line
252 int lcs_eol_one = lcs_eol; // lcs_eol until it's been used
253 int lcs_prec_todo = lcs_prec; // lcs_prec until it's been used
254
255 // saved "extra" items for when draw_state becomes WL_LINE (again)
256 int saved_n_extra = 0;
257 char_u *saved_p_extra = NULL;
258 int saved_c_extra = 0;
259 int saved_c_final = 0;
260 int saved_char_attr = 0;
261
262 int n_attr = 0; // chars with special attr
263 int saved_attr2 = 0; // char_attr saved for n_attr
264 int n_attr3 = 0; // chars with overruling special attr
265 int saved_attr3 = 0; // char_attr saved for n_attr3
266
267 int n_skip = 0; // nr of chars to skip for 'nowrap'
268
269 int fromcol = -10; // start of inverting
270 int tocol = MAXCOL; // end of inverting
271 int fromcol_prev = -2; // start of inverting after cursor
272 int noinvcur = FALSE; // don't invert the cursor
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200273 int lnum_in_visual_area = FALSE;
274 pos_T pos;
275 long v;
276
277 int char_attr = 0; // attributes for next character
278 int attr_pri = FALSE; // char_attr has priority
279 int area_highlighting = FALSE; // Visual or incsearch highlighting
280 // in this line
281 int vi_attr = 0; // attributes for Visual and incsearch
282 // highlighting
283 int wcr_attr = 0; // attributes from 'wincolor'
284 int win_attr = 0; // background for whole window, except
285 // margins and "~" lines.
286 int area_attr = 0; // attributes desired by highlighting
287 int search_attr = 0; // attributes desired by 'hlsearch'
288#ifdef FEAT_SYN_HL
289 int vcol_save_attr = 0; // saved attr for 'cursorcolumn'
290 int syntax_attr = 0; // attributes desired by syntax
Bram Moolenaar9115c612019-10-16 16:57:06 +0200291 int prev_syntax_col = -1; // column of prev_syntax_attr
292 int prev_syntax_attr = 0; // syntax_attr at prev_syntax_col
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200293 int has_syntax = FALSE; // this buffer has syntax highl.
294 int save_did_emsg;
295 int draw_color_col = FALSE; // highlight colorcolumn
296 int *color_cols = NULL; // pointer to according columns array
297#endif
298 int eol_hl_off = 0; // 1 if highlighted char after EOL
Bram Moolenaar05ad5ff2019-11-30 22:48:27 +0100299#ifdef FEAT_PROP_POPUP
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200300 int text_prop_count;
301 int text_prop_next = 0; // next text property to use
302 textprop_T *text_props = NULL;
303 int *text_prop_idxs = NULL;
304 int text_props_active = 0;
305 proptype_T *text_prop_type = NULL;
306 int text_prop_attr = 0;
307 int text_prop_combine = FALSE;
308#endif
309#ifdef FEAT_SPELL
310 int has_spell = FALSE; // this buffer has spell checking
Bram Moolenaar34390282019-10-16 14:38:26 +0200311 int can_spell;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200312# define SPWORDLEN 150
313 char_u nextline[SPWORDLEN * 2];// text with start of the next line
314 int nextlinecol = 0; // column where nextline[] starts
315 int nextline_idx = 0; // index in nextline[] where next line
316 // starts
317 int spell_attr = 0; // attributes desired by spelling
318 int word_end = 0; // last byte with same spell_attr
319 static linenr_T checked_lnum = 0; // line number for "checked_col"
320 static int checked_col = 0; // column in "checked_lnum" up to which
321 // there are no spell errors
322 static int cap_col = -1; // column to check for Cap word
323 static linenr_T capcol_lnum = 0; // line number where "cap_col" used
324 int cur_checked_col = 0; // checked column for current line
325#endif
326 int extra_check = 0; // has extra highlighting
327 int multi_attr = 0; // attributes desired by multibyte
328 int mb_l = 1; // multi-byte byte length
329 int mb_c = 0; // decoded multi-byte character
330 int mb_utf8 = FALSE; // screen char is UTF-8 char
331 int u8cc[MAX_MCO]; // composing UTF-8 chars
332#if defined(FEAT_DIFF) || defined(FEAT_SIGNS)
333 int filler_lines = 0; // nr of filler lines to be drawn
334 int filler_todo = 0; // nr of filler lines still to do + 1
335#endif
336#ifdef FEAT_DIFF
337 hlf_T diff_hlf = (hlf_T)0; // type of diff highlighting
338 int change_start = MAXCOL; // first col of changed area
339 int change_end = -1; // last col of changed area
340#endif
341 colnr_T trailcol = MAXCOL; // start of trailing spaces
342#ifdef FEAT_LINEBREAK
343 int need_showbreak = FALSE; // overlong line, skipping first x
344 // chars
345#endif
346#if defined(FEAT_SIGNS) || defined(FEAT_QUICKFIX) \
347 || defined(FEAT_SYN_HL) || defined(FEAT_DIFF)
348# define LINE_ATTR
349 int line_attr = 0; // attribute for the whole line
350 int line_attr_save;
351#endif
352#ifdef FEAT_SIGNS
353 int sign_present = FALSE;
354 sign_attrs_T sattr;
355#endif
356#ifdef FEAT_ARABIC
357 int prev_c = 0; // previous Arabic character
358 int prev_c1 = 0; // first composing char for prev_c
359#endif
360#if defined(LINE_ATTR)
361 int did_line_attr = 0;
362#endif
363#ifdef FEAT_TERMINAL
364 int get_term_attr = FALSE;
365#endif
366#ifdef FEAT_SYN_HL
367 int cul_attr = 0; // set when 'cursorline' active
368
369 // 'cursorlineopt' has "screenline" and cursor is in this line
370 int cul_screenline = FALSE;
371
372 // margin columns for the screen line, needed for when 'cursorlineopt'
373 // contains "screenline"
374 int left_curline_col = 0;
375 int right_curline_col = 0;
376#endif
377
378 // draw_state: items that are drawn in sequence:
379#define WL_START 0 // nothing done yet
380#ifdef FEAT_CMDWIN
381# define WL_CMDLINE WL_START + 1 // cmdline window column
382#else
383# define WL_CMDLINE WL_START
384#endif
385#ifdef FEAT_FOLDING
386# define WL_FOLD WL_CMDLINE + 1 // 'foldcolumn'
387#else
388# define WL_FOLD WL_CMDLINE
389#endif
390#ifdef FEAT_SIGNS
391# define WL_SIGN WL_FOLD + 1 // column for signs
392#else
393# define WL_SIGN WL_FOLD // column for signs
394#endif
395#define WL_NR WL_SIGN + 1 // line number
396#ifdef FEAT_LINEBREAK
397# define WL_BRI WL_NR + 1 // 'breakindent'
398#else
399# define WL_BRI WL_NR
400#endif
401#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
402# define WL_SBR WL_BRI + 1 // 'showbreak' or 'diff'
403#else
404# define WL_SBR WL_BRI
405#endif
406#define WL_LINE WL_SBR + 1 // text in the line
407 int draw_state = WL_START; // what to draw next
408#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
409 int feedback_col = 0;
410 int feedback_old_attr = -1;
411#endif
412 int screen_line_flags = 0;
413
414#if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA)
415 int match_conc = 0; // cchar for match functions
416#endif
417#ifdef FEAT_CONCEAL
418 int syntax_flags = 0;
419 int syntax_seqnr = 0;
420 int prev_syntax_id = 0;
421 int conceal_attr = HL_ATTR(HLF_CONCEAL);
422 int is_concealing = FALSE;
423 int boguscols = 0; // nonexistent columns added to force
424 // wrapping
425 int vcol_off = 0; // offset for concealed characters
426 int did_wcol = FALSE;
427 int old_boguscols = 0;
428# define VCOL_HLC (vcol - vcol_off)
429# define FIX_FOR_BOGUSCOLS \
430 { \
431 n_extra += vcol_off; \
432 vcol -= vcol_off; \
433 vcol_off = 0; \
434 col -= boguscols; \
435 old_boguscols = boguscols; \
436 boguscols = 0; \
437 }
438#else
439# define VCOL_HLC (vcol)
440#endif
441
442 if (startrow > endrow) // past the end already!
443 return startrow;
444
445 row = startrow;
446 screen_row = row + W_WINROW(wp);
447
448 if (!number_only)
449 {
450 // To speed up the loop below, set extra_check when there is linebreak,
451 // trailing white space and/or syntax processing to be done.
452#ifdef FEAT_LINEBREAK
453 extra_check = wp->w_p_lbr;
454#endif
455#ifdef FEAT_SYN_HL
456 if (syntax_present(wp) && !wp->w_s->b_syn_error
457# ifdef SYN_TIME_LIMIT
458 && !wp->w_s->b_syn_slow
459# endif
460 )
461 {
462 // Prepare for syntax highlighting in this line. When there is an
463 // error, stop syntax highlighting.
464 save_did_emsg = did_emsg;
465 did_emsg = FALSE;
466 syntax_start(wp, lnum);
467 if (did_emsg)
468 wp->w_s->b_syn_error = TRUE;
469 else
470 {
471 did_emsg = save_did_emsg;
472#ifdef SYN_TIME_LIMIT
473 if (!wp->w_s->b_syn_slow)
474#endif
475 {
476 has_syntax = TRUE;
477 extra_check = TRUE;
478 }
479 }
480 }
481
482 // Check for columns to display for 'colorcolumn'.
483 color_cols = wp->w_p_cc_cols;
484 if (color_cols != NULL)
485 draw_color_col = advance_color_col(VCOL_HLC, &color_cols);
486#endif
487
488#ifdef FEAT_TERMINAL
489 if (term_show_buffer(wp->w_buffer))
490 {
491 extra_check = TRUE;
492 get_term_attr = TRUE;
Bram Moolenaar219c7d02020-02-01 21:57:29 +0100493 win_attr = term_get_attr(wp, lnum, -1);
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200494 }
495#endif
496
497#ifdef FEAT_SPELL
498 if (wp->w_p_spell
499 && *wp->w_s->b_p_spl != NUL
500 && wp->w_s->b_langp.ga_len > 0
501 && *(char **)(wp->w_s->b_langp.ga_data) != NULL)
502 {
503 // Prepare for spell checking.
504 has_spell = TRUE;
505 extra_check = TRUE;
506
507 // Get the start of the next line, so that words that wrap to the
508 // next line are found too: "et<line-break>al.".
509 // Trick: skip a few chars for C/shell/Vim comments
510 nextline[SPWORDLEN] = NUL;
511 if (lnum < wp->w_buffer->b_ml.ml_line_count)
512 {
513 line = ml_get_buf(wp->w_buffer, lnum + 1, FALSE);
514 spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN);
515 }
516
517 // When a word wrapped from the previous line the start of the
518 // current line is valid.
519 if (lnum == checked_lnum)
520 cur_checked_col = checked_col;
521 checked_lnum = 0;
522
523 // When there was a sentence end in the previous line may require a
524 // word starting with capital in this line. In line 1 always check
525 // the first word.
526 if (lnum != capcol_lnum)
527 cap_col = -1;
528 if (lnum == 1)
529 cap_col = 0;
530 capcol_lnum = 0;
531 }
532#endif
533
534 // handle Visual active in this window
535 if (VIsual_active && wp->w_buffer == curwin->w_buffer)
536 {
Bram Moolenaar14285cb2020-03-27 20:58:37 +0100537 pos_T *top, *bot;
538
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200539 if (LTOREQ_POS(curwin->w_cursor, VIsual))
540 {
541 // Visual is after curwin->w_cursor
542 top = &curwin->w_cursor;
543 bot = &VIsual;
544 }
545 else
546 {
547 // Visual is before curwin->w_cursor
548 top = &VIsual;
549 bot = &curwin->w_cursor;
550 }
551 lnum_in_visual_area = (lnum >= top->lnum && lnum <= bot->lnum);
552 if (VIsual_mode == Ctrl_V)
553 {
554 // block mode
555 if (lnum_in_visual_area)
556 {
557 fromcol = wp->w_old_cursor_fcol;
558 tocol = wp->w_old_cursor_lcol;
559 }
560 }
561 else
562 {
563 // non-block mode
564 if (lnum > top->lnum && lnum <= bot->lnum)
565 fromcol = 0;
566 else if (lnum == top->lnum)
567 {
568 if (VIsual_mode == 'V') // linewise
569 fromcol = 0;
570 else
571 {
572 getvvcol(wp, top, (colnr_T *)&fromcol, NULL, NULL);
573 if (gchar_pos(top) == NUL)
574 tocol = fromcol + 1;
575 }
576 }
577 if (VIsual_mode != 'V' && lnum == bot->lnum)
578 {
579 if (*p_sel == 'e' && bot->col == 0 && bot->coladd == 0)
580 {
581 fromcol = -10;
582 tocol = MAXCOL;
583 }
584 else if (bot->col == MAXCOL)
585 tocol = MAXCOL;
586 else
587 {
588 pos = *bot;
589 if (*p_sel == 'e')
590 getvvcol(wp, &pos, (colnr_T *)&tocol, NULL, NULL);
591 else
592 {
593 getvvcol(wp, &pos, NULL, NULL, (colnr_T *)&tocol);
594 ++tocol;
595 }
596 }
597 }
598 }
599
600 // Check if the character under the cursor should not be inverted
Bram Moolenaar6656c2e2019-10-24 15:00:04 +0200601 if (!highlight_match && lnum == curwin->w_cursor.lnum
602 && wp == curwin
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200603#ifdef FEAT_GUI
604 && !gui.in_use
605#endif
606 )
607 noinvcur = TRUE;
608
609 // if inverting in this line set area_highlighting
610 if (fromcol >= 0)
611 {
612 area_highlighting = TRUE;
613 vi_attr = HL_ATTR(HLF_V);
614#if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
615 if ((clip_star.available && !clip_star.owned
616 && clip_isautosel_star())
617 || (clip_plus.available && !clip_plus.owned
618 && clip_isautosel_plus()))
619 vi_attr = HL_ATTR(HLF_VNC);
620#endif
621 }
622 }
623
624 // handle 'incsearch' and ":s///c" highlighting
625 else if (highlight_match
626 && wp == curwin
627 && lnum >= curwin->w_cursor.lnum
628 && lnum <= curwin->w_cursor.lnum + search_match_lines)
629 {
630 if (lnum == curwin->w_cursor.lnum)
631 getvcol(curwin, &(curwin->w_cursor),
632 (colnr_T *)&fromcol, NULL, NULL);
633 else
634 fromcol = 0;
635 if (lnum == curwin->w_cursor.lnum + search_match_lines)
636 {
637 pos.lnum = lnum;
638 pos.col = search_match_endcol;
639 getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL);
640 }
641 else
642 tocol = MAXCOL;
643 // do at least one character; happens when past end of line
644 if (fromcol == tocol)
645 tocol = fromcol + 1;
646 area_highlighting = TRUE;
647 vi_attr = HL_ATTR(HLF_I);
648 }
649 }
650
651#ifdef FEAT_DIFF
652 filler_lines = diff_check(wp, lnum);
653 if (filler_lines < 0)
654 {
655 if (filler_lines == -1)
656 {
657 if (diff_find_change(wp, lnum, &change_start, &change_end))
658 diff_hlf = HLF_ADD; // added line
659 else if (change_start == 0)
660 diff_hlf = HLF_TXD; // changed text
661 else
662 diff_hlf = HLF_CHD; // changed line
663 }
664 else
665 diff_hlf = HLF_ADD; // added line
666 filler_lines = 0;
667 area_highlighting = TRUE;
668 }
669 if (lnum == wp->w_topline)
670 filler_lines = wp->w_topfill;
671 filler_todo = filler_lines;
672#endif
673
674#ifdef FEAT_SIGNS
Bram Moolenaar4eb7dae2019-11-12 22:33:45 +0100675 sign_present = buf_get_signattrs(wp, lnum, &sattr);
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200676#endif
677
678#ifdef LINE_ATTR
679# ifdef FEAT_SIGNS
680 // If this line has a sign with line highlighting set line_attr.
681 if (sign_present)
Bram Moolenaar6656c2e2019-10-24 15:00:04 +0200682 line_attr = sattr.sat_linehl;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200683# endif
684# if defined(FEAT_QUICKFIX)
685 // Highlight the current line in the quickfix window.
686 if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum)
687 line_attr = HL_ATTR(HLF_QFL);
688# endif
689 if (line_attr != 0)
690 area_highlighting = TRUE;
691#endif
692
693 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
694 ptr = line;
695
696#ifdef FEAT_SPELL
697 if (has_spell && !number_only)
698 {
699 // For checking first word with a capital skip white space.
700 if (cap_col == 0)
701 cap_col = getwhitecols(line);
702
703 // To be able to spell-check over line boundaries copy the end of the
704 // current line into nextline[]. Above the start of the next line was
705 // copied to nextline[SPWORDLEN].
706 if (nextline[SPWORDLEN] == NUL)
707 {
708 // No next line or it is empty.
709 nextlinecol = MAXCOL;
710 nextline_idx = 0;
711 }
712 else
713 {
714 v = (long)STRLEN(line);
715 if (v < SPWORDLEN)
716 {
717 // Short line, use it completely and append the start of the
718 // next line.
719 nextlinecol = 0;
720 mch_memmove(nextline, line, (size_t)v);
721 STRMOVE(nextline + v, nextline + SPWORDLEN);
722 nextline_idx = v + 1;
723 }
724 else
725 {
726 // Long line, use only the last SPWORDLEN bytes.
727 nextlinecol = v - SPWORDLEN;
728 mch_memmove(nextline, line + nextlinecol, SPWORDLEN);
729 nextline_idx = SPWORDLEN + 1;
730 }
731 }
732 }
733#endif
734
735 if (wp->w_p_list)
736 {
737 if (lcs_space || lcs_trail || lcs_nbsp)
738 extra_check = TRUE;
739 // find start of trailing whitespace
740 if (lcs_trail)
741 {
742 trailcol = (colnr_T)STRLEN(ptr);
743 while (trailcol > (colnr_T)0 && VIM_ISWHITE(ptr[trailcol - 1]))
744 --trailcol;
745 trailcol += (colnr_T) (ptr - line);
746 }
747 }
748
749 wcr_attr = get_wcr_attr(wp);
750 if (wcr_attr != 0)
751 {
752 win_attr = wcr_attr;
753 area_highlighting = TRUE;
754 }
Bram Moolenaar34390282019-10-16 14:38:26 +0200755
Bram Moolenaar05ad5ff2019-11-30 22:48:27 +0100756#ifdef FEAT_PROP_POPUP
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200757 if (WIN_IS_POPUP(wp))
758 screen_line_flags |= SLF_POPUP;
759#endif
760
761 // 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the
762 // first character to be displayed.
763 if (wp->w_p_wrap)
764 v = wp->w_skipcol;
765 else
766 v = wp->w_leftcol;
767 if (v > 0 && !number_only)
768 {
769 char_u *prev_ptr = ptr;
770
771 while (vcol < v && *ptr != NUL)
772 {
773 c = win_lbr_chartabsize(wp, line, ptr, (colnr_T)vcol, NULL);
774 vcol += c;
775 prev_ptr = ptr;
776 MB_PTR_ADV(ptr);
777 }
778
779 // When:
780 // - 'cuc' is set, or
781 // - 'colorcolumn' is set, or
782 // - 'virtualedit' is set, or
783 // - the visual mode is active,
784 // the end of the line may be before the start of the displayed part.
785 if (vcol < v && (
786#ifdef FEAT_SYN_HL
787 wp->w_p_cuc || draw_color_col ||
788#endif
789 virtual_active() ||
790 (VIsual_active && wp->w_buffer == curwin->w_buffer)))
791 vcol = v;
792
793 // Handle a character that's not completely on the screen: Put ptr at
794 // that character but skip the first few screen characters.
795 if (vcol > v)
796 {
797 vcol -= c;
798 ptr = prev_ptr;
799 // If the character fits on the screen, don't need to skip it.
800 // Except for a TAB.
801 if (( (*mb_ptr2cells)(ptr) >= c || *ptr == TAB) && col == 0)
802 n_skip = v - vcol;
803 }
804
805 // Adjust for when the inverted text is before the screen,
806 // and when the start of the inverted text is before the screen.
807 if (tocol <= vcol)
808 fromcol = 0;
809 else if (fromcol >= 0 && fromcol < vcol)
810 fromcol = vcol;
811
812#ifdef FEAT_LINEBREAK
813 // When w_skipcol is non-zero, first line needs 'showbreak'
814 if (wp->w_p_wrap)
815 need_showbreak = TRUE;
816#endif
817#ifdef FEAT_SPELL
818 // When spell checking a word we need to figure out the start of the
819 // word and if it's badly spelled or not.
820 if (has_spell)
821 {
822 int len;
823 colnr_T linecol = (colnr_T)(ptr - line);
824 hlf_T spell_hlf = HLF_COUNT;
825
826 pos = wp->w_cursor;
827 wp->w_cursor.lnum = lnum;
828 wp->w_cursor.col = linecol;
829 len = spell_move_to(wp, FORWARD, TRUE, TRUE, &spell_hlf);
830
831 // spell_move_to() may call ml_get() and make "line" invalid
832 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
833 ptr = line + linecol;
834
835 if (len == 0 || (int)wp->w_cursor.col > ptr - line)
836 {
837 // no bad word found at line start, don't check until end of a
838 // word
839 spell_hlf = HLF_COUNT;
840 word_end = (int)(spell_to_word_end(ptr, wp) - line + 1);
841 }
842 else
843 {
844 // bad word found, use attributes until end of word
845 word_end = wp->w_cursor.col + len + 1;
846
847 // Turn index into actual attributes.
848 if (spell_hlf != HLF_COUNT)
849 spell_attr = highlight_attr[spell_hlf];
850 }
851 wp->w_cursor = pos;
852
853# ifdef FEAT_SYN_HL
854 // Need to restart syntax highlighting for this line.
855 if (has_syntax)
856 syntax_start(wp, lnum);
857# endif
858 }
859#endif
860 }
861
862 // Correct highlighting for cursor that can't be disabled.
863 // Avoids having to check this for each character.
864 if (fromcol >= 0)
865 {
866 if (noinvcur)
867 {
868 if ((colnr_T)fromcol == wp->w_virtcol)
869 {
870 // highlighting starts at cursor, let it start just after the
871 // cursor
872 fromcol_prev = fromcol;
873 fromcol = -1;
874 }
875 else if ((colnr_T)fromcol < wp->w_virtcol)
876 // restart highlighting after the cursor
877 fromcol_prev = wp->w_virtcol;
878 }
879 if (fromcol >= tocol)
880 fromcol = -1;
881 }
882
883#ifdef FEAT_SEARCH_EXTRA
884 if (!number_only)
885 {
886 v = (long)(ptr - line);
887 area_highlighting |= prepare_search_hl_line(wp, lnum, (colnr_T)v,
888 &line, &screen_search_hl,
889 &search_attr);
890 ptr = line + v; // "line" may have been updated
891 }
892#endif
893
894#ifdef FEAT_SYN_HL
895 // Cursor line highlighting for 'cursorline' in the current window.
896 if (wp->w_p_cul && lnum == wp->w_cursor.lnum)
897 {
898 // Do not show the cursor line in the text when Visual mode is active,
899 // because it's not clear what is selected then. Do update
900 // w_last_cursorline.
901 if (!(wp == curwin && VIsual_active)
902 && wp->w_p_culopt_flags != CULOPT_NBR)
903 {
904 cul_screenline = (wp->w_p_wrap
905 && (wp->w_p_culopt_flags & CULOPT_SCRLINE));
906
907 // Only set line_attr here when "screenline" is not present in
908 // 'cursorlineopt'. Otherwise it's done later.
909 if (!cul_screenline)
910 {
911 cul_attr = HL_ATTR(HLF_CUL);
Bram Moolenaar39f7aa32020-08-31 22:00:05 +0200912# ifdef FEAT_SIGNS
913 // Combine the 'cursorline' and sign highlighting, depending on
914 // the sign priority.
915 if (sign_present && sattr.sat_linehl > 0)
916 {
917 if (sattr.sat_priority >= 100)
918 line_attr = hl_combine_attr(cul_attr, line_attr);
919 else
920 line_attr = hl_combine_attr(line_attr, cul_attr);
921 }
922 else
923# endif
924 line_attr = cul_attr;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200925 wp->w_last_cursorline = wp->w_cursor.lnum;
926 }
927 else
928 {
929 line_attr_save = line_attr;
930 wp->w_last_cursorline = 0;
931 margin_columns_win(wp, &left_curline_col, &right_curline_col);
932 }
933 area_highlighting = TRUE;
934 }
935 else
936 wp->w_last_cursorline = wp->w_cursor.lnum;
937 }
938#endif
939
Bram Moolenaar05ad5ff2019-11-30 22:48:27 +0100940#ifdef FEAT_PROP_POPUP
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200941 {
942 char_u *prop_start;
943
944 text_prop_count = get_text_props(wp->w_buffer, lnum,
945 &prop_start, FALSE);
946 if (text_prop_count > 0)
947 {
948 // Make a copy of the properties, so that they are properly
949 // aligned.
950 text_props = ALLOC_MULT(textprop_T, text_prop_count);
951 if (text_props != NULL)
952 mch_memmove(text_props, prop_start,
953 text_prop_count * sizeof(textprop_T));
954
955 // Allocate an array for the indexes.
956 text_prop_idxs = ALLOC_MULT(int, text_prop_count);
957 area_highlighting = TRUE;
958 extra_check = TRUE;
959 }
960 }
961#endif
962
963 off = (unsigned)(current_ScreenLine - ScreenLines);
964 col = 0;
965
966#ifdef FEAT_RIGHTLEFT
967 if (wp->w_p_rl)
968 {
969 // Rightleft window: process the text in the normal direction, but put
970 // it in current_ScreenLine[] from right to left. Start at the
971 // rightmost column of the window.
972 col = wp->w_width - 1;
973 off += col;
974 screen_line_flags |= SLF_RIGHTLEFT;
975 }
976#endif
977
978 // Repeat for the whole displayed line.
979 for (;;)
980 {
981#if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA)
Bram Moolenaar211dd3f2020-06-25 20:07:04 +0200982 int has_match_conc = 0; // match wants to conceal
Bram Moolenaar7528d1f2019-09-19 23:06:20 +0200983#endif
984#ifdef FEAT_CONCEAL
985 int did_decrement_ptr = FALSE;
986#endif
987 // Skip this quickly when working on the text.
988 if (draw_state != WL_LINE)
989 {
990#ifdef FEAT_CMDWIN
991 if (draw_state == WL_CMDLINE - 1 && n_extra == 0)
992 {
993 draw_state = WL_CMDLINE;
994 if (cmdwin_type != 0 && wp == curwin)
995 {
996 // Draw the cmdline character.
997 n_extra = 1;
998 c_extra = cmdwin_type;
999 c_final = NUL;
1000 char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_AT));
1001 }
1002 }
1003#endif
1004
1005#ifdef FEAT_FOLDING
1006 if (draw_state == WL_FOLD - 1 && n_extra == 0)
1007 {
1008 int fdc = compute_foldcolumn(wp, 0);
1009
1010 draw_state = WL_FOLD;
1011 if (fdc > 0)
1012 {
1013 // Draw the 'foldcolumn'. Allocate a buffer, "extra" may
1014 // already be in use.
1015 vim_free(p_extra_free);
1016 p_extra_free = alloc(12 + 1);
1017
1018 if (p_extra_free != NULL)
1019 {
1020 fill_foldcolumn(p_extra_free, wp, FALSE, lnum);
1021 n_extra = fdc;
1022 p_extra_free[n_extra] = NUL;
1023 p_extra = p_extra_free;
1024 c_extra = NUL;
1025 c_final = NUL;
1026 char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_FC));
1027 }
1028 }
1029 }
1030#endif
1031
1032#ifdef FEAT_SIGNS
1033 if (draw_state == WL_SIGN - 1 && n_extra == 0)
1034 {
1035 draw_state = WL_SIGN;
1036 // Show the sign column when there are any signs in this
1037 // buffer or when using Netbeans.
1038 if (signcolumn_on(wp))
1039 get_sign_display_info(FALSE, wp, lnum, &sattr, wcr_attr,
1040 row, startrow, filler_lines, filler_todo, &c_extra,
1041 &c_final, extra, &p_extra, &n_extra, &char_attr);
1042 }
1043#endif
1044
1045 if (draw_state == WL_NR - 1 && n_extra == 0)
1046 {
1047 draw_state = WL_NR;
1048 // Display the absolute or relative line number. After the
1049 // first fill with blanks when the 'n' flag isn't in 'cpo'
1050 if ((wp->w_p_nu || wp->w_p_rnu)
1051 && (row == startrow
1052#ifdef FEAT_DIFF
1053 + filler_lines
1054#endif
1055 || vim_strchr(p_cpo, CPO_NUMCOL) == NULL))
1056 {
1057#ifdef FEAT_SIGNS
1058 // If 'signcolumn' is set to 'number' and a sign is present
1059 // in 'lnum', then display the sign instead of the line
1060 // number.
1061 if ((*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u')
1062 && sign_present)
1063 get_sign_display_info(TRUE, wp, lnum, &sattr, wcr_attr,
1064 row, startrow, filler_lines, filler_todo,
1065 &c_extra, &c_final, extra, &p_extra, &n_extra,
1066 &char_attr);
1067 else
1068#endif
1069 {
1070 // Draw the line number (empty space after wrapping).
1071 if (row == startrow
1072#ifdef FEAT_DIFF
1073 + filler_lines
1074#endif
1075 )
1076 {
1077 long num;
1078 char *fmt = "%*ld ";
1079
1080 if (wp->w_p_nu && !wp->w_p_rnu)
1081 // 'number' + 'norelativenumber'
1082 num = (long)lnum;
1083 else
1084 {
1085 // 'relativenumber', don't use negative numbers
1086 num = labs((long)get_cursor_rel_lnum(wp, lnum));
1087 if (num == 0 && wp->w_p_nu && wp->w_p_rnu)
1088 {
1089 // 'number' + 'relativenumber'
1090 num = lnum;
1091 fmt = "%-*ld ";
1092 }
1093 }
1094
1095 sprintf((char *)extra, fmt,
1096 number_width(wp), num);
1097 if (wp->w_skipcol > 0)
1098 for (p_extra = extra; *p_extra == ' '; ++p_extra)
1099 *p_extra = '-';
1100#ifdef FEAT_RIGHTLEFT
1101 if (wp->w_p_rl) // reverse line numbers
1102 {
1103 char_u *p1, *p2;
1104 int t;
1105
1106 // like rl_mirror(), but keep the space at the end
1107 p2 = skiptowhite(extra) - 1;
1108 for (p1 = extra; p1 < p2; ++p1, --p2)
1109 {
1110 t = *p1;
1111 *p1 = *p2;
1112 *p2 = t;
1113 }
1114 }
1115#endif
1116 p_extra = extra;
1117 c_extra = NUL;
1118 c_final = NUL;
1119 }
1120 else
1121 {
1122 c_extra = ' ';
1123 c_final = NUL;
1124 }
1125 n_extra = number_width(wp) + 1;
1126 char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_N));
1127#ifdef FEAT_SYN_HL
1128 // When 'cursorline' is set highlight the line number of
1129 // the current line differently.
1130 // When 'cursorlineopt' has "screenline" only highlight
1131 // the line number itself.
1132 // TODO: Can we use CursorLine instead of CursorLineNr
1133 // when CursorLineNr isn't set?
Bram Moolenaar49474ca2019-10-05 21:57:12 +02001134 if (wp->w_p_cul
1135 && lnum == wp->w_cursor.lnum
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001136 && (wp->w_p_culopt_flags & CULOPT_NBR)
1137 && (row == startrow
Bram Moolenaar49474ca2019-10-05 21:57:12 +02001138 || wp->w_p_culopt_flags & CULOPT_LINE))
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001139 char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_CLN));
1140#endif
Bram Moolenaarefae76a2019-10-27 22:54:58 +01001141 if (wp->w_p_rnu && lnum < wp->w_cursor.lnum
1142 && HL_ATTR(HLF_LNA) != 0)
1143 // Use LineNrAbove
1144 char_attr = hl_combine_attr(wcr_attr,
1145 HL_ATTR(HLF_LNA));
1146 if (wp->w_p_rnu && lnum > wp->w_cursor.lnum
1147 && HL_ATTR(HLF_LNB) != 0)
1148 // Use LineNrBelow
1149 char_attr = hl_combine_attr(wcr_attr,
1150 HL_ATTR(HLF_LNB));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001151 }
1152 }
1153 }
1154
1155#ifdef FEAT_LINEBREAK
Bram Moolenaarb81f56f2020-02-23 15:29:46 +01001156 if (wp->w_briopt_sbr && draw_state == WL_BRI - 1
Bram Moolenaaree857022019-11-09 23:26:40 +01001157 && n_extra == 0 && *get_showbreak_value(wp) != NUL)
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001158 // draw indent after showbreak value
1159 draw_state = WL_BRI;
Bram Moolenaarb81f56f2020-02-23 15:29:46 +01001160 else if (wp->w_briopt_sbr && draw_state == WL_SBR && n_extra == 0)
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001161 // After the showbreak, draw the breakindent
1162 draw_state = WL_BRI - 1;
1163
1164 // draw 'breakindent': indent wrapped text accordingly
1165 if (draw_state == WL_BRI - 1 && n_extra == 0)
1166 {
1167 draw_state = WL_BRI;
1168 // if need_showbreak is set, breakindent also applies
1169 if (wp->w_p_bri && n_extra == 0
1170 && (row != startrow || need_showbreak)
1171# ifdef FEAT_DIFF
1172 && filler_lines == 0
1173# endif
1174 )
1175 {
1176 char_attr = 0;
1177# ifdef FEAT_DIFF
1178 if (diff_hlf != (hlf_T)0)
1179 {
1180 char_attr = HL_ATTR(diff_hlf);
1181# ifdef FEAT_SYN_HL
1182 if (cul_attr != 0)
1183 char_attr = hl_combine_attr(char_attr, cul_attr);
1184# endif
1185 }
1186# endif
1187 p_extra = NULL;
1188 c_extra = ' ';
Bram Moolenaar2f7b7b12019-11-03 15:46:48 +01001189 c_final = NUL;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001190 n_extra = get_breakindent_win(wp,
1191 ml_get_buf(wp->w_buffer, lnum, FALSE));
Bram Moolenaare882f7a2020-05-16 14:07:39 +02001192 if (row == startrow)
1193 {
1194 n_extra -= win_col_off2(wp);
1195 if (n_extra < 0)
1196 n_extra = 0;
1197 }
Bram Moolenaarb81f56f2020-02-23 15:29:46 +01001198 if (wp->w_skipcol > 0 && wp->w_p_wrap && wp->w_briopt_sbr)
Bram Moolenaardfede9a2020-01-23 19:59:22 +01001199 need_showbreak = FALSE;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001200 // Correct end of highlighted area for 'breakindent',
1201 // required when 'linebreak' is also set.
1202 if (tocol == vcol)
1203 tocol += n_extra;
1204 }
1205 }
1206#endif
1207
1208#if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
1209 if (draw_state == WL_SBR - 1 && n_extra == 0)
1210 {
Bram Moolenaaree857022019-11-09 23:26:40 +01001211 char_u *sbr;
1212
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001213 draw_state = WL_SBR;
1214# ifdef FEAT_DIFF
1215 if (filler_todo > 0)
1216 {
1217 // Draw "deleted" diff line(s).
1218 if (char2cells(fill_diff) > 1)
1219 {
1220 c_extra = '-';
1221 c_final = NUL;
1222 }
1223 else
1224 {
1225 c_extra = fill_diff;
1226 c_final = NUL;
1227 }
1228# ifdef FEAT_RIGHTLEFT
1229 if (wp->w_p_rl)
1230 n_extra = col + 1;
1231 else
1232# endif
1233 n_extra = wp->w_width - col;
1234 char_attr = HL_ATTR(HLF_DED);
1235 }
1236# endif
1237# ifdef FEAT_LINEBREAK
Bram Moolenaaree857022019-11-09 23:26:40 +01001238 sbr = get_showbreak_value(wp);
1239 if (*sbr != NUL && need_showbreak)
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001240 {
1241 // Draw 'showbreak' at the start of each broken line.
Bram Moolenaaree857022019-11-09 23:26:40 +01001242 p_extra = sbr;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001243 c_extra = NUL;
1244 c_final = NUL;
Bram Moolenaaree857022019-11-09 23:26:40 +01001245 n_extra = (int)STRLEN(sbr);
Bram Moolenaardfede9a2020-01-23 19:59:22 +01001246 if (wp->w_skipcol == 0 || !wp->w_p_wrap)
1247 need_showbreak = FALSE;
Bram Moolenaaree857022019-11-09 23:26:40 +01001248 vcol_sbr = vcol + MB_CHARLEN(sbr);
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001249 // Correct end of highlighted area for 'showbreak',
1250 // required when 'linebreak' is also set.
1251 if (tocol == vcol)
1252 tocol += n_extra;
1253 // combine 'showbreak' with 'wincolor'
Bram Moolenaar42e931b2019-12-04 19:08:50 +01001254 char_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001255# ifdef FEAT_SYN_HL
1256 // combine 'showbreak' with 'cursorline'
1257 if (cul_attr != 0)
1258 char_attr = hl_combine_attr(char_attr, cul_attr);
1259# endif
1260 }
1261# endif
1262 }
1263#endif
1264
1265 if (draw_state == WL_LINE - 1 && n_extra == 0)
1266 {
1267 draw_state = WL_LINE;
1268 if (saved_n_extra)
1269 {
1270 // Continue item from end of wrapped line.
1271 n_extra = saved_n_extra;
1272 c_extra = saved_c_extra;
1273 c_final = saved_c_final;
1274 p_extra = saved_p_extra;
1275 char_attr = saved_char_attr;
1276 }
1277 else
1278 char_attr = win_attr;
1279 }
1280 }
1281#ifdef FEAT_SYN_HL
1282 if (cul_screenline)
1283 {
1284 if (draw_state == WL_LINE
1285 && vcol >= left_curline_col
1286 && vcol < right_curline_col)
1287 {
1288 cul_attr = HL_ATTR(HLF_CUL);
1289 line_attr = cul_attr;
1290 }
1291 else
1292 {
1293 cul_attr = 0;
1294 line_attr = line_attr_save;
1295 }
1296 }
1297#endif
1298
1299 // When still displaying '$' of change command, stop at cursor.
1300 // When only displaying the (relative) line number and that's done,
1301 // stop here.
Bram Moolenaar511feec2020-06-18 19:15:27 +02001302 if (((dollar_vcol >= 0 && wp == curwin
1303 && lnum == wp->w_cursor.lnum && vcol >= (long)wp->w_virtcol)
1304 || (number_only && draw_state > WL_NR))
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001305#ifdef FEAT_DIFF
1306 && filler_todo <= 0
1307#endif
1308 )
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001309 {
1310 screen_line(screen_row, wp->w_wincol, col, -(int)wp->w_width,
1311 screen_line_flags);
1312 // Pretend we have finished updating the window. Except when
1313 // 'cursorcolumn' is set.
1314#ifdef FEAT_SYN_HL
1315 if (wp->w_p_cuc)
1316 row = wp->w_cline_row + wp->w_cline_height;
1317 else
1318#endif
1319 row = wp->w_height;
1320 break;
1321 }
1322
Bram Moolenaar34390282019-10-16 14:38:26 +02001323 if (draw_state == WL_LINE && (area_highlighting || extra_check))
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001324 {
1325 // handle Visual or match highlighting in this line
1326 if (vcol == fromcol
1327 || (has_mbyte && vcol + 1 == fromcol && n_extra == 0
1328 && (*mb_ptr2cells)(ptr) > 1)
1329 || ((int)vcol_prev == fromcol_prev
1330 && vcol_prev < vcol // not at margin
1331 && vcol < tocol))
1332 area_attr = vi_attr; // start highlighting
1333 else if (area_attr != 0
1334 && (vcol == tocol
1335 || (noinvcur && (colnr_T)vcol == wp->w_virtcol)))
1336 area_attr = 0; // stop highlighting
1337
1338#ifdef FEAT_SEARCH_EXTRA
1339 if (!n_extra)
1340 {
1341 // Check for start/end of 'hlsearch' and other matches.
1342 // After end, check for start/end of next match.
1343 // When another match, have to check for start again.
1344 v = (long)(ptr - line);
1345 search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line,
1346 &screen_search_hl, &has_match_conc,
1347 &match_conc, did_line_attr, lcs_eol_one);
1348 ptr = line + v; // "line" may have been changed
Bram Moolenaarfc838d62020-06-25 22:23:48 +02001349
1350 // Do not allow a conceal over EOL otherwise EOL will be missed
1351 // and bad things happen.
1352 if (*ptr == NUL)
1353 has_match_conc = 0;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001354 }
1355#endif
1356
1357#ifdef FEAT_DIFF
1358 if (diff_hlf != (hlf_T)0)
1359 {
1360 if (diff_hlf == HLF_CHD && ptr - line >= change_start
1361 && n_extra == 0)
1362 diff_hlf = HLF_TXD; // changed text
1363 if (diff_hlf == HLF_TXD && ptr - line > change_end
1364 && n_extra == 0)
1365 diff_hlf = HLF_CHD; // changed line
1366 line_attr = HL_ATTR(diff_hlf);
1367 if (wp->w_p_cul && lnum == wp->w_cursor.lnum
1368 && wp->w_p_culopt_flags != CULOPT_NBR
1369 && (!cul_screenline || (vcol >= left_curline_col
1370 && vcol <= right_curline_col)))
1371 line_attr = hl_combine_attr(
1372 line_attr, HL_ATTR(HLF_CUL));
1373 }
1374#endif
1375
Bram Moolenaar05ad5ff2019-11-30 22:48:27 +01001376#ifdef FEAT_PROP_POPUP
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001377 if (text_props != NULL)
1378 {
1379 int pi;
1380 int bcol = (int)(ptr - line);
1381
1382 if (n_extra > 0)
1383 --bcol; // still working on the previous char, e.g. Tab
1384
1385 // Check if any active property ends.
1386 for (pi = 0; pi < text_props_active; ++pi)
1387 {
1388 int tpi = text_prop_idxs[pi];
1389
1390 if (bcol >= text_props[tpi].tp_col - 1
1391 + text_props[tpi].tp_len)
1392 {
1393 if (pi + 1 < text_props_active)
1394 mch_memmove(text_prop_idxs + pi,
1395 text_prop_idxs + pi + 1,
1396 sizeof(int)
1397 * (text_props_active - (pi + 1)));
1398 --text_props_active;
1399 --pi;
1400 }
1401 }
1402
1403 // Add any text property that starts in this column.
1404 while (text_prop_next < text_prop_count
1405 && bcol >= text_props[text_prop_next].tp_col - 1)
1406 text_prop_idxs[text_props_active++] = text_prop_next++;
1407
1408 text_prop_attr = 0;
1409 text_prop_combine = FALSE;
Bram Moolenaar053f7122019-09-23 22:17:15 +02001410 text_prop_type = NULL;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001411 if (text_props_active > 0)
1412 {
1413 // Sort the properties on priority and/or starting last.
1414 // Then combine the attributes, highest priority last.
1415 current_text_props = text_props;
1416 current_buf = wp->w_buffer;
1417 qsort((void *)text_prop_idxs, (size_t)text_props_active,
1418 sizeof(int), text_prop_compare);
1419
1420 for (pi = 0; pi < text_props_active; ++pi)
1421 {
1422 int tpi = text_prop_idxs[pi];
1423 proptype_T *pt = text_prop_type_by_id(
1424 wp->w_buffer, text_props[tpi].tp_type);
1425
1426 if (pt != NULL && pt->pt_hl_id > 0)
1427 {
1428 int pt_attr = syn_id2attr(pt->pt_hl_id);
1429
1430 text_prop_type = pt;
1431 text_prop_attr =
1432 hl_combine_attr(text_prop_attr, pt_attr);
1433 text_prop_combine = pt->pt_flags & PT_FLAG_COMBINE;
1434 }
1435 }
1436 }
1437 }
1438#endif
1439
Bram Moolenaara74fda62019-10-19 17:38:03 +02001440#ifdef FEAT_SYN_HL
Bram Moolenaara74fda62019-10-19 17:38:03 +02001441 if (extra_check && n_extra == 0)
Bram Moolenaar34390282019-10-16 14:38:26 +02001442 {
Bram Moolenaar82260af2019-10-20 13:16:22 +02001443 syntax_attr = 0;
Bram Moolenaara74fda62019-10-19 17:38:03 +02001444# ifdef FEAT_TERMINAL
Bram Moolenaar34390282019-10-16 14:38:26 +02001445 if (get_term_attr)
Bram Moolenaar219c7d02020-02-01 21:57:29 +01001446 syntax_attr = term_get_attr(wp, lnum, vcol);
Bram Moolenaara74fda62019-10-19 17:38:03 +02001447# endif
Bram Moolenaar34390282019-10-16 14:38:26 +02001448 // Get syntax attribute.
1449 if (has_syntax)
1450 {
1451 // Get the syntax attribute for the character. If there
1452 // is an error, disable syntax highlighting.
1453 save_did_emsg = did_emsg;
1454 did_emsg = FALSE;
1455
1456 v = (long)(ptr - line);
Bram Moolenaar9115c612019-10-16 16:57:06 +02001457 if (v == prev_syntax_col)
1458 // at same column again
1459 syntax_attr = prev_syntax_attr;
1460 else
1461 {
Bram Moolenaarb2fe1d62019-10-16 21:33:40 +02001462# ifdef FEAT_SPELL
Bram Moolenaar9115c612019-10-16 16:57:06 +02001463 can_spell = TRUE;
Bram Moolenaarb2fe1d62019-10-16 21:33:40 +02001464# endif
Bram Moolenaar9115c612019-10-16 16:57:06 +02001465 syntax_attr = get_syntax_attr((colnr_T)v,
Bram Moolenaar34390282019-10-16 14:38:26 +02001466# ifdef FEAT_SPELL
1467 has_spell ? &can_spell :
1468# endif
1469 NULL, FALSE);
Bram Moolenaar9115c612019-10-16 16:57:06 +02001470 prev_syntax_col = v;
1471 prev_syntax_attr = syntax_attr;
1472 }
Bram Moolenaar34390282019-10-16 14:38:26 +02001473
Bram Moolenaar34390282019-10-16 14:38:26 +02001474 if (did_emsg)
1475 {
1476 wp->w_s->b_syn_error = TRUE;
1477 has_syntax = FALSE;
1478 syntax_attr = 0;
1479 }
1480 else
1481 did_emsg = save_did_emsg;
1482# ifdef SYN_TIME_LIMIT
1483 if (wp->w_s->b_syn_slow)
1484 has_syntax = FALSE;
1485# endif
1486
1487 // Need to get the line again, a multi-line regexp may
1488 // have made it invalid.
1489 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
1490 ptr = line + v;
1491# ifdef FEAT_CONCEAL
1492 // no concealing past the end of the line, it interferes
1493 // with line highlighting
1494 if (*ptr == NUL)
1495 syntax_flags = 0;
1496 else
1497 syntax_flags = get_syntax_info(&syntax_seqnr);
1498# endif
1499 }
Bram Moolenaar34390282019-10-16 14:38:26 +02001500 }
Bram Moolenaar05ad5ff2019-11-30 22:48:27 +01001501# ifdef FEAT_PROP_POPUP
Bram Moolenaardbd43162019-11-09 21:28:14 +01001502 // Combine text property highlight into syntax highlight.
1503 if (text_prop_type != NULL)
1504 {
1505 if (text_prop_combine)
1506 syntax_attr = hl_combine_attr(syntax_attr, text_prop_attr);
1507 else
1508 syntax_attr = text_prop_attr;
1509 }
1510# endif
Bram Moolenaara74fda62019-10-19 17:38:03 +02001511#endif
Bram Moolenaar34390282019-10-16 14:38:26 +02001512
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001513 // Decide which of the highlight attributes to use.
1514 attr_pri = TRUE;
1515#ifdef LINE_ATTR
1516 if (area_attr != 0)
Bram Moolenaar84590062019-10-18 23:12:20 +02001517 {
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001518 char_attr = hl_combine_attr(line_attr, area_attr);
Bram Moolenaar84590062019-10-18 23:12:20 +02001519# ifdef FEAT_SYN_HL
Bram Moolenaardbd43162019-11-09 21:28:14 +01001520 char_attr = hl_combine_attr(syntax_attr, char_attr);
Bram Moolenaar84590062019-10-18 23:12:20 +02001521# endif
1522 }
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001523 else if (search_attr != 0)
Bram Moolenaar84590062019-10-18 23:12:20 +02001524 {
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001525 char_attr = hl_combine_attr(line_attr, search_attr);
Bram Moolenaar84590062019-10-18 23:12:20 +02001526# ifdef FEAT_SYN_HL
Bram Moolenaardbd43162019-11-09 21:28:14 +01001527 char_attr = hl_combine_attr(syntax_attr, char_attr);
Bram Moolenaar84590062019-10-18 23:12:20 +02001528# endif
1529 }
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001530 else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL)
1531 || vcol < fromcol || vcol_prev < fromcol_prev
1532 || vcol >= tocol))
1533 {
1534 // Use line_attr when not in the Visual or 'incsearch' area
1535 // (area_attr may be 0 when "noinvcur" is set).
Bram Moolenaar34390282019-10-16 14:38:26 +02001536# ifdef FEAT_SYN_HL
Bram Moolenaardbd43162019-11-09 21:28:14 +01001537 char_attr = hl_combine_attr(syntax_attr, line_attr);
1538# else
1539 char_attr = line_attr;
Bram Moolenaar34390282019-10-16 14:38:26 +02001540# endif
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001541 attr_pri = FALSE;
1542 }
1543#else
1544 if (area_attr != 0)
1545 char_attr = area_attr;
1546 else if (search_attr != 0)
1547 char_attr = search_attr;
1548#endif
1549 else
1550 {
1551 attr_pri = FALSE;
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001552#ifdef FEAT_SYN_HL
Bram Moolenaardbd43162019-11-09 21:28:14 +01001553 char_attr = syntax_attr;
Bram Moolenaara74fda62019-10-19 17:38:03 +02001554#else
Bram Moolenaardbd43162019-11-09 21:28:14 +01001555 char_attr = 0;
Bram Moolenaara74fda62019-10-19 17:38:03 +02001556#endif
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001557 }
1558 }
Bram Moolenaar024dbd22019-11-02 22:00:15 +01001559
1560 // combine attribute with 'wincolor'
1561 if (win_attr != 0)
1562 {
1563 if (char_attr == 0)
1564 char_attr = win_attr;
1565 else
1566 char_attr = hl_combine_attr(win_attr, char_attr);
1567 }
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001568
1569 // Get the next character to put on the screen.
1570
1571 // The "p_extra" points to the extra stuff that is inserted to
1572 // represent special characters (non-printable stuff) and other
1573 // things. When all characters are the same, c_extra is used.
1574 // If c_final is set, it will compulsorily be used at the end.
1575 // "p_extra" must end in a NUL to avoid mb_ptr2len() reads past
1576 // "p_extra[n_extra]".
1577 // For the '$' of the 'list' option, n_extra == 1, p_extra == "".
1578 if (n_extra > 0)
1579 {
1580 if (c_extra != NUL || (n_extra == 1 && c_final != NUL))
1581 {
1582 c = (n_extra == 1 && c_final != NUL) ? c_final : c_extra;
1583 mb_c = c; // doesn't handle non-utf-8 multi-byte!
1584 if (enc_utf8 && utf_char2len(c) > 1)
1585 {
1586 mb_utf8 = TRUE;
1587 u8cc[0] = 0;
1588 c = 0xc0;
1589 }
1590 else
1591 mb_utf8 = FALSE;
1592 }
1593 else
1594 {
1595 c = *p_extra;
1596 if (has_mbyte)
1597 {
1598 mb_c = c;
1599 if (enc_utf8)
1600 {
1601 // If the UTF-8 character is more than one byte:
1602 // Decode it into "mb_c".
1603 mb_l = utfc_ptr2len(p_extra);
1604 mb_utf8 = FALSE;
1605 if (mb_l > n_extra)
1606 mb_l = 1;
1607 else if (mb_l > 1)
1608 {
1609 mb_c = utfc_ptr2char(p_extra, u8cc);
1610 mb_utf8 = TRUE;
1611 c = 0xc0;
1612 }
1613 }
1614 else
1615 {
1616 // if this is a DBCS character, put it in "mb_c"
1617 mb_l = MB_BYTE2LEN(c);
1618 if (mb_l >= n_extra)
1619 mb_l = 1;
1620 else if (mb_l > 1)
1621 mb_c = (c << 8) + p_extra[1];
1622 }
1623 if (mb_l == 0) // at the NUL at end-of-line
1624 mb_l = 1;
1625
1626 // If a double-width char doesn't fit display a '>' in the
1627 // last column.
1628 if ((
1629# ifdef FEAT_RIGHTLEFT
1630 wp->w_p_rl ? (col <= 0) :
1631# endif
1632 (col >= wp->w_width - 1))
1633 && (*mb_char2cells)(mb_c) == 2)
1634 {
1635 c = '>';
1636 mb_c = c;
1637 mb_l = 1;
1638 mb_utf8 = FALSE;
1639 multi_attr = HL_ATTR(HLF_AT);
1640#ifdef FEAT_SYN_HL
1641 if (cul_attr)
1642 multi_attr = hl_combine_attr(multi_attr, cul_attr);
1643#endif
Bram Moolenaar92e25ab2019-11-26 22:39:10 +01001644 multi_attr = hl_combine_attr(win_attr, multi_attr);
1645
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001646 // put the pointer back to output the double-width
1647 // character at the start of the next line.
1648 ++n_extra;
1649 --p_extra;
1650 }
1651 else
1652 {
1653 n_extra -= mb_l - 1;
1654 p_extra += mb_l - 1;
1655 }
1656 }
1657 ++p_extra;
1658 }
1659 --n_extra;
1660 }
1661 else
1662 {
1663#ifdef FEAT_LINEBREAK
1664 int c0;
1665#endif
Bram Moolenaar2f7b7b12019-11-03 15:46:48 +01001666 VIM_CLEAR(p_extra_free);
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001667
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001668 // Get a character from the line itself.
1669 c = *ptr;
1670#ifdef FEAT_LINEBREAK
1671 c0 = *ptr;
1672#endif
1673 if (has_mbyte)
1674 {
1675 mb_c = c;
1676 if (enc_utf8)
1677 {
1678 // If the UTF-8 character is more than one byte: Decode it
1679 // into "mb_c".
1680 mb_l = utfc_ptr2len(ptr);
1681 mb_utf8 = FALSE;
1682 if (mb_l > 1)
1683 {
1684 mb_c = utfc_ptr2char(ptr, u8cc);
1685 // Overlong encoded ASCII or ASCII with composing char
1686 // is displayed normally, except a NUL.
1687 if (mb_c < 0x80)
1688 {
1689 c = mb_c;
1690#ifdef FEAT_LINEBREAK
1691 c0 = mb_c;
1692#endif
1693 }
1694 mb_utf8 = TRUE;
1695
1696 // At start of the line we can have a composing char.
1697 // Draw it as a space with a composing char.
1698 if (utf_iscomposing(mb_c))
1699 {
1700 int i;
1701
1702 for (i = Screen_mco - 1; i > 0; --i)
1703 u8cc[i] = u8cc[i - 1];
1704 u8cc[0] = mb_c;
1705 mb_c = ' ';
1706 }
1707 }
1708
1709 if ((mb_l == 1 && c >= 0x80)
1710 || (mb_l >= 1 && mb_c == 0)
1711 || (mb_l > 1 && (!vim_isprintc(mb_c))))
1712 {
1713 // Illegal UTF-8 byte: display as <xx>.
1714 // Non-BMP character : display as ? or fullwidth ?.
1715 transchar_hex(extra, mb_c);
1716# ifdef FEAT_RIGHTLEFT
1717 if (wp->w_p_rl) // reverse
1718 rl_mirror(extra);
1719# endif
1720 p_extra = extra;
1721 c = *p_extra;
1722 mb_c = mb_ptr2char_adv(&p_extra);
1723 mb_utf8 = (c >= 0x80);
1724 n_extra = (int)STRLEN(p_extra);
1725 c_extra = NUL;
1726 c_final = NUL;
1727 if (area_attr == 0 && search_attr == 0)
1728 {
1729 n_attr = n_extra + 1;
Bram Moolenaar42e931b2019-12-04 19:08:50 +01001730 extra_attr = hl_combine_attr(
1731 win_attr, HL_ATTR(HLF_8));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001732 saved_attr2 = char_attr; // save current attr
1733 }
1734 }
1735 else if (mb_l == 0) // at the NUL at end-of-line
1736 mb_l = 1;
1737#ifdef FEAT_ARABIC
1738 else if (p_arshape && !p_tbidi && ARABIC_CHAR(mb_c))
1739 {
1740 // Do Arabic shaping.
1741 int pc, pc1, nc;
1742 int pcc[MAX_MCO];
1743
1744 // The idea of what is the previous and next
1745 // character depends on 'rightleft'.
1746 if (wp->w_p_rl)
1747 {
1748 pc = prev_c;
1749 pc1 = prev_c1;
1750 nc = utf_ptr2char(ptr + mb_l);
1751 prev_c1 = u8cc[0];
1752 }
1753 else
1754 {
1755 pc = utfc_ptr2char(ptr + mb_l, pcc);
1756 nc = prev_c;
1757 pc1 = pcc[0];
1758 }
1759 prev_c = mb_c;
1760
1761 mb_c = arabic_shape(mb_c, &c, &u8cc[0], pc, pc1, nc);
1762 }
1763 else
1764 prev_c = mb_c;
1765#endif
1766 }
1767 else // enc_dbcs
1768 {
1769 mb_l = MB_BYTE2LEN(c);
1770 if (mb_l == 0) // at the NUL at end-of-line
1771 mb_l = 1;
1772 else if (mb_l > 1)
1773 {
1774 // We assume a second byte below 32 is illegal.
1775 // Hopefully this is OK for all double-byte encodings!
1776 if (ptr[1] >= 32)
1777 mb_c = (c << 8) + ptr[1];
1778 else
1779 {
1780 if (ptr[1] == NUL)
1781 {
1782 // head byte at end of line
1783 mb_l = 1;
Bram Moolenaar32ee6272020-06-10 14:16:49 +02001784 transchar_nonprint(wp->w_buffer, extra, c);
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001785 }
1786 else
1787 {
1788 // illegal tail byte
1789 mb_l = 2;
1790 STRCPY(extra, "XX");
1791 }
1792 p_extra = extra;
1793 n_extra = (int)STRLEN(extra) - 1;
1794 c_extra = NUL;
1795 c_final = NUL;
1796 c = *p_extra++;
1797 if (area_attr == 0 && search_attr == 0)
1798 {
1799 n_attr = n_extra + 1;
Bram Moolenaar42e931b2019-12-04 19:08:50 +01001800 extra_attr = hl_combine_attr(
1801 win_attr, HL_ATTR(HLF_8));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001802 saved_attr2 = char_attr; // save current attr
1803 }
1804 mb_c = c;
1805 }
1806 }
1807 }
1808 // If a double-width char doesn't fit display a '>' in the
1809 // last column; the character is displayed at the start of the
1810 // next line.
1811 if ((
1812# ifdef FEAT_RIGHTLEFT
1813 wp->w_p_rl ? (col <= 0) :
1814# endif
1815 (col >= wp->w_width - 1))
1816 && (*mb_char2cells)(mb_c) == 2)
1817 {
1818 c = '>';
1819 mb_c = c;
1820 mb_utf8 = FALSE;
1821 mb_l = 1;
Bram Moolenaar92e25ab2019-11-26 22:39:10 +01001822 multi_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001823 // Put pointer back so that the character will be
1824 // displayed at the start of the next line.
1825 --ptr;
1826#ifdef FEAT_CONCEAL
1827 did_decrement_ptr = TRUE;
1828#endif
1829 }
1830 else if (*ptr != NUL)
1831 ptr += mb_l - 1;
1832
1833 // If a double-width char doesn't fit at the left side display
1834 // a '<' in the first column. Don't do this for unprintable
1835 // characters.
1836 if (n_skip > 0 && mb_l > 1 && n_extra == 0)
1837 {
1838 n_extra = 1;
1839 c_extra = MB_FILLER_CHAR;
1840 c_final = NUL;
1841 c = ' ';
1842 if (area_attr == 0 && search_attr == 0)
1843 {
1844 n_attr = n_extra + 1;
Bram Moolenaar42e931b2019-12-04 19:08:50 +01001845 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001846 saved_attr2 = char_attr; // save current attr
1847 }
1848 mb_c = c;
1849 mb_utf8 = FALSE;
1850 mb_l = 1;
1851 }
1852
1853 }
1854 ++ptr;
1855
1856 if (extra_check)
1857 {
1858#ifdef FEAT_SPELL
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001859 // Check spelling (unless at the end of the line).
1860 // Only do this when there is no syntax highlighting, the
1861 // @Spell cluster is not used or the current syntax item
1862 // contains the @Spell cluster.
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02001863 v = (long)(ptr - line);
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001864 if (has_spell && v >= word_end && v > cur_checked_col)
1865 {
1866 spell_attr = 0;
1867 if (c != 0 && (
1868# ifdef FEAT_SYN_HL
1869 !has_syntax ||
1870# endif
1871 can_spell))
1872 {
1873 char_u *prev_ptr, *p;
1874 int len;
1875 hlf_T spell_hlf = HLF_COUNT;
Bram Moolenaarfabc3ca2020-11-05 19:07:21 +01001876
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001877 if (has_mbyte)
1878 {
1879 prev_ptr = ptr - mb_l;
1880 v -= mb_l - 1;
1881 }
1882 else
1883 prev_ptr = ptr - 1;
1884
1885 // Use nextline[] if possible, it has the start of the
1886 // next line concatenated.
1887 if ((prev_ptr - line) - nextlinecol >= 0)
1888 p = nextline + (prev_ptr - line) - nextlinecol;
1889 else
1890 p = prev_ptr;
1891 cap_col -= (int)(prev_ptr - line);
1892 len = spell_check(wp, p, &spell_hlf, &cap_col,
1893 nochange);
1894 word_end = v + len;
1895
1896 // In Insert mode only highlight a word that
1897 // doesn't touch the cursor.
1898 if (spell_hlf != HLF_COUNT
1899 && (State & INSERT) != 0
1900 && wp->w_cursor.lnum == lnum
1901 && wp->w_cursor.col >=
1902 (colnr_T)(prev_ptr - line)
1903 && wp->w_cursor.col < (colnr_T)word_end)
1904 {
1905 spell_hlf = HLF_COUNT;
1906 spell_redraw_lnum = lnum;
1907 }
1908
1909 if (spell_hlf == HLF_COUNT && p != prev_ptr
1910 && (p - nextline) + len > nextline_idx)
1911 {
1912 // Remember that the good word continues at the
1913 // start of the next line.
1914 checked_lnum = lnum + 1;
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02001915 checked_col = (int)((p - nextline)
1916 + len - nextline_idx);
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001917 }
1918
1919 // Turn index into actual attributes.
1920 if (spell_hlf != HLF_COUNT)
1921 spell_attr = highlight_attr[spell_hlf];
1922
1923 if (cap_col > 0)
1924 {
1925 if (p != prev_ptr
1926 && (p - nextline) + cap_col >= nextline_idx)
1927 {
1928 // Remember that the word in the next line
1929 // must start with a capital.
1930 capcol_lnum = lnum + 1;
1931 cap_col = (int)((p - nextline) + cap_col
1932 - nextline_idx);
1933 }
1934 else
1935 // Compute the actual column.
1936 cap_col += (int)(prev_ptr - line);
1937 }
1938 }
1939 }
1940 if (spell_attr != 0)
1941 {
1942 if (!attr_pri)
1943 char_attr = hl_combine_attr(char_attr, spell_attr);
1944 else
1945 char_attr = hl_combine_attr(spell_attr, char_attr);
1946 }
1947#endif
1948#ifdef FEAT_LINEBREAK
1949 // Found last space before word: check for line break.
1950 if (wp->w_p_lbr && c0 == c
1951 && VIM_ISBREAK(c) && !VIM_ISBREAK((int)*ptr))
1952 {
1953 int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0;
1954 char_u *p = ptr - (mb_off + 1);
1955
1956 // TODO: is passing p for start of the line OK?
1957 n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
1958 NULL) - 1;
1959 if (c == TAB && n_extra + col > wp->w_width)
1960# ifdef FEAT_VARTABS
1961 n_extra = tabstop_padding(vcol, wp->w_buffer->b_p_ts,
1962 wp->w_buffer->b_p_vts_array) - 1;
1963# else
1964 n_extra = (int)wp->w_buffer->b_p_ts
1965 - vcol % (int)wp->w_buffer->b_p_ts - 1;
1966# endif
1967
1968 c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' ';
1969 c_final = NUL;
1970 if (VIM_ISWHITE(c))
1971 {
Bram Moolenaar912bc4a2019-12-01 18:58:11 +01001972# ifdef FEAT_CONCEAL
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001973 if (c == TAB)
1974 // See "Tab alignment" below.
1975 FIX_FOR_BOGUSCOLS;
Bram Moolenaar912bc4a2019-12-01 18:58:11 +01001976# endif
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02001977 if (!wp->w_p_list)
1978 c = ' ';
1979 }
1980 }
1981#endif
1982
1983 // 'list': Change char 160 to lcs_nbsp and space to lcs_space.
1984 // But not when the character is followed by a composing
1985 // character (use mb_l to check that).
1986 if (wp->w_p_list
1987 && ((((c == 160 && mb_l == 1)
1988 || (mb_utf8
1989 && ((mb_c == 160 && mb_l == 2)
1990 || (mb_c == 0x202f && mb_l == 3))))
1991 && lcs_nbsp)
1992 || (c == ' '
1993 && mb_l == 1
1994 && lcs_space
1995 && ptr - line <= trailcol)))
1996 {
1997 c = (c == ' ') ? lcs_space : lcs_nbsp;
1998 if (area_attr == 0 && search_attr == 0)
1999 {
2000 n_attr = 1;
Bram Moolenaar42e931b2019-12-04 19:08:50 +01002001 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002002 saved_attr2 = char_attr; // save current attr
2003 }
2004 mb_c = c;
2005 if (enc_utf8 && utf_char2len(c) > 1)
2006 {
2007 mb_utf8 = TRUE;
2008 u8cc[0] = 0;
2009 c = 0xc0;
2010 }
2011 else
2012 mb_utf8 = FALSE;
2013 }
2014
2015 if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
2016 {
2017 c = lcs_trail;
2018 if (!attr_pri)
2019 {
2020 n_attr = 1;
Bram Moolenaar42e931b2019-12-04 19:08:50 +01002021 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002022 saved_attr2 = char_attr; // save current attr
2023 }
2024 mb_c = c;
2025 if (enc_utf8 && utf_char2len(c) > 1)
2026 {
2027 mb_utf8 = TRUE;
2028 u8cc[0] = 0;
2029 c = 0xc0;
2030 }
2031 else
2032 mb_utf8 = FALSE;
2033 }
2034 }
2035
2036 // Handling of non-printable characters.
2037 if (!vim_isprintc(c))
2038 {
2039 // when getting a character from the file, we may have to
2040 // turn it into something else on the way to putting it
2041 // into "ScreenLines".
2042 if (c == TAB && (!wp->w_p_list || lcs_tab1))
2043 {
2044 int tab_len = 0;
2045 long vcol_adjusted = vcol; // removed showbreak length
2046#ifdef FEAT_LINEBREAK
Bram Moolenaaree857022019-11-09 23:26:40 +01002047 char_u *sbr = get_showbreak_value(wp);
2048
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002049 // only adjust the tab_len, when at the first column
2050 // after the showbreak value was drawn
Bram Moolenaaree857022019-11-09 23:26:40 +01002051 if (*sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap)
2052 vcol_adjusted = vcol - MB_CHARLEN(sbr);
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002053#endif
2054 // tab amount depends on current column
2055#ifdef FEAT_VARTABS
2056 tab_len = tabstop_padding(vcol_adjusted,
2057 wp->w_buffer->b_p_ts,
2058 wp->w_buffer->b_p_vts_array) - 1;
2059#else
2060 tab_len = (int)wp->w_buffer->b_p_ts
2061 - vcol_adjusted % (int)wp->w_buffer->b_p_ts - 1;
2062#endif
2063
2064#ifdef FEAT_LINEBREAK
2065 if (!wp->w_p_lbr || !wp->w_p_list)
2066#endif
2067 // tab amount depends on current column
2068 n_extra = tab_len;
2069#ifdef FEAT_LINEBREAK
2070 else
2071 {
2072 char_u *p;
2073 int len;
2074 int i;
2075 int saved_nextra = n_extra;
2076
2077#ifdef FEAT_CONCEAL
2078 if (vcol_off > 0)
2079 // there are characters to conceal
2080 tab_len += vcol_off;
2081 // boguscols before FIX_FOR_BOGUSCOLS macro from above
2082 if (wp->w_p_list && lcs_tab1 && old_boguscols > 0
2083 && n_extra > tab_len)
2084 tab_len += n_extra - tab_len;
2085#endif
2086
2087 // if n_extra > 0, it gives the number of chars, to
2088 // use for a tab, else we need to calculate the width
2089 // for a tab
2090 len = (tab_len * mb_char2len(lcs_tab2));
2091 if (n_extra > 0)
2092 len += n_extra - tab_len;
2093 c = lcs_tab1;
2094 p = alloc(len + 1);
2095 vim_memset(p, ' ', len);
2096 p[len] = NUL;
2097 vim_free(p_extra_free);
2098 p_extra_free = p;
2099 for (i = 0; i < tab_len; i++)
2100 {
2101 int lcs = lcs_tab2;
2102
2103 if (*p == NUL)
2104 {
2105 tab_len = i;
2106 break;
2107 }
2108
2109 // if lcs_tab3 is given, need to change the char
2110 // for tab
2111 if (lcs_tab3 && i == tab_len - 1)
2112 lcs = lcs_tab3;
2113 mb_char2bytes(lcs, p);
2114 p += mb_char2len(lcs);
2115 n_extra += mb_char2len(lcs)
2116 - (saved_nextra > 0 ? 1 : 0);
2117 }
2118 p_extra = p_extra_free;
2119#ifdef FEAT_CONCEAL
2120 // n_extra will be increased by FIX_FOX_BOGUSCOLS
2121 // macro below, so need to adjust for that here
2122 if (vcol_off > 0)
2123 n_extra -= vcol_off;
2124#endif
2125 }
2126#endif
2127#ifdef FEAT_CONCEAL
2128 {
2129 int vc_saved = vcol_off;
2130
2131 // Tab alignment should be identical regardless of
2132 // 'conceallevel' value. So tab compensates of all
2133 // previous concealed characters, and thus resets
2134 // vcol_off and boguscols accumulated so far in the
2135 // line. Note that the tab can be longer than
2136 // 'tabstop' when there are concealed characters.
2137 FIX_FOR_BOGUSCOLS;
2138
2139 // Make sure, the highlighting for the tab char will be
2140 // correctly set further below (effectively reverts the
2141 // FIX_FOR_BOGSUCOLS macro
2142 if (n_extra == tab_len + vc_saved && wp->w_p_list
2143 && lcs_tab1)
2144 tab_len += vc_saved;
2145 }
2146#endif
2147 mb_utf8 = FALSE; // don't draw as UTF-8
2148 if (wp->w_p_list)
2149 {
2150 c = (n_extra == 0 && lcs_tab3) ? lcs_tab3 : lcs_tab1;
2151#ifdef FEAT_LINEBREAK
2152 if (wp->w_p_lbr)
2153 c_extra = NUL; // using p_extra from above
2154 else
2155#endif
2156 c_extra = lcs_tab2;
2157 c_final = lcs_tab3;
2158 n_attr = tab_len + 1;
Bram Moolenaar42e931b2019-12-04 19:08:50 +01002159 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002160 saved_attr2 = char_attr; // save current attr
2161 mb_c = c;
2162 if (enc_utf8 && utf_char2len(c) > 1)
2163 {
2164 mb_utf8 = TRUE;
2165 u8cc[0] = 0;
2166 c = 0xc0;
2167 }
2168 }
2169 else
2170 {
2171 c_final = NUL;
2172 c_extra = ' ';
2173 c = ' ';
2174 }
2175 }
2176 else if (c == NUL
2177 && (wp->w_p_list
2178 || ((fromcol >= 0 || fromcol_prev >= 0)
2179 && tocol > vcol
2180 && VIsual_mode != Ctrl_V
2181 && (
2182# ifdef FEAT_RIGHTLEFT
2183 wp->w_p_rl ? (col >= 0) :
2184# endif
2185 (col < wp->w_width))
2186 && !(noinvcur
2187 && lnum == wp->w_cursor.lnum
2188 && (colnr_T)vcol == wp->w_virtcol)))
2189 && lcs_eol_one > 0)
2190 {
2191 // Display a '$' after the line or highlight an extra
2192 // character if the line break is included.
2193#if defined(FEAT_DIFF) || defined(LINE_ATTR)
2194 // For a diff line the highlighting continues after the
2195 // "$".
2196 if (
2197# ifdef FEAT_DIFF
2198 diff_hlf == (hlf_T)0
2199# ifdef LINE_ATTR
2200 &&
2201# endif
2202# endif
2203# ifdef LINE_ATTR
2204 line_attr == 0
2205# endif
2206 )
2207#endif
2208 {
2209 // In virtualedit, visual selections may extend
2210 // beyond end of line.
2211 if (area_highlighting && virtual_active()
2212 && tocol != MAXCOL && vcol < tocol)
2213 n_extra = 0;
2214 else
2215 {
2216 p_extra = at_end_str;
2217 n_extra = 1;
2218 c_extra = NUL;
2219 c_final = NUL;
2220 }
2221 }
2222 if (wp->w_p_list && lcs_eol > 0)
2223 c = lcs_eol;
2224 else
2225 c = ' ';
2226 lcs_eol_one = -1;
2227 --ptr; // put it back at the NUL
2228 if (!attr_pri)
2229 {
Bram Moolenaar42e931b2019-12-04 19:08:50 +01002230 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002231 n_attr = 1;
2232 }
2233 mb_c = c;
2234 if (enc_utf8 && utf_char2len(c) > 1)
2235 {
2236 mb_utf8 = TRUE;
2237 u8cc[0] = 0;
2238 c = 0xc0;
2239 }
2240 else
2241 mb_utf8 = FALSE; // don't draw as UTF-8
2242 }
2243 else if (c != NUL)
2244 {
Bram Moolenaar32ee6272020-06-10 14:16:49 +02002245 p_extra = transchar_buf(wp->w_buffer, c);
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002246 if (n_extra == 0)
2247 n_extra = byte2cells(c) - 1;
2248#ifdef FEAT_RIGHTLEFT
2249 if ((dy_flags & DY_UHEX) && wp->w_p_rl)
2250 rl_mirror(p_extra); // reverse "<12>"
2251#endif
2252 c_extra = NUL;
2253 c_final = NUL;
2254#ifdef FEAT_LINEBREAK
2255 if (wp->w_p_lbr)
2256 {
2257 char_u *p;
2258
2259 c = *p_extra;
2260 p = alloc(n_extra + 1);
2261 vim_memset(p, ' ', n_extra);
2262 STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1);
2263 p[n_extra] = NUL;
2264 vim_free(p_extra_free);
2265 p_extra_free = p_extra = p;
2266 }
2267 else
2268#endif
2269 {
2270 n_extra = byte2cells(c) - 1;
2271 c = *p_extra++;
2272 }
2273 if (!attr_pri)
2274 {
2275 n_attr = n_extra + 1;
Bram Moolenaar42e931b2019-12-04 19:08:50 +01002276 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002277 saved_attr2 = char_attr; // save current attr
2278 }
2279 mb_utf8 = FALSE; // don't draw as UTF-8
2280 }
2281 else if (VIsual_active
2282 && (VIsual_mode == Ctrl_V
2283 || VIsual_mode == 'v')
2284 && virtual_active()
2285 && tocol != MAXCOL
2286 && vcol < tocol
2287 && (
2288#ifdef FEAT_RIGHTLEFT
2289 wp->w_p_rl ? (col >= 0) :
2290#endif
2291 (col < wp->w_width)))
2292 {
2293 c = ' ';
2294 --ptr; // put it back at the NUL
2295 }
2296#if defined(LINE_ATTR)
2297 else if ((
2298# ifdef FEAT_DIFF
2299 diff_hlf != (hlf_T)0 ||
2300# endif
2301# ifdef FEAT_TERMINAL
2302 win_attr != 0 ||
2303# endif
2304 line_attr != 0
2305 ) && (
2306# ifdef FEAT_RIGHTLEFT
2307 wp->w_p_rl ? (col >= 0) :
2308# endif
2309 (col
2310# ifdef FEAT_CONCEAL
2311 - boguscols
2312# endif
2313 < wp->w_width)))
2314 {
2315 // Highlight until the right side of the window
2316 c = ' ';
2317 --ptr; // put it back at the NUL
2318
2319 // Remember we do the char for line highlighting.
2320 ++did_line_attr;
2321
2322 // don't do search HL for the rest of the line
2323 if (line_attr != 0 && char_attr == search_attr
2324 && (did_line_attr > 1
2325 || (wp->w_p_list && lcs_eol > 0)))
2326 char_attr = line_attr;
2327# ifdef FEAT_DIFF
2328 if (diff_hlf == HLF_TXD)
2329 {
2330 diff_hlf = HLF_CHD;
2331 if (vi_attr == 0 || char_attr != vi_attr)
2332 {
2333 char_attr = HL_ATTR(diff_hlf);
2334 if (wp->w_p_cul && lnum == wp->w_cursor.lnum
2335 && wp->w_p_culopt_flags != CULOPT_NBR
2336 && (!cul_screenline
2337 || (vcol >= left_curline_col
2338 && vcol <= right_curline_col)))
2339 char_attr = hl_combine_attr(
2340 char_attr, HL_ATTR(HLF_CUL));
2341 }
2342 }
2343# endif
2344# ifdef FEAT_TERMINAL
2345 if (win_attr != 0)
2346 {
2347 char_attr = win_attr;
Bram Moolenaara3817732019-10-16 16:31:44 +02002348 if (wp->w_p_cul && lnum == wp->w_cursor.lnum
2349 && wp->w_p_culopt_flags != CULOPT_NBR)
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002350 {
2351 if (!cul_screenline || (vcol >= left_curline_col
2352 && vcol <= right_curline_col))
2353 char_attr = hl_combine_attr(
2354 char_attr, HL_ATTR(HLF_CUL));
2355 }
2356 else if (line_attr)
2357 char_attr = hl_combine_attr(char_attr, line_attr);
2358 }
2359# endif
2360 }
2361#endif
2362 }
2363
2364#ifdef FEAT_CONCEAL
2365 if ( wp->w_p_cole > 0
2366 && (wp != curwin || lnum != wp->w_cursor.lnum ||
2367 conceal_cursor_line(wp))
2368 && ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0)
2369 && !(lnum_in_visual_area
2370 && vim_strchr(wp->w_p_cocu, 'v') == NULL))
2371 {
2372 char_attr = conceal_attr;
2373 if ((prev_syntax_id != syntax_seqnr || has_match_conc > 1)
Bram Moolenaar211dd3f2020-06-25 20:07:04 +02002374 && (syn_get_sub_char() != NUL
2375 || (has_match_conc && match_conc)
2376 || wp->w_p_cole == 1)
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002377 && wp->w_p_cole != 3)
2378 {
2379 // First time at this concealed item: display one
2380 // character.
Bram Moolenaar211dd3f2020-06-25 20:07:04 +02002381 if (has_match_conc && match_conc)
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002382 c = match_conc;
2383 else if (syn_get_sub_char() != NUL)
2384 c = syn_get_sub_char();
2385 else if (lcs_conceal != NUL)
2386 c = lcs_conceal;
2387 else
2388 c = ' ';
2389
2390 prev_syntax_id = syntax_seqnr;
2391
2392 if (n_extra > 0)
2393 vcol_off += n_extra;
2394 vcol += n_extra;
2395 if (wp->w_p_wrap && n_extra > 0)
2396 {
2397# ifdef FEAT_RIGHTLEFT
2398 if (wp->w_p_rl)
2399 {
2400 col -= n_extra;
2401 boguscols -= n_extra;
2402 }
2403 else
2404# endif
2405 {
2406 boguscols += n_extra;
2407 col += n_extra;
2408 }
2409 }
2410 n_extra = 0;
2411 n_attr = 0;
2412 }
2413 else if (n_skip == 0)
2414 {
2415 is_concealing = TRUE;
2416 n_skip = 1;
2417 }
2418 mb_c = c;
2419 if (enc_utf8 && utf_char2len(c) > 1)
2420 {
2421 mb_utf8 = TRUE;
2422 u8cc[0] = 0;
2423 c = 0xc0;
2424 }
2425 else
2426 mb_utf8 = FALSE; // don't draw as UTF-8
2427 }
2428 else
2429 {
2430 prev_syntax_id = 0;
2431 is_concealing = FALSE;
2432 }
2433
2434 if (n_skip > 0 && did_decrement_ptr)
2435 // not showing the '>', put pointer back to avoid getting stuck
2436 ++ptr;
2437
2438#endif // FEAT_CONCEAL
2439 }
2440
2441#ifdef FEAT_CONCEAL
2442 // In the cursor line and we may be concealing characters: correct
2443 // the cursor column when we reach its position.
2444 if (!did_wcol && draw_state == WL_LINE
2445 && wp == curwin && lnum == wp->w_cursor.lnum
2446 && conceal_cursor_line(wp)
2447 && (int)wp->w_virtcol <= vcol + n_skip)
2448 {
2449# ifdef FEAT_RIGHTLEFT
2450 if (wp->w_p_rl)
2451 wp->w_wcol = wp->w_width - col + boguscols - 1;
2452 else
2453# endif
2454 wp->w_wcol = col - boguscols;
2455 wp->w_wrow = row;
2456 did_wcol = TRUE;
2457 curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;
2458 }
2459#endif
2460
2461 // Don't override visual selection highlighting.
2462 if (n_attr > 0
2463 && draw_state == WL_LINE
2464 && !attr_pri)
2465 {
2466#ifdef LINE_ATTR
2467 if (line_attr)
2468 char_attr = hl_combine_attr(extra_attr, line_attr);
2469 else
2470#endif
2471 char_attr = extra_attr;
2472 }
2473
2474#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
2475 // XIM don't send preedit_start and preedit_end, but they send
2476 // preedit_changed and commit. Thus Vim can't set "im_is_active", use
2477 // im_is_preediting() here.
2478 if (p_imst == IM_ON_THE_SPOT
2479 && xic != NULL
2480 && lnum == wp->w_cursor.lnum
2481 && (State & INSERT)
2482 && !p_imdisable
2483 && im_is_preediting()
2484 && draw_state == WL_LINE)
2485 {
2486 colnr_T tcol;
2487
2488 if (preedit_end_col == MAXCOL)
2489 getvcol(curwin, &(wp->w_cursor), &tcol, NULL, NULL);
2490 else
2491 tcol = preedit_end_col;
2492 if ((long)preedit_start_col <= vcol && vcol < (long)tcol)
2493 {
2494 if (feedback_old_attr < 0)
2495 {
2496 feedback_col = 0;
2497 feedback_old_attr = char_attr;
2498 }
2499 char_attr = im_get_feedback_attr(feedback_col);
2500 if (char_attr < 0)
2501 char_attr = feedback_old_attr;
2502 feedback_col++;
2503 }
2504 else if (feedback_old_attr >= 0)
2505 {
2506 char_attr = feedback_old_attr;
2507 feedback_old_attr = -1;
2508 feedback_col = 0;
2509 }
2510 }
2511#endif
2512 // Handle the case where we are in column 0 but not on the first
2513 // character of the line and the user wants us to show us a
2514 // special character (via 'listchars' option "precedes:<char>".
2515 if (lcs_prec_todo != NUL
2516 && wp->w_p_list
Bram Moolenaarbffba7f2019-09-20 17:00:17 +02002517 && (wp->w_p_wrap ?
2518 (wp->w_skipcol > 0 && row == 0) :
2519 wp->w_leftcol > 0)
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002520#ifdef FEAT_DIFF
2521 && filler_todo <= 0
2522#endif
2523 && draw_state > WL_NR
2524 && c != NUL)
2525 {
2526 c = lcs_prec;
2527 lcs_prec_todo = NUL;
2528 if (has_mbyte && (*mb_char2cells)(mb_c) > 1)
2529 {
2530 // Double-width character being overwritten by the "precedes"
2531 // character, need to fill up half the character.
2532 c_extra = MB_FILLER_CHAR;
2533 c_final = NUL;
2534 n_extra = 1;
2535 n_attr = 2;
Bram Moolenaar42e931b2019-12-04 19:08:50 +01002536 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002537 }
2538 mb_c = c;
2539 if (enc_utf8 && utf_char2len(c) > 1)
2540 {
2541 mb_utf8 = TRUE;
2542 u8cc[0] = 0;
2543 c = 0xc0;
2544 }
2545 else
2546 mb_utf8 = FALSE; // don't draw as UTF-8
2547 if (!attr_pri)
2548 {
2549 saved_attr3 = char_attr; // save current attr
Bram Moolenaar42e931b2019-12-04 19:08:50 +01002550 char_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002551 n_attr3 = 1;
2552 }
2553 }
2554
2555 // At end of the text line or just after the last character.
2556 if ((c == NUL
2557#if defined(LINE_ATTR)
2558 || did_line_attr == 1
2559#endif
2560 ) && eol_hl_off == 0)
2561 {
2562#ifdef FEAT_SEARCH_EXTRA
2563 // flag to indicate whether prevcol equals startcol of search_hl or
2564 // one of the matches
2565 int prevcol_hl_flag = get_prevcol_hl_flag(wp, &screen_search_hl,
2566 (long)(ptr - line) - (c == NUL));
2567#endif
2568 // Invert at least one char, used for Visual and empty line or
2569 // highlight match at end of line. If it's beyond the last
2570 // char on the screen, just overwrite that one (tricky!) Not
2571 // needed when a '$' was displayed for 'list'.
2572 if (lcs_eol == lcs_eol_one
2573 && ((area_attr != 0 && vcol == fromcol
2574 && (VIsual_mode != Ctrl_V
2575 || lnum == VIsual.lnum
2576 || lnum == curwin->w_cursor.lnum)
2577 && c == NUL)
2578#ifdef FEAT_SEARCH_EXTRA
2579 // highlight 'hlsearch' match at end of line
2580 || (prevcol_hl_flag
2581# ifdef FEAT_SYN_HL
2582 && !(wp->w_p_cul && lnum == wp->w_cursor.lnum
2583 && !(wp == curwin && VIsual_active))
2584# endif
2585# ifdef FEAT_DIFF
2586 && diff_hlf == (hlf_T)0
2587# endif
2588# if defined(LINE_ATTR)
2589 && did_line_attr <= 1
2590# endif
2591 )
2592#endif
2593 ))
2594 {
2595 int n = 0;
2596
2597#ifdef FEAT_RIGHTLEFT
2598 if (wp->w_p_rl)
2599 {
2600 if (col < 0)
2601 n = 1;
2602 }
2603 else
2604#endif
2605 {
2606 if (col >= wp->w_width)
2607 n = -1;
2608 }
2609 if (n != 0)
2610 {
2611 // At the window boundary, highlight the last character
2612 // instead (better than nothing).
2613 off += n;
2614 col += n;
2615 }
2616 else
2617 {
2618 // Add a blank character to highlight.
2619 ScreenLines[off] = ' ';
2620 if (enc_utf8)
2621 ScreenLinesUC[off] = 0;
2622 }
2623#ifdef FEAT_SEARCH_EXTRA
2624 if (area_attr == 0)
2625 {
2626 // Use attributes from match with highest priority among
2627 // 'search_hl' and the match list.
2628 get_search_match_hl(wp, &screen_search_hl,
2629 (long)(ptr - line), &char_attr);
2630 }
2631#endif
2632 ScreenAttrs[off] = char_attr;
2633#ifdef FEAT_RIGHTLEFT
2634 if (wp->w_p_rl)
2635 {
2636 --col;
2637 --off;
2638 }
2639 else
2640#endif
2641 {
2642 ++col;
2643 ++off;
2644 }
2645 ++vcol;
2646 eol_hl_off = 1;
2647 }
2648 }
2649
2650 // At end of the text line.
2651 if (c == NUL)
2652 {
2653#ifdef FEAT_SYN_HL
2654 // Highlight 'cursorcolumn' & 'colorcolumn' past end of the line.
2655 if (wp->w_p_wrap)
2656 v = wp->w_skipcol;
2657 else
2658 v = wp->w_leftcol;
2659
2660 // check if line ends before left margin
2661 if (vcol < v + col - win_col_off(wp))
2662 vcol = v + col - win_col_off(wp);
2663#ifdef FEAT_CONCEAL
2664 // Get rid of the boguscols now, we want to draw until the right
2665 // edge for 'cursorcolumn'.
2666 col -= boguscols;
2667 boguscols = 0;
2668#endif
2669
2670 if (draw_color_col)
2671 draw_color_col = advance_color_col(VCOL_HLC, &color_cols);
2672
2673 if (((wp->w_p_cuc
2674 && (int)wp->w_virtcol >= VCOL_HLC - eol_hl_off
2675 && (int)wp->w_virtcol <
2676 wp->w_width * (row - startrow + 1) + v
2677 && lnum != wp->w_cursor.lnum)
2678 || draw_color_col
2679 || win_attr != 0)
2680# ifdef FEAT_RIGHTLEFT
2681 && !wp->w_p_rl
2682# endif
2683 )
2684 {
2685 int rightmost_vcol = 0;
2686 int i;
2687
2688 if (wp->w_p_cuc)
2689 rightmost_vcol = wp->w_virtcol;
2690 if (draw_color_col)
2691 // determine rightmost colorcolumn to possibly draw
2692 for (i = 0; color_cols[i] >= 0; ++i)
2693 if (rightmost_vcol < color_cols[i])
2694 rightmost_vcol = color_cols[i];
2695
2696 while (col < wp->w_width)
2697 {
2698 ScreenLines[off] = ' ';
2699 if (enc_utf8)
2700 ScreenLinesUC[off] = 0;
2701 ++col;
2702 if (draw_color_col)
2703 draw_color_col = advance_color_col(VCOL_HLC,
2704 &color_cols);
2705
2706 if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol)
2707 ScreenAttrs[off++] = HL_ATTR(HLF_CUC);
2708 else if (draw_color_col && VCOL_HLC == *color_cols)
2709 ScreenAttrs[off++] = HL_ATTR(HLF_MC);
2710 else
2711 ScreenAttrs[off++] = win_attr;
2712
2713 if (VCOL_HLC >= rightmost_vcol && win_attr == 0)
2714 break;
2715
2716 ++vcol;
2717 }
2718 }
2719#endif
2720
2721 screen_line(screen_row, wp->w_wincol, col,
2722 (int)wp->w_width, screen_line_flags);
2723 row++;
2724
2725 // Update w_cline_height and w_cline_folded if the cursor line was
2726 // updated (saves a call to plines() later).
2727 if (wp == curwin && lnum == curwin->w_cursor.lnum)
2728 {
2729 curwin->w_cline_row = startrow;
2730 curwin->w_cline_height = row - startrow;
2731#ifdef FEAT_FOLDING
2732 curwin->w_cline_folded = FALSE;
2733#endif
2734 curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW);
2735 }
2736
2737 break;
2738 }
2739
2740 // Show "extends" character from 'listchars' if beyond the line end and
2741 // 'list' is set.
2742 if (lcs_ext != NUL
2743 && wp->w_p_list
2744 && !wp->w_p_wrap
2745#ifdef FEAT_DIFF
2746 && filler_todo <= 0
2747#endif
2748 && (
2749#ifdef FEAT_RIGHTLEFT
2750 wp->w_p_rl ? col == 0 :
2751#endif
2752 col == wp->w_width - 1)
2753 && (*ptr != NUL
2754 || (wp->w_p_list && lcs_eol_one > 0)
2755 || (n_extra && (c_extra != NUL || *p_extra != NUL))))
2756 {
2757 c = lcs_ext;
Bram Moolenaar42e931b2019-12-04 19:08:50 +01002758 char_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT));
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002759 mb_c = c;
2760 if (enc_utf8 && utf_char2len(c) > 1)
2761 {
2762 mb_utf8 = TRUE;
2763 u8cc[0] = 0;
2764 c = 0xc0;
2765 }
2766 else
2767 mb_utf8 = FALSE;
2768 }
2769
2770#ifdef FEAT_SYN_HL
2771 // advance to the next 'colorcolumn'
2772 if (draw_color_col)
2773 draw_color_col = advance_color_col(VCOL_HLC, &color_cols);
2774
2775 // Highlight the cursor column if 'cursorcolumn' is set. But don't
2776 // highlight the cursor position itself.
2777 // Also highlight the 'colorcolumn' if it is different than
2778 // 'cursorcolumn'
Bram Moolenaarad5e5632020-09-15 20:52:26 +02002779 // Also highlight the 'colorcolumn' if 'breakindent' and/or 'showbreak'
2780 // options are set
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002781 vcol_save_attr = -1;
Bram Moolenaarfabc3ca2020-11-05 19:07:21 +01002782 if (((draw_state == WL_LINE ||
Bram Moolenaarad5e5632020-09-15 20:52:26 +02002783 draw_state == WL_BRI ||
2784 draw_state == WL_SBR) && !lnum_in_visual_area
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002785 && search_attr == 0 && area_attr == 0)
Bram Moolenaarfabc3ca2020-11-05 19:07:21 +01002786# ifdef FEAT_DIFF
2787 && filler_todo <= 0
2788# endif
2789 )
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02002790 {
2791 if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol
2792 && lnum != wp->w_cursor.lnum)
2793 {
2794 vcol_save_attr = char_attr;
2795 char_attr = hl_combine_attr(char_attr, HL_ATTR(HLF_CUC));
2796 }
2797 else if (draw_color_col && VCOL_HLC == *color_cols)
2798 {
2799 vcol_save_attr = char_attr;
2800 char_attr = hl_combine_attr(char_attr, HL_ATTR(HLF_MC));
2801 }
2802 }
2803#endif
2804
2805 // Store character to be displayed.
2806 // Skip characters that are left of the screen for 'nowrap'.
2807 vcol_prev = vcol;
2808 if (draw_state < WL_LINE || n_skip <= 0)
2809 {
2810 // Store the character.
2811#if defined(FEAT_RIGHTLEFT)
2812 if (has_mbyte && wp->w_p_rl && (*mb_char2cells)(mb_c) > 1)
2813 {
2814 // A double-wide character is: put first halve in left cell.
2815 --off;
2816 --col;
2817 }
2818#endif
2819 ScreenLines[off] = c;
2820 if (enc_dbcs == DBCS_JPNU)
2821 {
2822 if ((mb_c & 0xff00) == 0x8e00)
2823 ScreenLines[off] = 0x8e;
2824 ScreenLines2[off] = mb_c & 0xff;
2825 }
2826 else if (enc_utf8)
2827 {
2828 if (mb_utf8)
2829 {
2830 int i;
2831
2832 ScreenLinesUC[off] = mb_c;
2833 if ((c & 0xff) == 0)
2834 ScreenLines[off] = 0x80; // avoid storing zero
2835 for (i = 0; i < Screen_mco; ++i)
2836 {
2837 ScreenLinesC[i][off] = u8cc[i];
2838 if (u8cc[i] == 0)
2839 break;
2840 }
2841 }
2842 else
2843 ScreenLinesUC[off] = 0;
2844 }
2845 if (multi_attr)
2846 {
2847 ScreenAttrs[off] = multi_attr;
2848 multi_attr = 0;
2849 }
2850 else
2851 ScreenAttrs[off] = char_attr;
2852
2853 if (has_mbyte && (*mb_char2cells)(mb_c) > 1)
2854 {
2855 // Need to fill two screen columns.
2856 ++off;
2857 ++col;
2858 if (enc_utf8)
2859 // UTF-8: Put a 0 in the second screen char.
2860 ScreenLines[off] = 0;
2861 else
2862 // DBCS: Put second byte in the second screen char.
2863 ScreenLines[off] = mb_c & 0xff;
2864 if (draw_state > WL_NR
2865#ifdef FEAT_DIFF
2866 && filler_todo <= 0
2867#endif
2868 )
2869 ++vcol;
2870 // When "tocol" is halfway a character, set it to the end of
2871 // the character, otherwise highlighting won't stop.
2872 if (tocol == vcol)
2873 ++tocol;
2874#ifdef FEAT_RIGHTLEFT
2875 if (wp->w_p_rl)
2876 {
2877 // now it's time to backup one cell
2878 --off;
2879 --col;
2880 }
2881#endif
2882 }
2883#ifdef FEAT_RIGHTLEFT
2884 if (wp->w_p_rl)
2885 {
2886 --off;
2887 --col;
2888 }
2889 else
2890#endif
2891 {
2892 ++off;
2893 ++col;
2894 }
2895 }
2896#ifdef FEAT_CONCEAL
2897 else if (wp->w_p_cole > 0 && is_concealing)
2898 {
2899 --n_skip;
2900 ++vcol_off;
2901 if (n_extra > 0)
2902 vcol_off += n_extra;
2903 if (wp->w_p_wrap)
2904 {
2905 // Special voodoo required if 'wrap' is on.
2906 //
2907 // Advance the column indicator to force the line
2908 // drawing to wrap early. This will make the line
2909 // take up the same screen space when parts are concealed,
2910 // so that cursor line computations aren't messed up.
2911 //
2912 // To avoid the fictitious advance of 'col' causing
2913 // trailing junk to be written out of the screen line
2914 // we are building, 'boguscols' keeps track of the number
2915 // of bad columns we have advanced.
2916 if (n_extra > 0)
2917 {
2918 vcol += n_extra;
2919# ifdef FEAT_RIGHTLEFT
2920 if (wp->w_p_rl)
2921 {
2922 col -= n_extra;
2923 boguscols -= n_extra;
2924 }
2925 else
2926# endif
2927 {
2928 col += n_extra;
2929 boguscols += n_extra;
2930 }
2931 n_extra = 0;
2932 n_attr = 0;
2933 }
2934
2935
2936 if (has_mbyte && (*mb_char2cells)(mb_c) > 1)
2937 {
2938 // Need to fill two screen columns.
2939# ifdef FEAT_RIGHTLEFT
2940 if (wp->w_p_rl)
2941 {
2942 --boguscols;
2943 --col;
2944 }
2945 else
2946# endif
2947 {
2948 ++boguscols;
2949 ++col;
2950 }
2951 }
2952
2953# ifdef FEAT_RIGHTLEFT
2954 if (wp->w_p_rl)
2955 {
2956 --boguscols;
2957 --col;
2958 }
2959 else
2960# endif
2961 {
2962 ++boguscols;
2963 ++col;
2964 }
2965 }
2966 else
2967 {
2968 if (n_extra > 0)
2969 {
2970 vcol += n_extra;
2971 n_extra = 0;
2972 n_attr = 0;
2973 }
2974 }
2975
2976 }
2977#endif // FEAT_CONCEAL
2978 else
2979 --n_skip;
2980
2981 // Only advance the "vcol" when after the 'number' or 'relativenumber'
2982 // column.
2983 if (draw_state > WL_NR
2984#ifdef FEAT_DIFF
2985 && filler_todo <= 0
2986#endif
2987 )
2988 ++vcol;
2989
2990#ifdef FEAT_SYN_HL
2991 if (vcol_save_attr >= 0)
2992 char_attr = vcol_save_attr;
2993#endif
2994
2995 // restore attributes after "predeces" in 'listchars'
2996 if (draw_state > WL_NR && n_attr3 > 0 && --n_attr3 == 0)
2997 char_attr = saved_attr3;
2998
2999 // restore attributes after last 'listchars' or 'number' char
3000 if (n_attr > 0 && draw_state == WL_LINE && --n_attr == 0)
3001 char_attr = saved_attr2;
3002
3003 // At end of screen line and there is more to come: Display the line
3004 // so far. If there is no more to display it is caught above.
3005 if ((
3006#ifdef FEAT_RIGHTLEFT
3007 wp->w_p_rl ? (col < 0) :
3008#endif
3009 (col >= wp->w_width))
3010 && (*ptr != NUL
3011#ifdef FEAT_DIFF
3012 || filler_todo > 0
3013#endif
3014 || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str)
3015 || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL)))
3016 )
3017 {
3018#ifdef FEAT_CONCEAL
3019 screen_line(screen_row, wp->w_wincol, col - boguscols,
3020 (int)wp->w_width, screen_line_flags);
3021 boguscols = 0;
3022#else
3023 screen_line(screen_row, wp->w_wincol, col,
3024 (int)wp->w_width, screen_line_flags);
3025#endif
3026 ++row;
3027 ++screen_row;
3028
3029 // When not wrapping and finished diff lines, or when displayed
3030 // '$' and highlighting until last column, break here.
3031 if ((!wp->w_p_wrap
3032#ifdef FEAT_DIFF
3033 && filler_todo <= 0
3034#endif
3035 ) || lcs_eol_one == -1)
3036 break;
3037
3038 // When the window is too narrow draw all "@" lines.
3039 if (draw_state != WL_LINE
3040#ifdef FEAT_DIFF
3041 && filler_todo <= 0
3042#endif
3043 )
3044 {
3045 win_draw_end(wp, '@', ' ', TRUE, row, wp->w_height, HLF_AT);
3046 draw_vsep_win(wp, row);
3047 row = endrow;
3048 }
3049
3050 // When line got too long for screen break here.
3051 if (row == endrow)
3052 {
3053 ++row;
3054 break;
3055 }
3056
3057 if (screen_cur_row == screen_row - 1
3058#ifdef FEAT_DIFF
3059 && filler_todo <= 0
3060#endif
3061 && wp->w_width == Columns)
3062 {
3063 // Remember that the line wraps, used for modeless copy.
3064 LineWraps[screen_row - 1] = TRUE;
3065
3066 // Special trick to make copy/paste of wrapped lines work with
3067 // xterm/screen: write an extra character beyond the end of
3068 // the line. This will work with all terminal types
3069 // (regardless of the xn,am settings).
3070 // Only do this on a fast tty.
3071 // Only do this if the cursor is on the current line
3072 // (something has been written in it).
3073 // Don't do this for the GUI.
3074 // Don't do this for double-width characters.
3075 // Don't do this for a window not at the right screen border.
3076 if (p_tf
3077#ifdef FEAT_GUI
3078 && !gui.in_use
3079#endif
3080 && !(has_mbyte
3081 && ((*mb_off2cells)(LineOffset[screen_row],
3082 LineOffset[screen_row] + screen_Columns)
3083 == 2
3084 || (*mb_off2cells)(LineOffset[screen_row - 1]
3085 + (int)Columns - 2,
3086 LineOffset[screen_row] + screen_Columns)
3087 == 2)))
3088 {
3089 // First make sure we are at the end of the screen line,
3090 // then output the same character again to let the
3091 // terminal know about the wrap. If the terminal doesn't
3092 // auto-wrap, we overwrite the character.
3093 if (screen_cur_col != wp->w_width)
3094 screen_char(LineOffset[screen_row - 1]
3095 + (unsigned)Columns - 1,
3096 screen_row - 1, (int)(Columns - 1));
3097
3098 // When there is a multi-byte character, just output a
3099 // space to keep it simple.
3100 if (has_mbyte && MB_BYTE2LEN(ScreenLines[LineOffset[
3101 screen_row - 1] + (Columns - 1)]) > 1)
3102 out_char(' ');
3103 else
3104 out_char(ScreenLines[LineOffset[screen_row - 1]
3105 + (Columns - 1)]);
3106 // force a redraw of the first char on the next line
3107 ScreenAttrs[LineOffset[screen_row]] = (sattr_T)-1;
3108 screen_start(); // don't know where cursor is now
3109 }
3110 }
3111
3112 col = 0;
3113 off = (unsigned)(current_ScreenLine - ScreenLines);
3114#ifdef FEAT_RIGHTLEFT
3115 if (wp->w_p_rl)
3116 {
3117 col = wp->w_width - 1; // col is not used if breaking!
3118 off += col;
3119 }
3120#endif
3121
3122 // reset the drawing state for the start of a wrapped line
3123 draw_state = WL_START;
3124 saved_n_extra = n_extra;
3125 saved_p_extra = p_extra;
3126 saved_c_extra = c_extra;
3127 saved_c_final = c_final;
3128#ifdef FEAT_SYN_HL
3129 if (!(cul_screenline
3130# ifdef FEAT_DIFF
Bram Moolenaare7705982020-04-21 22:23:15 +02003131 && diff_hlf == (hlf_T)0
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02003132# endif
Bram Moolenaare7705982020-04-21 22:23:15 +02003133 ))
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02003134 saved_char_attr = char_attr;
3135 else
3136#endif
3137 saved_char_attr = 0;
3138 n_extra = 0;
3139 lcs_prec_todo = lcs_prec;
3140#ifdef FEAT_LINEBREAK
3141# ifdef FEAT_DIFF
3142 if (filler_todo <= 0)
3143# endif
3144 need_showbreak = TRUE;
3145#endif
3146#ifdef FEAT_DIFF
3147 --filler_todo;
3148 // When the filler lines are actually below the last line of the
3149 // file, don't draw the line itself, break here.
3150 if (filler_todo == 0 && wp->w_botfill)
3151 break;
3152#endif
3153 }
3154
3155 } // for every character in the line
3156
3157#ifdef FEAT_SPELL
3158 // After an empty line check first word for capital.
3159 if (*skipwhite(line) == NUL)
3160 {
3161 capcol_lnum = lnum + 1;
3162 cap_col = 0;
3163 }
3164#endif
Bram Moolenaar05ad5ff2019-11-30 22:48:27 +01003165#ifdef FEAT_PROP_POPUP
Bram Moolenaar7528d1f2019-09-19 23:06:20 +02003166 vim_free(text_props);
3167 vim_free(text_prop_idxs);
3168#endif
3169
3170 vim_free(p_extra_free);
3171 return row;
3172}