Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1 | /* 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. |
Bram Moolenaar | e89aeed | 2022-08-22 13:00:16 +0100 | [diff] [blame] | 12 | * This is the middle level, drawscreen.c is the higher level and screen.c the |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 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 |
| 23 | advance_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 |
| 37 | margin_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 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 78 | // structure with variables passed between win_line() and other functions |
| 79 | typedef struct { |
| 80 | int draw_state; // what to draw next |
| 81 | |
| 82 | linenr_T lnum; // line number to be drawn |
| 83 | |
| 84 | int startrow; // first row in the window to be drawn |
| 85 | int row; // row in the window, excl w_winrow |
| 86 | int screen_row; // row on the screen, incl w_winrow |
| 87 | |
| 88 | long vcol; // virtual column, before wrapping |
| 89 | int col; // visual column on screen, after wrapping |
| 90 | #ifdef FEAT_CONCEAL |
| 91 | int boguscols; // nonexistent columns added to "col" to force |
| 92 | // wrapping |
| 93 | int vcol_off; // offset for concealed characters |
| 94 | #endif |
| 95 | #ifdef FEAT_SYN_HL |
| 96 | int draw_color_col; // highlight colorcolumn |
| 97 | int *color_cols; // pointer to according columns array |
| 98 | #endif |
| 99 | int eol_hl_off; // 1 if highlighted char after EOL |
| 100 | |
| 101 | unsigned off; // offset in ScreenLines/ScreenAttrs |
| 102 | |
| 103 | int win_attr; // background for the whole window, except |
| 104 | // margins and "~" lines. |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 105 | int wcr_attr; // attributes from 'wincolor' |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 106 | |
| 107 | int screen_line_flags; // flags for screen_line() |
| 108 | |
| 109 | // TRUE when 'cursorlineopt' has "screenline" and cursor is in this line |
| 110 | int cul_screenline; |
| 111 | |
| 112 | int char_attr; // attributes for the next character |
| 113 | |
| 114 | int n_extra; // number of extra bytes |
| 115 | char_u *p_extra; // string of extra chars, plus NUL, only used |
| 116 | // when c_extra and c_final are NUL |
| 117 | int c_extra; // extra chars, all the same |
| 118 | int c_final; // final char, mandatory if set |
| 119 | |
| 120 | // saved "extra" items for when draw_state becomes WL_LINE (again) |
| 121 | int saved_n_extra; |
| 122 | char_u *saved_p_extra; |
| 123 | int saved_c_extra; |
| 124 | int saved_c_final; |
| 125 | int saved_char_attr; |
| 126 | |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 127 | char_u extra[21]; // "%ld " and 'fdc' must fit in here |
| 128 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 129 | #ifdef FEAT_DIFF |
| 130 | hlf_T diff_hlf; // type of diff highlighting |
| 131 | #endif |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 132 | int filler_lines; // nr of filler lines to be drawn |
| 133 | int filler_todo; // nr of filler lines still to do + 1 |
| 134 | #ifdef FEAT_SIGNS |
| 135 | sign_attrs_T sattr; |
| 136 | #endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 137 | } winlinevars_T; |
| 138 | |
| 139 | // draw_state values for items that are drawn in sequence: |
| 140 | #define WL_START 0 // nothing done yet, must be zero |
| 141 | #ifdef FEAT_CMDWIN |
| 142 | # define WL_CMDLINE (WL_START + 1) // cmdline window column |
| 143 | #else |
| 144 | # define WL_CMDLINE WL_START |
| 145 | #endif |
| 146 | #ifdef FEAT_FOLDING |
| 147 | # define WL_FOLD (WL_CMDLINE + 1) // 'foldcolumn' |
| 148 | #else |
| 149 | # define WL_FOLD WL_CMDLINE |
| 150 | #endif |
| 151 | #ifdef FEAT_SIGNS |
| 152 | # define WL_SIGN (WL_FOLD + 1) // column for signs |
| 153 | #else |
| 154 | # define WL_SIGN WL_FOLD // column for signs |
| 155 | #endif |
| 156 | #define WL_NR (WL_SIGN + 1) // line number |
| 157 | #ifdef FEAT_LINEBREAK |
| 158 | # define WL_BRI (WL_NR + 1) // 'breakindent' |
| 159 | #else |
| 160 | # define WL_BRI WL_NR |
| 161 | #endif |
| 162 | #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF) |
| 163 | # define WL_SBR (WL_BRI + 1) // 'showbreak' or 'diff' |
| 164 | #else |
| 165 | # define WL_SBR WL_BRI |
| 166 | #endif |
| 167 | #define WL_LINE (WL_SBR + 1) // text in the line |
| 168 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 169 | #ifdef FEAT_SIGNS |
| 170 | /* |
Bram Moolenaar | e413ea0 | 2021-11-24 16:20:13 +0000 | [diff] [blame] | 171 | * Return TRUE if CursorLineSign highlight is to be used. |
| 172 | */ |
| 173 | static int |
| 174 | use_cursor_line_sign(win_T *wp, linenr_T lnum) |
| 175 | { |
| 176 | return wp->w_p_cul |
| 177 | && lnum == wp->w_cursor.lnum |
| 178 | && (wp->w_p_culopt_flags & CULOPT_NBR); |
| 179 | } |
| 180 | |
| 181 | /* |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 182 | * Get information needed to display the sign in line "wlv->lnum" in window |
| 183 | * "wp". |
| 184 | * If "nrcol" is TRUE, the sign is going to be displayed in the number column. |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 185 | * Otherwise the sign is going to be displayed in the sign column. |
| 186 | */ |
| 187 | static void |
| 188 | get_sign_display_info( |
| 189 | int nrcol, |
| 190 | win_T *wp, |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 191 | winlinevars_T *wlv) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 192 | { |
| 193 | int text_sign; |
| 194 | # ifdef FEAT_SIGN_ICONS |
| 195 | int icon_sign; |
| 196 | # endif |
| 197 | |
| 198 | // Draw two cells with the sign value or blank. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 199 | wlv->c_extra = ' '; |
| 200 | wlv->c_final = NUL; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 201 | if (nrcol) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 202 | wlv->n_extra = number_width(wp) + 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 203 | else |
| 204 | { |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 205 | if (use_cursor_line_sign(wp, wlv->lnum)) |
| 206 | wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_CLS)); |
Bram Moolenaar | e413ea0 | 2021-11-24 16:20:13 +0000 | [diff] [blame] | 207 | else |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 208 | wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_SC)); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 209 | wlv->n_extra = 2; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 210 | } |
| 211 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 212 | if (wlv->row == wlv->startrow |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 213 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 214 | + wlv->filler_lines && wlv->filler_todo <= 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 215 | #endif |
| 216 | ) |
| 217 | { |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 218 | text_sign = (wlv->sattr.sat_text != NULL) ? wlv->sattr.sat_typenr : 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 219 | # ifdef FEAT_SIGN_ICONS |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 220 | icon_sign = (wlv->sattr.sat_icon != NULL) ? wlv->sattr.sat_typenr : 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 221 | if (gui.in_use && icon_sign != 0) |
| 222 | { |
| 223 | // Use the image in this position. |
| 224 | if (nrcol) |
| 225 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 226 | wlv->c_extra = NUL; |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 227 | sprintf((char *)wlv->extra, "%-*c ", |
| 228 | number_width(wp), SIGN_BYTE); |
| 229 | wlv->p_extra = wlv->extra; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 230 | wlv->n_extra = (int)STRLEN(wlv->p_extra); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 231 | } |
| 232 | else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 233 | wlv->c_extra = SIGN_BYTE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 234 | # ifdef FEAT_NETBEANS_INTG |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 235 | if (netbeans_active() && (buf_signcount(wp->w_buffer, wlv->lnum) |
| 236 | > 1)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 237 | { |
| 238 | if (nrcol) |
| 239 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 240 | wlv->c_extra = NUL; |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 241 | sprintf((char *)wlv->extra, "%-*c ", number_width(wp), |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 242 | MULTISIGN_BYTE); |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 243 | wlv->p_extra = wlv->extra; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 244 | wlv->n_extra = (int)STRLEN(wlv->p_extra); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 245 | } |
| 246 | else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 247 | wlv->c_extra = MULTISIGN_BYTE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 248 | } |
| 249 | # endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 250 | wlv->c_final = NUL; |
| 251 | wlv->char_attr = icon_sign; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 252 | } |
| 253 | else |
| 254 | # endif |
| 255 | if (text_sign != 0) |
| 256 | { |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 257 | wlv->p_extra = wlv->sattr.sat_text; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 258 | if (wlv->p_extra != NULL) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 259 | { |
| 260 | if (nrcol) |
| 261 | { |
| 262 | int n, width = number_width(wp) - 2; |
| 263 | |
| 264 | for (n = 0; n < width; n++) |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 265 | wlv->extra[n] = ' '; |
| 266 | wlv->extra[n] = 0; |
| 267 | STRCAT(wlv->extra, wlv->p_extra); |
| 268 | STRCAT(wlv->extra, " "); |
| 269 | wlv->p_extra = wlv->extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 270 | } |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 271 | wlv->c_extra = NUL; |
| 272 | wlv->c_final = NUL; |
| 273 | wlv->n_extra = (int)STRLEN(wlv->p_extra); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 274 | } |
Bram Moolenaar | e413ea0 | 2021-11-24 16:20:13 +0000 | [diff] [blame] | 275 | |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 276 | if (use_cursor_line_sign(wp, wlv->lnum) |
| 277 | && wlv->sattr.sat_culhl > 0) |
| 278 | wlv->char_attr = wlv->sattr.sat_culhl; |
Bram Moolenaar | e413ea0 | 2021-11-24 16:20:13 +0000 | [diff] [blame] | 279 | else |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 280 | wlv->char_attr = wlv->sattr.sat_texthl; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | } |
| 284 | #endif |
| 285 | |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 286 | /* |
| 287 | * Display the absolute or relative line number. After the first row fill with |
| 288 | * blanks when the 'n' flag isn't in 'cpo'. |
| 289 | */ |
| 290 | static void |
| 291 | handle_lnum_col( |
| 292 | win_T *wp, |
| 293 | winlinevars_T *wlv, |
| 294 | int sign_present UNUSED, |
| 295 | int num_attr) |
| 296 | { |
| 297 | if ((wp->w_p_nu || wp->w_p_rnu) |
| 298 | && (wlv->row == wlv->startrow + wlv->filler_lines |
| 299 | || vim_strchr(p_cpo, CPO_NUMCOL) == NULL)) |
| 300 | { |
| 301 | #ifdef FEAT_SIGNS |
| 302 | // If 'signcolumn' is set to 'number' and a sign is present |
| 303 | // in 'lnum', then display the sign instead of the line |
| 304 | // number. |
| 305 | if ((*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u') && sign_present) |
| 306 | get_sign_display_info(TRUE, wp, wlv); |
| 307 | else |
| 308 | #endif |
| 309 | { |
| 310 | // Draw the line number (empty space after wrapping). |
| 311 | if (wlv->row == wlv->startrow + wlv->filler_lines) |
| 312 | { |
| 313 | long num; |
| 314 | char *fmt = "%*ld "; |
| 315 | |
| 316 | if (wp->w_p_nu && !wp->w_p_rnu) |
| 317 | // 'number' + 'norelativenumber' |
| 318 | num = (long)wlv->lnum; |
| 319 | else |
| 320 | { |
| 321 | // 'relativenumber', don't use negative numbers |
| 322 | num = labs((long)get_cursor_rel_lnum(wp, wlv->lnum)); |
| 323 | if (num == 0 && wp->w_p_nu && wp->w_p_rnu) |
| 324 | { |
| 325 | // 'number' + 'relativenumber' |
| 326 | num = wlv->lnum; |
| 327 | fmt = "%-*ld "; |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | sprintf((char *)wlv->extra, fmt, number_width(wp), num); |
| 332 | if (wp->w_skipcol > 0) |
| 333 | for (wlv->p_extra = wlv->extra; *wlv->p_extra == ' '; |
| 334 | ++wlv->p_extra) |
| 335 | *wlv->p_extra = '-'; |
| 336 | #ifdef FEAT_RIGHTLEFT |
| 337 | if (wp->w_p_rl) // reverse line numbers |
| 338 | { |
| 339 | char_u *p1, *p2; |
| 340 | int t; |
| 341 | |
| 342 | // like rl_mirror(), but keep the space at the end |
| 343 | p2 = skipwhite(wlv->extra); |
| 344 | p2 = skiptowhite(p2) - 1; |
| 345 | for (p1 = skipwhite(wlv->extra); p1 < p2; ++p1, --p2) |
| 346 | { |
| 347 | t = *p1; |
| 348 | *p1 = *p2; |
| 349 | *p2 = t; |
| 350 | } |
| 351 | } |
| 352 | #endif |
| 353 | wlv->p_extra = wlv->extra; |
| 354 | wlv->c_extra = NUL; |
| 355 | wlv->c_final = NUL; |
| 356 | } |
| 357 | else |
| 358 | { |
| 359 | wlv->c_extra = ' '; |
| 360 | wlv->c_final = NUL; |
| 361 | } |
| 362 | wlv->n_extra = number_width(wp) + 1; |
| 363 | wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_N)); |
| 364 | #ifdef FEAT_SYN_HL |
| 365 | // When 'cursorline' is set highlight the line number of |
| 366 | // the current line differently. |
| 367 | // When 'cursorlineopt' does not have "line" only |
| 368 | // highlight the line number itself. |
| 369 | // TODO: Can we use CursorLine instead of CursorLineNr |
| 370 | // when CursorLineNr isn't set? |
| 371 | if (wp->w_p_cul |
| 372 | && wlv->lnum == wp->w_cursor.lnum |
| 373 | && (wp->w_p_culopt_flags & CULOPT_NBR) |
| 374 | && (wlv->row == wlv->startrow + wlv->filler_lines |
| 375 | || (wlv->row > wlv->startrow + wlv->filler_lines |
| 376 | && (wp->w_p_culopt_flags & CULOPT_LINE)))) |
| 377 | wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_CLN)); |
| 378 | #endif |
| 379 | if (wp->w_p_rnu && wlv->lnum < wp->w_cursor.lnum |
| 380 | && HL_ATTR(HLF_LNA) != 0) |
| 381 | // Use LineNrAbove |
| 382 | wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_LNA)); |
| 383 | if (wp->w_p_rnu && wlv->lnum > wp->w_cursor.lnum |
| 384 | && HL_ATTR(HLF_LNB) != 0) |
| 385 | // Use LineNrBelow |
| 386 | wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_LNB)); |
| 387 | } |
| 388 | #ifdef FEAT_SIGNS |
| 389 | if (num_attr) |
| 390 | wlv->char_attr = num_attr; |
| 391 | #endif |
| 392 | } |
| 393 | } |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 394 | #if defined(FEAT_PROP_POPUP) || defined(PROTO) |
Bram Moolenaar | 952c9b0 | 2022-08-10 16:00:33 +0100 | [diff] [blame] | 395 | /* |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 396 | * Return the cell size of virtual text after truncation. |
| 397 | */ |
| 398 | static int |
| 399 | textprop_size_after_trunc( |
| 400 | win_T *wp, |
| 401 | int flags, // TP_FLAG_ALIGN_* |
| 402 | int added, |
| 403 | char_u *text, |
| 404 | int *n_used_ptr) |
| 405 | { |
| 406 | int space = (flags & (TP_FLAG_ALIGN_BELOW | TP_FLAG_ALIGN_ABOVE)) |
| 407 | ? wp->w_width : added; |
| 408 | int len = (int)STRLEN(text); |
| 409 | int strsize = 0; |
| 410 | int n_used; |
| 411 | |
| 412 | // if the remaining size is to small wrap anyway and use the next line |
| 413 | if (space < PROP_TEXT_MIN_CELLS) |
| 414 | space += wp->w_width; |
| 415 | for (n_used = 0; n_used < len; n_used += (*mb_ptr2len)(text + n_used)) |
| 416 | { |
| 417 | int clen = ptr2cells(text + n_used); |
| 418 | |
| 419 | if (strsize + clen > space) |
| 420 | break; |
| 421 | strsize += clen; |
| 422 | } |
| 423 | *n_used_ptr = n_used; |
| 424 | return strsize; |
| 425 | } |
| 426 | |
| 427 | /* |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 428 | * Take care of padding, right-align and truncation of virtual text after a |
| 429 | * line. |
| 430 | * if "n_attr" is not NULL then "n_extra" and "p_extra" are adjusted for any |
| 431 | * padding, right-align and truncation. Otherwise only the size is computed. |
| 432 | * When "n_attr" is NULL returns the number of screen cells used. |
| 433 | * Otherwise returns TRUE when drawing continues on the next line. |
Bram Moolenaar | 952c9b0 | 2022-08-10 16:00:33 +0100 | [diff] [blame] | 434 | */ |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 435 | int |
| 436 | text_prop_position( |
| 437 | win_T *wp, |
| 438 | textprop_T *tp, |
| 439 | int vcol, // current screen column |
| 440 | int *n_extra, // nr of bytes for virtual text |
| 441 | char_u **p_extra, // virtual text |
| 442 | int *n_attr, // attribute cells, NULL if not used |
| 443 | int *n_attr_skip) // cells to skip attr, NULL if not used |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 444 | { |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 445 | int right = (tp->tp_flags & TP_FLAG_ALIGN_RIGHT); |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 446 | int above = (tp->tp_flags & TP_FLAG_ALIGN_ABOVE); |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 447 | int below = (tp->tp_flags & TP_FLAG_ALIGN_BELOW); |
| 448 | int wrap = (tp->tp_flags & TP_FLAG_WRAP); |
| 449 | int padding = tp->tp_col == MAXCOL && tp->tp_len > 1 |
| 450 | ? tp->tp_len - 1 : 0; |
| 451 | int col_with_padding = vcol + (below ? 0 : padding); |
| 452 | int room = wp->w_width - col_with_padding; |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 453 | int before = room; // spaces before the text |
| 454 | int after = 0; // spaces after the text |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 455 | int n_used = *n_extra; |
| 456 | char_u *l = NULL; |
| 457 | int strsize = vim_strsize(*p_extra); |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 458 | int cells = wrap ? strsize : textprop_size_after_trunc(wp, |
| 459 | tp->tp_flags, before, *p_extra, &n_used); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 460 | |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 461 | if (wrap || right || above || below || padding > 0 || n_used < *n_extra) |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 462 | { |
Bram Moolenaar | b84d565 | 2022-09-20 17:57:53 +0100 | [diff] [blame] | 463 | int col_off = win_col_off(wp) + win_col_off2(wp); |
| 464 | int skip_add = 0; |
| 465 | |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 466 | if (above) |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 467 | { |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 468 | before = 0; |
Bram Moolenaar | 79f8b84 | 2022-09-11 13:31:01 +0100 | [diff] [blame] | 469 | after = wp->w_width - cells - win_col_off(wp) - padding; |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 470 | } |
| 471 | else |
| 472 | { |
| 473 | // Right-align: fill with before |
| 474 | if (right) |
| 475 | before -= cells; |
| 476 | if (before < 0 |
| 477 | || !(right || below) |
| 478 | || (below |
| 479 | ? (col_with_padding == 0 || !wp->w_p_wrap) |
| 480 | : (n_used < *n_extra))) |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 481 | { |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 482 | if (right && (wrap || room < PROP_TEXT_MIN_CELLS)) |
| 483 | { |
| 484 | // right-align on next line instead of wrapping if possible |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 485 | before = wp->w_width - col_off - strsize + room; |
| 486 | if (before < 0) |
| 487 | before = 0; |
| 488 | else |
| 489 | n_used = *n_extra; |
Bram Moolenaar | b84d565 | 2022-09-20 17:57:53 +0100 | [diff] [blame] | 490 | skip_add = col_off; |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 491 | } |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 492 | else |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 493 | before = 0; |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 494 | } |
Bram Moolenaar | 2fdc9b5 | 2022-09-20 15:59:22 +0100 | [diff] [blame] | 495 | else if (below && before > 0) |
| 496 | // include 'number' column et al. |
Bram Moolenaar | b84d565 | 2022-09-20 17:57:53 +0100 | [diff] [blame] | 497 | skip_add = col_off; |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 498 | } |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 499 | |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 500 | // With 'nowrap' add one to show the "extends" character if needed (it |
| 501 | // doesn't show if the text just fits). |
| 502 | if (!wp->w_p_wrap |
| 503 | && n_used < *n_extra |
| 504 | && wp->w_lcs_chars.ext != NUL |
| 505 | && wp->w_p_list) |
| 506 | ++n_used; |
Bram Moolenaar | b84d565 | 2022-09-20 17:57:53 +0100 | [diff] [blame] | 507 | if (!wp->w_p_wrap && below && padding > 0) |
| 508 | skip_add = col_off; |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 509 | |
| 510 | // add 1 for NUL, 2 for when '…' is used |
| 511 | if (n_attr != NULL) |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 512 | l = alloc(n_used + before + after + padding + 3); |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 513 | if (n_attr == NULL || l != NULL) |
| 514 | { |
| 515 | int off = 0; |
| 516 | |
| 517 | if (n_attr != NULL) |
| 518 | { |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 519 | vim_memset(l, ' ', before); |
| 520 | off += before; |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 521 | if (padding > 0) |
| 522 | { |
| 523 | vim_memset(l + off, ' ', padding); |
| 524 | off += padding; |
| 525 | } |
| 526 | vim_strncpy(l + off, *p_extra, n_used); |
| 527 | off += n_used; |
| 528 | } |
| 529 | else |
| 530 | { |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 531 | off = before + after + padding + n_used; |
| 532 | cells += before + after + padding; |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 533 | } |
| 534 | if (n_attr != NULL) |
| 535 | { |
| 536 | if (n_used < *n_extra && wp->w_p_wrap) |
| 537 | { |
| 538 | char_u *lp = l + off - 1; |
| 539 | |
| 540 | if (has_mbyte) |
| 541 | { |
| 542 | // change last character to '…' |
| 543 | lp -= (*mb_head_off)(l, lp); |
| 544 | STRCPY(lp, "…"); |
| 545 | n_used = lp - l + 3 - padding; |
| 546 | } |
| 547 | else |
| 548 | // change last character to '>' |
| 549 | *lp = '>'; |
| 550 | } |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 551 | else if (after > 0) |
| 552 | { |
| 553 | vim_memset(l + off, ' ', after); |
| 554 | l[off + after] = NUL; |
| 555 | } |
| 556 | |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 557 | *p_extra = l; |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 558 | *n_extra = n_used + before + after + padding; |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 559 | *n_attr = mb_charlen(*p_extra); |
Bram Moolenaar | 79f8b84 | 2022-09-11 13:31:01 +0100 | [diff] [blame] | 560 | if (above) |
Bram Moolenaar | ccfaa07 | 2022-09-20 16:15:30 +0100 | [diff] [blame] | 561 | *n_attr -= padding + after; |
Bram Moolenaar | b84d565 | 2022-09-20 17:57:53 +0100 | [diff] [blame] | 562 | *n_attr_skip = before + padding + skip_add; |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 563 | } |
| 564 | } |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 565 | } |
Bram Moolenaar | 952c9b0 | 2022-08-10 16:00:33 +0100 | [diff] [blame] | 566 | |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 567 | if (n_attr == NULL) |
| 568 | return cells; |
| 569 | return (below && col_with_padding > win_col_off(wp) && !wp->w_p_wrap); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 570 | } |
| 571 | #endif |
| 572 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 573 | /* |
| 574 | * Called when finished with the line: draw the screen line and handle any |
| 575 | * highlighting until the right of the window. |
| 576 | */ |
| 577 | static void |
| 578 | draw_screen_line(win_T *wp, winlinevars_T *wlv) |
| 579 | { |
| 580 | #ifdef FEAT_SYN_HL |
| 581 | long v; |
| 582 | |
| 583 | // Highlight 'cursorcolumn' & 'colorcolumn' past end of the line. |
| 584 | if (wp->w_p_wrap) |
| 585 | v = wp->w_skipcol; |
| 586 | else |
| 587 | v = wp->w_leftcol; |
| 588 | |
| 589 | // check if line ends before left margin |
| 590 | if (wlv->vcol < v + wlv->col - win_col_off(wp)) |
| 591 | wlv->vcol = v + wlv->col - win_col_off(wp); |
| 592 | # ifdef FEAT_CONCEAL |
| 593 | // Get rid of the boguscols now, we want to draw until the right |
| 594 | // edge for 'cursorcolumn'. |
| 595 | wlv->col -= wlv->boguscols; |
| 596 | wlv->boguscols = 0; |
| 597 | # define VCOL_HLC (wlv->vcol - wlv->vcol_off) |
| 598 | # else |
| 599 | # define VCOL_HLC (wlv->vcol) |
| 600 | # endif |
| 601 | |
| 602 | if (wlv->draw_color_col) |
| 603 | wlv->draw_color_col = advance_color_col(VCOL_HLC, &wlv->color_cols); |
| 604 | |
| 605 | if (((wp->w_p_cuc |
| 606 | && (int)wp->w_virtcol >= VCOL_HLC - wlv->eol_hl_off |
| 607 | && (int)wp->w_virtcol < |
| 608 | (long)wp->w_width * (wlv->row - wlv->startrow + 1) + v |
| 609 | && wlv->lnum != wp->w_cursor.lnum) |
| 610 | || wlv->draw_color_col |
| 611 | || wlv->win_attr != 0) |
| 612 | # ifdef FEAT_RIGHTLEFT |
| 613 | && !wp->w_p_rl |
| 614 | # endif |
| 615 | ) |
| 616 | { |
| 617 | int rightmost_vcol = 0; |
| 618 | int i; |
| 619 | |
| 620 | if (wp->w_p_cuc) |
| 621 | rightmost_vcol = wp->w_virtcol; |
| 622 | if (wlv->draw_color_col) |
| 623 | // determine rightmost colorcolumn to possibly draw |
| 624 | for (i = 0; wlv->color_cols[i] >= 0; ++i) |
| 625 | if (rightmost_vcol < wlv->color_cols[i]) |
| 626 | rightmost_vcol = wlv->color_cols[i]; |
| 627 | |
| 628 | while (wlv->col < wp->w_width) |
| 629 | { |
| 630 | ScreenLines[wlv->off] = ' '; |
| 631 | if (enc_utf8) |
| 632 | ScreenLinesUC[wlv->off] = 0; |
| 633 | ScreenCols[wlv->off] = MAXCOL; |
| 634 | ++wlv->col; |
| 635 | if (wlv->draw_color_col) |
| 636 | wlv->draw_color_col = advance_color_col( |
| 637 | VCOL_HLC, &wlv->color_cols); |
| 638 | |
| 639 | if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol) |
| 640 | ScreenAttrs[wlv->off++] = HL_ATTR(HLF_CUC); |
| 641 | else if (wlv->draw_color_col && VCOL_HLC == *wlv->color_cols) |
| 642 | ScreenAttrs[wlv->off++] = HL_ATTR(HLF_MC); |
| 643 | else |
| 644 | ScreenAttrs[wlv->off++] = wlv->win_attr; |
| 645 | |
| 646 | if (VCOL_HLC >= rightmost_vcol && wlv->win_attr == 0) |
| 647 | break; |
| 648 | |
| 649 | ++wlv->vcol; |
| 650 | } |
| 651 | } |
| 652 | #endif |
| 653 | |
| 654 | screen_line(wp, wlv->screen_row, wp->w_wincol, wlv->col, |
| 655 | wp->w_width, wlv->screen_line_flags); |
| 656 | ++wlv->row; |
| 657 | ++wlv->screen_row; |
| 658 | } |
| 659 | #undef VCOL_HLC |
| 660 | |
| 661 | /* |
| 662 | * Start a screen line at column zero. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 663 | * When "save_extra" is TRUE save and reset n_extra, p_extra, etc. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 664 | */ |
| 665 | static void |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 666 | win_line_start(win_T *wp UNUSED, winlinevars_T *wlv, int save_extra) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 667 | { |
| 668 | wlv->col = 0; |
| 669 | wlv->off = (unsigned)(current_ScreenLine - ScreenLines); |
| 670 | |
| 671 | #ifdef FEAT_RIGHTLEFT |
| 672 | if (wp->w_p_rl) |
| 673 | { |
| 674 | // Rightleft window: process the text in the normal direction, but put |
| 675 | // it in current_ScreenLine[] from right to left. Start at the |
| 676 | // rightmost column of the window. |
| 677 | wlv->col = wp->w_width - 1; |
| 678 | wlv->off += wlv->col; |
| 679 | wlv->screen_line_flags |= SLF_RIGHTLEFT; |
| 680 | } |
| 681 | #endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 682 | if (save_extra) |
| 683 | { |
| 684 | // reset the drawing state for the start of a wrapped line |
| 685 | wlv->draw_state = WL_START; |
| 686 | wlv->saved_n_extra = wlv->n_extra; |
| 687 | wlv->saved_p_extra = wlv->p_extra; |
| 688 | wlv->saved_c_extra = wlv->c_extra; |
| 689 | wlv->saved_c_final = wlv->c_final; |
| 690 | #ifdef FEAT_SYN_HL |
| 691 | if (!(wlv->cul_screenline |
| 692 | # ifdef FEAT_DIFF |
| 693 | && wlv->diff_hlf == (hlf_T)0 |
| 694 | # endif |
| 695 | )) |
| 696 | wlv->saved_char_attr = wlv->char_attr; |
| 697 | else |
| 698 | #endif |
| 699 | wlv->saved_char_attr = 0; |
| 700 | wlv->n_extra = 0; |
| 701 | } |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 702 | } |
| 703 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 704 | /* |
| 705 | * Display line "lnum" of window 'wp' on the screen. |
| 706 | * Start at row "startrow", stop when "endrow" is reached. |
| 707 | * wp->w_virtcol needs to be valid. |
| 708 | * |
| 709 | * Return the number of last row the line occupies. |
| 710 | */ |
| 711 | int |
| 712 | win_line( |
| 713 | win_T *wp, |
| 714 | linenr_T lnum, |
| 715 | int startrow, |
| 716 | int endrow, |
| 717 | int nochange UNUSED, // not updating for changed text |
| 718 | int number_only) // only update the number column |
| 719 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 720 | winlinevars_T wlv; // variables passed between functions |
| 721 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 722 | int c = 0; // init for GCC |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 723 | #ifdef FEAT_LINEBREAK |
| 724 | long vcol_sbr = -1; // virtual column after showbreak |
| 725 | #endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 726 | long vcol_prev = -1; // "wlv.vcol" of previous character |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 727 | char_u *line; // current line |
| 728 | char_u *ptr; // current position in "line" |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 729 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 730 | char_u *p_extra_free = NULL; // p_extra needs to be freed |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 731 | #ifdef FEAT_PROP_POPUP |
| 732 | char_u *p_extra_free2 = NULL; // another p_extra to be freed |
| 733 | #endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 734 | int extra_attr = 0; // attributes when n_extra != 0 |
Bram Moolenaar | 3569c0d | 2021-12-02 11:34:21 +0000 | [diff] [blame] | 735 | #if defined(FEAT_LINEBREAK) && defined(FEAT_PROP_POPUP) |
Bram Moolenaar | 6b839ac | 2021-11-29 21:12:35 +0000 | [diff] [blame] | 736 | int in_linebreak = FALSE; // n_extra set for showing linebreak |
| 737 | #endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 738 | static char_u *at_end_str = (char_u *)""; // used for p_extra when |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 739 | // displaying eol at end-of-line |
| 740 | int lcs_eol_one = wp->w_lcs_chars.eol; // eol until it's been used |
Bram Moolenaar | 3569c0d | 2021-12-02 11:34:21 +0000 | [diff] [blame] | 741 | int lcs_prec_todo = wp->w_lcs_chars.prec; |
| 742 | // prec until it's been used |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 743 | |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 744 | int n_attr = 0; // chars with special attr |
| 745 | int n_attr_skip = 0; // chars to skip before using extra_attr |
| 746 | int saved_attr2 = 0; // char_attr saved for n_attr |
| 747 | int n_attr3 = 0; // chars with overruling special attr |
| 748 | int saved_attr3 = 0; // char_attr saved for n_attr3 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 749 | |
| 750 | int n_skip = 0; // nr of chars to skip for 'nowrap' |
| 751 | |
| 752 | int fromcol = -10; // start of inverting |
| 753 | int tocol = MAXCOL; // end of inverting |
| 754 | int fromcol_prev = -2; // start of inverting after cursor |
| 755 | int noinvcur = FALSE; // don't invert the cursor |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 756 | int lnum_in_visual_area = FALSE; |
| 757 | pos_T pos; |
| 758 | long v; |
| 759 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 760 | int attr_pri = FALSE; // char_attr has priority |
| 761 | int area_highlighting = FALSE; // Visual or incsearch highlighting |
| 762 | // in this line |
| 763 | int vi_attr = 0; // attributes for Visual and incsearch |
| 764 | // highlighting |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 765 | int area_attr = 0; // attributes desired by highlighting |
| 766 | int search_attr = 0; // attributes desired by 'hlsearch' |
| 767 | #ifdef FEAT_SYN_HL |
| 768 | int vcol_save_attr = 0; // saved attr for 'cursorcolumn' |
| 769 | int syntax_attr = 0; // attributes desired by syntax |
Bram Moolenaar | 9115c61 | 2019-10-16 16:57:06 +0200 | [diff] [blame] | 770 | int prev_syntax_col = -1; // column of prev_syntax_attr |
| 771 | int prev_syntax_attr = 0; // syntax_attr at prev_syntax_col |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 772 | int has_syntax = FALSE; // this buffer has syntax highl. |
| 773 | int save_did_emsg; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 774 | #endif |
Bram Moolenaar | 05ad5ff | 2019-11-30 22:48:27 +0100 | [diff] [blame] | 775 | #ifdef FEAT_PROP_POPUP |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 776 | int text_prop_count; |
| 777 | int text_prop_next = 0; // next text property to use |
| 778 | textprop_T *text_props = NULL; |
| 779 | int *text_prop_idxs = NULL; |
| 780 | int text_props_active = 0; |
| 781 | proptype_T *text_prop_type = NULL; |
Bram Moolenaar | 9e7e28f | 2022-08-14 16:36:38 +0100 | [diff] [blame] | 782 | int extra_for_textprop = FALSE; // wlv.n_extra set for textprop |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 783 | int text_prop_attr = 0; |
Bram Moolenaar | cf2bb63 | 2022-09-02 13:26:29 +0100 | [diff] [blame] | 784 | int text_prop_attr_comb = 0; // text_prop_attr combined with |
| 785 | // syntax_attr |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 786 | int text_prop_id = 0; // active property ID |
Bram Moolenaar | 4d2031f | 2022-08-05 20:03:55 +0100 | [diff] [blame] | 787 | int text_prop_flags = 0; |
Bram Moolenaar | c9dc03f | 2022-09-12 17:51:07 +0100 | [diff] [blame] | 788 | int text_prop_above = FALSE; // first doing virtual text above |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 789 | int text_prop_follows = FALSE; // another text prop to display |
Bram Moolenaar | e38fc86 | 2022-08-11 17:24:50 +0100 | [diff] [blame] | 790 | int saved_search_attr = 0; // search_attr to be used when n_extra |
| 791 | // goes to zero |
Bram Moolenaar | 6eda17d | 2022-09-12 19:25:11 +0100 | [diff] [blame] | 792 | int saved_area_attr = 0; // idem for area_attr |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 793 | #endif |
| 794 | #ifdef FEAT_SPELL |
| 795 | int has_spell = FALSE; // this buffer has spell checking |
Bram Moolenaar | ae49aa8 | 2022-02-25 21:05:36 +0000 | [diff] [blame] | 796 | int can_spell = FALSE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 797 | # define SPWORDLEN 150 |
| 798 | char_u nextline[SPWORDLEN * 2];// text with start of the next line |
| 799 | int nextlinecol = 0; // column where nextline[] starts |
| 800 | int nextline_idx = 0; // index in nextline[] where next line |
| 801 | // starts |
| 802 | int spell_attr = 0; // attributes desired by spelling |
| 803 | int word_end = 0; // last byte with same spell_attr |
| 804 | static linenr_T checked_lnum = 0; // line number for "checked_col" |
| 805 | static int checked_col = 0; // column in "checked_lnum" up to which |
| 806 | // there are no spell errors |
| 807 | static int cap_col = -1; // column to check for Cap word |
| 808 | static linenr_T capcol_lnum = 0; // line number where "cap_col" used |
| 809 | int cur_checked_col = 0; // checked column for current line |
| 810 | #endif |
| 811 | int extra_check = 0; // has extra highlighting |
| 812 | int multi_attr = 0; // attributes desired by multibyte |
| 813 | int mb_l = 1; // multi-byte byte length |
| 814 | int mb_c = 0; // decoded multi-byte character |
| 815 | int mb_utf8 = FALSE; // screen char is UTF-8 char |
| 816 | int u8cc[MAX_MCO]; // composing UTF-8 chars |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 817 | #ifdef FEAT_DIFF |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 818 | int change_start = MAXCOL; // first col of changed area |
| 819 | int change_end = -1; // last col of changed area |
| 820 | #endif |
| 821 | colnr_T trailcol = MAXCOL; // start of trailing spaces |
Bram Moolenaar | 91478ae | 2021-02-03 15:58:13 +0100 | [diff] [blame] | 822 | colnr_T leadcol = 0; // start of leading spaces |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 823 | int in_multispace = FALSE; // in multiple consecutive spaces |
| 824 | int multispace_pos = 0; // position in lcs-multispace string |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 825 | #ifdef FEAT_LINEBREAK |
| 826 | int need_showbreak = FALSE; // overlong line, skipping first x |
| 827 | // chars |
Bram Moolenaar | 3ec3b8e | 2022-08-05 21:39:30 +0100 | [diff] [blame] | 828 | int dont_use_showbreak = FALSE; // do not use 'showbreak' |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 829 | #endif |
| 830 | #if defined(FEAT_SIGNS) || defined(FEAT_QUICKFIX) \ |
| 831 | || defined(FEAT_SYN_HL) || defined(FEAT_DIFF) |
| 832 | # define LINE_ATTR |
| 833 | int line_attr = 0; // attribute for the whole line |
Bram Moolenaar | bf91584 | 2022-08-06 22:38:02 +0100 | [diff] [blame] | 834 | int line_attr_save = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 835 | #endif |
| 836 | #ifdef FEAT_SIGNS |
| 837 | int sign_present = FALSE; |
James McCoy | a80aad7 | 2021-12-22 19:45:28 +0000 | [diff] [blame] | 838 | int num_attr = 0; // attribute for the number column |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 839 | #endif |
| 840 | #ifdef FEAT_ARABIC |
| 841 | int prev_c = 0; // previous Arabic character |
| 842 | int prev_c1 = 0; // first composing char for prev_c |
| 843 | #endif |
| 844 | #if defined(LINE_ATTR) |
| 845 | int did_line_attr = 0; |
| 846 | #endif |
| 847 | #ifdef FEAT_TERMINAL |
| 848 | int get_term_attr = FALSE; |
| 849 | #endif |
| 850 | #ifdef FEAT_SYN_HL |
| 851 | int cul_attr = 0; // set when 'cursorline' active |
| 852 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 853 | // margin columns for the screen line, needed for when 'cursorlineopt' |
| 854 | // contains "screenline" |
| 855 | int left_curline_col = 0; |
| 856 | int right_curline_col = 0; |
| 857 | #endif |
| 858 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 859 | #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
| 860 | int feedback_col = 0; |
| 861 | int feedback_old_attr = -1; |
| 862 | #endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 863 | |
| 864 | #if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA) |
| 865 | int match_conc = 0; // cchar for match functions |
Bram Moolenaar | 0c359af | 2021-11-29 19:18:57 +0000 | [diff] [blame] | 866 | int on_last_col = FALSE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 867 | #endif |
| 868 | #ifdef FEAT_CONCEAL |
| 869 | int syntax_flags = 0; |
| 870 | int syntax_seqnr = 0; |
| 871 | int prev_syntax_id = 0; |
| 872 | int conceal_attr = HL_ATTR(HLF_CONCEAL); |
| 873 | int is_concealing = FALSE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 874 | int did_wcol = FALSE; |
| 875 | int old_boguscols = 0; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 876 | # define VCOL_HLC (wlv.vcol - wlv.vcol_off) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 877 | # define FIX_FOR_BOGUSCOLS \ |
| 878 | { \ |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 879 | wlv.n_extra += wlv.vcol_off; \ |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 880 | wlv.vcol -= wlv.vcol_off; \ |
| 881 | wlv.vcol_off = 0; \ |
| 882 | wlv.col -= wlv.boguscols; \ |
| 883 | old_boguscols = wlv.boguscols; \ |
| 884 | wlv.boguscols = 0; \ |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 885 | } |
| 886 | #else |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 887 | # define VCOL_HLC (wlv.vcol) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 888 | #endif |
| 889 | |
| 890 | if (startrow > endrow) // past the end already! |
| 891 | return startrow; |
| 892 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 893 | CLEAR_FIELD(wlv); |
| 894 | |
| 895 | wlv.lnum = lnum; |
| 896 | wlv.startrow = startrow; |
| 897 | wlv.row = startrow; |
| 898 | wlv.screen_row = wlv.row + W_WINROW(wp); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 899 | |
| 900 | if (!number_only) |
| 901 | { |
| 902 | // To speed up the loop below, set extra_check when there is linebreak, |
| 903 | // trailing white space and/or syntax processing to be done. |
| 904 | #ifdef FEAT_LINEBREAK |
| 905 | extra_check = wp->w_p_lbr; |
| 906 | #endif |
| 907 | #ifdef FEAT_SYN_HL |
| 908 | if (syntax_present(wp) && !wp->w_s->b_syn_error |
| 909 | # ifdef SYN_TIME_LIMIT |
| 910 | && !wp->w_s->b_syn_slow |
| 911 | # endif |
| 912 | ) |
| 913 | { |
| 914 | // Prepare for syntax highlighting in this line. When there is an |
| 915 | // error, stop syntax highlighting. |
| 916 | save_did_emsg = did_emsg; |
| 917 | did_emsg = FALSE; |
| 918 | syntax_start(wp, lnum); |
| 919 | if (did_emsg) |
| 920 | wp->w_s->b_syn_error = TRUE; |
| 921 | else |
| 922 | { |
| 923 | did_emsg = save_did_emsg; |
| 924 | #ifdef SYN_TIME_LIMIT |
| 925 | if (!wp->w_s->b_syn_slow) |
| 926 | #endif |
| 927 | { |
| 928 | has_syntax = TRUE; |
| 929 | extra_check = TRUE; |
| 930 | } |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | // Check for columns to display for 'colorcolumn'. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 935 | wlv.color_cols = wp->w_p_cc_cols; |
| 936 | if (wlv.color_cols != NULL) |
| 937 | wlv.draw_color_col = advance_color_col(VCOL_HLC, &wlv.color_cols); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 938 | #endif |
| 939 | |
| 940 | #ifdef FEAT_TERMINAL |
| 941 | if (term_show_buffer(wp->w_buffer)) |
| 942 | { |
| 943 | extra_check = TRUE; |
| 944 | get_term_attr = TRUE; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 945 | wlv.win_attr = term_get_attr(wp, lnum, -1); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 946 | } |
| 947 | #endif |
| 948 | |
| 949 | #ifdef FEAT_SPELL |
| 950 | if (wp->w_p_spell |
| 951 | && *wp->w_s->b_p_spl != NUL |
| 952 | && wp->w_s->b_langp.ga_len > 0 |
| 953 | && *(char **)(wp->w_s->b_langp.ga_data) != NULL) |
| 954 | { |
| 955 | // Prepare for spell checking. |
| 956 | has_spell = TRUE; |
| 957 | extra_check = TRUE; |
| 958 | |
| 959 | // Get the start of the next line, so that words that wrap to the |
| 960 | // next line are found too: "et<line-break>al.". |
| 961 | // Trick: skip a few chars for C/shell/Vim comments |
| 962 | nextline[SPWORDLEN] = NUL; |
| 963 | if (lnum < wp->w_buffer->b_ml.ml_line_count) |
| 964 | { |
| 965 | line = ml_get_buf(wp->w_buffer, lnum + 1, FALSE); |
| 966 | spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN); |
| 967 | } |
| 968 | |
| 969 | // When a word wrapped from the previous line the start of the |
| 970 | // current line is valid. |
| 971 | if (lnum == checked_lnum) |
| 972 | cur_checked_col = checked_col; |
| 973 | checked_lnum = 0; |
| 974 | |
| 975 | // When there was a sentence end in the previous line may require a |
| 976 | // word starting with capital in this line. In line 1 always check |
| 977 | // the first word. |
| 978 | if (lnum != capcol_lnum) |
| 979 | cap_col = -1; |
| 980 | if (lnum == 1) |
| 981 | cap_col = 0; |
| 982 | capcol_lnum = 0; |
| 983 | } |
| 984 | #endif |
| 985 | |
| 986 | // handle Visual active in this window |
| 987 | if (VIsual_active && wp->w_buffer == curwin->w_buffer) |
| 988 | { |
Bram Moolenaar | 14285cb | 2020-03-27 20:58:37 +0100 | [diff] [blame] | 989 | pos_T *top, *bot; |
| 990 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 991 | if (LTOREQ_POS(curwin->w_cursor, VIsual)) |
| 992 | { |
| 993 | // Visual is after curwin->w_cursor |
| 994 | top = &curwin->w_cursor; |
| 995 | bot = &VIsual; |
| 996 | } |
| 997 | else |
| 998 | { |
| 999 | // Visual is before curwin->w_cursor |
| 1000 | top = &VIsual; |
| 1001 | bot = &curwin->w_cursor; |
| 1002 | } |
| 1003 | lnum_in_visual_area = (lnum >= top->lnum && lnum <= bot->lnum); |
| 1004 | if (VIsual_mode == Ctrl_V) |
| 1005 | { |
| 1006 | // block mode |
| 1007 | if (lnum_in_visual_area) |
| 1008 | { |
| 1009 | fromcol = wp->w_old_cursor_fcol; |
| 1010 | tocol = wp->w_old_cursor_lcol; |
| 1011 | } |
| 1012 | } |
| 1013 | else |
| 1014 | { |
| 1015 | // non-block mode |
| 1016 | if (lnum > top->lnum && lnum <= bot->lnum) |
| 1017 | fromcol = 0; |
| 1018 | else if (lnum == top->lnum) |
| 1019 | { |
| 1020 | if (VIsual_mode == 'V') // linewise |
| 1021 | fromcol = 0; |
| 1022 | else |
| 1023 | { |
| 1024 | getvvcol(wp, top, (colnr_T *)&fromcol, NULL, NULL); |
| 1025 | if (gchar_pos(top) == NUL) |
| 1026 | tocol = fromcol + 1; |
| 1027 | } |
| 1028 | } |
| 1029 | if (VIsual_mode != 'V' && lnum == bot->lnum) |
| 1030 | { |
| 1031 | if (*p_sel == 'e' && bot->col == 0 && bot->coladd == 0) |
| 1032 | { |
| 1033 | fromcol = -10; |
| 1034 | tocol = MAXCOL; |
| 1035 | } |
| 1036 | else if (bot->col == MAXCOL) |
| 1037 | tocol = MAXCOL; |
| 1038 | else |
| 1039 | { |
| 1040 | pos = *bot; |
| 1041 | if (*p_sel == 'e') |
| 1042 | getvvcol(wp, &pos, (colnr_T *)&tocol, NULL, NULL); |
| 1043 | else |
| 1044 | { |
| 1045 | getvvcol(wp, &pos, NULL, NULL, (colnr_T *)&tocol); |
| 1046 | ++tocol; |
| 1047 | } |
| 1048 | } |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | // Check if the character under the cursor should not be inverted |
Bram Moolenaar | 6656c2e | 2019-10-24 15:00:04 +0200 | [diff] [blame] | 1053 | if (!highlight_match && lnum == curwin->w_cursor.lnum |
| 1054 | && wp == curwin |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1055 | #ifdef FEAT_GUI |
| 1056 | && !gui.in_use |
| 1057 | #endif |
| 1058 | ) |
| 1059 | noinvcur = TRUE; |
| 1060 | |
| 1061 | // if inverting in this line set area_highlighting |
| 1062 | if (fromcol >= 0) |
| 1063 | { |
| 1064 | area_highlighting = TRUE; |
| 1065 | vi_attr = HL_ATTR(HLF_V); |
| 1066 | #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11) |
| 1067 | if ((clip_star.available && !clip_star.owned |
| 1068 | && clip_isautosel_star()) |
| 1069 | || (clip_plus.available && !clip_plus.owned |
| 1070 | && clip_isautosel_plus())) |
| 1071 | vi_attr = HL_ATTR(HLF_VNC); |
| 1072 | #endif |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | // handle 'incsearch' and ":s///c" highlighting |
| 1077 | else if (highlight_match |
| 1078 | && wp == curwin |
| 1079 | && lnum >= curwin->w_cursor.lnum |
| 1080 | && lnum <= curwin->w_cursor.lnum + search_match_lines) |
| 1081 | { |
| 1082 | if (lnum == curwin->w_cursor.lnum) |
| 1083 | getvcol(curwin, &(curwin->w_cursor), |
| 1084 | (colnr_T *)&fromcol, NULL, NULL); |
| 1085 | else |
| 1086 | fromcol = 0; |
| 1087 | if (lnum == curwin->w_cursor.lnum + search_match_lines) |
| 1088 | { |
| 1089 | pos.lnum = lnum; |
| 1090 | pos.col = search_match_endcol; |
| 1091 | getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL); |
| 1092 | } |
| 1093 | else |
| 1094 | tocol = MAXCOL; |
| 1095 | // do at least one character; happens when past end of line |
Bram Moolenaar | 448465e | 2020-11-25 13:49:27 +0100 | [diff] [blame] | 1096 | if (fromcol == tocol && search_match_endcol) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1097 | tocol = fromcol + 1; |
| 1098 | area_highlighting = TRUE; |
| 1099 | vi_attr = HL_ATTR(HLF_I); |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1104 | wlv.filler_lines = diff_check(wp, lnum); |
| 1105 | if (wlv.filler_lines < 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1106 | { |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1107 | if (wlv.filler_lines == -1) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1108 | { |
| 1109 | if (diff_find_change(wp, lnum, &change_start, &change_end)) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1110 | wlv.diff_hlf = HLF_ADD; // added line |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1111 | else if (change_start == 0) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1112 | wlv.diff_hlf = HLF_TXD; // changed text |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1113 | else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1114 | wlv.diff_hlf = HLF_CHD; // changed line |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1115 | } |
| 1116 | else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1117 | wlv.diff_hlf = HLF_ADD; // added line |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1118 | wlv.filler_lines = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1119 | area_highlighting = TRUE; |
| 1120 | } |
| 1121 | if (lnum == wp->w_topline) |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1122 | wlv.filler_lines = wp->w_topfill; |
| 1123 | wlv.filler_todo = wlv.filler_lines; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1124 | #endif |
| 1125 | |
| 1126 | #ifdef FEAT_SIGNS |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1127 | sign_present = buf_get_signattrs(wp, lnum, &wlv.sattr); |
James McCoy | a80aad7 | 2021-12-22 19:45:28 +0000 | [diff] [blame] | 1128 | if (sign_present) |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1129 | num_attr = wlv.sattr.sat_numhl; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1130 | #endif |
| 1131 | |
| 1132 | #ifdef LINE_ATTR |
| 1133 | # ifdef FEAT_SIGNS |
| 1134 | // If this line has a sign with line highlighting set line_attr. |
| 1135 | if (sign_present) |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1136 | line_attr = wlv.sattr.sat_linehl; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1137 | # endif |
| 1138 | # if defined(FEAT_QUICKFIX) |
| 1139 | // Highlight the current line in the quickfix window. |
| 1140 | if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum) |
| 1141 | line_attr = HL_ATTR(HLF_QFL); |
| 1142 | # endif |
| 1143 | if (line_attr != 0) |
| 1144 | area_highlighting = TRUE; |
| 1145 | #endif |
| 1146 | |
| 1147 | line = ml_get_buf(wp->w_buffer, lnum, FALSE); |
| 1148 | ptr = line; |
| 1149 | |
| 1150 | #ifdef FEAT_SPELL |
| 1151 | if (has_spell && !number_only) |
| 1152 | { |
| 1153 | // For checking first word with a capital skip white space. |
| 1154 | if (cap_col == 0) |
| 1155 | cap_col = getwhitecols(line); |
| 1156 | |
| 1157 | // To be able to spell-check over line boundaries copy the end of the |
| 1158 | // current line into nextline[]. Above the start of the next line was |
| 1159 | // copied to nextline[SPWORDLEN]. |
| 1160 | if (nextline[SPWORDLEN] == NUL) |
| 1161 | { |
| 1162 | // No next line or it is empty. |
| 1163 | nextlinecol = MAXCOL; |
| 1164 | nextline_idx = 0; |
| 1165 | } |
| 1166 | else |
| 1167 | { |
| 1168 | v = (long)STRLEN(line); |
| 1169 | if (v < SPWORDLEN) |
| 1170 | { |
| 1171 | // Short line, use it completely and append the start of the |
| 1172 | // next line. |
| 1173 | nextlinecol = 0; |
| 1174 | mch_memmove(nextline, line, (size_t)v); |
| 1175 | STRMOVE(nextline + v, nextline + SPWORDLEN); |
| 1176 | nextline_idx = v + 1; |
| 1177 | } |
| 1178 | else |
| 1179 | { |
| 1180 | // Long line, use only the last SPWORDLEN bytes. |
| 1181 | nextlinecol = v - SPWORDLEN; |
| 1182 | mch_memmove(nextline, line + nextlinecol, SPWORDLEN); |
| 1183 | nextline_idx = SPWORDLEN + 1; |
| 1184 | } |
| 1185 | } |
| 1186 | } |
| 1187 | #endif |
| 1188 | |
| 1189 | if (wp->w_p_list) |
| 1190 | { |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 1191 | if (wp->w_lcs_chars.space |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 1192 | || wp->w_lcs_chars.multispace != NULL |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 1193 | || wp->w_lcs_chars.leadmultispace != NULL |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 1194 | || wp->w_lcs_chars.trail |
| 1195 | || wp->w_lcs_chars.lead |
| 1196 | || wp->w_lcs_chars.nbsp) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1197 | extra_check = TRUE; |
Bram Moolenaar | 91478ae | 2021-02-03 15:58:13 +0100 | [diff] [blame] | 1198 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1199 | // find start of trailing whitespace |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 1200 | if (wp->w_lcs_chars.trail) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1201 | { |
| 1202 | trailcol = (colnr_T)STRLEN(ptr); |
| 1203 | while (trailcol > (colnr_T)0 && VIM_ISWHITE(ptr[trailcol - 1])) |
| 1204 | --trailcol; |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 1205 | trailcol += (colnr_T)(ptr - line); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1206 | } |
Bram Moolenaar | 91478ae | 2021-02-03 15:58:13 +0100 | [diff] [blame] | 1207 | // find end of leading whitespace |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 1208 | if (wp->w_lcs_chars.lead || wp->w_lcs_chars.leadmultispace != NULL) |
Bram Moolenaar | 91478ae | 2021-02-03 15:58:13 +0100 | [diff] [blame] | 1209 | { |
| 1210 | leadcol = 0; |
| 1211 | while (VIM_ISWHITE(ptr[leadcol])) |
| 1212 | ++leadcol; |
| 1213 | if (ptr[leadcol] == NUL) |
| 1214 | // in a line full of spaces all of them are treated as trailing |
| 1215 | leadcol = (colnr_T)0; |
| 1216 | else |
| 1217 | // keep track of the first column not filled with spaces |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 1218 | leadcol += (colnr_T)(ptr - line) + 1; |
Bram Moolenaar | 91478ae | 2021-02-03 15:58:13 +0100 | [diff] [blame] | 1219 | } |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1220 | } |
| 1221 | |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1222 | wlv.wcr_attr = get_wcr_attr(wp); |
| 1223 | if (wlv.wcr_attr != 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1224 | { |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1225 | wlv.win_attr = wlv.wcr_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1226 | area_highlighting = TRUE; |
| 1227 | } |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 1228 | |
Bram Moolenaar | 05ad5ff | 2019-11-30 22:48:27 +0100 | [diff] [blame] | 1229 | #ifdef FEAT_PROP_POPUP |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1230 | if (WIN_IS_POPUP(wp)) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1231 | wlv.screen_line_flags |= SLF_POPUP; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1232 | #endif |
| 1233 | |
| 1234 | // 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the |
| 1235 | // first character to be displayed. |
| 1236 | if (wp->w_p_wrap) |
| 1237 | v = wp->w_skipcol; |
| 1238 | else |
| 1239 | v = wp->w_leftcol; |
| 1240 | if (v > 0 && !number_only) |
| 1241 | { |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1242 | char_u *prev_ptr = ptr; |
| 1243 | chartabsize_T cts; |
Bram Moolenaar | 6d023f9 | 2022-07-25 21:15:45 +0100 | [diff] [blame] | 1244 | int charsize = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1245 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1246 | init_chartabsize_arg(&cts, wp, lnum, wlv.vcol, line, ptr); |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1247 | while (cts.cts_vcol < v && *cts.cts_ptr != NUL) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1248 | { |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1249 | charsize = win_lbr_chartabsize(&cts, NULL); |
| 1250 | cts.cts_vcol += charsize; |
| 1251 | prev_ptr = cts.cts_ptr; |
| 1252 | MB_PTR_ADV(cts.cts_ptr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1253 | } |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1254 | wlv.vcol = cts.cts_vcol; |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1255 | ptr = cts.cts_ptr; |
| 1256 | clear_chartabsize_arg(&cts); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1257 | |
| 1258 | // When: |
| 1259 | // - 'cuc' is set, or |
| 1260 | // - 'colorcolumn' is set, or |
| 1261 | // - 'virtualedit' is set, or |
| 1262 | // - the visual mode is active, |
| 1263 | // the end of the line may be before the start of the displayed part. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1264 | if (wlv.vcol < v && ( |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1265 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1266 | wp->w_p_cuc || wlv.draw_color_col || |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1267 | #endif |
| 1268 | virtual_active() || |
| 1269 | (VIsual_active && wp->w_buffer == curwin->w_buffer))) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1270 | wlv.vcol = v; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1271 | |
| 1272 | // Handle a character that's not completely on the screen: Put ptr at |
| 1273 | // that character but skip the first few screen characters. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1274 | if (wlv.vcol > v) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1275 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1276 | wlv.vcol -= charsize; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1277 | ptr = prev_ptr; |
| 1278 | // If the character fits on the screen, don't need to skip it. |
| 1279 | // Except for a TAB. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1280 | if (((*mb_ptr2cells)(ptr) >= charsize || *ptr == TAB) |
| 1281 | && wlv.col == 0) |
| 1282 | n_skip = v - wlv.vcol; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1283 | } |
| 1284 | |
| 1285 | // Adjust for when the inverted text is before the screen, |
| 1286 | // and when the start of the inverted text is before the screen. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1287 | if (tocol <= wlv.vcol) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1288 | fromcol = 0; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1289 | else if (fromcol >= 0 && fromcol < wlv.vcol) |
| 1290 | fromcol = wlv.vcol; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1291 | |
| 1292 | #ifdef FEAT_LINEBREAK |
| 1293 | // When w_skipcol is non-zero, first line needs 'showbreak' |
| 1294 | if (wp->w_p_wrap) |
| 1295 | need_showbreak = TRUE; |
| 1296 | #endif |
| 1297 | #ifdef FEAT_SPELL |
| 1298 | // When spell checking a word we need to figure out the start of the |
| 1299 | // word and if it's badly spelled or not. |
| 1300 | if (has_spell) |
| 1301 | { |
| 1302 | int len; |
| 1303 | colnr_T linecol = (colnr_T)(ptr - line); |
| 1304 | hlf_T spell_hlf = HLF_COUNT; |
| 1305 | |
| 1306 | pos = wp->w_cursor; |
| 1307 | wp->w_cursor.lnum = lnum; |
| 1308 | wp->w_cursor.col = linecol; |
| 1309 | len = spell_move_to(wp, FORWARD, TRUE, TRUE, &spell_hlf); |
| 1310 | |
| 1311 | // spell_move_to() may call ml_get() and make "line" invalid |
| 1312 | line = ml_get_buf(wp->w_buffer, lnum, FALSE); |
| 1313 | ptr = line + linecol; |
| 1314 | |
| 1315 | if (len == 0 || (int)wp->w_cursor.col > ptr - line) |
| 1316 | { |
| 1317 | // no bad word found at line start, don't check until end of a |
| 1318 | // word |
| 1319 | spell_hlf = HLF_COUNT; |
| 1320 | word_end = (int)(spell_to_word_end(ptr, wp) - line + 1); |
| 1321 | } |
| 1322 | else |
| 1323 | { |
| 1324 | // bad word found, use attributes until end of word |
| 1325 | word_end = wp->w_cursor.col + len + 1; |
| 1326 | |
| 1327 | // Turn index into actual attributes. |
| 1328 | if (spell_hlf != HLF_COUNT) |
| 1329 | spell_attr = highlight_attr[spell_hlf]; |
| 1330 | } |
| 1331 | wp->w_cursor = pos; |
| 1332 | |
| 1333 | # ifdef FEAT_SYN_HL |
| 1334 | // Need to restart syntax highlighting for this line. |
| 1335 | if (has_syntax) |
| 1336 | syntax_start(wp, lnum); |
| 1337 | # endif |
| 1338 | } |
| 1339 | #endif |
| 1340 | } |
| 1341 | |
| 1342 | // Correct highlighting for cursor that can't be disabled. |
| 1343 | // Avoids having to check this for each character. |
| 1344 | if (fromcol >= 0) |
| 1345 | { |
| 1346 | if (noinvcur) |
| 1347 | { |
| 1348 | if ((colnr_T)fromcol == wp->w_virtcol) |
| 1349 | { |
| 1350 | // highlighting starts at cursor, let it start just after the |
| 1351 | // cursor |
| 1352 | fromcol_prev = fromcol; |
| 1353 | fromcol = -1; |
| 1354 | } |
| 1355 | else if ((colnr_T)fromcol < wp->w_virtcol) |
| 1356 | // restart highlighting after the cursor |
| 1357 | fromcol_prev = wp->w_virtcol; |
| 1358 | } |
| 1359 | if (fromcol >= tocol) |
| 1360 | fromcol = -1; |
| 1361 | } |
| 1362 | |
| 1363 | #ifdef FEAT_SEARCH_EXTRA |
| 1364 | if (!number_only) |
| 1365 | { |
| 1366 | v = (long)(ptr - line); |
| 1367 | area_highlighting |= prepare_search_hl_line(wp, lnum, (colnr_T)v, |
| 1368 | &line, &screen_search_hl, |
| 1369 | &search_attr); |
| 1370 | ptr = line + v; // "line" may have been updated |
| 1371 | } |
| 1372 | #endif |
| 1373 | |
| 1374 | #ifdef FEAT_SYN_HL |
| 1375 | // Cursor line highlighting for 'cursorline' in the current window. |
| 1376 | if (wp->w_p_cul && lnum == wp->w_cursor.lnum) |
| 1377 | { |
| 1378 | // Do not show the cursor line in the text when Visual mode is active, |
zeertzjq | c20e46a | 2022-03-23 14:55:23 +0000 | [diff] [blame] | 1379 | // because it's not clear what is selected then. |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1380 | if (!(wp == curwin && VIsual_active) |
| 1381 | && wp->w_p_culopt_flags != CULOPT_NBR) |
| 1382 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1383 | wlv.cul_screenline = (wp->w_p_wrap |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1384 | && (wp->w_p_culopt_flags & CULOPT_SCRLINE)); |
| 1385 | |
| 1386 | // Only set line_attr here when "screenline" is not present in |
| 1387 | // 'cursorlineopt'. Otherwise it's done later. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1388 | if (!wlv.cul_screenline) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1389 | { |
| 1390 | cul_attr = HL_ATTR(HLF_CUL); |
Bram Moolenaar | 39f7aa3 | 2020-08-31 22:00:05 +0200 | [diff] [blame] | 1391 | # ifdef FEAT_SIGNS |
| 1392 | // Combine the 'cursorline' and sign highlighting, depending on |
| 1393 | // the sign priority. |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1394 | if (sign_present && wlv.sattr.sat_linehl > 0) |
Bram Moolenaar | 39f7aa3 | 2020-08-31 22:00:05 +0200 | [diff] [blame] | 1395 | { |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1396 | if (wlv.sattr.sat_priority >= 100) |
Bram Moolenaar | 39f7aa3 | 2020-08-31 22:00:05 +0200 | [diff] [blame] | 1397 | line_attr = hl_combine_attr(cul_attr, line_attr); |
| 1398 | else |
| 1399 | line_attr = hl_combine_attr(line_attr, cul_attr); |
| 1400 | } |
| 1401 | else |
| 1402 | # endif |
Bram Moolenaar | 7fe956d | 2022-07-03 14:21:09 +0100 | [diff] [blame] | 1403 | # if defined(FEAT_QUICKFIX) |
Bram Moolenaar | 6e5c611 | 2022-08-08 16:03:06 +0100 | [diff] [blame] | 1404 | // let the line attribute overrule 'cursorline', otherwise |
| 1405 | // it disappears when both have background set; |
| 1406 | // 'cursorline' can use underline or bold to make it show |
| 1407 | line_attr = hl_combine_attr(cul_attr, line_attr); |
Bram Moolenaar | 7fe956d | 2022-07-03 14:21:09 +0100 | [diff] [blame] | 1408 | # else |
Bram Moolenaar | 39f7aa3 | 2020-08-31 22:00:05 +0200 | [diff] [blame] | 1409 | line_attr = cul_attr; |
Bram Moolenaar | 7fe956d | 2022-07-03 14:21:09 +0100 | [diff] [blame] | 1410 | # endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1411 | } |
| 1412 | else |
| 1413 | { |
| 1414 | line_attr_save = line_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1415 | margin_columns_win(wp, &left_curline_col, &right_curline_col); |
| 1416 | } |
| 1417 | area_highlighting = TRUE; |
| 1418 | } |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1419 | } |
| 1420 | #endif |
| 1421 | |
Bram Moolenaar | 05ad5ff | 2019-11-30 22:48:27 +0100 | [diff] [blame] | 1422 | #ifdef FEAT_PROP_POPUP |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1423 | { |
| 1424 | char_u *prop_start; |
| 1425 | |
| 1426 | text_prop_count = get_text_props(wp->w_buffer, lnum, |
| 1427 | &prop_start, FALSE); |
| 1428 | if (text_prop_count > 0) |
| 1429 | { |
| 1430 | // Make a copy of the properties, so that they are properly |
| 1431 | // aligned. |
| 1432 | text_props = ALLOC_MULT(textprop_T, text_prop_count); |
| 1433 | if (text_props != NULL) |
| 1434 | mch_memmove(text_props, prop_start, |
| 1435 | text_prop_count * sizeof(textprop_T)); |
| 1436 | |
| 1437 | // Allocate an array for the indexes. |
| 1438 | text_prop_idxs = ALLOC_MULT(int, text_prop_count); |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1439 | if (text_prop_idxs == NULL) |
| 1440 | VIM_CLEAR(text_props); |
| 1441 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1442 | area_highlighting = TRUE; |
| 1443 | extra_check = TRUE; |
| 1444 | } |
| 1445 | } |
| 1446 | #endif |
| 1447 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1448 | win_line_start(wp, &wlv, FALSE); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1449 | |
| 1450 | // Repeat for the whole displayed line. |
| 1451 | for (;;) |
| 1452 | { |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 1453 | char_u *prev_ptr = ptr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1454 | #if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA) |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 1455 | int has_match_conc = 0; // match wants to conceal |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1456 | #endif |
| 1457 | #ifdef FEAT_CONCEAL |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 1458 | int did_decrement_ptr = FALSE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1459 | #endif |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 1460 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1461 | // Skip this quickly when working on the text. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1462 | if (wlv.draw_state != WL_LINE) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1463 | { |
zeertzjq | 4f33bc2 | 2021-08-05 17:57:02 +0200 | [diff] [blame] | 1464 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1465 | if (wlv.cul_screenline) |
zeertzjq | 4f33bc2 | 2021-08-05 17:57:02 +0200 | [diff] [blame] | 1466 | { |
| 1467 | cul_attr = 0; |
| 1468 | line_attr = line_attr_save; |
| 1469 | } |
| 1470 | #endif |
| 1471 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1472 | #ifdef FEAT_CMDWIN |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1473 | if (wlv.draw_state == WL_CMDLINE - 1 && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1474 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1475 | wlv.draw_state = WL_CMDLINE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1476 | if (cmdwin_type != 0 && wp == curwin) |
| 1477 | { |
| 1478 | // Draw the cmdline character. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1479 | wlv.n_extra = 1; |
| 1480 | wlv.c_extra = cmdwin_type; |
| 1481 | wlv.c_final = NUL; |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1482 | wlv.char_attr = |
| 1483 | hl_combine_attr(wlv.wcr_attr, HL_ATTR(HLF_AT)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1484 | } |
| 1485 | } |
| 1486 | #endif |
| 1487 | |
| 1488 | #ifdef FEAT_FOLDING |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1489 | if (wlv.draw_state == WL_FOLD - 1 && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1490 | { |
| 1491 | int fdc = compute_foldcolumn(wp, 0); |
| 1492 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1493 | wlv.draw_state = WL_FOLD; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1494 | if (fdc > 0) |
| 1495 | { |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1496 | // Draw the 'foldcolumn'. Allocate a buffer, "wlv.extra" |
| 1497 | // may already be in use. |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1498 | vim_free(p_extra_free); |
Bram Moolenaar | 4fa1175 | 2021-03-03 13:26:02 +0100 | [diff] [blame] | 1499 | p_extra_free = alloc(MAX_MCO * fdc + 1); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1500 | if (p_extra_free != NULL) |
| 1501 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1502 | wlv.n_extra = (int)fill_foldcolumn(p_extra_free, wp, |
Bram Moolenaar | 4fa1175 | 2021-03-03 13:26:02 +0100 | [diff] [blame] | 1503 | FALSE, lnum); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1504 | p_extra_free[wlv.n_extra] = NUL; |
| 1505 | wlv.p_extra = p_extra_free; |
| 1506 | wlv.c_extra = NUL; |
| 1507 | wlv.c_final = NUL; |
Bram Moolenaar | e413ea0 | 2021-11-24 16:20:13 +0000 | [diff] [blame] | 1508 | if (use_cursor_line_sign(wp, lnum)) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1509 | wlv.char_attr = |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1510 | hl_combine_attr(wlv.wcr_attr, HL_ATTR(HLF_CLF)); |
Bram Moolenaar | e413ea0 | 2021-11-24 16:20:13 +0000 | [diff] [blame] | 1511 | else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1512 | wlv.char_attr = |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1513 | hl_combine_attr(wlv.wcr_attr, HL_ATTR(HLF_FC)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1514 | } |
| 1515 | } |
| 1516 | } |
| 1517 | #endif |
| 1518 | |
| 1519 | #ifdef FEAT_SIGNS |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1520 | if (wlv.draw_state == WL_SIGN - 1 && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1521 | { |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1522 | // Show the sign column when desired or when using Netbeans. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1523 | wlv.draw_state = WL_SIGN; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1524 | if (signcolumn_on(wp)) |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1525 | get_sign_display_info(FALSE, wp, &wlv); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1526 | } |
| 1527 | #endif |
| 1528 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1529 | if (wlv.draw_state == WL_NR - 1 && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1530 | { |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1531 | // Show the line number, if desired. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1532 | wlv.draw_state = WL_NR; |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1533 | handle_lnum_col(wp, &wlv, sign_present, num_attr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1534 | } |
| 1535 | |
| 1536 | #ifdef FEAT_LINEBREAK |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1537 | if (wp->w_briopt_sbr && wlv.draw_state == WL_BRI - 1 |
| 1538 | && wlv.n_extra == 0 |
| 1539 | && *get_showbreak_value(wp) != NUL) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1540 | // draw indent after showbreak value |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1541 | wlv.draw_state = WL_BRI; |
| 1542 | else if (wp->w_briopt_sbr && wlv.draw_state == WL_SBR |
| 1543 | && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1544 | // After the showbreak, draw the breakindent |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1545 | wlv.draw_state = WL_BRI - 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1546 | |
| 1547 | // draw 'breakindent': indent wrapped text accordingly |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1548 | if (wlv.draw_state == WL_BRI - 1 && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1549 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1550 | wlv.draw_state = WL_BRI; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1551 | // if need_showbreak is set, breakindent also applies |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1552 | if (wp->w_p_bri && (wlv.row != startrow || need_showbreak) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1553 | # ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1554 | && wlv.filler_lines == 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1555 | # endif |
Bram Moolenaar | 73c3842 | 2022-08-07 11:53:40 +0100 | [diff] [blame] | 1556 | # ifdef FEAT_PROP_POPUP |
| 1557 | && !dont_use_showbreak |
| 1558 | # endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1559 | ) |
| 1560 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1561 | wlv.char_attr = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1562 | # ifdef FEAT_DIFF |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1563 | if (wlv.diff_hlf != (hlf_T)0) |
| 1564 | wlv.char_attr = HL_ATTR(wlv.diff_hlf); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1565 | # endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1566 | wlv.p_extra = NULL; |
| 1567 | wlv.c_extra = ' '; |
| 1568 | wlv.c_final = NUL; |
| 1569 | wlv.n_extra = get_breakindent_win(wp, |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1570 | ml_get_buf(wp->w_buffer, lnum, FALSE)); |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1571 | if (wlv.row == startrow) |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 1572 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1573 | wlv.n_extra -= win_col_off2(wp); |
| 1574 | if (wlv.n_extra < 0) |
| 1575 | wlv.n_extra = 0; |
Bram Moolenaar | e882f7a | 2020-05-16 14:07:39 +0200 | [diff] [blame] | 1576 | } |
Bram Moolenaar | b81f56f | 2020-02-23 15:29:46 +0100 | [diff] [blame] | 1577 | if (wp->w_skipcol > 0 && wp->w_p_wrap && wp->w_briopt_sbr) |
Bram Moolenaar | dfede9a | 2020-01-23 19:59:22 +0100 | [diff] [blame] | 1578 | need_showbreak = FALSE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1579 | // Correct end of highlighted area for 'breakindent', |
| 1580 | // required when 'linebreak' is also set. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1581 | if (tocol == wlv.vcol) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1582 | tocol += wlv.n_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1583 | } |
| 1584 | } |
| 1585 | #endif |
| 1586 | |
| 1587 | #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1588 | if (wlv.draw_state == WL_SBR - 1 && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1589 | { |
Bram Moolenaar | ee85702 | 2019-11-09 23:26:40 +0100 | [diff] [blame] | 1590 | char_u *sbr; |
| 1591 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1592 | wlv.draw_state = WL_SBR; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1593 | # ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1594 | if (wlv.filler_todo > 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1595 | { |
| 1596 | // Draw "deleted" diff line(s). |
Bram Moolenaar | 96ba25a | 2022-07-04 17:34:33 +0100 | [diff] [blame] | 1597 | if (char2cells(wp->w_fill_chars.diff) > 1) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1598 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1599 | wlv.c_extra = '-'; |
| 1600 | wlv.c_final = NUL; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1601 | } |
| 1602 | else |
| 1603 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1604 | wlv.c_extra = wp->w_fill_chars.diff; |
| 1605 | wlv.c_final = NUL; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1606 | } |
| 1607 | # ifdef FEAT_RIGHTLEFT |
| 1608 | if (wp->w_p_rl) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1609 | wlv.n_extra = wlv.col + 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1610 | else |
| 1611 | # endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1612 | wlv.n_extra = wp->w_width - wlv.col; |
| 1613 | wlv.char_attr = HL_ATTR(HLF_DED); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1614 | } |
| 1615 | # endif |
| 1616 | # ifdef FEAT_LINEBREAK |
Bram Moolenaar | ee85702 | 2019-11-09 23:26:40 +0100 | [diff] [blame] | 1617 | sbr = get_showbreak_value(wp); |
| 1618 | if (*sbr != NUL && need_showbreak) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1619 | { |
| 1620 | // Draw 'showbreak' at the start of each broken line. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1621 | wlv.p_extra = sbr; |
| 1622 | wlv.c_extra = NUL; |
| 1623 | wlv.c_final = NUL; |
| 1624 | wlv.n_extra = (int)STRLEN(sbr); |
Bram Moolenaar | dfede9a | 2020-01-23 19:59:22 +0100 | [diff] [blame] | 1625 | if (wp->w_skipcol == 0 || !wp->w_p_wrap) |
| 1626 | need_showbreak = FALSE; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1627 | vcol_sbr = wlv.vcol + MB_CHARLEN(sbr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1628 | // Correct end of highlighted area for 'showbreak', |
| 1629 | // required when 'linebreak' is also set. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1630 | if (tocol == wlv.vcol) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1631 | tocol += wlv.n_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1632 | // combine 'showbreak' with 'wincolor' |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1633 | wlv.char_attr = hl_combine_attr(wlv.win_attr, |
| 1634 | HL_ATTR(HLF_AT)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1635 | # ifdef FEAT_SYN_HL |
| 1636 | // combine 'showbreak' with 'cursorline' |
| 1637 | if (cul_attr != 0) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1638 | wlv.char_attr = hl_combine_attr(wlv.char_attr, |
| 1639 | cul_attr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1640 | # endif |
| 1641 | } |
| 1642 | # endif |
| 1643 | } |
| 1644 | #endif |
| 1645 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1646 | if (wlv.draw_state == WL_LINE - 1 && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1647 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1648 | wlv.draw_state = WL_LINE; |
| 1649 | if (wlv.saved_n_extra) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1650 | { |
| 1651 | // Continue item from end of wrapped line. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1652 | wlv.n_extra = wlv.saved_n_extra; |
| 1653 | wlv.c_extra = wlv.saved_c_extra; |
| 1654 | wlv.c_final = wlv.saved_c_final; |
| 1655 | wlv.p_extra = wlv.saved_p_extra; |
| 1656 | wlv.char_attr = wlv.saved_char_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1657 | } |
| 1658 | else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1659 | wlv.char_attr = wlv.win_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1660 | } |
| 1661 | } |
| 1662 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1663 | if (wlv.cul_screenline && wlv.draw_state == WL_LINE |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1664 | && wlv.vcol >= left_curline_col |
| 1665 | && wlv.vcol < right_curline_col) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1666 | { |
zeertzjq | 4f33bc2 | 2021-08-05 17:57:02 +0200 | [diff] [blame] | 1667 | cul_attr = HL_ATTR(HLF_CUL); |
| 1668 | line_attr = cul_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1669 | } |
| 1670 | #endif |
| 1671 | |
| 1672 | // When still displaying '$' of change command, stop at cursor. |
| 1673 | // When only displaying the (relative) line number and that's done, |
| 1674 | // stop here. |
Bram Moolenaar | 511feec | 2020-06-18 19:15:27 +0200 | [diff] [blame] | 1675 | if (((dollar_vcol >= 0 && wp == curwin |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1676 | && lnum == wp->w_cursor.lnum && wlv.vcol >= (long)wp->w_virtcol) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1677 | || (number_only && wlv.draw_state > WL_NR)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1678 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 1679 | && wlv.filler_todo <= 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1680 | #endif |
| 1681 | ) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1682 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1683 | screen_line(wp, wlv.screen_row, wp->w_wincol, wlv.col, -wp->w_width, |
| 1684 | wlv.screen_line_flags); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1685 | // Pretend we have finished updating the window. Except when |
| 1686 | // 'cursorcolumn' is set. |
| 1687 | #ifdef FEAT_SYN_HL |
| 1688 | if (wp->w_p_cuc) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1689 | wlv.row = wp->w_cline_row + wp->w_cline_height; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1690 | else |
| 1691 | #endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1692 | wlv.row = wp->w_height; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1693 | break; |
| 1694 | } |
| 1695 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1696 | if (wlv.draw_state == WL_LINE && (area_highlighting || extra_check)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1697 | { |
| 1698 | // handle Visual or match highlighting in this line |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1699 | if (wlv.vcol == fromcol |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1700 | || (has_mbyte && wlv.vcol + 1 == fromcol && wlv.n_extra == 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1701 | && (*mb_ptr2cells)(ptr) > 1) |
| 1702 | || ((int)vcol_prev == fromcol_prev |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1703 | && vcol_prev < wlv.vcol // not at margin |
| 1704 | && wlv.vcol < tocol)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1705 | area_attr = vi_attr; // start highlighting |
| 1706 | else if (area_attr != 0 |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1707 | && (wlv.vcol == tocol |
| 1708 | || (noinvcur && (colnr_T)wlv.vcol == wp->w_virtcol))) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1709 | area_attr = 0; // stop highlighting |
| 1710 | |
Bram Moolenaar | 05ad5ff | 2019-11-30 22:48:27 +0100 | [diff] [blame] | 1711 | #ifdef FEAT_PROP_POPUP |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1712 | if (text_props != NULL) |
| 1713 | { |
| 1714 | int pi; |
| 1715 | int bcol = (int)(ptr - line); |
| 1716 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1717 | if (wlv.n_extra > 0 |
Bram Moolenaar | 6b839ac | 2021-11-29 21:12:35 +0000 | [diff] [blame] | 1718 | # ifdef FEAT_LINEBREAK |
| 1719 | && !in_linebreak |
| 1720 | # endif |
| 1721 | ) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1722 | --bcol; // still working on the previous char, e.g. Tab |
| 1723 | |
| 1724 | // Check if any active property ends. |
| 1725 | for (pi = 0; pi < text_props_active; ++pi) |
| 1726 | { |
| 1727 | int tpi = text_prop_idxs[pi]; |
| 1728 | |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1729 | if (text_props[tpi].tp_col != MAXCOL |
| 1730 | && bcol >= text_props[tpi].tp_col - 1 |
| 1731 | + text_props[tpi].tp_len) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1732 | { |
| 1733 | if (pi + 1 < text_props_active) |
| 1734 | mch_memmove(text_prop_idxs + pi, |
| 1735 | text_prop_idxs + pi + 1, |
| 1736 | sizeof(int) |
| 1737 | * (text_props_active - (pi + 1))); |
| 1738 | --text_props_active; |
| 1739 | --pi; |
Bram Moolenaar | 6b839ac | 2021-11-29 21:12:35 +0000 | [diff] [blame] | 1740 | # ifdef FEAT_LINEBREAK |
| 1741 | // not exactly right but should work in most cases |
Bram Moolenaar | cf2bb63 | 2022-09-02 13:26:29 +0100 | [diff] [blame] | 1742 | if (in_linebreak && syntax_attr == text_prop_attr_comb) |
Bram Moolenaar | 6b839ac | 2021-11-29 21:12:35 +0000 | [diff] [blame] | 1743 | syntax_attr = 0; |
| 1744 | # endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1745 | } |
| 1746 | } |
| 1747 | |
Bram Moolenaar | acdc911 | 2021-12-02 19:46:57 +0000 | [diff] [blame] | 1748 | # ifdef FEAT_LINEBREAK |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1749 | if (wlv.n_extra > 0 && in_linebreak) |
Bram Moolenaar | acdc911 | 2021-12-02 19:46:57 +0000 | [diff] [blame] | 1750 | // not on the next char yet, don't start another prop |
| 1751 | --bcol; |
| 1752 | # endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1753 | // Add any text property that starts in this column. |
Bram Moolenaar | 48ca24d | 2022-08-06 22:03:20 +0100 | [diff] [blame] | 1754 | // With 'nowrap' and not in the first screen line only "below" |
| 1755 | // text prop can show. |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1756 | while (text_prop_next < text_prop_count |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1757 | && (text_props[text_prop_next].tp_col == MAXCOL |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 1758 | ? ((*ptr == NUL |
Bram Moolenaar | 48ca24d | 2022-08-06 22:03:20 +0100 | [diff] [blame] | 1759 | && (wp->w_p_wrap |
| 1760 | || wlv.row == startrow |
| 1761 | || (text_props[text_prop_next].tp_flags |
| 1762 | & TP_FLAG_ALIGN_BELOW))) |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 1763 | || (bcol == 0 && |
| 1764 | (text_props[text_prop_next].tp_flags |
| 1765 | & TP_FLAG_ALIGN_ABOVE))) |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1766 | : bcol >= text_props[text_prop_next].tp_col - 1)) |
Bram Moolenaar | f3fa184 | 2021-02-10 17:20:28 +0100 | [diff] [blame] | 1767 | { |
Bram Moolenaar | 9113c2c | 2022-08-13 20:17:34 +0100 | [diff] [blame] | 1768 | if (text_props[text_prop_next].tp_col == MAXCOL |
Bram Moolenaar | c3a483f | 2022-08-14 19:37:36 +0100 | [diff] [blame] | 1769 | && *ptr == NUL && wp->w_p_list && lcs_eol_one > 0) |
| 1770 | { |
| 1771 | // first display the '$' after the line |
| 1772 | text_prop_follows = TRUE; |
| 1773 | break; |
| 1774 | } |
| 1775 | if (text_props[text_prop_next].tp_col == MAXCOL |
Bram Moolenaar | 9113c2c | 2022-08-13 20:17:34 +0100 | [diff] [blame] | 1776 | || bcol <= text_props[text_prop_next].tp_col - 1 |
Bram Moolenaar | f3fa184 | 2021-02-10 17:20:28 +0100 | [diff] [blame] | 1777 | + text_props[text_prop_next].tp_len) |
| 1778 | text_prop_idxs[text_props_active++] = text_prop_next; |
| 1779 | ++text_prop_next; |
| 1780 | } |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1781 | |
Bram Moolenaar | 9e7e28f | 2022-08-14 16:36:38 +0100 | [diff] [blame] | 1782 | if (wlv.n_extra == 0 || !extra_for_textprop) |
| 1783 | { |
| 1784 | text_prop_attr = 0; |
Bram Moolenaar | cf2bb63 | 2022-09-02 13:26:29 +0100 | [diff] [blame] | 1785 | text_prop_attr_comb = 0; |
Bram Moolenaar | 9e7e28f | 2022-08-14 16:36:38 +0100 | [diff] [blame] | 1786 | text_prop_flags = 0; |
| 1787 | text_prop_type = NULL; |
| 1788 | text_prop_id = 0; |
| 1789 | } |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1790 | if (text_props_active > 0 && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1791 | { |
Bram Moolenaar | be3dbda | 2022-07-26 11:42:34 +0100 | [diff] [blame] | 1792 | int used_tpi = -1; |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1793 | int used_attr = 0; |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1794 | int other_tpi = -1; |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1795 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1796 | // Sort the properties on priority and/or starting last. |
| 1797 | // Then combine the attributes, highest priority last. |
Bram Moolenaar | c9dc03f | 2022-09-12 17:51:07 +0100 | [diff] [blame] | 1798 | text_prop_above = FALSE; |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1799 | text_prop_follows = FALSE; |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1800 | sort_text_props(wp->w_buffer, text_props, |
| 1801 | text_prop_idxs, text_props_active); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1802 | |
| 1803 | for (pi = 0; pi < text_props_active; ++pi) |
| 1804 | { |
| 1805 | int tpi = text_prop_idxs[pi]; |
| 1806 | proptype_T *pt = text_prop_type_by_id( |
| 1807 | wp->w_buffer, text_props[tpi].tp_type); |
| 1808 | |
Bram Moolenaar | 3331dd0 | 2022-08-10 16:49:02 +0100 | [diff] [blame] | 1809 | if (pt != NULL && (pt->pt_hl_id > 0 |
| 1810 | || text_props[tpi].tp_id < 0) |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1811 | && text_props[tpi].tp_id != -MAXCOL) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1812 | { |
Bram Moolenaar | 87f3a2c | 2022-08-10 20:50:23 +0100 | [diff] [blame] | 1813 | if (pt->pt_hl_id > 0) |
| 1814 | used_attr = syn_id2attr(pt->pt_hl_id); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1815 | text_prop_type = pt; |
| 1816 | text_prop_attr = |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1817 | hl_combine_attr(text_prop_attr, used_attr); |
Bram Moolenaar | 4d2031f | 2022-08-05 20:03:55 +0100 | [diff] [blame] | 1818 | text_prop_flags = pt->pt_flags; |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1819 | text_prop_id = text_props[tpi].tp_id; |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1820 | other_tpi = used_tpi; |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1821 | used_tpi = tpi; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1822 | } |
| 1823 | } |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1824 | if (text_prop_id < 0 && used_tpi >= 0 |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1825 | && -text_prop_id |
| 1826 | <= wp->w_buffer->b_textprop_text.ga_len) |
| 1827 | { |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1828 | textprop_T *tp = &text_props[used_tpi]; |
| 1829 | char_u *p = ((char_u **)wp->w_buffer |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1830 | ->b_textprop_text.ga_data)[ |
| 1831 | -text_prop_id - 1]; |
Bram Moolenaar | c9dc03f | 2022-09-12 17:51:07 +0100 | [diff] [blame] | 1832 | int above = (tp->tp_flags |
| 1833 | & TP_FLAG_ALIGN_ABOVE); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1834 | |
| 1835 | // reset the ID in the copy to avoid it being used |
| 1836 | // again |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1837 | tp->tp_id = -MAXCOL; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1838 | |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1839 | if (p != NULL) |
| 1840 | { |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1841 | int right = (tp->tp_flags |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1842 | & TP_FLAG_ALIGN_RIGHT); |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1843 | int below = (tp->tp_flags |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1844 | & TP_FLAG_ALIGN_BELOW); |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1845 | int wrap = (tp->tp_flags & TP_FLAG_WRAP); |
| 1846 | int padding = tp->tp_col == MAXCOL |
| 1847 | && tp->tp_len > 1 |
| 1848 | ? tp->tp_len - 1 : 0; |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1849 | |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1850 | // Insert virtual text before the current |
| 1851 | // character, or add after the end of the line. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1852 | wlv.p_extra = p; |
| 1853 | wlv.c_extra = NUL; |
| 1854 | wlv.c_final = NUL; |
| 1855 | wlv.n_extra = (int)STRLEN(p); |
Bram Moolenaar | 9e7e28f | 2022-08-14 16:36:38 +0100 | [diff] [blame] | 1856 | extra_for_textprop = TRUE; |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1857 | extra_attr = used_attr; |
Bram Moolenaar | 09ff4b5 | 2022-08-01 16:51:02 +0100 | [diff] [blame] | 1858 | n_attr = mb_charlen(p); |
Bram Moolenaar | 6eda17d | 2022-09-12 19:25:11 +0100 | [diff] [blame] | 1859 | // restore search_attr and area_attr when n_extra |
| 1860 | // is down to zero |
Bram Moolenaar | e38fc86 | 2022-08-11 17:24:50 +0100 | [diff] [blame] | 1861 | saved_search_attr = search_attr; |
Bram Moolenaar | 6eda17d | 2022-09-12 19:25:11 +0100 | [diff] [blame] | 1862 | saved_area_attr = area_attr; |
| 1863 | search_attr = 0; |
| 1864 | area_attr = 0; |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1865 | text_prop_attr = 0; |
Bram Moolenaar | cf2bb63 | 2022-09-02 13:26:29 +0100 | [diff] [blame] | 1866 | text_prop_attr_comb = 0; |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1867 | if (*ptr == NUL) |
| 1868 | // don't combine char attr after EOL |
Bram Moolenaar | 4d2031f | 2022-08-05 20:03:55 +0100 | [diff] [blame] | 1869 | text_prop_flags &= ~PT_FLAG_COMBINE; |
Bram Moolenaar | 3ec3b8e | 2022-08-05 21:39:30 +0100 | [diff] [blame] | 1870 | #ifdef FEAT_LINEBREAK |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 1871 | if (above || below || right || !wrap) |
Bram Moolenaar | 3ec3b8e | 2022-08-05 21:39:30 +0100 | [diff] [blame] | 1872 | { |
| 1873 | // no 'showbreak' before "below" text property |
Bram Moolenaar | 04e0ed1 | 2022-09-10 20:00:56 +0100 | [diff] [blame] | 1874 | // or after "above" or "right" text property |
Bram Moolenaar | 3ec3b8e | 2022-08-05 21:39:30 +0100 | [diff] [blame] | 1875 | need_showbreak = FALSE; |
| 1876 | dont_use_showbreak = TRUE; |
| 1877 | } |
| 1878 | #endif |
Bram Moolenaar | 79f8b84 | 2022-09-11 13:31:01 +0100 | [diff] [blame] | 1879 | if ((right || above || below || !wrap |
| 1880 | || padding > 0) && wp->w_width > 2) |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1881 | { |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1882 | char_u *prev_p_extra = wlv.p_extra; |
| 1883 | int start_line; |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1884 | |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1885 | // Take care of padding, right-align and |
| 1886 | // truncation. |
| 1887 | // Shared with win_lbr_chartabsize(), must do |
| 1888 | // exactly the same. |
| 1889 | start_line = text_prop_position(wp, tp, |
| 1890 | wlv.col, |
| 1891 | &wlv.n_extra, &wlv.p_extra, |
| 1892 | &n_attr, &n_attr_skip); |
| 1893 | if (wlv.p_extra != prev_p_extra) |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1894 | { |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1895 | // wlv.p_extra was allocated |
| 1896 | vim_free(p_extra_free2); |
| 1897 | p_extra_free2 = wlv.p_extra; |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1898 | } |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1899 | |
Bram Moolenaar | a4abe51 | 2022-09-15 19:44:09 +0100 | [diff] [blame] | 1900 | if (lcs_eol_one < 0 && wlv.col |
| 1901 | + wlv.n_extra - 2 > wp->w_width) |
| 1902 | // don't bail out at end of line |
| 1903 | lcs_eol_one = 0; |
| 1904 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1905 | // When 'wrap' is off then for "below" we need |
| 1906 | // to start a new line explictly. |
Bram Moolenaar | f396ce8 | 2022-08-23 18:39:37 +0100 | [diff] [blame] | 1907 | if (start_line) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1908 | { |
| 1909 | draw_screen_line(wp, &wlv); |
| 1910 | |
| 1911 | // When line got too long for screen break |
| 1912 | // here. |
| 1913 | if (wlv.row == endrow) |
| 1914 | { |
| 1915 | ++wlv.row; |
| 1916 | break; |
| 1917 | } |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1918 | win_line_start(wp, &wlv, TRUE); |
| 1919 | continue; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1920 | } |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1921 | } |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1922 | } |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1923 | |
| 1924 | // If another text prop follows the condition below at |
| 1925 | // the last window column must know. |
Bram Moolenaar | c9dc03f | 2022-09-12 17:51:07 +0100 | [diff] [blame] | 1926 | // If this is an "above" text prop and 'nowrap' the we |
| 1927 | // must wrap anyway. |
| 1928 | text_prop_above = above; |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 1929 | text_prop_follows = other_tpi != -1; |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 1930 | } |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1931 | } |
Bram Moolenaar | 398649e | 2022-08-04 15:03:48 +0100 | [diff] [blame] | 1932 | else if (text_prop_next < text_prop_count |
| 1933 | && text_props[text_prop_next].tp_col == MAXCOL |
Bram Moolenaar | 48ca24d | 2022-08-06 22:03:20 +0100 | [diff] [blame] | 1934 | && ((*ptr != NUL && ptr[mb_ptr2len(ptr)] == NUL) |
| 1935 | || (!wp->w_p_wrap |
| 1936 | && wlv.col == wp->w_width - 1 |
| 1937 | && (text_props[text_prop_next].tp_flags |
| 1938 | & TP_FLAG_ALIGN_BELOW)))) |
Bram Moolenaar | 398649e | 2022-08-04 15:03:48 +0100 | [diff] [blame] | 1939 | // When at last-but-one character and a text property |
| 1940 | // follows after it, we may need to flush the line after |
| 1941 | // displaying that character. |
Bram Moolenaar | 48ca24d | 2022-08-06 22:03:20 +0100 | [diff] [blame] | 1942 | // Or when not wrapping and at the rightmost column. |
Bram Moolenaar | 398649e | 2022-08-04 15:03:48 +0100 | [diff] [blame] | 1943 | text_prop_follows = TRUE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 1944 | } |
| 1945 | #endif |
| 1946 | |
Bram Moolenaar | e38fc86 | 2022-08-11 17:24:50 +0100 | [diff] [blame] | 1947 | #ifdef FEAT_SEARCH_EXTRA |
| 1948 | if (wlv.n_extra == 0) |
| 1949 | { |
| 1950 | // Check for start/end of 'hlsearch' and other matches. |
| 1951 | // After end, check for start/end of next match. |
| 1952 | // When another match, have to check for start again. |
| 1953 | v = (long)(ptr - line); |
| 1954 | search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line, |
| 1955 | &screen_search_hl, &has_match_conc, |
| 1956 | &match_conc, did_line_attr, lcs_eol_one, |
| 1957 | &on_last_col); |
| 1958 | ptr = line + v; // "line" may have been changed |
| 1959 | prev_ptr = ptr; |
| 1960 | |
| 1961 | // Do not allow a conceal over EOL otherwise EOL will be missed |
| 1962 | // and bad things happen. |
| 1963 | if (*ptr == NUL) |
| 1964 | has_match_conc = 0; |
| 1965 | } |
| 1966 | #endif |
| 1967 | |
| 1968 | #ifdef FEAT_DIFF |
| 1969 | if (wlv.diff_hlf != (hlf_T)0) |
| 1970 | { |
| 1971 | if (wlv.diff_hlf == HLF_CHD && ptr - line >= change_start |
| 1972 | && wlv.n_extra == 0) |
| 1973 | wlv.diff_hlf = HLF_TXD; // changed text |
| 1974 | if (wlv.diff_hlf == HLF_TXD && ptr - line > change_end |
| 1975 | && wlv.n_extra == 0) |
| 1976 | wlv.diff_hlf = HLF_CHD; // changed line |
| 1977 | line_attr = HL_ATTR(wlv.diff_hlf); |
| 1978 | if (wp->w_p_cul && lnum == wp->w_cursor.lnum |
| 1979 | && wp->w_p_culopt_flags != CULOPT_NBR |
| 1980 | && (!wlv.cul_screenline || (wlv.vcol >= left_curline_col |
| 1981 | && wlv.vcol <= right_curline_col))) |
| 1982 | line_attr = hl_combine_attr( |
| 1983 | line_attr, HL_ATTR(HLF_CUL)); |
| 1984 | } |
| 1985 | #endif |
| 1986 | |
Bram Moolenaar | a74fda6 | 2019-10-19 17:38:03 +0200 | [diff] [blame] | 1987 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 1988 | if (extra_check && wlv.n_extra == 0) |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 1989 | { |
Bram Moolenaar | 82260af | 2019-10-20 13:16:22 +0200 | [diff] [blame] | 1990 | syntax_attr = 0; |
Bram Moolenaar | a74fda6 | 2019-10-19 17:38:03 +0200 | [diff] [blame] | 1991 | # ifdef FEAT_TERMINAL |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 1992 | if (get_term_attr) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 1993 | syntax_attr = term_get_attr(wp, lnum, wlv.vcol); |
Bram Moolenaar | a74fda6 | 2019-10-19 17:38:03 +0200 | [diff] [blame] | 1994 | # endif |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 1995 | // Get syntax attribute. |
| 1996 | if (has_syntax) |
| 1997 | { |
| 1998 | // Get the syntax attribute for the character. If there |
| 1999 | // is an error, disable syntax highlighting. |
| 2000 | save_did_emsg = did_emsg; |
| 2001 | did_emsg = FALSE; |
| 2002 | |
| 2003 | v = (long)(ptr - line); |
Bram Moolenaar | 9115c61 | 2019-10-16 16:57:06 +0200 | [diff] [blame] | 2004 | if (v == prev_syntax_col) |
| 2005 | // at same column again |
| 2006 | syntax_attr = prev_syntax_attr; |
| 2007 | else |
| 2008 | { |
Bram Moolenaar | b2fe1d6 | 2019-10-16 21:33:40 +0200 | [diff] [blame] | 2009 | # ifdef FEAT_SPELL |
Bram Moolenaar | 9115c61 | 2019-10-16 16:57:06 +0200 | [diff] [blame] | 2010 | can_spell = TRUE; |
Bram Moolenaar | b2fe1d6 | 2019-10-16 21:33:40 +0200 | [diff] [blame] | 2011 | # endif |
Bram Moolenaar | 9115c61 | 2019-10-16 16:57:06 +0200 | [diff] [blame] | 2012 | syntax_attr = get_syntax_attr((colnr_T)v, |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 2013 | # ifdef FEAT_SPELL |
| 2014 | has_spell ? &can_spell : |
| 2015 | # endif |
| 2016 | NULL, FALSE); |
Bram Moolenaar | 9115c61 | 2019-10-16 16:57:06 +0200 | [diff] [blame] | 2017 | prev_syntax_col = v; |
| 2018 | prev_syntax_attr = syntax_attr; |
| 2019 | } |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 2020 | |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 2021 | if (did_emsg) |
| 2022 | { |
| 2023 | wp->w_s->b_syn_error = TRUE; |
| 2024 | has_syntax = FALSE; |
| 2025 | syntax_attr = 0; |
| 2026 | } |
| 2027 | else |
| 2028 | did_emsg = save_did_emsg; |
| 2029 | # ifdef SYN_TIME_LIMIT |
| 2030 | if (wp->w_s->b_syn_slow) |
| 2031 | has_syntax = FALSE; |
| 2032 | # endif |
| 2033 | |
| 2034 | // Need to get the line again, a multi-line regexp may |
| 2035 | // have made it invalid. |
| 2036 | line = ml_get_buf(wp->w_buffer, lnum, FALSE); |
| 2037 | ptr = line + v; |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 2038 | prev_ptr = ptr; |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 2039 | # ifdef FEAT_CONCEAL |
| 2040 | // no concealing past the end of the line, it interferes |
| 2041 | // with line highlighting |
| 2042 | if (*ptr == NUL) |
| 2043 | syntax_flags = 0; |
| 2044 | else |
| 2045 | syntax_flags = get_syntax_info(&syntax_seqnr); |
| 2046 | # endif |
| 2047 | } |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 2048 | } |
Bram Moolenaar | 05ad5ff | 2019-11-30 22:48:27 +0100 | [diff] [blame] | 2049 | # ifdef FEAT_PROP_POPUP |
Bram Moolenaar | dbd4316 | 2019-11-09 21:28:14 +0100 | [diff] [blame] | 2050 | // Combine text property highlight into syntax highlight. |
| 2051 | if (text_prop_type != NULL) |
| 2052 | { |
Bram Moolenaar | 4d2031f | 2022-08-05 20:03:55 +0100 | [diff] [blame] | 2053 | if (text_prop_flags & PT_FLAG_COMBINE) |
Bram Moolenaar | dbd4316 | 2019-11-09 21:28:14 +0100 | [diff] [blame] | 2054 | syntax_attr = hl_combine_attr(syntax_attr, text_prop_attr); |
| 2055 | else |
| 2056 | syntax_attr = text_prop_attr; |
Bram Moolenaar | cf2bb63 | 2022-09-02 13:26:29 +0100 | [diff] [blame] | 2057 | text_prop_attr_comb = syntax_attr; |
Bram Moolenaar | dbd4316 | 2019-11-09 21:28:14 +0100 | [diff] [blame] | 2058 | } |
| 2059 | # endif |
Bram Moolenaar | a74fda6 | 2019-10-19 17:38:03 +0200 | [diff] [blame] | 2060 | #endif |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 2061 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2062 | // Decide which of the highlight attributes to use. |
| 2063 | attr_pri = TRUE; |
| 2064 | #ifdef LINE_ATTR |
| 2065 | if (area_attr != 0) |
Bram Moolenaar | 8459006 | 2019-10-18 23:12:20 +0200 | [diff] [blame] | 2066 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2067 | wlv.char_attr = hl_combine_attr(line_attr, area_attr); |
Bram Moolenaar | 2d5f385 | 2021-04-21 15:11:42 +0200 | [diff] [blame] | 2068 | if (!highlight_match) |
| 2069 | // let search highlight show in Visual area if possible |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2070 | wlv.char_attr = hl_combine_attr(search_attr, wlv.char_attr); |
Bram Moolenaar | 8459006 | 2019-10-18 23:12:20 +0200 | [diff] [blame] | 2071 | # ifdef FEAT_SYN_HL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2072 | wlv.char_attr = hl_combine_attr(syntax_attr, wlv.char_attr); |
Bram Moolenaar | 8459006 | 2019-10-18 23:12:20 +0200 | [diff] [blame] | 2073 | # endif |
| 2074 | } |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2075 | else if (search_attr != 0) |
Bram Moolenaar | 8459006 | 2019-10-18 23:12:20 +0200 | [diff] [blame] | 2076 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2077 | wlv.char_attr = hl_combine_attr(line_attr, search_attr); |
Bram Moolenaar | 8459006 | 2019-10-18 23:12:20 +0200 | [diff] [blame] | 2078 | # ifdef FEAT_SYN_HL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2079 | wlv.char_attr = hl_combine_attr(syntax_attr, wlv.char_attr); |
Bram Moolenaar | 8459006 | 2019-10-18 23:12:20 +0200 | [diff] [blame] | 2080 | # endif |
| 2081 | } |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2082 | else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2083 | || wlv.vcol < fromcol || vcol_prev < fromcol_prev |
| 2084 | || wlv.vcol >= tocol)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2085 | { |
| 2086 | // Use line_attr when not in the Visual or 'incsearch' area |
| 2087 | // (area_attr may be 0 when "noinvcur" is set). |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 2088 | # ifdef FEAT_SYN_HL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2089 | wlv.char_attr = hl_combine_attr(syntax_attr, line_attr); |
Bram Moolenaar | dbd4316 | 2019-11-09 21:28:14 +0100 | [diff] [blame] | 2090 | # else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2091 | wlv.char_attr = line_attr; |
Bram Moolenaar | 3439028 | 2019-10-16 14:38:26 +0200 | [diff] [blame] | 2092 | # endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2093 | attr_pri = FALSE; |
| 2094 | } |
| 2095 | #else |
| 2096 | if (area_attr != 0) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2097 | wlv.char_attr = area_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2098 | else if (search_attr != 0) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2099 | wlv.char_attr = search_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2100 | #endif |
| 2101 | else |
| 2102 | { |
| 2103 | attr_pri = FALSE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2104 | #ifdef FEAT_SYN_HL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2105 | wlv.char_attr = syntax_attr; |
Bram Moolenaar | a74fda6 | 2019-10-19 17:38:03 +0200 | [diff] [blame] | 2106 | #else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2107 | wlv.char_attr = 0; |
Bram Moolenaar | a74fda6 | 2019-10-19 17:38:03 +0200 | [diff] [blame] | 2108 | #endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2109 | } |
Bram Moolenaar | 4d2031f | 2022-08-05 20:03:55 +0100 | [diff] [blame] | 2110 | #ifdef FEAT_PROP_POPUP |
| 2111 | // override with text property highlight when "override" is TRUE |
| 2112 | if (text_prop_type != NULL && (text_prop_flags & PT_FLAG_OVERRIDE)) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2113 | wlv.char_attr = hl_combine_attr(wlv.char_attr, text_prop_attr); |
Bram Moolenaar | 4d2031f | 2022-08-05 20:03:55 +0100 | [diff] [blame] | 2114 | #endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2115 | } |
Bram Moolenaar | 024dbd2 | 2019-11-02 22:00:15 +0100 | [diff] [blame] | 2116 | |
| 2117 | // combine attribute with 'wincolor' |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2118 | if (wlv.win_attr != 0) |
Bram Moolenaar | 024dbd2 | 2019-11-02 22:00:15 +0100 | [diff] [blame] | 2119 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2120 | if (wlv.char_attr == 0) |
| 2121 | wlv.char_attr = wlv.win_attr; |
Bram Moolenaar | 024dbd2 | 2019-11-02 22:00:15 +0100 | [diff] [blame] | 2122 | else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2123 | wlv.char_attr = hl_combine_attr(wlv.win_attr, wlv.char_attr); |
Bram Moolenaar | 024dbd2 | 2019-11-02 22:00:15 +0100 | [diff] [blame] | 2124 | } |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2125 | |
| 2126 | // Get the next character to put on the screen. |
| 2127 | |
| 2128 | // The "p_extra" points to the extra stuff that is inserted to |
| 2129 | // represent special characters (non-printable stuff) and other |
| 2130 | // things. When all characters are the same, c_extra is used. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2131 | // If wlv.c_final is set, it will compulsorily be used at the end. |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2132 | // "p_extra" must end in a NUL to avoid mb_ptr2len() reads past |
| 2133 | // "p_extra[n_extra]". |
| 2134 | // For the '$' of the 'list' option, n_extra == 1, p_extra == "". |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2135 | if (wlv.n_extra > 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2136 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2137 | if (wlv.c_extra != NUL || (wlv.n_extra == 1 && wlv.c_final != NUL)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2138 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2139 | c = (wlv.n_extra == 1 && wlv.c_final != NUL) |
| 2140 | ? wlv.c_final : wlv.c_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2141 | mb_c = c; // doesn't handle non-utf-8 multi-byte! |
| 2142 | if (enc_utf8 && utf_char2len(c) > 1) |
| 2143 | { |
| 2144 | mb_utf8 = TRUE; |
| 2145 | u8cc[0] = 0; |
| 2146 | c = 0xc0; |
| 2147 | } |
| 2148 | else |
| 2149 | mb_utf8 = FALSE; |
| 2150 | } |
| 2151 | else |
| 2152 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2153 | c = *wlv.p_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2154 | if (has_mbyte) |
| 2155 | { |
| 2156 | mb_c = c; |
| 2157 | if (enc_utf8) |
| 2158 | { |
| 2159 | // If the UTF-8 character is more than one byte: |
| 2160 | // Decode it into "mb_c". |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2161 | mb_l = utfc_ptr2len(wlv.p_extra); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2162 | mb_utf8 = FALSE; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2163 | if (mb_l > wlv.n_extra) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2164 | mb_l = 1; |
| 2165 | else if (mb_l > 1) |
| 2166 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2167 | mb_c = utfc_ptr2char(wlv.p_extra, u8cc); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2168 | mb_utf8 = TRUE; |
| 2169 | c = 0xc0; |
| 2170 | } |
| 2171 | } |
| 2172 | else |
| 2173 | { |
| 2174 | // if this is a DBCS character, put it in "mb_c" |
| 2175 | mb_l = MB_BYTE2LEN(c); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2176 | if (mb_l >= wlv.n_extra) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2177 | mb_l = 1; |
| 2178 | else if (mb_l > 1) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2179 | mb_c = (c << 8) + wlv.p_extra[1]; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2180 | } |
| 2181 | if (mb_l == 0) // at the NUL at end-of-line |
| 2182 | mb_l = 1; |
| 2183 | |
| 2184 | // If a double-width char doesn't fit display a '>' in the |
| 2185 | // last column. |
| 2186 | if (( |
| 2187 | # ifdef FEAT_RIGHTLEFT |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2188 | wp->w_p_rl ? (wlv.col <= 0) : |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2189 | # endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2190 | (wlv.col >= wp->w_width - 1)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2191 | && (*mb_char2cells)(mb_c) == 2) |
| 2192 | { |
| 2193 | c = '>'; |
| 2194 | mb_c = c; |
| 2195 | mb_l = 1; |
| 2196 | mb_utf8 = FALSE; |
| 2197 | multi_attr = HL_ATTR(HLF_AT); |
| 2198 | #ifdef FEAT_SYN_HL |
| 2199 | if (cul_attr) |
| 2200 | multi_attr = hl_combine_attr(multi_attr, cul_attr); |
| 2201 | #endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2202 | multi_attr = hl_combine_attr(wlv.win_attr, multi_attr); |
Bram Moolenaar | 92e25ab | 2019-11-26 22:39:10 +0100 | [diff] [blame] | 2203 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2204 | // put the pointer back to output the double-width |
| 2205 | // character at the start of the next line. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2206 | ++wlv.n_extra; |
| 2207 | --wlv.p_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2208 | } |
| 2209 | else |
| 2210 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2211 | wlv.n_extra -= mb_l - 1; |
| 2212 | wlv.p_extra += mb_l - 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2213 | } |
| 2214 | } |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2215 | ++wlv.p_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2216 | } |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2217 | --wlv.n_extra; |
Bram Moolenaar | e38fc86 | 2022-08-11 17:24:50 +0100 | [diff] [blame] | 2218 | #if defined(FEAT_PROP_POPUP) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2219 | if (wlv.n_extra <= 0) |
Bram Moolenaar | e38fc86 | 2022-08-11 17:24:50 +0100 | [diff] [blame] | 2220 | { |
Bram Moolenaar | 9e7e28f | 2022-08-14 16:36:38 +0100 | [diff] [blame] | 2221 | extra_for_textprop = FALSE; |
Bram Moolenaar | 6b839ac | 2021-11-29 21:12:35 +0000 | [diff] [blame] | 2222 | in_linebreak = FALSE; |
Bram Moolenaar | e38fc86 | 2022-08-11 17:24:50 +0100 | [diff] [blame] | 2223 | if (search_attr == 0) |
| 2224 | search_attr = saved_search_attr; |
Bram Moolenaar | 6eda17d | 2022-09-12 19:25:11 +0100 | [diff] [blame] | 2225 | if (area_attr == 0 && *ptr != NUL) |
| 2226 | area_attr = saved_area_attr; |
Bram Moolenaar | e38fc86 | 2022-08-11 17:24:50 +0100 | [diff] [blame] | 2227 | } |
Bram Moolenaar | 6b839ac | 2021-11-29 21:12:35 +0000 | [diff] [blame] | 2228 | #endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2229 | } |
| 2230 | else |
| 2231 | { |
| 2232 | #ifdef FEAT_LINEBREAK |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 2233 | int c0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2234 | #endif |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 2235 | prev_ptr = ptr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2236 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2237 | // Get a character from the line itself. |
| 2238 | c = *ptr; |
| 2239 | #ifdef FEAT_LINEBREAK |
| 2240 | c0 = *ptr; |
| 2241 | #endif |
| 2242 | if (has_mbyte) |
| 2243 | { |
| 2244 | mb_c = c; |
| 2245 | if (enc_utf8) |
| 2246 | { |
| 2247 | // If the UTF-8 character is more than one byte: Decode it |
| 2248 | // into "mb_c". |
| 2249 | mb_l = utfc_ptr2len(ptr); |
| 2250 | mb_utf8 = FALSE; |
| 2251 | if (mb_l > 1) |
| 2252 | { |
| 2253 | mb_c = utfc_ptr2char(ptr, u8cc); |
| 2254 | // Overlong encoded ASCII or ASCII with composing char |
| 2255 | // is displayed normally, except a NUL. |
| 2256 | if (mb_c < 0x80) |
| 2257 | { |
| 2258 | c = mb_c; |
| 2259 | #ifdef FEAT_LINEBREAK |
| 2260 | c0 = mb_c; |
| 2261 | #endif |
| 2262 | } |
| 2263 | mb_utf8 = TRUE; |
| 2264 | |
| 2265 | // At start of the line we can have a composing char. |
| 2266 | // Draw it as a space with a composing char. |
| 2267 | if (utf_iscomposing(mb_c)) |
| 2268 | { |
| 2269 | int i; |
| 2270 | |
| 2271 | for (i = Screen_mco - 1; i > 0; --i) |
| 2272 | u8cc[i] = u8cc[i - 1]; |
| 2273 | u8cc[0] = mb_c; |
| 2274 | mb_c = ' '; |
| 2275 | } |
| 2276 | } |
| 2277 | |
| 2278 | if ((mb_l == 1 && c >= 0x80) |
| 2279 | || (mb_l >= 1 && mb_c == 0) |
| 2280 | || (mb_l > 1 && (!vim_isprintc(mb_c)))) |
| 2281 | { |
| 2282 | // Illegal UTF-8 byte: display as <xx>. |
| 2283 | // Non-BMP character : display as ? or fullwidth ?. |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 2284 | transchar_hex(wlv.extra, mb_c); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2285 | # ifdef FEAT_RIGHTLEFT |
| 2286 | if (wp->w_p_rl) // reverse |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 2287 | rl_mirror(wlv.extra); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2288 | # endif |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 2289 | wlv.p_extra = wlv.extra; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2290 | c = *wlv.p_extra; |
| 2291 | mb_c = mb_ptr2char_adv(&wlv.p_extra); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2292 | mb_utf8 = (c >= 0x80); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2293 | wlv.n_extra = (int)STRLEN(wlv.p_extra); |
| 2294 | wlv.c_extra = NUL; |
| 2295 | wlv.c_final = NUL; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2296 | if (area_attr == 0 && search_attr == 0) |
| 2297 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2298 | n_attr = wlv.n_extra + 1; |
Bram Moolenaar | 42e931b | 2019-12-04 19:08:50 +0100 | [diff] [blame] | 2299 | extra_attr = hl_combine_attr( |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2300 | wlv.win_attr, HL_ATTR(HLF_8)); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2301 | saved_attr2 = wlv.char_attr; // save current attr |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2302 | } |
| 2303 | } |
| 2304 | else if (mb_l == 0) // at the NUL at end-of-line |
| 2305 | mb_l = 1; |
| 2306 | #ifdef FEAT_ARABIC |
| 2307 | else if (p_arshape && !p_tbidi && ARABIC_CHAR(mb_c)) |
| 2308 | { |
| 2309 | // Do Arabic shaping. |
| 2310 | int pc, pc1, nc; |
| 2311 | int pcc[MAX_MCO]; |
| 2312 | |
| 2313 | // The idea of what is the previous and next |
| 2314 | // character depends on 'rightleft'. |
| 2315 | if (wp->w_p_rl) |
| 2316 | { |
| 2317 | pc = prev_c; |
| 2318 | pc1 = prev_c1; |
| 2319 | nc = utf_ptr2char(ptr + mb_l); |
| 2320 | prev_c1 = u8cc[0]; |
| 2321 | } |
| 2322 | else |
| 2323 | { |
| 2324 | pc = utfc_ptr2char(ptr + mb_l, pcc); |
| 2325 | nc = prev_c; |
| 2326 | pc1 = pcc[0]; |
| 2327 | } |
| 2328 | prev_c = mb_c; |
| 2329 | |
| 2330 | mb_c = arabic_shape(mb_c, &c, &u8cc[0], pc, pc1, nc); |
| 2331 | } |
| 2332 | else |
| 2333 | prev_c = mb_c; |
| 2334 | #endif |
| 2335 | } |
| 2336 | else // enc_dbcs |
| 2337 | { |
| 2338 | mb_l = MB_BYTE2LEN(c); |
| 2339 | if (mb_l == 0) // at the NUL at end-of-line |
| 2340 | mb_l = 1; |
| 2341 | else if (mb_l > 1) |
| 2342 | { |
| 2343 | // We assume a second byte below 32 is illegal. |
| 2344 | // Hopefully this is OK for all double-byte encodings! |
| 2345 | if (ptr[1] >= 32) |
| 2346 | mb_c = (c << 8) + ptr[1]; |
| 2347 | else |
| 2348 | { |
| 2349 | if (ptr[1] == NUL) |
| 2350 | { |
| 2351 | // head byte at end of line |
| 2352 | mb_l = 1; |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 2353 | transchar_nonprint(wp->w_buffer, wlv.extra, c); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2354 | } |
| 2355 | else |
| 2356 | { |
| 2357 | // illegal tail byte |
| 2358 | mb_l = 2; |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 2359 | STRCPY(wlv.extra, "XX"); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2360 | } |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 2361 | wlv.p_extra = wlv.extra; |
| 2362 | wlv.n_extra = (int)STRLEN(wlv.extra) - 1; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2363 | wlv.c_extra = NUL; |
| 2364 | wlv.c_final = NUL; |
| 2365 | c = *wlv.p_extra++; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2366 | if (area_attr == 0 && search_attr == 0) |
| 2367 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2368 | n_attr = wlv.n_extra + 1; |
Bram Moolenaar | 42e931b | 2019-12-04 19:08:50 +0100 | [diff] [blame] | 2369 | extra_attr = hl_combine_attr( |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2370 | wlv.win_attr, HL_ATTR(HLF_8)); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2371 | // save current attr |
| 2372 | saved_attr2 = wlv.char_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2373 | } |
| 2374 | mb_c = c; |
| 2375 | } |
| 2376 | } |
| 2377 | } |
| 2378 | // If a double-width char doesn't fit display a '>' in the |
| 2379 | // last column; the character is displayed at the start of the |
| 2380 | // next line. |
| 2381 | if (( |
| 2382 | # ifdef FEAT_RIGHTLEFT |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2383 | wp->w_p_rl ? (wlv.col <= 0) : |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2384 | # endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2385 | (wlv.col >= wp->w_width - 1)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2386 | && (*mb_char2cells)(mb_c) == 2) |
| 2387 | { |
| 2388 | c = '>'; |
| 2389 | mb_c = c; |
| 2390 | mb_utf8 = FALSE; |
| 2391 | mb_l = 1; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2392 | multi_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2393 | // Put pointer back so that the character will be |
| 2394 | // displayed at the start of the next line. |
| 2395 | --ptr; |
| 2396 | #ifdef FEAT_CONCEAL |
| 2397 | did_decrement_ptr = TRUE; |
| 2398 | #endif |
| 2399 | } |
| 2400 | else if (*ptr != NUL) |
| 2401 | ptr += mb_l - 1; |
| 2402 | |
| 2403 | // If a double-width char doesn't fit at the left side display |
| 2404 | // a '<' in the first column. Don't do this for unprintable |
| 2405 | // characters. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2406 | if (n_skip > 0 && mb_l > 1 && wlv.n_extra == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2407 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2408 | wlv.n_extra = 1; |
| 2409 | wlv.c_extra = MB_FILLER_CHAR; |
| 2410 | wlv.c_final = NUL; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2411 | c = ' '; |
| 2412 | if (area_attr == 0 && search_attr == 0) |
| 2413 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2414 | n_attr = wlv.n_extra + 1; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2415 | extra_attr = hl_combine_attr( |
| 2416 | wlv.win_attr, HL_ATTR(HLF_AT)); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2417 | saved_attr2 = wlv.char_attr; // save current attr |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2418 | } |
| 2419 | mb_c = c; |
| 2420 | mb_utf8 = FALSE; |
| 2421 | mb_l = 1; |
| 2422 | } |
| 2423 | |
| 2424 | } |
| 2425 | ++ptr; |
| 2426 | |
| 2427 | if (extra_check) |
| 2428 | { |
| 2429 | #ifdef FEAT_SPELL |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2430 | // Check spelling (unless at the end of the line). |
| 2431 | // Only do this when there is no syntax highlighting, the |
| 2432 | // @Spell cluster is not used or the current syntax item |
| 2433 | // contains the @Spell cluster. |
Bram Moolenaar | 7751d1d | 2019-10-18 20:37:08 +0200 | [diff] [blame] | 2434 | v = (long)(ptr - line); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2435 | if (has_spell && v >= word_end && v > cur_checked_col) |
| 2436 | { |
| 2437 | spell_attr = 0; |
Christian Brabandt | afa23d1 | 2022-08-09 12:25:10 +0100 | [diff] [blame] | 2438 | // do not calculate cap_col at the end of the line or when |
| 2439 | // only white space is following |
| 2440 | if (c != 0 && (*skipwhite(prev_ptr) != NUL) && ( |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2441 | # ifdef FEAT_SYN_HL |
| 2442 | !has_syntax || |
| 2443 | # endif |
| 2444 | can_spell)) |
| 2445 | { |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 2446 | char_u *p; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2447 | int len; |
| 2448 | hlf_T spell_hlf = HLF_COUNT; |
Bram Moolenaar | fabc3ca | 2020-11-05 19:07:21 +0100 | [diff] [blame] | 2449 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2450 | if (has_mbyte) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2451 | v -= mb_l - 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2452 | |
| 2453 | // Use nextline[] if possible, it has the start of the |
| 2454 | // next line concatenated. |
| 2455 | if ((prev_ptr - line) - nextlinecol >= 0) |
| 2456 | p = nextline + (prev_ptr - line) - nextlinecol; |
| 2457 | else |
| 2458 | p = prev_ptr; |
| 2459 | cap_col -= (int)(prev_ptr - line); |
| 2460 | len = spell_check(wp, p, &spell_hlf, &cap_col, |
| 2461 | nochange); |
| 2462 | word_end = v + len; |
| 2463 | |
| 2464 | // In Insert mode only highlight a word that |
| 2465 | // doesn't touch the cursor. |
| 2466 | if (spell_hlf != HLF_COUNT |
Bram Moolenaar | 2495910 | 2022-05-07 20:01:16 +0100 | [diff] [blame] | 2467 | && (State & MODE_INSERT) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2468 | && wp->w_cursor.lnum == lnum |
| 2469 | && wp->w_cursor.col >= |
| 2470 | (colnr_T)(prev_ptr - line) |
| 2471 | && wp->w_cursor.col < (colnr_T)word_end) |
| 2472 | { |
| 2473 | spell_hlf = HLF_COUNT; |
| 2474 | spell_redraw_lnum = lnum; |
| 2475 | } |
| 2476 | |
| 2477 | if (spell_hlf == HLF_COUNT && p != prev_ptr |
| 2478 | && (p - nextline) + len > nextline_idx) |
| 2479 | { |
| 2480 | // Remember that the good word continues at the |
| 2481 | // start of the next line. |
| 2482 | checked_lnum = lnum + 1; |
Bram Moolenaar | 7751d1d | 2019-10-18 20:37:08 +0200 | [diff] [blame] | 2483 | checked_col = (int)((p - nextline) |
| 2484 | + len - nextline_idx); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2485 | } |
| 2486 | |
| 2487 | // Turn index into actual attributes. |
| 2488 | if (spell_hlf != HLF_COUNT) |
| 2489 | spell_attr = highlight_attr[spell_hlf]; |
| 2490 | |
| 2491 | if (cap_col > 0) |
| 2492 | { |
| 2493 | if (p != prev_ptr |
| 2494 | && (p - nextline) + cap_col >= nextline_idx) |
| 2495 | { |
| 2496 | // Remember that the word in the next line |
| 2497 | // must start with a capital. |
| 2498 | capcol_lnum = lnum + 1; |
| 2499 | cap_col = (int)((p - nextline) + cap_col |
| 2500 | - nextline_idx); |
| 2501 | } |
| 2502 | else |
| 2503 | // Compute the actual column. |
| 2504 | cap_col += (int)(prev_ptr - line); |
| 2505 | } |
| 2506 | } |
| 2507 | } |
| 2508 | if (spell_attr != 0) |
| 2509 | { |
| 2510 | if (!attr_pri) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2511 | wlv.char_attr = hl_combine_attr(wlv.char_attr, |
| 2512 | spell_attr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2513 | else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2514 | wlv.char_attr = hl_combine_attr(spell_attr, |
| 2515 | wlv.char_attr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2516 | } |
| 2517 | #endif |
| 2518 | #ifdef FEAT_LINEBREAK |
| 2519 | // Found last space before word: check for line break. |
| 2520 | if (wp->w_p_lbr && c0 == c |
| 2521 | && VIM_ISBREAK(c) && !VIM_ISBREAK((int)*ptr)) |
| 2522 | { |
Bram Moolenaar | 20e0c3d | 2021-08-31 20:57:55 +0200 | [diff] [blame] | 2523 | int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) |
| 2524 | : 0; |
| 2525 | char_u *p = ptr - (mb_off + 1); |
Bram Moolenaar | 7f9969c | 2022-07-25 18:13:54 +0100 | [diff] [blame] | 2526 | chartabsize_T cts; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2527 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2528 | init_chartabsize_arg(&cts, wp, lnum, wlv.vcol, line, p); |
Bram Moolenaar | 52de3a8 | 2022-08-10 13:12:03 +0100 | [diff] [blame] | 2529 | # ifdef FEAT_PROP_POPUP |
| 2530 | // do not want virtual text counted here |
| 2531 | cts.cts_has_prop_with_text = FALSE; |
| 2532 | # endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2533 | wlv.n_extra = win_lbr_chartabsize(&cts, NULL) - 1; |
Bram Moolenaar | 52de3a8 | 2022-08-10 13:12:03 +0100 | [diff] [blame] | 2534 | clear_chartabsize_arg(&cts); |
Bram Moolenaar | a06e345 | 2021-05-29 17:56:37 +0200 | [diff] [blame] | 2535 | |
| 2536 | // We have just drawn the showbreak value, no need to add |
Bram Moolenaar | 20e0c3d | 2021-08-31 20:57:55 +0200 | [diff] [blame] | 2537 | // space for it again. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2538 | if (wlv.vcol == vcol_sbr) |
Bram Moolenaar | 20e0c3d | 2021-08-31 20:57:55 +0200 | [diff] [blame] | 2539 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2540 | wlv.n_extra -= MB_CHARLEN(get_showbreak_value(wp)); |
| 2541 | if (wlv.n_extra < 0) |
| 2542 | wlv.n_extra = 0; |
Bram Moolenaar | 20e0c3d | 2021-08-31 20:57:55 +0200 | [diff] [blame] | 2543 | } |
Bram Moolenaar | 0bbca54 | 2022-01-11 13:14:54 +0000 | [diff] [blame] | 2544 | if (on_last_col && c != TAB) |
Bram Moolenaar | 0c359af | 2021-11-29 19:18:57 +0000 | [diff] [blame] | 2545 | // Do not continue search/match highlighting over the |
Bram Moolenaar | 0bbca54 | 2022-01-11 13:14:54 +0000 | [diff] [blame] | 2546 | // line break, but for TABs the highlighting should |
| 2547 | // include the complete width of the character |
Bram Moolenaar | 0c359af | 2021-11-29 19:18:57 +0000 | [diff] [blame] | 2548 | search_attr = 0; |
Bram Moolenaar | a06e345 | 2021-05-29 17:56:37 +0200 | [diff] [blame] | 2549 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2550 | if (c == TAB && wlv.n_extra + wlv.col > wp->w_width) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2551 | # ifdef FEAT_VARTABS |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2552 | wlv.n_extra = tabstop_padding(wlv.vcol, |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2553 | wp->w_buffer->b_p_ts, |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2554 | wp->w_buffer->b_p_vts_array) - 1; |
| 2555 | # else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2556 | wlv.n_extra = (int)wp->w_buffer->b_p_ts |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2557 | - wlv.vcol % (int)wp->w_buffer->b_p_ts - 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2558 | # endif |
| 2559 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2560 | wlv.c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' '; |
| 2561 | wlv.c_final = NUL; |
Bram Moolenaar | 52de3a8 | 2022-08-10 13:12:03 +0100 | [diff] [blame] | 2562 | # ifdef FEAT_PROP_POPUP |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2563 | if (wlv.n_extra > 0 && c != TAB) |
Bram Moolenaar | 6b839ac | 2021-11-29 21:12:35 +0000 | [diff] [blame] | 2564 | in_linebreak = TRUE; |
Bram Moolenaar | 3569c0d | 2021-12-02 11:34:21 +0000 | [diff] [blame] | 2565 | # endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2566 | if (VIM_ISWHITE(c)) |
| 2567 | { |
Bram Moolenaar | 912bc4a | 2019-12-01 18:58:11 +0100 | [diff] [blame] | 2568 | # ifdef FEAT_CONCEAL |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2569 | if (c == TAB) |
| 2570 | // See "Tab alignment" below. |
| 2571 | FIX_FOR_BOGUSCOLS; |
Bram Moolenaar | 912bc4a | 2019-12-01 18:58:11 +0100 | [diff] [blame] | 2572 | # endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2573 | if (!wp->w_p_list) |
| 2574 | c = ' '; |
| 2575 | } |
| 2576 | } |
| 2577 | #endif |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 2578 | in_multispace = c == ' ' |
| 2579 | && ((ptr > line + 1 && ptr[-2] == ' ') || *ptr == ' '); |
| 2580 | if (!in_multispace) |
| 2581 | multispace_pos = 0; |
| 2582 | |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2583 | // 'list': Change char 160 to 'nbsp' and space to 'space' |
| 2584 | // setting in 'listchars'. But not when the character is |
| 2585 | // followed by a composing character (use mb_l to check that). |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2586 | if (wp->w_p_list |
| 2587 | && ((((c == 160 && mb_l == 1) |
| 2588 | || (mb_utf8 |
| 2589 | && ((mb_c == 160 && mb_l == 2) |
| 2590 | || (mb_c == 0x202f && mb_l == 3)))) |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2591 | && wp->w_lcs_chars.nbsp) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2592 | || (c == ' ' |
| 2593 | && mb_l == 1 |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 2594 | && (wp->w_lcs_chars.space |
| 2595 | || (in_multispace |
| 2596 | && wp->w_lcs_chars.multispace != NULL)) |
Bram Moolenaar | 91478ae | 2021-02-03 15:58:13 +0100 | [diff] [blame] | 2597 | && ptr - line >= leadcol |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2598 | && ptr - line <= trailcol))) |
| 2599 | { |
zeertzjq | f14b8ba | 2021-09-10 16:58:30 +0200 | [diff] [blame] | 2600 | if (in_multispace && wp->w_lcs_chars.multispace != NULL) |
| 2601 | { |
| 2602 | c = wp->w_lcs_chars.multispace[multispace_pos++]; |
| 2603 | if (wp->w_lcs_chars.multispace[multispace_pos] == NUL) |
| 2604 | multispace_pos = 0; |
| 2605 | } |
| 2606 | else |
| 2607 | c = (c == ' ') ? wp->w_lcs_chars.space |
| 2608 | : wp->w_lcs_chars.nbsp; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2609 | if (area_attr == 0 && search_attr == 0) |
| 2610 | { |
| 2611 | n_attr = 1; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2612 | extra_attr = hl_combine_attr(wlv.win_attr, |
| 2613 | HL_ATTR(HLF_8)); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2614 | saved_attr2 = wlv.char_attr; // save current attr |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2615 | } |
| 2616 | mb_c = c; |
| 2617 | if (enc_utf8 && utf_char2len(c) > 1) |
| 2618 | { |
| 2619 | mb_utf8 = TRUE; |
| 2620 | u8cc[0] = 0; |
| 2621 | c = 0xc0; |
| 2622 | } |
| 2623 | else |
| 2624 | mb_utf8 = FALSE; |
| 2625 | } |
| 2626 | |
zeertzjq | 2e7cba3 | 2022-06-10 15:30:32 +0100 | [diff] [blame] | 2627 | if (c == ' ' && ((trailcol != MAXCOL && ptr > line + trailcol) |
| 2628 | || (leadcol != 0 && ptr < line + leadcol))) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2629 | { |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 2630 | if (leadcol != 0 && in_multispace && ptr < line + leadcol |
| 2631 | && wp->w_lcs_chars.leadmultispace != NULL) |
| 2632 | { |
| 2633 | c = wp->w_lcs_chars.leadmultispace[multispace_pos++]; |
zeertzjq | 2e7cba3 | 2022-06-10 15:30:32 +0100 | [diff] [blame] | 2634 | if (wp->w_lcs_chars.leadmultispace[multispace_pos] |
| 2635 | == NUL) |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 2636 | multispace_pos = 0; |
| 2637 | } |
| 2638 | |
| 2639 | else if (ptr > line + trailcol && wp->w_lcs_chars.trail) |
| 2640 | c = wp->w_lcs_chars.trail; |
| 2641 | |
| 2642 | else if (ptr < line + leadcol && wp->w_lcs_chars.lead) |
| 2643 | c = wp->w_lcs_chars.lead; |
| 2644 | |
zeertzjq | 2e7cba3 | 2022-06-10 15:30:32 +0100 | [diff] [blame] | 2645 | else if (leadcol != 0 && wp->w_lcs_chars.space) |
Bram Moolenaar | aca12fd | 2022-06-07 10:16:15 +0100 | [diff] [blame] | 2646 | c = wp->w_lcs_chars.space; |
| 2647 | |
| 2648 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2649 | if (!attr_pri) |
| 2650 | { |
| 2651 | n_attr = 1; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2652 | extra_attr = hl_combine_attr(wlv.win_attr, |
| 2653 | HL_ATTR(HLF_8)); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2654 | saved_attr2 = wlv.char_attr; // save current attr |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2655 | } |
| 2656 | mb_c = c; |
| 2657 | if (enc_utf8 && utf_char2len(c) > 1) |
| 2658 | { |
| 2659 | mb_utf8 = TRUE; |
| 2660 | u8cc[0] = 0; |
| 2661 | c = 0xc0; |
| 2662 | } |
| 2663 | else |
| 2664 | mb_utf8 = FALSE; |
| 2665 | } |
| 2666 | } |
| 2667 | |
| 2668 | // Handling of non-printable characters. |
| 2669 | if (!vim_isprintc(c)) |
| 2670 | { |
| 2671 | // when getting a character from the file, we may have to |
| 2672 | // turn it into something else on the way to putting it |
| 2673 | // into "ScreenLines". |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2674 | if (c == TAB && (!wp->w_p_list || wp->w_lcs_chars.tab1)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2675 | { |
| 2676 | int tab_len = 0; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2677 | long vcol_adjusted = wlv.vcol; // removed showbreak length |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2678 | #ifdef FEAT_LINEBREAK |
Bram Moolenaar | ee85702 | 2019-11-09 23:26:40 +0100 | [diff] [blame] | 2679 | char_u *sbr = get_showbreak_value(wp); |
| 2680 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2681 | // only adjust the tab_len, when at the first column |
| 2682 | // after the showbreak value was drawn |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2683 | if (*sbr != NUL && wlv.vcol == vcol_sbr && wp->w_p_wrap) |
| 2684 | vcol_adjusted = wlv.vcol - MB_CHARLEN(sbr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2685 | #endif |
| 2686 | // tab amount depends on current column |
| 2687 | #ifdef FEAT_VARTABS |
| 2688 | tab_len = tabstop_padding(vcol_adjusted, |
| 2689 | wp->w_buffer->b_p_ts, |
| 2690 | wp->w_buffer->b_p_vts_array) - 1; |
| 2691 | #else |
| 2692 | tab_len = (int)wp->w_buffer->b_p_ts |
| 2693 | - vcol_adjusted % (int)wp->w_buffer->b_p_ts - 1; |
| 2694 | #endif |
| 2695 | |
| 2696 | #ifdef FEAT_LINEBREAK |
| 2697 | if (!wp->w_p_lbr || !wp->w_p_list) |
| 2698 | #endif |
| 2699 | // tab amount depends on current column |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2700 | wlv.n_extra = tab_len; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2701 | #ifdef FEAT_LINEBREAK |
| 2702 | else |
| 2703 | { |
| 2704 | char_u *p; |
| 2705 | int len; |
| 2706 | int i; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2707 | int saved_nextra = wlv.n_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2708 | |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2709 | # ifdef FEAT_CONCEAL |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2710 | if (wlv.vcol_off > 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2711 | // there are characters to conceal |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2712 | tab_len += wlv.vcol_off; |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2713 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2714 | // boguscols before FIX_FOR_BOGUSCOLS macro from above |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2715 | if (wp->w_p_list && wp->w_lcs_chars.tab1 |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2716 | && old_boguscols > 0 |
| 2717 | && wlv.n_extra > tab_len) |
| 2718 | tab_len += wlv.n_extra - tab_len; |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2719 | # endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2720 | // If wlv.n_extra > 0, it gives the number of chars, to |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2721 | // use for a tab, else we need to calculate the width |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2722 | // for a tab. |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2723 | len = (tab_len * mb_char2len(wp->w_lcs_chars.tab2)); |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2724 | if (wp->w_lcs_chars.tab3) |
| 2725 | len += mb_char2len(wp->w_lcs_chars.tab3); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2726 | if (wlv.n_extra > 0) |
| 2727 | len += wlv.n_extra - tab_len; |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2728 | c = wp->w_lcs_chars.tab1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2729 | p = alloc(len + 1); |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2730 | if (p == NULL) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2731 | wlv.n_extra = 0; |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2732 | else |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2733 | { |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2734 | vim_memset(p, ' ', len); |
| 2735 | p[len] = NUL; |
| 2736 | vim_free(p_extra_free); |
| 2737 | p_extra_free = p; |
| 2738 | for (i = 0; i < tab_len; i++) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2739 | { |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2740 | int lcs = wp->w_lcs_chars.tab2; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2741 | |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2742 | if (*p == NUL) |
| 2743 | { |
| 2744 | tab_len = i; |
| 2745 | break; |
| 2746 | } |
| 2747 | |
| 2748 | // if tab3 is given, use it for the last char |
| 2749 | if (wp->w_lcs_chars.tab3 && i == tab_len - 1) |
| 2750 | lcs = wp->w_lcs_chars.tab3; |
| 2751 | p += mb_char2bytes(lcs, p); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2752 | wlv.n_extra += mb_char2len(lcs) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2753 | - (saved_nextra > 0 ? 1 : 0); |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2754 | } |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2755 | wlv.p_extra = p_extra_free; |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2756 | # ifdef FEAT_CONCEAL |
| 2757 | // n_extra will be increased by FIX_FOX_BOGUSCOLS |
| 2758 | // macro below, so need to adjust for that here |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2759 | if (wlv.vcol_off > 0) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2760 | wlv.n_extra -= wlv.vcol_off; |
Bram Moolenaar | 89a54b4 | 2021-09-07 20:45:31 +0200 | [diff] [blame] | 2761 | # endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2762 | } |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2763 | } |
| 2764 | #endif |
| 2765 | #ifdef FEAT_CONCEAL |
| 2766 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2767 | int vc_saved = wlv.vcol_off; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2768 | |
| 2769 | // Tab alignment should be identical regardless of |
| 2770 | // 'conceallevel' value. So tab compensates of all |
| 2771 | // previous concealed characters, and thus resets |
| 2772 | // vcol_off and boguscols accumulated so far in the |
| 2773 | // line. Note that the tab can be longer than |
| 2774 | // 'tabstop' when there are concealed characters. |
| 2775 | FIX_FOR_BOGUSCOLS; |
| 2776 | |
| 2777 | // Make sure, the highlighting for the tab char will be |
| 2778 | // correctly set further below (effectively reverts the |
Dominique Pelle | af4a61a | 2021-12-27 17:21:41 +0000 | [diff] [blame] | 2779 | // FIX_FOR_BOGSUCOLS macro). |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2780 | if (wlv.n_extra == tab_len + vc_saved && wp->w_p_list |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2781 | && wp->w_lcs_chars.tab1) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2782 | tab_len += vc_saved; |
| 2783 | } |
| 2784 | #endif |
| 2785 | mb_utf8 = FALSE; // don't draw as UTF-8 |
| 2786 | if (wp->w_p_list) |
| 2787 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2788 | c = (wlv.n_extra == 0 && wp->w_lcs_chars.tab3) |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2789 | ? wp->w_lcs_chars.tab3 |
| 2790 | : wp->w_lcs_chars.tab1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2791 | #ifdef FEAT_LINEBREAK |
| 2792 | if (wp->w_p_lbr) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2793 | wlv.c_extra = NUL; // using p_extra from above |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2794 | else |
| 2795 | #endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2796 | wlv.c_extra = wp->w_lcs_chars.tab2; |
| 2797 | wlv.c_final = wp->w_lcs_chars.tab3; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2798 | n_attr = tab_len + 1; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2799 | extra_attr = hl_combine_attr(wlv.win_attr, |
| 2800 | HL_ATTR(HLF_8)); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2801 | saved_attr2 = wlv.char_attr; // save current attr |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2802 | mb_c = c; |
| 2803 | if (enc_utf8 && utf_char2len(c) > 1) |
| 2804 | { |
| 2805 | mb_utf8 = TRUE; |
| 2806 | u8cc[0] = 0; |
| 2807 | c = 0xc0; |
| 2808 | } |
| 2809 | } |
| 2810 | else |
| 2811 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2812 | wlv.c_final = NUL; |
| 2813 | wlv.c_extra = ' '; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2814 | c = ' '; |
| 2815 | } |
| 2816 | } |
| 2817 | else if (c == NUL |
| 2818 | && (wp->w_p_list |
| 2819 | || ((fromcol >= 0 || fromcol_prev >= 0) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2820 | && tocol > wlv.vcol |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2821 | && VIsual_mode != Ctrl_V |
| 2822 | && ( |
| 2823 | # ifdef FEAT_RIGHTLEFT |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2824 | wp->w_p_rl ? (wlv.col >= 0) : |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2825 | # endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2826 | (wlv.col < wp->w_width)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2827 | && !(noinvcur |
| 2828 | && lnum == wp->w_cursor.lnum |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2829 | && (colnr_T)wlv.vcol == wp->w_virtcol))) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2830 | && lcs_eol_one > 0) |
| 2831 | { |
| 2832 | // Display a '$' after the line or highlight an extra |
| 2833 | // character if the line break is included. |
| 2834 | #if defined(FEAT_DIFF) || defined(LINE_ATTR) |
| 2835 | // For a diff line the highlighting continues after the |
| 2836 | // "$". |
| 2837 | if ( |
| 2838 | # ifdef FEAT_DIFF |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2839 | wlv.diff_hlf == (hlf_T)0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2840 | # ifdef LINE_ATTR |
| 2841 | && |
| 2842 | # endif |
| 2843 | # endif |
| 2844 | # ifdef LINE_ATTR |
| 2845 | line_attr == 0 |
| 2846 | # endif |
| 2847 | ) |
| 2848 | #endif |
| 2849 | { |
| 2850 | // In virtualedit, visual selections may extend |
| 2851 | // beyond end of line. |
Bram Moolenaar | c3a483f | 2022-08-14 19:37:36 +0100 | [diff] [blame] | 2852 | if (!(area_highlighting && virtual_active() |
| 2853 | && tocol != MAXCOL && wlv.vcol < tocol)) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2854 | wlv.p_extra = at_end_str; |
Bram Moolenaar | c3a483f | 2022-08-14 19:37:36 +0100 | [diff] [blame] | 2855 | wlv.n_extra = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2856 | } |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2857 | if (wp->w_p_list && wp->w_lcs_chars.eol > 0) |
| 2858 | c = wp->w_lcs_chars.eol; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2859 | else |
| 2860 | c = ' '; |
| 2861 | lcs_eol_one = -1; |
| 2862 | --ptr; // put it back at the NUL |
| 2863 | if (!attr_pri) |
| 2864 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2865 | extra_attr = hl_combine_attr(wlv.win_attr, |
| 2866 | HL_ATTR(HLF_AT)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2867 | n_attr = 1; |
| 2868 | } |
| 2869 | mb_c = c; |
| 2870 | if (enc_utf8 && utf_char2len(c) > 1) |
| 2871 | { |
| 2872 | mb_utf8 = TRUE; |
| 2873 | u8cc[0] = 0; |
| 2874 | c = 0xc0; |
| 2875 | } |
| 2876 | else |
| 2877 | mb_utf8 = FALSE; // don't draw as UTF-8 |
| 2878 | } |
| 2879 | else if (c != NUL) |
| 2880 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2881 | wlv.p_extra = transchar_buf(wp->w_buffer, c); |
| 2882 | if (wlv.n_extra == 0) |
| 2883 | wlv.n_extra = byte2cells(c) - 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2884 | #ifdef FEAT_RIGHTLEFT |
| 2885 | if ((dy_flags & DY_UHEX) && wp->w_p_rl) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2886 | rl_mirror(wlv.p_extra); // reverse "<12>" |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2887 | #endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2888 | wlv.c_extra = NUL; |
| 2889 | wlv.c_final = NUL; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2890 | #ifdef FEAT_LINEBREAK |
| 2891 | if (wp->w_p_lbr) |
| 2892 | { |
| 2893 | char_u *p; |
| 2894 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2895 | c = *wlv.p_extra; |
| 2896 | p = alloc(wlv.n_extra + 1); |
| 2897 | vim_memset(p, ' ', wlv.n_extra); |
| 2898 | STRNCPY(p, wlv.p_extra + 1, STRLEN(wlv.p_extra) - 1); |
| 2899 | p[wlv.n_extra] = NUL; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2900 | vim_free(p_extra_free); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2901 | p_extra_free = wlv.p_extra = p; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2902 | } |
| 2903 | else |
| 2904 | #endif |
| 2905 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2906 | wlv.n_extra = byte2cells(c) - 1; |
| 2907 | c = *wlv.p_extra++; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2908 | } |
| 2909 | if (!attr_pri) |
| 2910 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2911 | n_attr = wlv.n_extra + 1; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2912 | extra_attr = hl_combine_attr(wlv.win_attr, |
| 2913 | HL_ATTR(HLF_8)); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2914 | saved_attr2 = wlv.char_attr; // save current attr |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2915 | } |
| 2916 | mb_utf8 = FALSE; // don't draw as UTF-8 |
| 2917 | } |
| 2918 | else if (VIsual_active |
| 2919 | && (VIsual_mode == Ctrl_V |
| 2920 | || VIsual_mode == 'v') |
| 2921 | && virtual_active() |
| 2922 | && tocol != MAXCOL |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2923 | && wlv.vcol < tocol |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2924 | && ( |
| 2925 | #ifdef FEAT_RIGHTLEFT |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2926 | wp->w_p_rl ? (wlv.col >= 0) : |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2927 | #endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2928 | (wlv.col < wp->w_width))) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2929 | { |
| 2930 | c = ' '; |
| 2931 | --ptr; // put it back at the NUL |
| 2932 | } |
| 2933 | #if defined(LINE_ATTR) |
| 2934 | else if (( |
| 2935 | # ifdef FEAT_DIFF |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2936 | wlv.diff_hlf != (hlf_T)0 || |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2937 | # endif |
| 2938 | # ifdef FEAT_TERMINAL |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2939 | wlv.win_attr != 0 || |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2940 | # endif |
| 2941 | line_attr != 0 |
| 2942 | ) && ( |
| 2943 | # ifdef FEAT_RIGHTLEFT |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2944 | wp->w_p_rl ? (wlv.col >= 0) : |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2945 | # endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2946 | (wlv.col |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2947 | # ifdef FEAT_CONCEAL |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2948 | - wlv.boguscols |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2949 | # endif |
| 2950 | < wp->w_width))) |
| 2951 | { |
| 2952 | // Highlight until the right side of the window |
| 2953 | c = ' '; |
| 2954 | --ptr; // put it back at the NUL |
| 2955 | |
| 2956 | // Remember we do the char for line highlighting. |
| 2957 | ++did_line_attr; |
| 2958 | |
| 2959 | // don't do search HL for the rest of the line |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2960 | if (line_attr != 0 && wlv.char_attr == search_attr |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2961 | && (did_line_attr > 1 |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 2962 | || (wp->w_p_list && |
| 2963 | wp->w_lcs_chars.eol > 0))) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2964 | wlv.char_attr = line_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2965 | # ifdef FEAT_DIFF |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2966 | if (wlv.diff_hlf == HLF_TXD) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2967 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2968 | wlv.diff_hlf = HLF_CHD; |
| 2969 | if (vi_attr == 0 || wlv.char_attr != vi_attr) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2970 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2971 | wlv.char_attr = HL_ATTR(wlv.diff_hlf); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2972 | if (wp->w_p_cul && lnum == wp->w_cursor.lnum |
| 2973 | && wp->w_p_culopt_flags != CULOPT_NBR |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2974 | && (!wlv.cul_screenline |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2975 | || (wlv.vcol >= left_curline_col |
| 2976 | && wlv.vcol <= right_curline_col))) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2977 | wlv.char_attr = hl_combine_attr( |
| 2978 | wlv.char_attr, HL_ATTR(HLF_CUL)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2979 | } |
| 2980 | } |
| 2981 | # endif |
| 2982 | # ifdef FEAT_TERMINAL |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2983 | if (wlv.win_attr != 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2984 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2985 | wlv.char_attr = wlv.win_attr; |
Bram Moolenaar | a381773 | 2019-10-16 16:31:44 +0200 | [diff] [blame] | 2986 | if (wp->w_p_cul && lnum == wp->w_cursor.lnum |
| 2987 | && wp->w_p_culopt_flags != CULOPT_NBR) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2988 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2989 | if (!wlv.cul_screenline |
| 2990 | || (wlv.vcol >= left_curline_col |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 2991 | && wlv.vcol <= right_curline_col)) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2992 | wlv.char_attr = hl_combine_attr( |
| 2993 | wlv.char_attr, HL_ATTR(HLF_CUL)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2994 | } |
| 2995 | else if (line_attr) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 2996 | wlv.char_attr = hl_combine_attr(wlv.char_attr, |
| 2997 | line_attr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 2998 | } |
| 2999 | # endif |
| 3000 | } |
| 3001 | #endif |
| 3002 | } |
| 3003 | |
| 3004 | #ifdef FEAT_CONCEAL |
| 3005 | if ( wp->w_p_cole > 0 |
LemonBoy | 9830db6 | 2022-05-08 21:25:20 +0100 | [diff] [blame] | 3006 | && (wp != curwin || lnum != wp->w_cursor.lnum |
| 3007 | || conceal_cursor_line(wp)) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3008 | && ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0) |
| 3009 | && !(lnum_in_visual_area |
| 3010 | && vim_strchr(wp->w_p_cocu, 'v') == NULL)) |
| 3011 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3012 | wlv.char_attr = conceal_attr; |
LemonBoy | 9830db6 | 2022-05-08 21:25:20 +0100 | [diff] [blame] | 3013 | if (((prev_syntax_id != syntax_seqnr |
| 3014 | && (syntax_flags & HL_CONCEAL) != 0) |
| 3015 | || has_match_conc > 1) |
Bram Moolenaar | 211dd3f | 2020-06-25 20:07:04 +0200 | [diff] [blame] | 3016 | && (syn_get_sub_char() != NUL |
| 3017 | || (has_match_conc && match_conc) |
| 3018 | || wp->w_p_cole == 1) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3019 | && wp->w_p_cole != 3) |
| 3020 | { |
| 3021 | // First time at this concealed item: display one |
| 3022 | // character. |
Bram Moolenaar | 211dd3f | 2020-06-25 20:07:04 +0200 | [diff] [blame] | 3023 | if (has_match_conc && match_conc) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3024 | c = match_conc; |
| 3025 | else if (syn_get_sub_char() != NUL) |
| 3026 | c = syn_get_sub_char(); |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 3027 | else if (wp->w_lcs_chars.conceal != NUL) |
| 3028 | c = wp->w_lcs_chars.conceal; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3029 | else |
| 3030 | c = ' '; |
| 3031 | |
| 3032 | prev_syntax_id = syntax_seqnr; |
| 3033 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3034 | if (wlv.n_extra > 0) |
| 3035 | wlv.vcol_off += wlv.n_extra; |
| 3036 | wlv.vcol += wlv.n_extra; |
| 3037 | if (wp->w_p_wrap && wlv.n_extra > 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3038 | { |
| 3039 | # ifdef FEAT_RIGHTLEFT |
| 3040 | if (wp->w_p_rl) |
| 3041 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3042 | wlv.col -= wlv.n_extra; |
| 3043 | wlv.boguscols -= wlv.n_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3044 | } |
| 3045 | else |
| 3046 | # endif |
| 3047 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3048 | wlv.boguscols += wlv.n_extra; |
| 3049 | wlv.col += wlv.n_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3050 | } |
| 3051 | } |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3052 | wlv.n_extra = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3053 | n_attr = 0; |
| 3054 | } |
| 3055 | else if (n_skip == 0) |
| 3056 | { |
| 3057 | is_concealing = TRUE; |
| 3058 | n_skip = 1; |
| 3059 | } |
| 3060 | mb_c = c; |
| 3061 | if (enc_utf8 && utf_char2len(c) > 1) |
| 3062 | { |
| 3063 | mb_utf8 = TRUE; |
| 3064 | u8cc[0] = 0; |
| 3065 | c = 0xc0; |
| 3066 | } |
| 3067 | else |
| 3068 | mb_utf8 = FALSE; // don't draw as UTF-8 |
| 3069 | } |
| 3070 | else |
| 3071 | { |
| 3072 | prev_syntax_id = 0; |
| 3073 | is_concealing = FALSE; |
| 3074 | } |
| 3075 | |
| 3076 | if (n_skip > 0 && did_decrement_ptr) |
| 3077 | // not showing the '>', put pointer back to avoid getting stuck |
| 3078 | ++ptr; |
| 3079 | |
| 3080 | #endif // FEAT_CONCEAL |
| 3081 | } |
| 3082 | |
| 3083 | #ifdef FEAT_CONCEAL |
| 3084 | // In the cursor line and we may be concealing characters: correct |
| 3085 | // the cursor column when we reach its position. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3086 | if (!did_wcol && wlv.draw_state == WL_LINE |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3087 | && wp == curwin && lnum == wp->w_cursor.lnum |
| 3088 | && conceal_cursor_line(wp) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3089 | && (int)wp->w_virtcol <= wlv.vcol + n_skip) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3090 | { |
Bram Moolenaar | 1efefda | 2020-11-17 19:22:06 +0100 | [diff] [blame] | 3091 | # ifdef FEAT_RIGHTLEFT |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3092 | if (wp->w_p_rl) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3093 | wp->w_wcol = wp->w_width - wlv.col + wlv.boguscols - 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3094 | else |
Bram Moolenaar | 1efefda | 2020-11-17 19:22:06 +0100 | [diff] [blame] | 3095 | # endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3096 | wp->w_wcol = wlv.col - wlv.boguscols; |
| 3097 | wp->w_wrow = wlv.row; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3098 | did_wcol = TRUE; |
| 3099 | curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL; |
Bram Moolenaar | 1efefda | 2020-11-17 19:22:06 +0100 | [diff] [blame] | 3100 | # ifdef FEAT_PROP_POPUP |
Bram Moolenaar | 6a07644 | 2020-11-15 20:32:58 +0100 | [diff] [blame] | 3101 | curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED); |
Bram Moolenaar | 1efefda | 2020-11-17 19:22:06 +0100 | [diff] [blame] | 3102 | # endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3103 | } |
| 3104 | #endif |
| 3105 | |
Bram Moolenaar | 9e7e28f | 2022-08-14 16:36:38 +0100 | [diff] [blame] | 3106 | // Use "extra_attr", but don't override visual selection highlighting, |
| 3107 | // unless text property overrides. |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 3108 | // Don't use "extra_attr" until n_attr_skip is zero. |
| 3109 | if (n_attr_skip == 0 && n_attr > 0 |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3110 | && wlv.draw_state == WL_LINE |
Bram Moolenaar | 677a39f | 2022-08-14 16:50:42 +0100 | [diff] [blame] | 3111 | && (!attr_pri |
| 3112 | #ifdef FEAT_PROP_POPUP |
| 3113 | || (text_prop_flags & PT_FLAG_OVERRIDE) |
| 3114 | #endif |
| 3115 | )) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3116 | { |
| 3117 | #ifdef LINE_ATTR |
| 3118 | if (line_attr) |
Bram Moolenaar | 9113c2c | 2022-08-13 20:17:34 +0100 | [diff] [blame] | 3119 | wlv.char_attr = hl_combine_attr(line_attr, extra_attr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3120 | else |
| 3121 | #endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3122 | wlv.char_attr = extra_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3123 | } |
| 3124 | |
| 3125 | #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
| 3126 | // XIM don't send preedit_start and preedit_end, but they send |
| 3127 | // preedit_changed and commit. Thus Vim can't set "im_is_active", use |
| 3128 | // im_is_preediting() here. |
| 3129 | if (p_imst == IM_ON_THE_SPOT |
| 3130 | && xic != NULL |
| 3131 | && lnum == wp->w_cursor.lnum |
Bram Moolenaar | 2495910 | 2022-05-07 20:01:16 +0100 | [diff] [blame] | 3132 | && (State & MODE_INSERT) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3133 | && !p_imdisable |
| 3134 | && im_is_preediting() |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3135 | && wlv.draw_state == WL_LINE) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3136 | { |
| 3137 | colnr_T tcol; |
| 3138 | |
| 3139 | if (preedit_end_col == MAXCOL) |
| 3140 | getvcol(curwin, &(wp->w_cursor), &tcol, NULL, NULL); |
| 3141 | else |
| 3142 | tcol = preedit_end_col; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3143 | if ((long)preedit_start_col <= wlv.vcol && wlv.vcol < (long)tcol) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3144 | { |
| 3145 | if (feedback_old_attr < 0) |
| 3146 | { |
| 3147 | feedback_col = 0; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3148 | feedback_old_attr = wlv.char_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3149 | } |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3150 | wlv.char_attr = im_get_feedback_attr(feedback_col); |
| 3151 | if (wlv.char_attr < 0) |
| 3152 | wlv.char_attr = feedback_old_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3153 | feedback_col++; |
| 3154 | } |
| 3155 | else if (feedback_old_attr >= 0) |
| 3156 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3157 | wlv.char_attr = feedback_old_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3158 | feedback_old_attr = -1; |
| 3159 | feedback_col = 0; |
| 3160 | } |
| 3161 | } |
| 3162 | #endif |
| 3163 | // Handle the case where we are in column 0 but not on the first |
| 3164 | // character of the line and the user wants us to show us a |
| 3165 | // special character (via 'listchars' option "precedes:<char>". |
| 3166 | if (lcs_prec_todo != NUL |
| 3167 | && wp->w_p_list |
Bram Moolenaar | bffba7f | 2019-09-20 17:00:17 +0200 | [diff] [blame] | 3168 | && (wp->w_p_wrap ? |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3169 | (wp->w_skipcol > 0 && wlv.row == 0) : |
Bram Moolenaar | bffba7f | 2019-09-20 17:00:17 +0200 | [diff] [blame] | 3170 | wp->w_leftcol > 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3171 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3172 | && wlv.filler_todo <= 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3173 | #endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3174 | && wlv.draw_state > WL_NR |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3175 | && c != NUL) |
| 3176 | { |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 3177 | c = wp->w_lcs_chars.prec; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3178 | lcs_prec_todo = NUL; |
| 3179 | if (has_mbyte && (*mb_char2cells)(mb_c) > 1) |
| 3180 | { |
| 3181 | // Double-width character being overwritten by the "precedes" |
| 3182 | // character, need to fill up half the character. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3183 | wlv.c_extra = MB_FILLER_CHAR; |
| 3184 | wlv.c_final = NUL; |
| 3185 | wlv.n_extra = 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3186 | n_attr = 2; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3187 | extra_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3188 | } |
| 3189 | mb_c = c; |
| 3190 | if (enc_utf8 && utf_char2len(c) > 1) |
| 3191 | { |
| 3192 | mb_utf8 = TRUE; |
| 3193 | u8cc[0] = 0; |
| 3194 | c = 0xc0; |
| 3195 | } |
| 3196 | else |
| 3197 | mb_utf8 = FALSE; // don't draw as UTF-8 |
| 3198 | if (!attr_pri) |
| 3199 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3200 | saved_attr3 = wlv.char_attr; // save current attr |
| 3201 | wlv.char_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3202 | n_attr3 = 1; |
| 3203 | } |
| 3204 | } |
| 3205 | |
| 3206 | // At end of the text line or just after the last character. |
| 3207 | if ((c == NUL |
| 3208 | #if defined(LINE_ATTR) |
| 3209 | || did_line_attr == 1 |
| 3210 | #endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3211 | ) && wlv.eol_hl_off == 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3212 | { |
| 3213 | #ifdef FEAT_SEARCH_EXTRA |
| 3214 | // flag to indicate whether prevcol equals startcol of search_hl or |
| 3215 | // one of the matches |
| 3216 | int prevcol_hl_flag = get_prevcol_hl_flag(wp, &screen_search_hl, |
| 3217 | (long)(ptr - line) - (c == NUL)); |
| 3218 | #endif |
| 3219 | // Invert at least one char, used for Visual and empty line or |
| 3220 | // highlight match at end of line. If it's beyond the last |
| 3221 | // char on the screen, just overwrite that one (tricky!) Not |
| 3222 | // needed when a '$' was displayed for 'list'. |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 3223 | if (wp->w_lcs_chars.eol == lcs_eol_one |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3224 | && ((area_attr != 0 && wlv.vcol == fromcol |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3225 | && (VIsual_mode != Ctrl_V |
| 3226 | || lnum == VIsual.lnum |
| 3227 | || lnum == curwin->w_cursor.lnum) |
| 3228 | && c == NUL) |
| 3229 | #ifdef FEAT_SEARCH_EXTRA |
| 3230 | // highlight 'hlsearch' match at end of line |
| 3231 | || (prevcol_hl_flag |
| 3232 | # ifdef FEAT_SYN_HL |
| 3233 | && !(wp->w_p_cul && lnum == wp->w_cursor.lnum |
| 3234 | && !(wp == curwin && VIsual_active)) |
| 3235 | # endif |
| 3236 | # ifdef FEAT_DIFF |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3237 | && wlv.diff_hlf == (hlf_T)0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3238 | # endif |
| 3239 | # if defined(LINE_ATTR) |
| 3240 | && did_line_attr <= 1 |
| 3241 | # endif |
| 3242 | ) |
| 3243 | #endif |
| 3244 | )) |
| 3245 | { |
| 3246 | int n = 0; |
| 3247 | |
| 3248 | #ifdef FEAT_RIGHTLEFT |
| 3249 | if (wp->w_p_rl) |
| 3250 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3251 | if (wlv.col < 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3252 | n = 1; |
| 3253 | } |
| 3254 | else |
| 3255 | #endif |
| 3256 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3257 | if (wlv.col >= wp->w_width) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3258 | n = -1; |
| 3259 | } |
| 3260 | if (n != 0) |
| 3261 | { |
| 3262 | // At the window boundary, highlight the last character |
| 3263 | // instead (better than nothing). |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3264 | wlv.off += n; |
| 3265 | wlv.col += n; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3266 | } |
| 3267 | else |
| 3268 | { |
| 3269 | // Add a blank character to highlight. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3270 | ScreenLines[wlv.off] = ' '; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3271 | if (enc_utf8) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3272 | ScreenLinesUC[wlv.off] = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3273 | } |
| 3274 | #ifdef FEAT_SEARCH_EXTRA |
| 3275 | if (area_attr == 0) |
| 3276 | { |
| 3277 | // Use attributes from match with highest priority among |
| 3278 | // 'search_hl' and the match list. |
| 3279 | get_search_match_hl(wp, &screen_search_hl, |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3280 | (long)(ptr - line), &wlv.char_attr); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3281 | } |
| 3282 | #endif |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3283 | ScreenAttrs[wlv.off] = wlv.char_attr; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3284 | ScreenCols[wlv.off] = MAXCOL; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3285 | #ifdef FEAT_RIGHTLEFT |
| 3286 | if (wp->w_p_rl) |
| 3287 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3288 | --wlv.col; |
| 3289 | --wlv.off; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3290 | } |
| 3291 | else |
| 3292 | #endif |
| 3293 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3294 | ++wlv.col; |
| 3295 | ++wlv.off; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3296 | } |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3297 | ++wlv.vcol; |
| 3298 | wlv.eol_hl_off = 1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3299 | } |
| 3300 | } |
| 3301 | |
| 3302 | // At end of the text line. |
| 3303 | if (c == NUL) |
| 3304 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3305 | draw_screen_line(wp, &wlv); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3306 | |
| 3307 | // Update w_cline_height and w_cline_folded if the cursor line was |
| 3308 | // updated (saves a call to plines() later). |
| 3309 | if (wp == curwin && lnum == curwin->w_cursor.lnum) |
| 3310 | { |
| 3311 | curwin->w_cline_row = startrow; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3312 | curwin->w_cline_height = wlv.row - startrow; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3313 | #ifdef FEAT_FOLDING |
| 3314 | curwin->w_cline_folded = FALSE; |
| 3315 | #endif |
| 3316 | curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW); |
| 3317 | } |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3318 | break; |
| 3319 | } |
| 3320 | |
| 3321 | // Show "extends" character from 'listchars' if beyond the line end and |
| 3322 | // 'list' is set. |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 3323 | if (wp->w_lcs_chars.ext != NUL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3324 | && wlv.draw_state == WL_LINE |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3325 | && wp->w_p_list |
| 3326 | && !wp->w_p_wrap |
| 3327 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3328 | && wlv.filler_todo <= 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3329 | #endif |
| 3330 | && ( |
| 3331 | #ifdef FEAT_RIGHTLEFT |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3332 | wp->w_p_rl ? wlv.col == 0 : |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3333 | #endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3334 | wlv.col == wp->w_width - 1) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3335 | && (*ptr != NUL |
Bram Moolenaar | c3a483f | 2022-08-14 19:37:36 +0100 | [diff] [blame] | 3336 | || lcs_eol_one > 0 |
| 3337 | || (wlv.n_extra > 0 && (wlv.c_extra != NUL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3338 | || *wlv.p_extra != NUL)))) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3339 | { |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 3340 | c = wp->w_lcs_chars.ext; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3341 | wlv.char_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3342 | mb_c = c; |
| 3343 | if (enc_utf8 && utf_char2len(c) > 1) |
| 3344 | { |
| 3345 | mb_utf8 = TRUE; |
| 3346 | u8cc[0] = 0; |
| 3347 | c = 0xc0; |
| 3348 | } |
| 3349 | else |
| 3350 | mb_utf8 = FALSE; |
| 3351 | } |
| 3352 | |
| 3353 | #ifdef FEAT_SYN_HL |
| 3354 | // advance to the next 'colorcolumn' |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3355 | if (wlv.draw_color_col) |
| 3356 | wlv.draw_color_col = advance_color_col(VCOL_HLC, &wlv.color_cols); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3357 | |
| 3358 | // Highlight the cursor column if 'cursorcolumn' is set. But don't |
| 3359 | // highlight the cursor position itself. |
| 3360 | // Also highlight the 'colorcolumn' if it is different than |
| 3361 | // 'cursorcolumn' |
Bram Moolenaar | ad5e563 | 2020-09-15 20:52:26 +0200 | [diff] [blame] | 3362 | // Also highlight the 'colorcolumn' if 'breakindent' and/or 'showbreak' |
| 3363 | // options are set |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3364 | vcol_save_attr = -1; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3365 | if (((wlv.draw_state == WL_LINE |
| 3366 | || wlv.draw_state == WL_BRI |
| 3367 | || wlv.draw_state == WL_SBR) |
| 3368 | && !lnum_in_visual_area |
| 3369 | && search_attr == 0 |
| 3370 | && area_attr == 0) |
Bram Moolenaar | fabc3ca | 2020-11-05 19:07:21 +0100 | [diff] [blame] | 3371 | # ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3372 | && wlv.filler_todo <= 0 |
Bram Moolenaar | fabc3ca | 2020-11-05 19:07:21 +0100 | [diff] [blame] | 3373 | # endif |
| 3374 | ) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3375 | { |
| 3376 | if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol |
| 3377 | && lnum != wp->w_cursor.lnum) |
| 3378 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3379 | vcol_save_attr = wlv.char_attr; |
| 3380 | wlv.char_attr = hl_combine_attr(wlv.char_attr, |
| 3381 | HL_ATTR(HLF_CUC)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3382 | } |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3383 | else if (wlv.draw_color_col && VCOL_HLC == *wlv.color_cols) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3384 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3385 | vcol_save_attr = wlv.char_attr; |
| 3386 | wlv.char_attr = hl_combine_attr(wlv.char_attr, HL_ATTR(HLF_MC)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3387 | } |
| 3388 | } |
| 3389 | #endif |
| 3390 | |
| 3391 | // Store character to be displayed. |
| 3392 | // Skip characters that are left of the screen for 'nowrap'. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3393 | vcol_prev = wlv.vcol; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3394 | if (wlv.draw_state < WL_LINE || n_skip <= 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3395 | { |
| 3396 | // Store the character. |
| 3397 | #if defined(FEAT_RIGHTLEFT) |
| 3398 | if (has_mbyte && wp->w_p_rl && (*mb_char2cells)(mb_c) > 1) |
| 3399 | { |
Dominique Pelle | af4a61a | 2021-12-27 17:21:41 +0000 | [diff] [blame] | 3400 | // A double-wide character is: put first half in left cell. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3401 | --wlv.off; |
| 3402 | --wlv.col; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3403 | } |
| 3404 | #endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3405 | ScreenLines[wlv.off] = c; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3406 | if (enc_dbcs == DBCS_JPNU) |
| 3407 | { |
| 3408 | if ((mb_c & 0xff00) == 0x8e00) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3409 | ScreenLines[wlv.off] = 0x8e; |
| 3410 | ScreenLines2[wlv.off] = mb_c & 0xff; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3411 | } |
| 3412 | else if (enc_utf8) |
| 3413 | { |
| 3414 | if (mb_utf8) |
| 3415 | { |
| 3416 | int i; |
| 3417 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3418 | ScreenLinesUC[wlv.off] = mb_c; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3419 | if ((c & 0xff) == 0) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3420 | ScreenLines[wlv.off] = 0x80; // avoid storing zero |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3421 | for (i = 0; i < Screen_mco; ++i) |
| 3422 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3423 | ScreenLinesC[i][wlv.off] = u8cc[i]; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3424 | if (u8cc[i] == 0) |
| 3425 | break; |
| 3426 | } |
| 3427 | } |
| 3428 | else |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3429 | ScreenLinesUC[wlv.off] = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3430 | } |
| 3431 | if (multi_attr) |
| 3432 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3433 | ScreenAttrs[wlv.off] = multi_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3434 | multi_attr = 0; |
| 3435 | } |
| 3436 | else |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3437 | ScreenAttrs[wlv.off] = wlv.char_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3438 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3439 | ScreenCols[wlv.off] = (colnr_T)(prev_ptr - line); |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 3440 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3441 | if (has_mbyte && (*mb_char2cells)(mb_c) > 1) |
| 3442 | { |
| 3443 | // Need to fill two screen columns. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3444 | ++wlv.off; |
| 3445 | ++wlv.col; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3446 | if (enc_utf8) |
| 3447 | // UTF-8: Put a 0 in the second screen char. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3448 | ScreenLines[wlv.off] = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3449 | else |
| 3450 | // DBCS: Put second byte in the second screen char. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3451 | ScreenLines[wlv.off] = mb_c & 0xff; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3452 | if (wlv.draw_state > WL_NR |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3453 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3454 | && wlv.filler_todo <= 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3455 | #endif |
| 3456 | ) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3457 | ++wlv.vcol; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3458 | // When "tocol" is halfway a character, set it to the end of |
| 3459 | // the character, otherwise highlighting won't stop. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3460 | if (tocol == wlv.vcol) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3461 | ++tocol; |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 3462 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3463 | ScreenCols[wlv.off] = (colnr_T)(prev_ptr - line); |
Bram Moolenaar | b908188 | 2022-07-09 04:56:24 +0100 | [diff] [blame] | 3464 | |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3465 | #ifdef FEAT_RIGHTLEFT |
| 3466 | if (wp->w_p_rl) |
| 3467 | { |
| 3468 | // now it's time to backup one cell |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3469 | --wlv.off; |
| 3470 | --wlv.col; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3471 | } |
| 3472 | #endif |
| 3473 | } |
| 3474 | #ifdef FEAT_RIGHTLEFT |
| 3475 | if (wp->w_p_rl) |
| 3476 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3477 | --wlv.off; |
| 3478 | --wlv.col; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3479 | } |
| 3480 | else |
| 3481 | #endif |
| 3482 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3483 | ++wlv.off; |
| 3484 | ++wlv.col; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3485 | } |
| 3486 | } |
| 3487 | #ifdef FEAT_CONCEAL |
| 3488 | else if (wp->w_p_cole > 0 && is_concealing) |
| 3489 | { |
| 3490 | --n_skip; |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3491 | ++wlv.vcol_off; |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3492 | if (wlv.n_extra > 0) |
| 3493 | wlv.vcol_off += wlv.n_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3494 | if (wp->w_p_wrap) |
| 3495 | { |
| 3496 | // Special voodoo required if 'wrap' is on. |
| 3497 | // |
| 3498 | // Advance the column indicator to force the line |
| 3499 | // drawing to wrap early. This will make the line |
| 3500 | // take up the same screen space when parts are concealed, |
| 3501 | // so that cursor line computations aren't messed up. |
| 3502 | // |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3503 | // To avoid the fictitious advance of 'wlv.col' causing |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3504 | // trailing junk to be written out of the screen line |
| 3505 | // we are building, 'boguscols' keeps track of the number |
| 3506 | // of bad columns we have advanced. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3507 | if (wlv.n_extra > 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3508 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3509 | wlv.vcol += wlv.n_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3510 | # ifdef FEAT_RIGHTLEFT |
| 3511 | if (wp->w_p_rl) |
| 3512 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3513 | wlv.col -= wlv.n_extra; |
| 3514 | wlv.boguscols -= wlv.n_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3515 | } |
| 3516 | else |
| 3517 | # endif |
| 3518 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3519 | wlv.col += wlv.n_extra; |
| 3520 | wlv.boguscols += wlv.n_extra; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3521 | } |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3522 | wlv.n_extra = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3523 | n_attr = 0; |
| 3524 | } |
| 3525 | |
| 3526 | |
| 3527 | if (has_mbyte && (*mb_char2cells)(mb_c) > 1) |
| 3528 | { |
| 3529 | // Need to fill two screen columns. |
| 3530 | # ifdef FEAT_RIGHTLEFT |
| 3531 | if (wp->w_p_rl) |
| 3532 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3533 | --wlv.boguscols; |
| 3534 | --wlv.col; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3535 | } |
| 3536 | else |
| 3537 | # endif |
| 3538 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3539 | ++wlv.boguscols; |
| 3540 | ++wlv.col; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3541 | } |
| 3542 | } |
| 3543 | |
| 3544 | # ifdef FEAT_RIGHTLEFT |
| 3545 | if (wp->w_p_rl) |
| 3546 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3547 | --wlv.boguscols; |
| 3548 | --wlv.col; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3549 | } |
| 3550 | else |
| 3551 | # endif |
| 3552 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3553 | ++wlv.boguscols; |
| 3554 | ++wlv.col; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3555 | } |
| 3556 | } |
| 3557 | else |
| 3558 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3559 | if (wlv.n_extra > 0) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3560 | { |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3561 | wlv.vcol += wlv.n_extra; |
| 3562 | wlv.n_extra = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3563 | n_attr = 0; |
| 3564 | } |
| 3565 | } |
| 3566 | |
| 3567 | } |
| 3568 | #endif // FEAT_CONCEAL |
| 3569 | else |
| 3570 | --n_skip; |
| 3571 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3572 | // Only advance the "wlv.vcol" when after the 'number' or |
| 3573 | // 'relativenumber' column. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3574 | if (wlv.draw_state > WL_NR |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3575 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3576 | && wlv.filler_todo <= 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3577 | #endif |
| 3578 | ) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3579 | ++wlv.vcol; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3580 | |
| 3581 | #ifdef FEAT_SYN_HL |
| 3582 | if (vcol_save_attr >= 0) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3583 | wlv.char_attr = vcol_save_attr; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3584 | #endif |
| 3585 | |
| 3586 | // restore attributes after "predeces" in 'listchars' |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3587 | if (wlv.draw_state > WL_NR && n_attr3 > 0 && --n_attr3 == 0) |
| 3588 | wlv.char_attr = saved_attr3; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3589 | |
| 3590 | // restore attributes after last 'listchars' or 'number' char |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3591 | if (n_attr > 0 && wlv.draw_state == WL_LINE |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 3592 | && n_attr_skip == 0 && --n_attr == 0) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3593 | wlv.char_attr = saved_attr2; |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 3594 | if (n_attr_skip > 0) |
| 3595 | --n_attr_skip; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3596 | |
| 3597 | // At end of screen line and there is more to come: Display the line |
| 3598 | // so far. If there is no more to display it is caught above. |
| 3599 | if (( |
| 3600 | #ifdef FEAT_RIGHTLEFT |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3601 | wp->w_p_rl ? (wlv.col < 0) : |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3602 | #endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3603 | (wlv.col >= wp->w_width)) |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3604 | && (wlv.draw_state != WL_LINE |
Bram Moolenaar | 41fb723 | 2021-07-08 12:40:05 +0200 | [diff] [blame] | 3605 | || *ptr != NUL |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3606 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3607 | || wlv.filler_todo > 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3608 | #endif |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 3609 | #ifdef FEAT_PROP_POPUP |
Bram Moolenaar | c9dc03f | 2022-09-12 17:51:07 +0100 | [diff] [blame] | 3610 | || text_prop_above || text_prop_follows |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 3611 | #endif |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 3612 | || (wp->w_p_list && wp->w_lcs_chars.eol != NUL |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3613 | && wlv.p_extra != at_end_str) |
| 3614 | || (wlv.n_extra != 0 && (wlv.c_extra != NUL |
| 3615 | || *wlv.p_extra != NUL))) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3616 | ) |
| 3617 | { |
| 3618 | #ifdef FEAT_CONCEAL |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3619 | screen_line(wp, wlv.screen_row, wp->w_wincol, |
| 3620 | wlv.col - wlv.boguscols, |
| 3621 | wp->w_width, wlv.screen_line_flags); |
| 3622 | wlv.boguscols = 0; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3623 | #else |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3624 | screen_line(wp, wlv.screen_row, wp->w_wincol, wlv.col, |
| 3625 | wp->w_width, wlv.screen_line_flags); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3626 | #endif |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3627 | ++wlv.row; |
| 3628 | ++wlv.screen_row; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3629 | |
| 3630 | // When not wrapping and finished diff lines, or when displayed |
| 3631 | // '$' and highlighting until last column, break here. |
| 3632 | if ((!wp->w_p_wrap |
| 3633 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3634 | && wlv.filler_todo <= 0 |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 3635 | #endif |
| 3636 | #ifdef FEAT_PROP_POPUP |
Bram Moolenaar | c9dc03f | 2022-09-12 17:51:07 +0100 | [diff] [blame] | 3637 | && !text_prop_above && !text_prop_follows |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3638 | #endif |
| 3639 | ) || lcs_eol_one == -1) |
| 3640 | break; |
Bram Moolenaar | 48ca24d | 2022-08-06 22:03:20 +0100 | [diff] [blame] | 3641 | #ifdef FEAT_PROP_POPUP |
Bram Moolenaar | c9dc03f | 2022-09-12 17:51:07 +0100 | [diff] [blame] | 3642 | if (!wp->w_p_wrap && text_prop_follows && !text_prop_above) |
Bram Moolenaar | 48ca24d | 2022-08-06 22:03:20 +0100 | [diff] [blame] | 3643 | { |
| 3644 | // do not output more of the line, only the "below" prop |
| 3645 | ptr += STRLEN(ptr); |
| 3646 | # ifdef FEAT_LINEBREAK |
| 3647 | dont_use_showbreak = TRUE; |
| 3648 | # endif |
| 3649 | } |
| 3650 | #endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3651 | |
| 3652 | // When the window is too narrow draw all "@" lines. |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3653 | if (wlv.draw_state != WL_LINE |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3654 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3655 | && wlv.filler_todo <= 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3656 | #endif |
| 3657 | ) |
| 3658 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3659 | win_draw_end(wp, '@', ' ', TRUE, wlv.row, wp->w_height, HLF_AT); |
| 3660 | draw_vsep_win(wp, wlv.row); |
| 3661 | wlv.row = endrow; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3662 | } |
| 3663 | |
| 3664 | // When line got too long for screen break here. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3665 | if (wlv.row == endrow) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3666 | { |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3667 | ++wlv.row; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3668 | break; |
| 3669 | } |
| 3670 | |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3671 | if (screen_cur_row == wlv.screen_row - 1 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3672 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3673 | && wlv.filler_todo <= 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3674 | #endif |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 3675 | #ifdef FEAT_PROP_POPUP |
Bram Moolenaar | c9dc03f | 2022-09-12 17:51:07 +0100 | [diff] [blame] | 3676 | && !text_prop_above && !text_prop_follows |
Bram Moolenaar | b7963df | 2022-07-31 17:12:43 +0100 | [diff] [blame] | 3677 | #endif |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3678 | && wp->w_width == Columns) |
| 3679 | { |
| 3680 | // Remember that the line wraps, used for modeless copy. |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3681 | LineWraps[wlv.screen_row - 1] = TRUE; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3682 | |
| 3683 | // Special trick to make copy/paste of wrapped lines work with |
| 3684 | // xterm/screen: write an extra character beyond the end of |
| 3685 | // the line. This will work with all terminal types |
| 3686 | // (regardless of the xn,am settings). |
| 3687 | // Only do this on a fast tty. |
| 3688 | // Only do this if the cursor is on the current line |
| 3689 | // (something has been written in it). |
| 3690 | // Don't do this for the GUI. |
| 3691 | // Don't do this for double-width characters. |
| 3692 | // Don't do this for a window not at the right screen border. |
| 3693 | if (p_tf |
| 3694 | #ifdef FEAT_GUI |
| 3695 | && !gui.in_use |
| 3696 | #endif |
| 3697 | && !(has_mbyte |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3698 | && ((*mb_off2cells)(LineOffset[wlv.screen_row], |
| 3699 | LineOffset[wlv.screen_row] + screen_Columns) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3700 | == 2 |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3701 | || (*mb_off2cells)( |
| 3702 | LineOffset[wlv.screen_row - 1] |
| 3703 | + (int)Columns - 2, |
| 3704 | LineOffset[wlv.screen_row] |
| 3705 | + screen_Columns) == 2))) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3706 | { |
| 3707 | // First make sure we are at the end of the screen line, |
| 3708 | // then output the same character again to let the |
| 3709 | // terminal know about the wrap. If the terminal doesn't |
| 3710 | // auto-wrap, we overwrite the character. |
| 3711 | if (screen_cur_col != wp->w_width) |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3712 | screen_char(LineOffset[wlv.screen_row - 1] |
| 3713 | + (unsigned)Columns - 1, |
| 3714 | wlv.screen_row - 1, (int)(Columns - 1)); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3715 | |
| 3716 | // When there is a multi-byte character, just output a |
| 3717 | // space to keep it simple. |
| 3718 | if (has_mbyte && MB_BYTE2LEN(ScreenLines[LineOffset[ |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3719 | wlv.screen_row - 1] + (Columns - 1)]) > 1) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3720 | out_char(' '); |
| 3721 | else |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3722 | out_char(ScreenLines[LineOffset[wlv.screen_row - 1] |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3723 | + (Columns - 1)]); |
| 3724 | // force a redraw of the first char on the next line |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3725 | ScreenAttrs[LineOffset[wlv.screen_row]] = (sattr_T)-1; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3726 | screen_start(); // don't know where cursor is now |
| 3727 | } |
| 3728 | } |
| 3729 | |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3730 | win_line_start(wp, &wlv, TRUE); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3731 | |
Bram Moolenaar | eed9d46 | 2021-02-15 20:38:25 +0100 | [diff] [blame] | 3732 | lcs_prec_todo = wp->w_lcs_chars.prec; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3733 | #ifdef FEAT_LINEBREAK |
Bram Moolenaar | 3ec3b8e | 2022-08-05 21:39:30 +0100 | [diff] [blame] | 3734 | if (!dont_use_showbreak |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3735 | # ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3736 | && wlv.filler_todo <= 0 |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3737 | # endif |
Bram Moolenaar | 3ec3b8e | 2022-08-05 21:39:30 +0100 | [diff] [blame] | 3738 | ) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3739 | need_showbreak = TRUE; |
| 3740 | #endif |
| 3741 | #ifdef FEAT_DIFF |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3742 | --wlv.filler_todo; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3743 | // When the filler lines are actually below the last line of the |
| 3744 | // file, don't draw the line itself, break here. |
Bram Moolenaar | d7657e9 | 2022-09-20 18:59:30 +0100 | [diff] [blame] | 3745 | if (wlv.filler_todo == 0 && wp->w_botfill) |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3746 | break; |
| 3747 | #endif |
| 3748 | } |
| 3749 | |
| 3750 | } // for every character in the line |
| 3751 | |
| 3752 | #ifdef FEAT_SPELL |
| 3753 | // After an empty line check first word for capital. |
| 3754 | if (*skipwhite(line) == NUL) |
| 3755 | { |
| 3756 | capcol_lnum = lnum + 1; |
| 3757 | cap_col = 0; |
| 3758 | } |
| 3759 | #endif |
Bram Moolenaar | 05ad5ff | 2019-11-30 22:48:27 +0100 | [diff] [blame] | 3760 | #ifdef FEAT_PROP_POPUP |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3761 | vim_free(text_props); |
| 3762 | vim_free(text_prop_idxs); |
Bram Moolenaar | 1306b36 | 2022-08-06 15:59:06 +0100 | [diff] [blame] | 3763 | vim_free(p_extra_free2); |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3764 | #endif |
| 3765 | |
| 3766 | vim_free(p_extra_free); |
Bram Moolenaar | 4d91d34 | 2022-08-06 13:48:20 +0100 | [diff] [blame] | 3767 | return wlv.row; |
Bram Moolenaar | 7528d1f | 2019-09-19 23:06:20 +0200 | [diff] [blame] | 3768 | } |