Mercurial > vim
comparison src/drawline.c @ 29621:f1ed6f520d09 v9.0.0151
patch 9.0.0151: a "below" aligned text property does not work with 'nowrap'
Commit: https://github.com/vim/vim/commit/4d91d347e65a5621621ea1e3c97dce2c677ed71d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 6 13:48:20 2022 +0100
patch 9.0.0151: a "below" aligned text property does not work with 'nowrap'
Problem: A "below" aligned text property does not work with 'nowrap'.
Solution: Start a new screen line to display the virtual text.
(closes #10851)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 06 Aug 2022 15:00:03 +0200 |
parents | bab343b21da8 |
children | 4ddf25d17cda |
comparison
equal
deleted
inserted
replaced
29620:1e975951ffb7 | 29621:f1ed6f520d09 |
---|---|
247 } | 247 } |
248 return col1 == col2 ? 0 : col1 > col2 ? 1 : -1; | 248 return col1 == col2 ? 0 : col1 > col2 ? 1 : -1; |
249 } | 249 } |
250 #endif | 250 #endif |
251 | 251 |
252 // structure with variables passed between win_line() and other functions | |
253 typedef struct { | |
254 linenr_T lnum; // line number to be drawn | |
255 | |
256 int startrow; // first row in the window to be drawn | |
257 int row; // row in the window, excl w_winrow | |
258 int screen_row; // row on the screen, incl w_winrow | |
259 | |
260 long vcol; // virtual column, before wrapping | |
261 int col; // visual column on screen, after wrapping | |
262 #ifdef FEAT_CONCEAL | |
263 int boguscols; // nonexistent columns added to "col" to force | |
264 // wrapping | |
265 int vcol_off; // offset for concealed characters | |
266 #endif | |
267 #ifdef FEAT_SYN_HL | |
268 int draw_color_col; // highlight colorcolumn | |
269 int *color_cols; // pointer to according columns array | |
270 #endif | |
271 int eol_hl_off; // 1 if highlighted char after EOL | |
272 | |
273 unsigned off; // offset in ScreenLines/ScreenAttrs | |
274 | |
275 int win_attr; // background for the whole window, except | |
276 // margins and "~" lines. | |
277 int screen_line_flags; | |
278 } winlinevars_T; | |
279 | |
280 /* | |
281 * Called when finished with the line: draw the screen line and handle any | |
282 * highlighting until the right of the window. | |
283 */ | |
284 static void | |
285 draw_screen_line(win_T *wp, winlinevars_T *wlv) | |
286 { | |
287 #ifdef FEAT_SYN_HL | |
288 long v; | |
289 | |
290 // Highlight 'cursorcolumn' & 'colorcolumn' past end of the line. | |
291 if (wp->w_p_wrap) | |
292 v = wp->w_skipcol; | |
293 else | |
294 v = wp->w_leftcol; | |
295 | |
296 // check if line ends before left margin | |
297 if (wlv->vcol < v + wlv->col - win_col_off(wp)) | |
298 wlv->vcol = v + wlv->col - win_col_off(wp); | |
299 # ifdef FEAT_CONCEAL | |
300 // Get rid of the boguscols now, we want to draw until the right | |
301 // edge for 'cursorcolumn'. | |
302 wlv->col -= wlv->boguscols; | |
303 wlv->boguscols = 0; | |
304 # define VCOL_HLC (wlv->vcol - wlv->vcol_off) | |
305 # else | |
306 # define VCOL_HLC (wlv->vcol) | |
307 # endif | |
308 | |
309 if (wlv->draw_color_col) | |
310 wlv->draw_color_col = advance_color_col(VCOL_HLC, &wlv->color_cols); | |
311 | |
312 if (((wp->w_p_cuc | |
313 && (int)wp->w_virtcol >= VCOL_HLC - wlv->eol_hl_off | |
314 && (int)wp->w_virtcol < | |
315 (long)wp->w_width * (wlv->row - wlv->startrow + 1) + v | |
316 && wlv->lnum != wp->w_cursor.lnum) | |
317 || wlv->draw_color_col | |
318 || wlv->win_attr != 0) | |
319 # ifdef FEAT_RIGHTLEFT | |
320 && !wp->w_p_rl | |
321 # endif | |
322 ) | |
323 { | |
324 int rightmost_vcol = 0; | |
325 int i; | |
326 | |
327 if (wp->w_p_cuc) | |
328 rightmost_vcol = wp->w_virtcol; | |
329 if (wlv->draw_color_col) | |
330 // determine rightmost colorcolumn to possibly draw | |
331 for (i = 0; wlv->color_cols[i] >= 0; ++i) | |
332 if (rightmost_vcol < wlv->color_cols[i]) | |
333 rightmost_vcol = wlv->color_cols[i]; | |
334 | |
335 while (wlv->col < wp->w_width) | |
336 { | |
337 ScreenLines[wlv->off] = ' '; | |
338 if (enc_utf8) | |
339 ScreenLinesUC[wlv->off] = 0; | |
340 ScreenCols[wlv->off] = MAXCOL; | |
341 ++wlv->col; | |
342 if (wlv->draw_color_col) | |
343 wlv->draw_color_col = advance_color_col( | |
344 VCOL_HLC, &wlv->color_cols); | |
345 | |
346 if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol) | |
347 ScreenAttrs[wlv->off++] = HL_ATTR(HLF_CUC); | |
348 else if (wlv->draw_color_col && VCOL_HLC == *wlv->color_cols) | |
349 ScreenAttrs[wlv->off++] = HL_ATTR(HLF_MC); | |
350 else | |
351 ScreenAttrs[wlv->off++] = wlv->win_attr; | |
352 | |
353 if (VCOL_HLC >= rightmost_vcol && wlv->win_attr == 0) | |
354 break; | |
355 | |
356 ++wlv->vcol; | |
357 } | |
358 } | |
359 #endif | |
360 | |
361 screen_line(wp, wlv->screen_row, wp->w_wincol, wlv->col, | |
362 wp->w_width, wlv->screen_line_flags); | |
363 ++wlv->row; | |
364 ++wlv->screen_row; | |
365 } | |
366 #undef VCOL_HLC | |
367 | |
368 /* | |
369 * Start a screen line at column zero. | |
370 */ | |
371 static void | |
372 win_line_start(win_T *wp, winlinevars_T *wlv) | |
373 { | |
374 wlv->col = 0; | |
375 wlv->off = (unsigned)(current_ScreenLine - ScreenLines); | |
376 | |
377 #ifdef FEAT_RIGHTLEFT | |
378 if (wp->w_p_rl) | |
379 { | |
380 // Rightleft window: process the text in the normal direction, but put | |
381 // it in current_ScreenLine[] from right to left. Start at the | |
382 // rightmost column of the window. | |
383 wlv->col = wp->w_width - 1; | |
384 wlv->off += wlv->col; | |
385 wlv->screen_line_flags |= SLF_RIGHTLEFT; | |
386 } | |
387 #endif | |
388 } | |
389 | |
252 /* | 390 /* |
253 * Display line "lnum" of window 'wp' on the screen. | 391 * Display line "lnum" of window 'wp' on the screen. |
254 * Start at row "startrow", stop when "endrow" is reached. | 392 * Start at row "startrow", stop when "endrow" is reached. |
255 * wp->w_virtcol needs to be valid. | 393 * wp->w_virtcol needs to be valid. |
256 * | 394 * |
263 int startrow, | 401 int startrow, |
264 int endrow, | 402 int endrow, |
265 int nochange UNUSED, // not updating for changed text | 403 int nochange UNUSED, // not updating for changed text |
266 int number_only) // only update the number column | 404 int number_only) // only update the number column |
267 { | 405 { |
268 int col = 0; // visual column on screen | 406 winlinevars_T wlv; // variables passed between functions |
269 unsigned off; // offset in ScreenLines/ScreenAttrs | 407 |
270 int c = 0; // init for GCC | 408 int c = 0; // init for GCC |
271 long vcol = 0; // virtual column (for tabs) | |
272 #ifdef FEAT_LINEBREAK | 409 #ifdef FEAT_LINEBREAK |
273 long vcol_sbr = -1; // virtual column after showbreak | 410 long vcol_sbr = -1; // virtual column after showbreak |
274 #endif | 411 #endif |
275 long vcol_prev = -1; // "vcol" of previous character | 412 long vcol_prev = -1; // "wlv.vcol" of previous character |
276 char_u *line; // current line | 413 char_u *line; // current line |
277 char_u *ptr; // current position in "line" | 414 char_u *ptr; // current position in "line" |
278 int row; // row in the window, excl w_winrow | |
279 int screen_row; // row on the screen, incl w_winrow | |
280 | 415 |
281 char_u extra[21]; // "%ld " and 'fdc' must fit in here | 416 char_u extra[21]; // "%ld " and 'fdc' must fit in here |
282 int n_extra = 0; // number of extra bytes | 417 int n_extra = 0; // number of extra bytes |
283 char_u *p_extra = NULL; // string of extra chars, plus NUL | 418 char_u *p_extra = NULL; // string of extra chars, plus NUL |
284 char_u *p_extra_free = NULL; // p_extra needs to be freed | 419 char_u *p_extra_free = NULL; // p_extra needs to be freed |
322 int area_highlighting = FALSE; // Visual or incsearch highlighting | 457 int area_highlighting = FALSE; // Visual or incsearch highlighting |
323 // in this line | 458 // in this line |
324 int vi_attr = 0; // attributes for Visual and incsearch | 459 int vi_attr = 0; // attributes for Visual and incsearch |
325 // highlighting | 460 // highlighting |
326 int wcr_attr = 0; // attributes from 'wincolor' | 461 int wcr_attr = 0; // attributes from 'wincolor' |
327 int win_attr = 0; // background for whole window, except | |
328 // margins and "~" lines. | |
329 int area_attr = 0; // attributes desired by highlighting | 462 int area_attr = 0; // attributes desired by highlighting |
330 int search_attr = 0; // attributes desired by 'hlsearch' | 463 int search_attr = 0; // attributes desired by 'hlsearch' |
331 #ifdef FEAT_SYN_HL | 464 #ifdef FEAT_SYN_HL |
332 int vcol_save_attr = 0; // saved attr for 'cursorcolumn' | 465 int vcol_save_attr = 0; // saved attr for 'cursorcolumn' |
333 int syntax_attr = 0; // attributes desired by syntax | 466 int syntax_attr = 0; // attributes desired by syntax |
334 int prev_syntax_col = -1; // column of prev_syntax_attr | 467 int prev_syntax_col = -1; // column of prev_syntax_attr |
335 int prev_syntax_attr = 0; // syntax_attr at prev_syntax_col | 468 int prev_syntax_attr = 0; // syntax_attr at prev_syntax_col |
336 int has_syntax = FALSE; // this buffer has syntax highl. | 469 int has_syntax = FALSE; // this buffer has syntax highl. |
337 int save_did_emsg; | 470 int save_did_emsg; |
338 int draw_color_col = FALSE; // highlight colorcolumn | 471 #endif |
339 int *color_cols = NULL; // pointer to according columns array | |
340 #endif | |
341 int eol_hl_off = 0; // 1 if highlighted char after EOL | |
342 #ifdef FEAT_PROP_POPUP | 472 #ifdef FEAT_PROP_POPUP |
343 int text_prop_count; | 473 int text_prop_count; |
344 int text_prop_next = 0; // next text property to use | 474 int text_prop_next = 0; // next text property to use |
345 textprop_T *text_props = NULL; | 475 textprop_T *text_props = NULL; |
346 int *text_prop_idxs = NULL; | 476 int *text_prop_idxs = NULL; |
459 int draw_state = WL_START; // what to draw next | 589 int draw_state = WL_START; // what to draw next |
460 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | 590 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
461 int feedback_col = 0; | 591 int feedback_col = 0; |
462 int feedback_old_attr = -1; | 592 int feedback_old_attr = -1; |
463 #endif | 593 #endif |
464 int screen_line_flags = 0; | |
465 | 594 |
466 #if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA) | 595 #if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA) |
467 int match_conc = 0; // cchar for match functions | 596 int match_conc = 0; // cchar for match functions |
468 int on_last_col = FALSE; | 597 int on_last_col = FALSE; |
469 #endif | 598 #endif |
471 int syntax_flags = 0; | 600 int syntax_flags = 0; |
472 int syntax_seqnr = 0; | 601 int syntax_seqnr = 0; |
473 int prev_syntax_id = 0; | 602 int prev_syntax_id = 0; |
474 int conceal_attr = HL_ATTR(HLF_CONCEAL); | 603 int conceal_attr = HL_ATTR(HLF_CONCEAL); |
475 int is_concealing = FALSE; | 604 int is_concealing = FALSE; |
476 int boguscols = 0; // nonexistent columns added to force | |
477 // wrapping | |
478 int vcol_off = 0; // offset for concealed characters | |
479 int did_wcol = FALSE; | 605 int did_wcol = FALSE; |
480 int old_boguscols = 0; | 606 int old_boguscols = 0; |
481 # define VCOL_HLC (vcol - vcol_off) | 607 # define VCOL_HLC (wlv.vcol - wlv.vcol_off) |
482 # define FIX_FOR_BOGUSCOLS \ | 608 # define FIX_FOR_BOGUSCOLS \ |
483 { \ | 609 { \ |
484 n_extra += vcol_off; \ | 610 n_extra += wlv.vcol_off; \ |
485 vcol -= vcol_off; \ | 611 wlv.vcol -= wlv.vcol_off; \ |
486 vcol_off = 0; \ | 612 wlv.vcol_off = 0; \ |
487 col -= boguscols; \ | 613 wlv.col -= wlv.boguscols; \ |
488 old_boguscols = boguscols; \ | 614 old_boguscols = wlv.boguscols; \ |
489 boguscols = 0; \ | 615 wlv.boguscols = 0; \ |
490 } | 616 } |
491 #else | 617 #else |
492 # define VCOL_HLC (vcol) | 618 # define VCOL_HLC (wlv.vcol) |
493 #endif | 619 #endif |
494 | 620 |
495 if (startrow > endrow) // past the end already! | 621 if (startrow > endrow) // past the end already! |
496 return startrow; | 622 return startrow; |
497 | 623 |
498 row = startrow; | 624 CLEAR_FIELD(wlv); |
499 screen_row = row + W_WINROW(wp); | 625 |
626 wlv.lnum = lnum; | |
627 wlv.startrow = startrow; | |
628 wlv.row = startrow; | |
629 wlv.screen_row = wlv.row + W_WINROW(wp); | |
500 | 630 |
501 if (!number_only) | 631 if (!number_only) |
502 { | 632 { |
503 // To speed up the loop below, set extra_check when there is linebreak, | 633 // To speed up the loop below, set extra_check when there is linebreak, |
504 // trailing white space and/or syntax processing to be done. | 634 // trailing white space and/or syntax processing to be done. |
531 } | 661 } |
532 } | 662 } |
533 } | 663 } |
534 | 664 |
535 // Check for columns to display for 'colorcolumn'. | 665 // Check for columns to display for 'colorcolumn'. |
536 color_cols = wp->w_p_cc_cols; | 666 wlv.color_cols = wp->w_p_cc_cols; |
537 if (color_cols != NULL) | 667 if (wlv.color_cols != NULL) |
538 draw_color_col = advance_color_col(VCOL_HLC, &color_cols); | 668 wlv.draw_color_col = advance_color_col(VCOL_HLC, &wlv.color_cols); |
539 #endif | 669 #endif |
540 | 670 |
541 #ifdef FEAT_TERMINAL | 671 #ifdef FEAT_TERMINAL |
542 if (term_show_buffer(wp->w_buffer)) | 672 if (term_show_buffer(wp->w_buffer)) |
543 { | 673 { |
544 extra_check = TRUE; | 674 extra_check = TRUE; |
545 get_term_attr = TRUE; | 675 get_term_attr = TRUE; |
546 win_attr = term_get_attr(wp, lnum, -1); | 676 wlv.win_attr = term_get_attr(wp, lnum, -1); |
547 } | 677 } |
548 #endif | 678 #endif |
549 | 679 |
550 #ifdef FEAT_SPELL | 680 #ifdef FEAT_SPELL |
551 if (wp->w_p_spell | 681 if (wp->w_p_spell |
821 } | 951 } |
822 | 952 |
823 wcr_attr = get_wcr_attr(wp); | 953 wcr_attr = get_wcr_attr(wp); |
824 if (wcr_attr != 0) | 954 if (wcr_attr != 0) |
825 { | 955 { |
826 win_attr = wcr_attr; | 956 wlv.win_attr = wcr_attr; |
827 area_highlighting = TRUE; | 957 area_highlighting = TRUE; |
828 } | 958 } |
829 | 959 |
830 #ifdef FEAT_PROP_POPUP | 960 #ifdef FEAT_PROP_POPUP |
831 if (WIN_IS_POPUP(wp)) | 961 if (WIN_IS_POPUP(wp)) |
832 screen_line_flags |= SLF_POPUP; | 962 wlv.screen_line_flags |= SLF_POPUP; |
833 #endif | 963 #endif |
834 | 964 |
835 // 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the | 965 // 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the |
836 // first character to be displayed. | 966 // first character to be displayed. |
837 if (wp->w_p_wrap) | 967 if (wp->w_p_wrap) |
842 { | 972 { |
843 char_u *prev_ptr = ptr; | 973 char_u *prev_ptr = ptr; |
844 chartabsize_T cts; | 974 chartabsize_T cts; |
845 int charsize = 0; | 975 int charsize = 0; |
846 | 976 |
847 init_chartabsize_arg(&cts, wp, lnum, vcol, line, ptr); | 977 init_chartabsize_arg(&cts, wp, lnum, wlv.vcol, line, ptr); |
848 while (cts.cts_vcol < v && *cts.cts_ptr != NUL) | 978 while (cts.cts_vcol < v && *cts.cts_ptr != NUL) |
849 { | 979 { |
850 charsize = win_lbr_chartabsize(&cts, NULL); | 980 charsize = win_lbr_chartabsize(&cts, NULL); |
851 cts.cts_vcol += charsize; | 981 cts.cts_vcol += charsize; |
852 prev_ptr = cts.cts_ptr; | 982 prev_ptr = cts.cts_ptr; |
853 MB_PTR_ADV(cts.cts_ptr); | 983 MB_PTR_ADV(cts.cts_ptr); |
854 } | 984 } |
855 vcol = cts.cts_vcol; | 985 wlv.vcol = cts.cts_vcol; |
856 ptr = cts.cts_ptr; | 986 ptr = cts.cts_ptr; |
857 clear_chartabsize_arg(&cts); | 987 clear_chartabsize_arg(&cts); |
858 | 988 |
859 // When: | 989 // When: |
860 // - 'cuc' is set, or | 990 // - 'cuc' is set, or |
861 // - 'colorcolumn' is set, or | 991 // - 'colorcolumn' is set, or |
862 // - 'virtualedit' is set, or | 992 // - 'virtualedit' is set, or |
863 // - the visual mode is active, | 993 // - the visual mode is active, |
864 // the end of the line may be before the start of the displayed part. | 994 // the end of the line may be before the start of the displayed part. |
865 if (vcol < v && ( | 995 if (wlv.vcol < v && ( |
866 #ifdef FEAT_SYN_HL | 996 #ifdef FEAT_SYN_HL |
867 wp->w_p_cuc || draw_color_col || | 997 wp->w_p_cuc || wlv.draw_color_col || |
868 #endif | 998 #endif |
869 virtual_active() || | 999 virtual_active() || |
870 (VIsual_active && wp->w_buffer == curwin->w_buffer))) | 1000 (VIsual_active && wp->w_buffer == curwin->w_buffer))) |
871 vcol = v; | 1001 wlv.vcol = v; |
872 | 1002 |
873 // Handle a character that's not completely on the screen: Put ptr at | 1003 // Handle a character that's not completely on the screen: Put ptr at |
874 // that character but skip the first few screen characters. | 1004 // that character but skip the first few screen characters. |
875 if (vcol > v) | 1005 if (wlv.vcol > v) |
876 { | 1006 { |
877 vcol -= charsize; | 1007 wlv.vcol -= charsize; |
878 ptr = prev_ptr; | 1008 ptr = prev_ptr; |
879 // If the character fits on the screen, don't need to skip it. | 1009 // If the character fits on the screen, don't need to skip it. |
880 // Except for a TAB. | 1010 // Except for a TAB. |
881 if (( (*mb_ptr2cells)(ptr) >= charsize || *ptr == TAB) && col == 0) | 1011 if (((*mb_ptr2cells)(ptr) >= charsize || *ptr == TAB) |
882 n_skip = v - vcol; | 1012 && wlv.col == 0) |
1013 n_skip = v - wlv.vcol; | |
883 } | 1014 } |
884 | 1015 |
885 // Adjust for when the inverted text is before the screen, | 1016 // Adjust for when the inverted text is before the screen, |
886 // and when the start of the inverted text is before the screen. | 1017 // and when the start of the inverted text is before the screen. |
887 if (tocol <= vcol) | 1018 if (tocol <= wlv.vcol) |
888 fromcol = 0; | 1019 fromcol = 0; |
889 else if (fromcol >= 0 && fromcol < vcol) | 1020 else if (fromcol >= 0 && fromcol < wlv.vcol) |
890 fromcol = vcol; | 1021 fromcol = wlv.vcol; |
891 | 1022 |
892 #ifdef FEAT_LINEBREAK | 1023 #ifdef FEAT_LINEBREAK |
893 // When w_skipcol is non-zero, first line needs 'showbreak' | 1024 // When w_skipcol is non-zero, first line needs 'showbreak' |
894 if (wp->w_p_wrap) | 1025 if (wp->w_p_wrap) |
895 need_showbreak = TRUE; | 1026 need_showbreak = TRUE; |
1037 extra_check = TRUE; | 1168 extra_check = TRUE; |
1038 } | 1169 } |
1039 } | 1170 } |
1040 #endif | 1171 #endif |
1041 | 1172 |
1042 off = (unsigned)(current_ScreenLine - ScreenLines); | 1173 win_line_start(wp, &wlv); |
1043 col = 0; | |
1044 | |
1045 #ifdef FEAT_RIGHTLEFT | |
1046 if (wp->w_p_rl) | |
1047 { | |
1048 // Rightleft window: process the text in the normal direction, but put | |
1049 // it in current_ScreenLine[] from right to left. Start at the | |
1050 // rightmost column of the window. | |
1051 col = wp->w_width - 1; | |
1052 off += col; | |
1053 screen_line_flags |= SLF_RIGHTLEFT; | |
1054 } | |
1055 #endif | |
1056 | 1174 |
1057 // Repeat for the whole displayed line. | 1175 // Repeat for the whole displayed line. |
1058 for (;;) | 1176 for (;;) |
1059 { | 1177 { |
1060 char_u *prev_ptr = ptr; | 1178 char_u *prev_ptr = ptr; |
1128 draw_state = WL_SIGN; | 1246 draw_state = WL_SIGN; |
1129 // Show the sign column when there are any signs in this | 1247 // Show the sign column when there are any signs in this |
1130 // buffer or when using Netbeans. | 1248 // buffer or when using Netbeans. |
1131 if (signcolumn_on(wp)) | 1249 if (signcolumn_on(wp)) |
1132 get_sign_display_info(FALSE, wp, lnum, &sattr, wcr_attr, | 1250 get_sign_display_info(FALSE, wp, lnum, &sattr, wcr_attr, |
1133 row, startrow, filler_lines, filler_todo, &c_extra, | 1251 wlv.row, startrow, filler_lines, filler_todo, |
1134 &c_final, extra, &p_extra, &n_extra, &char_attr); | 1252 &c_extra, &c_final, extra, &p_extra, &n_extra, |
1253 &char_attr); | |
1135 } | 1254 } |
1136 #endif | 1255 #endif |
1137 | 1256 |
1138 if (draw_state == WL_NR - 1 && n_extra == 0) | 1257 if (draw_state == WL_NR - 1 && n_extra == 0) |
1139 { | 1258 { |
1140 draw_state = WL_NR; | 1259 draw_state = WL_NR; |
1141 // Display the absolute or relative line number. After the | 1260 // Display the absolute or relative line number. After the |
1142 // first fill with blanks when the 'n' flag isn't in 'cpo' | 1261 // first fill with blanks when the 'n' flag isn't in 'cpo' |
1143 if ((wp->w_p_nu || wp->w_p_rnu) | 1262 if ((wp->w_p_nu || wp->w_p_rnu) |
1144 && (row == startrow + filler_lines | 1263 && (wlv.row == startrow + filler_lines |
1145 || vim_strchr(p_cpo, CPO_NUMCOL) == NULL)) | 1264 || vim_strchr(p_cpo, CPO_NUMCOL) == NULL)) |
1146 { | 1265 { |
1147 #ifdef FEAT_SIGNS | 1266 #ifdef FEAT_SIGNS |
1148 // If 'signcolumn' is set to 'number' and a sign is present | 1267 // If 'signcolumn' is set to 'number' and a sign is present |
1149 // in 'lnum', then display the sign instead of the line | 1268 // in 'lnum', then display the sign instead of the line |
1150 // number. | 1269 // number. |
1151 if ((*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u') | 1270 if ((*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u') |
1152 && sign_present) | 1271 && sign_present) |
1153 get_sign_display_info(TRUE, wp, lnum, &sattr, wcr_attr, | 1272 get_sign_display_info(TRUE, wp, lnum, &sattr, wcr_attr, |
1154 row, startrow, filler_lines, filler_todo, | 1273 wlv.row, startrow, filler_lines, filler_todo, |
1155 &c_extra, &c_final, extra, &p_extra, &n_extra, | 1274 &c_extra, &c_final, extra, &p_extra, &n_extra, |
1156 &char_attr); | 1275 &char_attr); |
1157 else | 1276 else |
1158 #endif | 1277 #endif |
1159 { | 1278 { |
1160 // Draw the line number (empty space after wrapping). | 1279 // Draw the line number (empty space after wrapping). |
1161 if (row == startrow + filler_lines) | 1280 if (wlv.row == startrow + filler_lines) |
1162 { | 1281 { |
1163 long num; | 1282 long num; |
1164 char *fmt = "%*ld "; | 1283 char *fmt = "%*ld "; |
1165 | 1284 |
1166 if (wp->w_p_nu && !wp->w_p_rnu) | 1285 if (wp->w_p_nu && !wp->w_p_rnu) |
1219 // TODO: Can we use CursorLine instead of CursorLineNr | 1338 // TODO: Can we use CursorLine instead of CursorLineNr |
1220 // when CursorLineNr isn't set? | 1339 // when CursorLineNr isn't set? |
1221 if (wp->w_p_cul | 1340 if (wp->w_p_cul |
1222 && lnum == wp->w_cursor.lnum | 1341 && lnum == wp->w_cursor.lnum |
1223 && (wp->w_p_culopt_flags & CULOPT_NBR) | 1342 && (wp->w_p_culopt_flags & CULOPT_NBR) |
1224 && (row == startrow + filler_lines | 1343 && (wlv.row == startrow + filler_lines |
1225 || (row > startrow + filler_lines | 1344 || (wlv.row > startrow + filler_lines |
1226 && (wp->w_p_culopt_flags & CULOPT_LINE)))) | 1345 && (wp->w_p_culopt_flags & CULOPT_LINE)))) |
1227 char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_CLN)); | 1346 char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_CLN)); |
1228 #endif | 1347 #endif |
1229 if (wp->w_p_rnu && lnum < wp->w_cursor.lnum | 1348 if (wp->w_p_rnu && lnum < wp->w_cursor.lnum |
1230 && HL_ATTR(HLF_LNA) != 0) | 1349 && HL_ATTR(HLF_LNA) != 0) |
1256 // draw 'breakindent': indent wrapped text accordingly | 1375 // draw 'breakindent': indent wrapped text accordingly |
1257 if (draw_state == WL_BRI - 1 && n_extra == 0) | 1376 if (draw_state == WL_BRI - 1 && n_extra == 0) |
1258 { | 1377 { |
1259 draw_state = WL_BRI; | 1378 draw_state = WL_BRI; |
1260 // if need_showbreak is set, breakindent also applies | 1379 // if need_showbreak is set, breakindent also applies |
1261 if (wp->w_p_bri && (row != startrow || need_showbreak) | 1380 if (wp->w_p_bri && (wlv.row != startrow || need_showbreak) |
1262 # ifdef FEAT_DIFF | 1381 # ifdef FEAT_DIFF |
1263 && filler_lines == 0 | 1382 && filler_lines == 0 |
1264 # endif | 1383 # endif |
1265 ) | 1384 ) |
1266 { | 1385 { |
1272 p_extra = NULL; | 1391 p_extra = NULL; |
1273 c_extra = ' '; | 1392 c_extra = ' '; |
1274 c_final = NUL; | 1393 c_final = NUL; |
1275 n_extra = get_breakindent_win(wp, | 1394 n_extra = get_breakindent_win(wp, |
1276 ml_get_buf(wp->w_buffer, lnum, FALSE)); | 1395 ml_get_buf(wp->w_buffer, lnum, FALSE)); |
1277 if (row == startrow) | 1396 if (wlv.row == startrow) |
1278 { | 1397 { |
1279 n_extra -= win_col_off2(wp); | 1398 n_extra -= win_col_off2(wp); |
1280 if (n_extra < 0) | 1399 if (n_extra < 0) |
1281 n_extra = 0; | 1400 n_extra = 0; |
1282 } | 1401 } |
1283 if (wp->w_skipcol > 0 && wp->w_p_wrap && wp->w_briopt_sbr) | 1402 if (wp->w_skipcol > 0 && wp->w_p_wrap && wp->w_briopt_sbr) |
1284 need_showbreak = FALSE; | 1403 need_showbreak = FALSE; |
1285 // Correct end of highlighted area for 'breakindent', | 1404 // Correct end of highlighted area for 'breakindent', |
1286 // required when 'linebreak' is also set. | 1405 // required when 'linebreak' is also set. |
1287 if (tocol == vcol) | 1406 if (tocol == wlv.vcol) |
1288 tocol += n_extra; | 1407 tocol += n_extra; |
1289 } | 1408 } |
1290 } | 1409 } |
1291 #endif | 1410 #endif |
1292 | 1411 |
1310 c_extra = wp->w_fill_chars.diff; | 1429 c_extra = wp->w_fill_chars.diff; |
1311 c_final = NUL; | 1430 c_final = NUL; |
1312 } | 1431 } |
1313 # ifdef FEAT_RIGHTLEFT | 1432 # ifdef FEAT_RIGHTLEFT |
1314 if (wp->w_p_rl) | 1433 if (wp->w_p_rl) |
1315 n_extra = col + 1; | 1434 n_extra = wlv.col + 1; |
1316 else | 1435 else |
1317 # endif | 1436 # endif |
1318 n_extra = wp->w_width - col; | 1437 n_extra = wp->w_width - wlv.col; |
1319 char_attr = HL_ATTR(HLF_DED); | 1438 char_attr = HL_ATTR(HLF_DED); |
1320 } | 1439 } |
1321 # endif | 1440 # endif |
1322 # ifdef FEAT_LINEBREAK | 1441 # ifdef FEAT_LINEBREAK |
1323 sbr = get_showbreak_value(wp); | 1442 sbr = get_showbreak_value(wp); |
1328 c_extra = NUL; | 1447 c_extra = NUL; |
1329 c_final = NUL; | 1448 c_final = NUL; |
1330 n_extra = (int)STRLEN(sbr); | 1449 n_extra = (int)STRLEN(sbr); |
1331 if (wp->w_skipcol == 0 || !wp->w_p_wrap) | 1450 if (wp->w_skipcol == 0 || !wp->w_p_wrap) |
1332 need_showbreak = FALSE; | 1451 need_showbreak = FALSE; |
1333 vcol_sbr = vcol + MB_CHARLEN(sbr); | 1452 vcol_sbr = wlv.vcol + MB_CHARLEN(sbr); |
1334 // Correct end of highlighted area for 'showbreak', | 1453 // Correct end of highlighted area for 'showbreak', |
1335 // required when 'linebreak' is also set. | 1454 // required when 'linebreak' is also set. |
1336 if (tocol == vcol) | 1455 if (tocol == wlv.vcol) |
1337 tocol += n_extra; | 1456 tocol += n_extra; |
1338 // combine 'showbreak' with 'wincolor' | 1457 // combine 'showbreak' with 'wincolor' |
1339 char_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT)); | 1458 char_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT)); |
1340 # ifdef FEAT_SYN_HL | 1459 # ifdef FEAT_SYN_HL |
1341 // combine 'showbreak' with 'cursorline' | 1460 // combine 'showbreak' with 'cursorline' |
1342 if (cul_attr != 0) | 1461 if (cul_attr != 0) |
1343 char_attr = hl_combine_attr(char_attr, cul_attr); | 1462 char_attr = hl_combine_attr(char_attr, cul_attr); |
1344 # endif | 1463 # endif |
1358 c_final = saved_c_final; | 1477 c_final = saved_c_final; |
1359 p_extra = saved_p_extra; | 1478 p_extra = saved_p_extra; |
1360 char_attr = saved_char_attr; | 1479 char_attr = saved_char_attr; |
1361 } | 1480 } |
1362 else | 1481 else |
1363 char_attr = win_attr; | 1482 char_attr = wlv.win_attr; |
1364 } | 1483 } |
1365 } | 1484 } |
1366 #ifdef FEAT_SYN_HL | 1485 #ifdef FEAT_SYN_HL |
1367 if (cul_screenline && draw_state == WL_LINE | 1486 if (cul_screenline && draw_state == WL_LINE |
1368 && vcol >= left_curline_col | 1487 && wlv.vcol >= left_curline_col |
1369 && vcol < right_curline_col) | 1488 && wlv.vcol < right_curline_col) |
1370 { | 1489 { |
1371 cul_attr = HL_ATTR(HLF_CUL); | 1490 cul_attr = HL_ATTR(HLF_CUL); |
1372 line_attr = cul_attr; | 1491 line_attr = cul_attr; |
1373 } | 1492 } |
1374 #endif | 1493 #endif |
1375 | 1494 |
1376 // When still displaying '$' of change command, stop at cursor. | 1495 // When still displaying '$' of change command, stop at cursor. |
1377 // When only displaying the (relative) line number and that's done, | 1496 // When only displaying the (relative) line number and that's done, |
1378 // stop here. | 1497 // stop here. |
1379 if (((dollar_vcol >= 0 && wp == curwin | 1498 if (((dollar_vcol >= 0 && wp == curwin |
1380 && lnum == wp->w_cursor.lnum && vcol >= (long)wp->w_virtcol) | 1499 && lnum == wp->w_cursor.lnum && wlv.vcol >= (long)wp->w_virtcol) |
1381 || (number_only && draw_state > WL_NR)) | 1500 || (number_only && draw_state > WL_NR)) |
1382 #ifdef FEAT_DIFF | 1501 #ifdef FEAT_DIFF |
1383 && filler_todo <= 0 | 1502 && filler_todo <= 0 |
1384 #endif | 1503 #endif |
1385 ) | 1504 ) |
1386 { | 1505 { |
1387 screen_line(wp, screen_row, wp->w_wincol, col, -wp->w_width, | 1506 screen_line(wp, wlv.screen_row, wp->w_wincol, wlv.col, -wp->w_width, |
1388 screen_line_flags); | 1507 wlv.screen_line_flags); |
1389 // Pretend we have finished updating the window. Except when | 1508 // Pretend we have finished updating the window. Except when |
1390 // 'cursorcolumn' is set. | 1509 // 'cursorcolumn' is set. |
1391 #ifdef FEAT_SYN_HL | 1510 #ifdef FEAT_SYN_HL |
1392 if (wp->w_p_cuc) | 1511 if (wp->w_p_cuc) |
1393 row = wp->w_cline_row + wp->w_cline_height; | 1512 wlv.row = wp->w_cline_row + wp->w_cline_height; |
1394 else | 1513 else |
1395 #endif | 1514 #endif |
1396 row = wp->w_height; | 1515 wlv.row = wp->w_height; |
1397 break; | 1516 break; |
1398 } | 1517 } |
1399 | 1518 |
1400 if (draw_state == WL_LINE && (area_highlighting || extra_check)) | 1519 if (draw_state == WL_LINE && (area_highlighting || extra_check)) |
1401 { | 1520 { |
1402 // handle Visual or match highlighting in this line | 1521 // handle Visual or match highlighting in this line |
1403 if (vcol == fromcol | 1522 if (wlv.vcol == fromcol |
1404 || (has_mbyte && vcol + 1 == fromcol && n_extra == 0 | 1523 || (has_mbyte && wlv.vcol + 1 == fromcol && n_extra == 0 |
1405 && (*mb_ptr2cells)(ptr) > 1) | 1524 && (*mb_ptr2cells)(ptr) > 1) |
1406 || ((int)vcol_prev == fromcol_prev | 1525 || ((int)vcol_prev == fromcol_prev |
1407 && vcol_prev < vcol // not at margin | 1526 && vcol_prev < wlv.vcol // not at margin |
1408 && vcol < tocol)) | 1527 && wlv.vcol < tocol)) |
1409 area_attr = vi_attr; // start highlighting | 1528 area_attr = vi_attr; // start highlighting |
1410 else if (area_attr != 0 | 1529 else if (area_attr != 0 |
1411 && (vcol == tocol | 1530 && (wlv.vcol == tocol |
1412 || (noinvcur && (colnr_T)vcol == wp->w_virtcol))) | 1531 || (noinvcur && (colnr_T)wlv.vcol == wp->w_virtcol))) |
1413 area_attr = 0; // stop highlighting | 1532 area_attr = 0; // stop highlighting |
1414 | 1533 |
1415 #ifdef FEAT_SEARCH_EXTRA | 1534 #ifdef FEAT_SEARCH_EXTRA |
1416 if (!n_extra) | 1535 if (!n_extra) |
1417 { | 1536 { |
1443 && n_extra == 0) | 1562 && n_extra == 0) |
1444 diff_hlf = HLF_CHD; // changed line | 1563 diff_hlf = HLF_CHD; // changed line |
1445 line_attr = HL_ATTR(diff_hlf); | 1564 line_attr = HL_ATTR(diff_hlf); |
1446 if (wp->w_p_cul && lnum == wp->w_cursor.lnum | 1565 if (wp->w_p_cul && lnum == wp->w_cursor.lnum |
1447 && wp->w_p_culopt_flags != CULOPT_NBR | 1566 && wp->w_p_culopt_flags != CULOPT_NBR |
1448 && (!cul_screenline || (vcol >= left_curline_col | 1567 && (!cul_screenline || (wlv.vcol >= left_curline_col |
1449 && vcol <= right_curline_col))) | 1568 && wlv.vcol <= right_curline_col))) |
1450 line_attr = hl_combine_attr( | 1569 line_attr = hl_combine_attr( |
1451 line_attr, HL_ATTR(HLF_CUL)); | 1570 line_attr, HL_ATTR(HLF_CUL)); |
1452 } | 1571 } |
1453 #endif | 1572 #endif |
1454 | 1573 |
1580 // Keep in sync with where | 1699 // Keep in sync with where |
1581 // textprop_size_after_trunc() is called in | 1700 // textprop_size_after_trunc() is called in |
1582 // win_lbr_chartabsize(). | 1701 // win_lbr_chartabsize(). |
1583 if ((right || below || !wrap) && wp->w_width > 2) | 1702 if ((right || below || !wrap) && wp->w_width > 2) |
1584 { | 1703 { |
1585 int added = wp->w_width - col; | 1704 int added = wp->w_width - wlv.col; |
1586 int n_used = n_extra; | 1705 int n_used = n_extra; |
1587 char_u *l; | 1706 char_u *l; |
1588 int strsize = wrap | 1707 int strsize = wrap |
1589 ? vim_strsize(p_extra) | 1708 ? vim_strsize(p_extra) |
1590 : textprop_size_after_trunc(wp, | 1709 : textprop_size_after_trunc(wp, |
1593 if (wrap || right || below || n_used < n_extra) | 1712 if (wrap || right || below || n_used < n_extra) |
1594 { | 1713 { |
1595 // Right-align: fill with spaces | 1714 // Right-align: fill with spaces |
1596 if (right) | 1715 if (right) |
1597 added -= strsize; | 1716 added -= strsize; |
1598 if (added < 0 || (below && col == 0) | 1717 if (added < 0 |
1599 || (!below && n_used < n_extra)) | 1718 || (below |
1719 ? wlv.col == 0 || !wp->w_p_wrap | |
1720 : n_used < n_extra)) | |
1600 added = 0; | 1721 added = 0; |
1601 // add 1 for NUL, 2 for when '…' is used | 1722 // add 1 for NUL, 2 for when '…' is used |
1602 l = alloc(n_used + added + 3); | 1723 l = alloc(n_used + added + 3); |
1603 if (l != NULL) | 1724 if (l != NULL) |
1604 { | 1725 { |
1623 p_extra = p_extra_free = l; | 1744 p_extra = p_extra_free = l; |
1624 n_extra = n_used + added; | 1745 n_extra = n_used + added; |
1625 n_attr_skip = added; | 1746 n_attr_skip = added; |
1626 } | 1747 } |
1627 } | 1748 } |
1749 | |
1750 // When 'wrap' is off then for "below" we need | |
1751 // to start a new line explictly. | |
1752 if (!wp->w_p_wrap) | |
1753 { | |
1754 draw_screen_line(wp, &wlv); | |
1755 | |
1756 // When line got too long for screen break | |
1757 // here. | |
1758 if (wlv.row == endrow) | |
1759 { | |
1760 ++wlv.row; | |
1761 break; | |
1762 } | |
1763 win_line_start(wp, &wlv); | |
1764 } | |
1628 } | 1765 } |
1629 } | 1766 } |
1630 // reset the ID in the copy to avoid it being used | 1767 // reset the ID in the copy to avoid it being used |
1631 // again | 1768 // again |
1632 text_props[used_tpi].tp_id = -MAXCOL; | 1769 text_props[used_tpi].tp_id = -MAXCOL; |
1651 if (extra_check && n_extra == 0) | 1788 if (extra_check && n_extra == 0) |
1652 { | 1789 { |
1653 syntax_attr = 0; | 1790 syntax_attr = 0; |
1654 # ifdef FEAT_TERMINAL | 1791 # ifdef FEAT_TERMINAL |
1655 if (get_term_attr) | 1792 if (get_term_attr) |
1656 syntax_attr = term_get_attr(wp, lnum, vcol); | 1793 syntax_attr = term_get_attr(wp, lnum, wlv.vcol); |
1657 # endif | 1794 # endif |
1658 // Get syntax attribute. | 1795 // Get syntax attribute. |
1659 if (has_syntax) | 1796 if (has_syntax) |
1660 { | 1797 { |
1661 // Get the syntax attribute for the character. If there | 1798 // Get the syntax attribute for the character. If there |
1740 # ifdef FEAT_SYN_HL | 1877 # ifdef FEAT_SYN_HL |
1741 char_attr = hl_combine_attr(syntax_attr, char_attr); | 1878 char_attr = hl_combine_attr(syntax_attr, char_attr); |
1742 # endif | 1879 # endif |
1743 } | 1880 } |
1744 else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL) | 1881 else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL) |
1745 || vcol < fromcol || vcol_prev < fromcol_prev | 1882 || wlv.vcol < fromcol || vcol_prev < fromcol_prev |
1746 || vcol >= tocol)) | 1883 || wlv.vcol >= tocol)) |
1747 { | 1884 { |
1748 // Use line_attr when not in the Visual or 'incsearch' area | 1885 // Use line_attr when not in the Visual or 'incsearch' area |
1749 // (area_attr may be 0 when "noinvcur" is set). | 1886 // (area_attr may be 0 when "noinvcur" is set). |
1750 # ifdef FEAT_SYN_HL | 1887 # ifdef FEAT_SYN_HL |
1751 char_attr = hl_combine_attr(syntax_attr, line_attr); | 1888 char_attr = hl_combine_attr(syntax_attr, line_attr); |
1775 char_attr = hl_combine_attr(char_attr, text_prop_attr); | 1912 char_attr = hl_combine_attr(char_attr, text_prop_attr); |
1776 #endif | 1913 #endif |
1777 } | 1914 } |
1778 | 1915 |
1779 // combine attribute with 'wincolor' | 1916 // combine attribute with 'wincolor' |
1780 if (win_attr != 0) | 1917 if (wlv.win_attr != 0) |
1781 { | 1918 { |
1782 if (char_attr == 0) | 1919 if (char_attr == 0) |
1783 char_attr = win_attr; | 1920 char_attr = wlv.win_attr; |
1784 else | 1921 else |
1785 char_attr = hl_combine_attr(win_attr, char_attr); | 1922 char_attr = hl_combine_attr(wlv.win_attr, char_attr); |
1786 } | 1923 } |
1787 | 1924 |
1788 // Get the next character to put on the screen. | 1925 // Get the next character to put on the screen. |
1789 | 1926 |
1790 // The "p_extra" points to the extra stuff that is inserted to | 1927 // The "p_extra" points to the extra stuff that is inserted to |
1844 | 1981 |
1845 // If a double-width char doesn't fit display a '>' in the | 1982 // If a double-width char doesn't fit display a '>' in the |
1846 // last column. | 1983 // last column. |
1847 if (( | 1984 if (( |
1848 # ifdef FEAT_RIGHTLEFT | 1985 # ifdef FEAT_RIGHTLEFT |
1849 wp->w_p_rl ? (col <= 0) : | 1986 wp->w_p_rl ? (wlv.col <= 0) : |
1850 # endif | 1987 # endif |
1851 (col >= wp->w_width - 1)) | 1988 (wlv.col >= wp->w_width - 1)) |
1852 && (*mb_char2cells)(mb_c) == 2) | 1989 && (*mb_char2cells)(mb_c) == 2) |
1853 { | 1990 { |
1854 c = '>'; | 1991 c = '>'; |
1855 mb_c = c; | 1992 mb_c = c; |
1856 mb_l = 1; | 1993 mb_l = 1; |
1858 multi_attr = HL_ATTR(HLF_AT); | 1995 multi_attr = HL_ATTR(HLF_AT); |
1859 #ifdef FEAT_SYN_HL | 1996 #ifdef FEAT_SYN_HL |
1860 if (cul_attr) | 1997 if (cul_attr) |
1861 multi_attr = hl_combine_attr(multi_attr, cul_attr); | 1998 multi_attr = hl_combine_attr(multi_attr, cul_attr); |
1862 #endif | 1999 #endif |
1863 multi_attr = hl_combine_attr(win_attr, multi_attr); | 2000 multi_attr = hl_combine_attr(wlv.win_attr, multi_attr); |
1864 | 2001 |
1865 // put the pointer back to output the double-width | 2002 // put the pointer back to output the double-width |
1866 // character at the start of the next line. | 2003 // character at the start of the next line. |
1867 ++n_extra; | 2004 ++n_extra; |
1868 --p_extra; | 2005 --p_extra; |
1950 c_final = NUL; | 2087 c_final = NUL; |
1951 if (area_attr == 0 && search_attr == 0) | 2088 if (area_attr == 0 && search_attr == 0) |
1952 { | 2089 { |
1953 n_attr = n_extra + 1; | 2090 n_attr = n_extra + 1; |
1954 extra_attr = hl_combine_attr( | 2091 extra_attr = hl_combine_attr( |
1955 win_attr, HL_ATTR(HLF_8)); | 2092 wlv.win_attr, HL_ATTR(HLF_8)); |
1956 saved_attr2 = char_attr; // save current attr | 2093 saved_attr2 = char_attr; // save current attr |
1957 } | 2094 } |
1958 } | 2095 } |
1959 else if (mb_l == 0) // at the NUL at end-of-line | 2096 else if (mb_l == 0) // at the NUL at end-of-line |
1960 mb_l = 1; | 2097 mb_l = 1; |
2020 c = *p_extra++; | 2157 c = *p_extra++; |
2021 if (area_attr == 0 && search_attr == 0) | 2158 if (area_attr == 0 && search_attr == 0) |
2022 { | 2159 { |
2023 n_attr = n_extra + 1; | 2160 n_attr = n_extra + 1; |
2024 extra_attr = hl_combine_attr( | 2161 extra_attr = hl_combine_attr( |
2025 win_attr, HL_ATTR(HLF_8)); | 2162 wlv.win_attr, HL_ATTR(HLF_8)); |
2026 saved_attr2 = char_attr; // save current attr | 2163 saved_attr2 = char_attr; // save current attr |
2027 } | 2164 } |
2028 mb_c = c; | 2165 mb_c = c; |
2029 } | 2166 } |
2030 } | 2167 } |
2032 // If a double-width char doesn't fit display a '>' in the | 2169 // If a double-width char doesn't fit display a '>' in the |
2033 // last column; the character is displayed at the start of the | 2170 // last column; the character is displayed at the start of the |
2034 // next line. | 2171 // next line. |
2035 if (( | 2172 if (( |
2036 # ifdef FEAT_RIGHTLEFT | 2173 # ifdef FEAT_RIGHTLEFT |
2037 wp->w_p_rl ? (col <= 0) : | 2174 wp->w_p_rl ? (wlv.col <= 0) : |
2038 # endif | 2175 # endif |
2039 (col >= wp->w_width - 1)) | 2176 (wlv.col >= wp->w_width - 1)) |
2040 && (*mb_char2cells)(mb_c) == 2) | 2177 && (*mb_char2cells)(mb_c) == 2) |
2041 { | 2178 { |
2042 c = '>'; | 2179 c = '>'; |
2043 mb_c = c; | 2180 mb_c = c; |
2044 mb_utf8 = FALSE; | 2181 mb_utf8 = FALSE; |
2045 mb_l = 1; | 2182 mb_l = 1; |
2046 multi_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT)); | 2183 multi_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT)); |
2047 // Put pointer back so that the character will be | 2184 // Put pointer back so that the character will be |
2048 // displayed at the start of the next line. | 2185 // displayed at the start of the next line. |
2049 --ptr; | 2186 --ptr; |
2050 #ifdef FEAT_CONCEAL | 2187 #ifdef FEAT_CONCEAL |
2051 did_decrement_ptr = TRUE; | 2188 did_decrement_ptr = TRUE; |
2064 c_final = NUL; | 2201 c_final = NUL; |
2065 c = ' '; | 2202 c = ' '; |
2066 if (area_attr == 0 && search_attr == 0) | 2203 if (area_attr == 0 && search_attr == 0) |
2067 { | 2204 { |
2068 n_attr = n_extra + 1; | 2205 n_attr = n_extra + 1; |
2069 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT)); | 2206 extra_attr = hl_combine_attr( |
2207 wlv.win_attr, HL_ATTR(HLF_AT)); | |
2070 saved_attr2 = char_attr; // save current attr | 2208 saved_attr2 = char_attr; // save current attr |
2071 } | 2209 } |
2072 mb_c = c; | 2210 mb_c = c; |
2073 mb_utf8 = FALSE; | 2211 mb_utf8 = FALSE; |
2074 mb_l = 1; | 2212 mb_l = 1; |
2172 int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) | 2310 int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) |
2173 : 0; | 2311 : 0; |
2174 char_u *p = ptr - (mb_off + 1); | 2312 char_u *p = ptr - (mb_off + 1); |
2175 chartabsize_T cts; | 2313 chartabsize_T cts; |
2176 | 2314 |
2177 init_chartabsize_arg(&cts, wp, lnum, vcol, line, p); | 2315 init_chartabsize_arg(&cts, wp, lnum, wlv.vcol, line, p); |
2178 n_extra = win_lbr_chartabsize(&cts, NULL) - 1; | 2316 n_extra = win_lbr_chartabsize(&cts, NULL) - 1; |
2179 | 2317 |
2180 // We have just drawn the showbreak value, no need to add | 2318 // We have just drawn the showbreak value, no need to add |
2181 // space for it again. | 2319 // space for it again. |
2182 if (vcol == vcol_sbr) | 2320 if (wlv.vcol == vcol_sbr) |
2183 { | 2321 { |
2184 n_extra -= MB_CHARLEN(get_showbreak_value(wp)); | 2322 n_extra -= MB_CHARLEN(get_showbreak_value(wp)); |
2185 if (n_extra < 0) | 2323 if (n_extra < 0) |
2186 n_extra = 0; | 2324 n_extra = 0; |
2187 } | 2325 } |
2189 // Do not continue search/match highlighting over the | 2327 // Do not continue search/match highlighting over the |
2190 // line break, but for TABs the highlighting should | 2328 // line break, but for TABs the highlighting should |
2191 // include the complete width of the character | 2329 // include the complete width of the character |
2192 search_attr = 0; | 2330 search_attr = 0; |
2193 | 2331 |
2194 if (c == TAB && n_extra + col > wp->w_width) | 2332 if (c == TAB && n_extra + wlv.col > wp->w_width) |
2195 # ifdef FEAT_VARTABS | 2333 # ifdef FEAT_VARTABS |
2196 n_extra = tabstop_padding(vcol, wp->w_buffer->b_p_ts, | 2334 n_extra = tabstop_padding(wlv.vcol, |
2335 wp->w_buffer->b_p_ts, | |
2197 wp->w_buffer->b_p_vts_array) - 1; | 2336 wp->w_buffer->b_p_vts_array) - 1; |
2198 # else | 2337 # else |
2199 n_extra = (int)wp->w_buffer->b_p_ts | 2338 n_extra = (int)wp->w_buffer->b_p_ts |
2200 - vcol % (int)wp->w_buffer->b_p_ts - 1; | 2339 - wlv.vcol % (int)wp->w_buffer->b_p_ts - 1; |
2201 # endif | 2340 # endif |
2202 | 2341 |
2203 c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' '; | 2342 c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' '; |
2204 c_final = NUL; | 2343 c_final = NUL; |
2205 # if defined(FEAT_PROP_POPUP) | 2344 # if defined(FEAT_PROP_POPUP) |
2252 c = (c == ' ') ? wp->w_lcs_chars.space | 2391 c = (c == ' ') ? wp->w_lcs_chars.space |
2253 : wp->w_lcs_chars.nbsp; | 2392 : wp->w_lcs_chars.nbsp; |
2254 if (area_attr == 0 && search_attr == 0) | 2393 if (area_attr == 0 && search_attr == 0) |
2255 { | 2394 { |
2256 n_attr = 1; | 2395 n_attr = 1; |
2257 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8)); | 2396 extra_attr = hl_combine_attr(wlv.win_attr, |
2397 HL_ATTR(HLF_8)); | |
2258 saved_attr2 = char_attr; // save current attr | 2398 saved_attr2 = char_attr; // save current attr |
2259 } | 2399 } |
2260 mb_c = c; | 2400 mb_c = c; |
2261 if (enc_utf8 && utf_char2len(c) > 1) | 2401 if (enc_utf8 && utf_char2len(c) > 1) |
2262 { | 2402 { |
2291 | 2431 |
2292 | 2432 |
2293 if (!attr_pri) | 2433 if (!attr_pri) |
2294 { | 2434 { |
2295 n_attr = 1; | 2435 n_attr = 1; |
2296 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8)); | 2436 extra_attr = hl_combine_attr(wlv.win_attr, |
2437 HL_ATTR(HLF_8)); | |
2297 saved_attr2 = char_attr; // save current attr | 2438 saved_attr2 = char_attr; // save current attr |
2298 } | 2439 } |
2299 mb_c = c; | 2440 mb_c = c; |
2300 if (enc_utf8 && utf_char2len(c) > 1) | 2441 if (enc_utf8 && utf_char2len(c) > 1) |
2301 { | 2442 { |
2315 // turn it into something else on the way to putting it | 2456 // turn it into something else on the way to putting it |
2316 // into "ScreenLines". | 2457 // into "ScreenLines". |
2317 if (c == TAB && (!wp->w_p_list || wp->w_lcs_chars.tab1)) | 2458 if (c == TAB && (!wp->w_p_list || wp->w_lcs_chars.tab1)) |
2318 { | 2459 { |
2319 int tab_len = 0; | 2460 int tab_len = 0; |
2320 long vcol_adjusted = vcol; // removed showbreak length | 2461 long vcol_adjusted = wlv.vcol; // removed showbreak length |
2321 #ifdef FEAT_LINEBREAK | 2462 #ifdef FEAT_LINEBREAK |
2322 char_u *sbr = get_showbreak_value(wp); | 2463 char_u *sbr = get_showbreak_value(wp); |
2323 | 2464 |
2324 // only adjust the tab_len, when at the first column | 2465 // only adjust the tab_len, when at the first column |
2325 // after the showbreak value was drawn | 2466 // after the showbreak value was drawn |
2326 if (*sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap) | 2467 if (*sbr != NUL && wlv.vcol == vcol_sbr && wp->w_p_wrap) |
2327 vcol_adjusted = vcol - MB_CHARLEN(sbr); | 2468 vcol_adjusted = wlv.vcol - MB_CHARLEN(sbr); |
2328 #endif | 2469 #endif |
2329 // tab amount depends on current column | 2470 // tab amount depends on current column |
2330 #ifdef FEAT_VARTABS | 2471 #ifdef FEAT_VARTABS |
2331 tab_len = tabstop_padding(vcol_adjusted, | 2472 tab_len = tabstop_padding(vcol_adjusted, |
2332 wp->w_buffer->b_p_ts, | 2473 wp->w_buffer->b_p_ts, |
2348 int len; | 2489 int len; |
2349 int i; | 2490 int i; |
2350 int saved_nextra = n_extra; | 2491 int saved_nextra = n_extra; |
2351 | 2492 |
2352 # ifdef FEAT_CONCEAL | 2493 # ifdef FEAT_CONCEAL |
2353 if (vcol_off > 0) | 2494 if (wlv.vcol_off > 0) |
2354 // there are characters to conceal | 2495 // there are characters to conceal |
2355 tab_len += vcol_off; | 2496 tab_len += wlv.vcol_off; |
2356 | 2497 |
2357 // boguscols before FIX_FOR_BOGUSCOLS macro from above | 2498 // boguscols before FIX_FOR_BOGUSCOLS macro from above |
2358 if (wp->w_p_list && wp->w_lcs_chars.tab1 | 2499 if (wp->w_p_list && wp->w_lcs_chars.tab1 |
2359 && old_boguscols > 0 | 2500 && old_boguscols > 0 |
2360 && n_extra > tab_len) | 2501 && n_extra > tab_len) |
2397 } | 2538 } |
2398 p_extra = p_extra_free; | 2539 p_extra = p_extra_free; |
2399 # ifdef FEAT_CONCEAL | 2540 # ifdef FEAT_CONCEAL |
2400 // n_extra will be increased by FIX_FOX_BOGUSCOLS | 2541 // n_extra will be increased by FIX_FOX_BOGUSCOLS |
2401 // macro below, so need to adjust for that here | 2542 // macro below, so need to adjust for that here |
2402 if (vcol_off > 0) | 2543 if (wlv.vcol_off > 0) |
2403 n_extra -= vcol_off; | 2544 n_extra -= wlv.vcol_off; |
2404 # endif | 2545 # endif |
2405 } | 2546 } |
2406 } | 2547 } |
2407 #endif | 2548 #endif |
2408 #ifdef FEAT_CONCEAL | 2549 #ifdef FEAT_CONCEAL |
2409 { | 2550 { |
2410 int vc_saved = vcol_off; | 2551 int vc_saved = wlv.vcol_off; |
2411 | 2552 |
2412 // Tab alignment should be identical regardless of | 2553 // Tab alignment should be identical regardless of |
2413 // 'conceallevel' value. So tab compensates of all | 2554 // 'conceallevel' value. So tab compensates of all |
2414 // previous concealed characters, and thus resets | 2555 // previous concealed characters, and thus resets |
2415 // vcol_off and boguscols accumulated so far in the | 2556 // vcol_off and boguscols accumulated so far in the |
2437 else | 2578 else |
2438 #endif | 2579 #endif |
2439 c_extra = wp->w_lcs_chars.tab2; | 2580 c_extra = wp->w_lcs_chars.tab2; |
2440 c_final = wp->w_lcs_chars.tab3; | 2581 c_final = wp->w_lcs_chars.tab3; |
2441 n_attr = tab_len + 1; | 2582 n_attr = tab_len + 1; |
2442 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8)); | 2583 extra_attr = hl_combine_attr(wlv.win_attr, |
2584 HL_ATTR(HLF_8)); | |
2443 saved_attr2 = char_attr; // save current attr | 2585 saved_attr2 = char_attr; // save current attr |
2444 mb_c = c; | 2586 mb_c = c; |
2445 if (enc_utf8 && utf_char2len(c) > 1) | 2587 if (enc_utf8 && utf_char2len(c) > 1) |
2446 { | 2588 { |
2447 mb_utf8 = TRUE; | 2589 mb_utf8 = TRUE; |
2457 } | 2599 } |
2458 } | 2600 } |
2459 else if (c == NUL | 2601 else if (c == NUL |
2460 && (wp->w_p_list | 2602 && (wp->w_p_list |
2461 || ((fromcol >= 0 || fromcol_prev >= 0) | 2603 || ((fromcol >= 0 || fromcol_prev >= 0) |
2462 && tocol > vcol | 2604 && tocol > wlv.vcol |
2463 && VIsual_mode != Ctrl_V | 2605 && VIsual_mode != Ctrl_V |
2464 && ( | 2606 && ( |
2465 # ifdef FEAT_RIGHTLEFT | 2607 # ifdef FEAT_RIGHTLEFT |
2466 wp->w_p_rl ? (col >= 0) : | 2608 wp->w_p_rl ? (wlv.col >= 0) : |
2467 # endif | 2609 # endif |
2468 (col < wp->w_width)) | 2610 (wlv.col < wp->w_width)) |
2469 && !(noinvcur | 2611 && !(noinvcur |
2470 && lnum == wp->w_cursor.lnum | 2612 && lnum == wp->w_cursor.lnum |
2471 && (colnr_T)vcol == wp->w_virtcol))) | 2613 && (colnr_T)wlv.vcol == wp->w_virtcol))) |
2472 && lcs_eol_one > 0) | 2614 && lcs_eol_one > 0) |
2473 { | 2615 { |
2474 // Display a '$' after the line or highlight an extra | 2616 // Display a '$' after the line or highlight an extra |
2475 // character if the line break is included. | 2617 // character if the line break is included. |
2476 #if defined(FEAT_DIFF) || defined(LINE_ATTR) | 2618 #if defined(FEAT_DIFF) || defined(LINE_ATTR) |
2490 #endif | 2632 #endif |
2491 { | 2633 { |
2492 // In virtualedit, visual selections may extend | 2634 // In virtualedit, visual selections may extend |
2493 // beyond end of line. | 2635 // beyond end of line. |
2494 if (area_highlighting && virtual_active() | 2636 if (area_highlighting && virtual_active() |
2495 && tocol != MAXCOL && vcol < tocol) | 2637 && tocol != MAXCOL && wlv.vcol < tocol) |
2496 n_extra = 0; | 2638 n_extra = 0; |
2497 else | 2639 else |
2498 { | 2640 { |
2499 p_extra = at_end_str; | 2641 p_extra = at_end_str; |
2500 n_extra = 1; | 2642 n_extra = 1; |
2508 c = ' '; | 2650 c = ' '; |
2509 lcs_eol_one = -1; | 2651 lcs_eol_one = -1; |
2510 --ptr; // put it back at the NUL | 2652 --ptr; // put it back at the NUL |
2511 if (!attr_pri) | 2653 if (!attr_pri) |
2512 { | 2654 { |
2513 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT)); | 2655 extra_attr = hl_combine_attr(wlv.win_attr, |
2656 HL_ATTR(HLF_AT)); | |
2514 n_attr = 1; | 2657 n_attr = 1; |
2515 } | 2658 } |
2516 mb_c = c; | 2659 mb_c = c; |
2517 if (enc_utf8 && utf_char2len(c) > 1) | 2660 if (enc_utf8 && utf_char2len(c) > 1) |
2518 { | 2661 { |
2554 c = *p_extra++; | 2697 c = *p_extra++; |
2555 } | 2698 } |
2556 if (!attr_pri) | 2699 if (!attr_pri) |
2557 { | 2700 { |
2558 n_attr = n_extra + 1; | 2701 n_attr = n_extra + 1; |
2559 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8)); | 2702 extra_attr = hl_combine_attr(wlv.win_attr, |
2703 HL_ATTR(HLF_8)); | |
2560 saved_attr2 = char_attr; // save current attr | 2704 saved_attr2 = char_attr; // save current attr |
2561 } | 2705 } |
2562 mb_utf8 = FALSE; // don't draw as UTF-8 | 2706 mb_utf8 = FALSE; // don't draw as UTF-8 |
2563 } | 2707 } |
2564 else if (VIsual_active | 2708 else if (VIsual_active |
2565 && (VIsual_mode == Ctrl_V | 2709 && (VIsual_mode == Ctrl_V |
2566 || VIsual_mode == 'v') | 2710 || VIsual_mode == 'v') |
2567 && virtual_active() | 2711 && virtual_active() |
2568 && tocol != MAXCOL | 2712 && tocol != MAXCOL |
2569 && vcol < tocol | 2713 && wlv.vcol < tocol |
2570 && ( | 2714 && ( |
2571 #ifdef FEAT_RIGHTLEFT | 2715 #ifdef FEAT_RIGHTLEFT |
2572 wp->w_p_rl ? (col >= 0) : | 2716 wp->w_p_rl ? (wlv.col >= 0) : |
2573 #endif | 2717 #endif |
2574 (col < wp->w_width))) | 2718 (wlv.col < wp->w_width))) |
2575 { | 2719 { |
2576 c = ' '; | 2720 c = ' '; |
2577 --ptr; // put it back at the NUL | 2721 --ptr; // put it back at the NUL |
2578 } | 2722 } |
2579 #if defined(LINE_ATTR) | 2723 #if defined(LINE_ATTR) |
2580 else if (( | 2724 else if (( |
2581 # ifdef FEAT_DIFF | 2725 # ifdef FEAT_DIFF |
2582 diff_hlf != (hlf_T)0 || | 2726 diff_hlf != (hlf_T)0 || |
2583 # endif | 2727 # endif |
2584 # ifdef FEAT_TERMINAL | 2728 # ifdef FEAT_TERMINAL |
2585 win_attr != 0 || | 2729 wlv.win_attr != 0 || |
2586 # endif | 2730 # endif |
2587 line_attr != 0 | 2731 line_attr != 0 |
2588 ) && ( | 2732 ) && ( |
2589 # ifdef FEAT_RIGHTLEFT | 2733 # ifdef FEAT_RIGHTLEFT |
2590 wp->w_p_rl ? (col >= 0) : | 2734 wp->w_p_rl ? (wlv.col >= 0) : |
2591 # endif | 2735 # endif |
2592 (col | 2736 (wlv.col |
2593 # ifdef FEAT_CONCEAL | 2737 # ifdef FEAT_CONCEAL |
2594 - boguscols | 2738 - wlv.boguscols |
2595 # endif | 2739 # endif |
2596 < wp->w_width))) | 2740 < wp->w_width))) |
2597 { | 2741 { |
2598 // Highlight until the right side of the window | 2742 // Highlight until the right side of the window |
2599 c = ' '; | 2743 c = ' '; |
2616 { | 2760 { |
2617 char_attr = HL_ATTR(diff_hlf); | 2761 char_attr = HL_ATTR(diff_hlf); |
2618 if (wp->w_p_cul && lnum == wp->w_cursor.lnum | 2762 if (wp->w_p_cul && lnum == wp->w_cursor.lnum |
2619 && wp->w_p_culopt_flags != CULOPT_NBR | 2763 && wp->w_p_culopt_flags != CULOPT_NBR |
2620 && (!cul_screenline | 2764 && (!cul_screenline |
2621 || (vcol >= left_curline_col | 2765 || (wlv.vcol >= left_curline_col |
2622 && vcol <= right_curline_col))) | 2766 && wlv.vcol <= right_curline_col))) |
2623 char_attr = hl_combine_attr( | 2767 char_attr = hl_combine_attr( |
2624 char_attr, HL_ATTR(HLF_CUL)); | 2768 char_attr, HL_ATTR(HLF_CUL)); |
2625 } | 2769 } |
2626 } | 2770 } |
2627 # endif | 2771 # endif |
2628 # ifdef FEAT_TERMINAL | 2772 # ifdef FEAT_TERMINAL |
2629 if (win_attr != 0) | 2773 if (wlv.win_attr != 0) |
2630 { | 2774 { |
2631 char_attr = win_attr; | 2775 char_attr = wlv.win_attr; |
2632 if (wp->w_p_cul && lnum == wp->w_cursor.lnum | 2776 if (wp->w_p_cul && lnum == wp->w_cursor.lnum |
2633 && wp->w_p_culopt_flags != CULOPT_NBR) | 2777 && wp->w_p_culopt_flags != CULOPT_NBR) |
2634 { | 2778 { |
2635 if (!cul_screenline || (vcol >= left_curline_col | 2779 if (!cul_screenline || (wlv.vcol >= left_curline_col |
2636 && vcol <= right_curline_col)) | 2780 && wlv.vcol <= right_curline_col)) |
2637 char_attr = hl_combine_attr( | 2781 char_attr = hl_combine_attr( |
2638 char_attr, HL_ATTR(HLF_CUL)); | 2782 char_attr, HL_ATTR(HLF_CUL)); |
2639 } | 2783 } |
2640 else if (line_attr) | 2784 else if (line_attr) |
2641 char_attr = hl_combine_attr(char_attr, line_attr); | 2785 char_attr = hl_combine_attr(char_attr, line_attr); |
2674 c = ' '; | 2818 c = ' '; |
2675 | 2819 |
2676 prev_syntax_id = syntax_seqnr; | 2820 prev_syntax_id = syntax_seqnr; |
2677 | 2821 |
2678 if (n_extra > 0) | 2822 if (n_extra > 0) |
2679 vcol_off += n_extra; | 2823 wlv.vcol_off += n_extra; |
2680 vcol += n_extra; | 2824 wlv.vcol += n_extra; |
2681 if (wp->w_p_wrap && n_extra > 0) | 2825 if (wp->w_p_wrap && n_extra > 0) |
2682 { | 2826 { |
2683 # ifdef FEAT_RIGHTLEFT | 2827 # ifdef FEAT_RIGHTLEFT |
2684 if (wp->w_p_rl) | 2828 if (wp->w_p_rl) |
2685 { | 2829 { |
2686 col -= n_extra; | 2830 wlv.col -= n_extra; |
2687 boguscols -= n_extra; | 2831 wlv.boguscols -= n_extra; |
2688 } | 2832 } |
2689 else | 2833 else |
2690 # endif | 2834 # endif |
2691 { | 2835 { |
2692 boguscols += n_extra; | 2836 wlv.boguscols += n_extra; |
2693 col += n_extra; | 2837 wlv.col += n_extra; |
2694 } | 2838 } |
2695 } | 2839 } |
2696 n_extra = 0; | 2840 n_extra = 0; |
2697 n_attr = 0; | 2841 n_attr = 0; |
2698 } | 2842 } |
2728 // In the cursor line and we may be concealing characters: correct | 2872 // In the cursor line and we may be concealing characters: correct |
2729 // the cursor column when we reach its position. | 2873 // the cursor column when we reach its position. |
2730 if (!did_wcol && draw_state == WL_LINE | 2874 if (!did_wcol && draw_state == WL_LINE |
2731 && wp == curwin && lnum == wp->w_cursor.lnum | 2875 && wp == curwin && lnum == wp->w_cursor.lnum |
2732 && conceal_cursor_line(wp) | 2876 && conceal_cursor_line(wp) |
2733 && (int)wp->w_virtcol <= vcol + n_skip) | 2877 && (int)wp->w_virtcol <= wlv.vcol + n_skip) |
2734 { | 2878 { |
2735 # ifdef FEAT_RIGHTLEFT | 2879 # ifdef FEAT_RIGHTLEFT |
2736 if (wp->w_p_rl) | 2880 if (wp->w_p_rl) |
2737 wp->w_wcol = wp->w_width - col + boguscols - 1; | 2881 wp->w_wcol = wp->w_width - wlv.col + wlv.boguscols - 1; |
2738 else | 2882 else |
2739 # endif | 2883 # endif |
2740 wp->w_wcol = col - boguscols; | 2884 wp->w_wcol = wlv.col - wlv.boguscols; |
2741 wp->w_wrow = row; | 2885 wp->w_wrow = wlv.row; |
2742 did_wcol = TRUE; | 2886 did_wcol = TRUE; |
2743 curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL; | 2887 curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL; |
2744 # ifdef FEAT_PROP_POPUP | 2888 # ifdef FEAT_PROP_POPUP |
2745 curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED); | 2889 curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED); |
2746 # endif | 2890 # endif |
2777 | 2921 |
2778 if (preedit_end_col == MAXCOL) | 2922 if (preedit_end_col == MAXCOL) |
2779 getvcol(curwin, &(wp->w_cursor), &tcol, NULL, NULL); | 2923 getvcol(curwin, &(wp->w_cursor), &tcol, NULL, NULL); |
2780 else | 2924 else |
2781 tcol = preedit_end_col; | 2925 tcol = preedit_end_col; |
2782 if ((long)preedit_start_col <= vcol && vcol < (long)tcol) | 2926 if ((long)preedit_start_col <= wlv.vcol && wlv.vcol < (long)tcol) |
2783 { | 2927 { |
2784 if (feedback_old_attr < 0) | 2928 if (feedback_old_attr < 0) |
2785 { | 2929 { |
2786 feedback_col = 0; | 2930 feedback_col = 0; |
2787 feedback_old_attr = char_attr; | 2931 feedback_old_attr = char_attr; |
2803 // character of the line and the user wants us to show us a | 2947 // character of the line and the user wants us to show us a |
2804 // special character (via 'listchars' option "precedes:<char>". | 2948 // special character (via 'listchars' option "precedes:<char>". |
2805 if (lcs_prec_todo != NUL | 2949 if (lcs_prec_todo != NUL |
2806 && wp->w_p_list | 2950 && wp->w_p_list |
2807 && (wp->w_p_wrap ? | 2951 && (wp->w_p_wrap ? |
2808 (wp->w_skipcol > 0 && row == 0) : | 2952 (wp->w_skipcol > 0 && wlv.row == 0) : |
2809 wp->w_leftcol > 0) | 2953 wp->w_leftcol > 0) |
2810 #ifdef FEAT_DIFF | 2954 #ifdef FEAT_DIFF |
2811 && filler_todo <= 0 | 2955 && filler_todo <= 0 |
2812 #endif | 2956 #endif |
2813 && draw_state > WL_NR | 2957 && draw_state > WL_NR |
2821 // character, need to fill up half the character. | 2965 // character, need to fill up half the character. |
2822 c_extra = MB_FILLER_CHAR; | 2966 c_extra = MB_FILLER_CHAR; |
2823 c_final = NUL; | 2967 c_final = NUL; |
2824 n_extra = 1; | 2968 n_extra = 1; |
2825 n_attr = 2; | 2969 n_attr = 2; |
2826 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT)); | 2970 extra_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT)); |
2827 } | 2971 } |
2828 mb_c = c; | 2972 mb_c = c; |
2829 if (enc_utf8 && utf_char2len(c) > 1) | 2973 if (enc_utf8 && utf_char2len(c) > 1) |
2830 { | 2974 { |
2831 mb_utf8 = TRUE; | 2975 mb_utf8 = TRUE; |
2835 else | 2979 else |
2836 mb_utf8 = FALSE; // don't draw as UTF-8 | 2980 mb_utf8 = FALSE; // don't draw as UTF-8 |
2837 if (!attr_pri) | 2981 if (!attr_pri) |
2838 { | 2982 { |
2839 saved_attr3 = char_attr; // save current attr | 2983 saved_attr3 = char_attr; // save current attr |
2840 char_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT)); | 2984 char_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT)); |
2841 n_attr3 = 1; | 2985 n_attr3 = 1; |
2842 } | 2986 } |
2843 } | 2987 } |
2844 | 2988 |
2845 // At end of the text line or just after the last character. | 2989 // At end of the text line or just after the last character. |
2846 if ((c == NUL | 2990 if ((c == NUL |
2847 #if defined(LINE_ATTR) | 2991 #if defined(LINE_ATTR) |
2848 || did_line_attr == 1 | 2992 || did_line_attr == 1 |
2849 #endif | 2993 #endif |
2850 ) && eol_hl_off == 0) | 2994 ) && wlv.eol_hl_off == 0) |
2851 { | 2995 { |
2852 #ifdef FEAT_SEARCH_EXTRA | 2996 #ifdef FEAT_SEARCH_EXTRA |
2853 // flag to indicate whether prevcol equals startcol of search_hl or | 2997 // flag to indicate whether prevcol equals startcol of search_hl or |
2854 // one of the matches | 2998 // one of the matches |
2855 int prevcol_hl_flag = get_prevcol_hl_flag(wp, &screen_search_hl, | 2999 int prevcol_hl_flag = get_prevcol_hl_flag(wp, &screen_search_hl, |
2858 // Invert at least one char, used for Visual and empty line or | 3002 // Invert at least one char, used for Visual and empty line or |
2859 // highlight match at end of line. If it's beyond the last | 3003 // highlight match at end of line. If it's beyond the last |
2860 // char on the screen, just overwrite that one (tricky!) Not | 3004 // char on the screen, just overwrite that one (tricky!) Not |
2861 // needed when a '$' was displayed for 'list'. | 3005 // needed when a '$' was displayed for 'list'. |
2862 if (wp->w_lcs_chars.eol == lcs_eol_one | 3006 if (wp->w_lcs_chars.eol == lcs_eol_one |
2863 && ((area_attr != 0 && vcol == fromcol | 3007 && ((area_attr != 0 && wlv.vcol == fromcol |
2864 && (VIsual_mode != Ctrl_V | 3008 && (VIsual_mode != Ctrl_V |
2865 || lnum == VIsual.lnum | 3009 || lnum == VIsual.lnum |
2866 || lnum == curwin->w_cursor.lnum) | 3010 || lnum == curwin->w_cursor.lnum) |
2867 && c == NUL) | 3011 && c == NUL) |
2868 #ifdef FEAT_SEARCH_EXTRA | 3012 #ifdef FEAT_SEARCH_EXTRA |
2885 int n = 0; | 3029 int n = 0; |
2886 | 3030 |
2887 #ifdef FEAT_RIGHTLEFT | 3031 #ifdef FEAT_RIGHTLEFT |
2888 if (wp->w_p_rl) | 3032 if (wp->w_p_rl) |
2889 { | 3033 { |
2890 if (col < 0) | 3034 if (wlv.col < 0) |
2891 n = 1; | 3035 n = 1; |
2892 } | 3036 } |
2893 else | 3037 else |
2894 #endif | 3038 #endif |
2895 { | 3039 { |
2896 if (col >= wp->w_width) | 3040 if (wlv.col >= wp->w_width) |
2897 n = -1; | 3041 n = -1; |
2898 } | 3042 } |
2899 if (n != 0) | 3043 if (n != 0) |
2900 { | 3044 { |
2901 // At the window boundary, highlight the last character | 3045 // At the window boundary, highlight the last character |
2902 // instead (better than nothing). | 3046 // instead (better than nothing). |
2903 off += n; | 3047 wlv.off += n; |
2904 col += n; | 3048 wlv.col += n; |
2905 } | 3049 } |
2906 else | 3050 else |
2907 { | 3051 { |
2908 // Add a blank character to highlight. | 3052 // Add a blank character to highlight. |
2909 ScreenLines[off] = ' '; | 3053 ScreenLines[wlv.off] = ' '; |
2910 if (enc_utf8) | 3054 if (enc_utf8) |
2911 ScreenLinesUC[off] = 0; | 3055 ScreenLinesUC[wlv.off] = 0; |
2912 } | 3056 } |
2913 #ifdef FEAT_SEARCH_EXTRA | 3057 #ifdef FEAT_SEARCH_EXTRA |
2914 if (area_attr == 0) | 3058 if (area_attr == 0) |
2915 { | 3059 { |
2916 // Use attributes from match with highest priority among | 3060 // Use attributes from match with highest priority among |
2917 // 'search_hl' and the match list. | 3061 // 'search_hl' and the match list. |
2918 get_search_match_hl(wp, &screen_search_hl, | 3062 get_search_match_hl(wp, &screen_search_hl, |
2919 (long)(ptr - line), &char_attr); | 3063 (long)(ptr - line), &char_attr); |
2920 } | 3064 } |
2921 #endif | 3065 #endif |
2922 ScreenAttrs[off] = char_attr; | 3066 ScreenAttrs[wlv.off] = char_attr; |
2923 ScreenCols[off] = MAXCOL; | 3067 ScreenCols[wlv.off] = MAXCOL; |
2924 #ifdef FEAT_RIGHTLEFT | 3068 #ifdef FEAT_RIGHTLEFT |
2925 if (wp->w_p_rl) | 3069 if (wp->w_p_rl) |
2926 { | 3070 { |
2927 --col; | 3071 --wlv.col; |
2928 --off; | 3072 --wlv.off; |
2929 } | 3073 } |
2930 else | 3074 else |
2931 #endif | 3075 #endif |
2932 { | 3076 { |
2933 ++col; | 3077 ++wlv.col; |
2934 ++off; | 3078 ++wlv.off; |
2935 } | 3079 } |
2936 ++vcol; | 3080 ++wlv.vcol; |
2937 eol_hl_off = 1; | 3081 wlv.eol_hl_off = 1; |
2938 } | 3082 } |
2939 } | 3083 } |
2940 | 3084 |
2941 // At end of the text line. | 3085 // At end of the text line. |
2942 if (c == NUL) | 3086 if (c == NUL) |
2943 { | 3087 { |
2944 #ifdef FEAT_SYN_HL | 3088 draw_screen_line(wp, &wlv); |
2945 // Highlight 'cursorcolumn' & 'colorcolumn' past end of the line. | |
2946 if (wp->w_p_wrap) | |
2947 v = wp->w_skipcol; | |
2948 else | |
2949 v = wp->w_leftcol; | |
2950 | |
2951 // check if line ends before left margin | |
2952 if (vcol < v + col - win_col_off(wp)) | |
2953 vcol = v + col - win_col_off(wp); | |
2954 #ifdef FEAT_CONCEAL | |
2955 // Get rid of the boguscols now, we want to draw until the right | |
2956 // edge for 'cursorcolumn'. | |
2957 col -= boguscols; | |
2958 boguscols = 0; | |
2959 #endif | |
2960 | |
2961 if (draw_color_col) | |
2962 draw_color_col = advance_color_col(VCOL_HLC, &color_cols); | |
2963 | |
2964 if (((wp->w_p_cuc | |
2965 && (int)wp->w_virtcol >= VCOL_HLC - eol_hl_off | |
2966 && (int)wp->w_virtcol < | |
2967 (long)wp->w_width * (row - startrow + 1) + v | |
2968 && lnum != wp->w_cursor.lnum) | |
2969 || draw_color_col | |
2970 || win_attr != 0) | |
2971 # ifdef FEAT_RIGHTLEFT | |
2972 && !wp->w_p_rl | |
2973 # endif | |
2974 ) | |
2975 { | |
2976 int rightmost_vcol = 0; | |
2977 int i; | |
2978 | |
2979 if (wp->w_p_cuc) | |
2980 rightmost_vcol = wp->w_virtcol; | |
2981 if (draw_color_col) | |
2982 // determine rightmost colorcolumn to possibly draw | |
2983 for (i = 0; color_cols[i] >= 0; ++i) | |
2984 if (rightmost_vcol < color_cols[i]) | |
2985 rightmost_vcol = color_cols[i]; | |
2986 | |
2987 while (col < wp->w_width) | |
2988 { | |
2989 ScreenLines[off] = ' '; | |
2990 if (enc_utf8) | |
2991 ScreenLinesUC[off] = 0; | |
2992 ScreenCols[off] = MAXCOL; | |
2993 ++col; | |
2994 if (draw_color_col) | |
2995 draw_color_col = advance_color_col(VCOL_HLC, | |
2996 &color_cols); | |
2997 | |
2998 if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol) | |
2999 ScreenAttrs[off++] = HL_ATTR(HLF_CUC); | |
3000 else if (draw_color_col && VCOL_HLC == *color_cols) | |
3001 ScreenAttrs[off++] = HL_ATTR(HLF_MC); | |
3002 else | |
3003 ScreenAttrs[off++] = win_attr; | |
3004 | |
3005 if (VCOL_HLC >= rightmost_vcol && win_attr == 0) | |
3006 break; | |
3007 | |
3008 ++vcol; | |
3009 } | |
3010 } | |
3011 #endif | |
3012 | |
3013 screen_line(wp, screen_row, wp->w_wincol, col, | |
3014 wp->w_width, screen_line_flags); | |
3015 row++; | |
3016 | 3089 |
3017 // Update w_cline_height and w_cline_folded if the cursor line was | 3090 // Update w_cline_height and w_cline_folded if the cursor line was |
3018 // updated (saves a call to plines() later). | 3091 // updated (saves a call to plines() later). |
3019 if (wp == curwin && lnum == curwin->w_cursor.lnum) | 3092 if (wp == curwin && lnum == curwin->w_cursor.lnum) |
3020 { | 3093 { |
3021 curwin->w_cline_row = startrow; | 3094 curwin->w_cline_row = startrow; |
3022 curwin->w_cline_height = row - startrow; | 3095 curwin->w_cline_height = wlv.row - startrow; |
3023 #ifdef FEAT_FOLDING | 3096 #ifdef FEAT_FOLDING |
3024 curwin->w_cline_folded = FALSE; | 3097 curwin->w_cline_folded = FALSE; |
3025 #endif | 3098 #endif |
3026 curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW); | 3099 curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW); |
3027 } | 3100 } |
3028 | |
3029 break; | 3101 break; |
3030 } | 3102 } |
3031 | 3103 |
3032 // Show "extends" character from 'listchars' if beyond the line end and | 3104 // Show "extends" character from 'listchars' if beyond the line end and |
3033 // 'list' is set. | 3105 // 'list' is set. |
3038 #ifdef FEAT_DIFF | 3110 #ifdef FEAT_DIFF |
3039 && filler_todo <= 0 | 3111 && filler_todo <= 0 |
3040 #endif | 3112 #endif |
3041 && ( | 3113 && ( |
3042 #ifdef FEAT_RIGHTLEFT | 3114 #ifdef FEAT_RIGHTLEFT |
3043 wp->w_p_rl ? col == 0 : | 3115 wp->w_p_rl ? wlv.col == 0 : |
3044 #endif | 3116 #endif |
3045 col == wp->w_width - 1) | 3117 wlv.col == wp->w_width - 1) |
3046 && (*ptr != NUL | 3118 && (*ptr != NUL |
3047 || (wp->w_p_list && lcs_eol_one > 0) | 3119 || (wp->w_p_list && lcs_eol_one > 0) |
3048 || (n_extra && (c_extra != NUL || *p_extra != NUL)))) | 3120 || (n_extra && (c_extra != NUL || *p_extra != NUL)))) |
3049 { | 3121 { |
3050 c = wp->w_lcs_chars.ext; | 3122 c = wp->w_lcs_chars.ext; |
3051 char_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_AT)); | 3123 char_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT)); |
3052 mb_c = c; | 3124 mb_c = c; |
3053 if (enc_utf8 && utf_char2len(c) > 1) | 3125 if (enc_utf8 && utf_char2len(c) > 1) |
3054 { | 3126 { |
3055 mb_utf8 = TRUE; | 3127 mb_utf8 = TRUE; |
3056 u8cc[0] = 0; | 3128 u8cc[0] = 0; |
3060 mb_utf8 = FALSE; | 3132 mb_utf8 = FALSE; |
3061 } | 3133 } |
3062 | 3134 |
3063 #ifdef FEAT_SYN_HL | 3135 #ifdef FEAT_SYN_HL |
3064 // advance to the next 'colorcolumn' | 3136 // advance to the next 'colorcolumn' |
3065 if (draw_color_col) | 3137 if (wlv.draw_color_col) |
3066 draw_color_col = advance_color_col(VCOL_HLC, &color_cols); | 3138 wlv.draw_color_col = advance_color_col(VCOL_HLC, &wlv.color_cols); |
3067 | 3139 |
3068 // Highlight the cursor column if 'cursorcolumn' is set. But don't | 3140 // Highlight the cursor column if 'cursorcolumn' is set. But don't |
3069 // highlight the cursor position itself. | 3141 // highlight the cursor position itself. |
3070 // Also highlight the 'colorcolumn' if it is different than | 3142 // Also highlight the 'colorcolumn' if it is different than |
3071 // 'cursorcolumn' | 3143 // 'cursorcolumn' |
3085 && lnum != wp->w_cursor.lnum) | 3157 && lnum != wp->w_cursor.lnum) |
3086 { | 3158 { |
3087 vcol_save_attr = char_attr; | 3159 vcol_save_attr = char_attr; |
3088 char_attr = hl_combine_attr(char_attr, HL_ATTR(HLF_CUC)); | 3160 char_attr = hl_combine_attr(char_attr, HL_ATTR(HLF_CUC)); |
3089 } | 3161 } |
3090 else if (draw_color_col && VCOL_HLC == *color_cols) | 3162 else if (wlv.draw_color_col && VCOL_HLC == *wlv.color_cols) |
3091 { | 3163 { |
3092 vcol_save_attr = char_attr; | 3164 vcol_save_attr = char_attr; |
3093 char_attr = hl_combine_attr(char_attr, HL_ATTR(HLF_MC)); | 3165 char_attr = hl_combine_attr(char_attr, HL_ATTR(HLF_MC)); |
3094 } | 3166 } |
3095 } | 3167 } |
3096 #endif | 3168 #endif |
3097 | 3169 |
3098 // Store character to be displayed. | 3170 // Store character to be displayed. |
3099 // Skip characters that are left of the screen for 'nowrap'. | 3171 // Skip characters that are left of the screen for 'nowrap'. |
3100 vcol_prev = vcol; | 3172 vcol_prev = wlv.vcol; |
3101 if (draw_state < WL_LINE || n_skip <= 0) | 3173 if (draw_state < WL_LINE || n_skip <= 0) |
3102 { | 3174 { |
3103 // Store the character. | 3175 // Store the character. |
3104 #if defined(FEAT_RIGHTLEFT) | 3176 #if defined(FEAT_RIGHTLEFT) |
3105 if (has_mbyte && wp->w_p_rl && (*mb_char2cells)(mb_c) > 1) | 3177 if (has_mbyte && wp->w_p_rl && (*mb_char2cells)(mb_c) > 1) |
3106 { | 3178 { |
3107 // A double-wide character is: put first half in left cell. | 3179 // A double-wide character is: put first half in left cell. |
3108 --off; | 3180 --wlv.off; |
3109 --col; | 3181 --wlv.col; |
3110 } | 3182 } |
3111 #endif | 3183 #endif |
3112 ScreenLines[off] = c; | 3184 ScreenLines[wlv.off] = c; |
3113 if (enc_dbcs == DBCS_JPNU) | 3185 if (enc_dbcs == DBCS_JPNU) |
3114 { | 3186 { |
3115 if ((mb_c & 0xff00) == 0x8e00) | 3187 if ((mb_c & 0xff00) == 0x8e00) |
3116 ScreenLines[off] = 0x8e; | 3188 ScreenLines[wlv.off] = 0x8e; |
3117 ScreenLines2[off] = mb_c & 0xff; | 3189 ScreenLines2[wlv.off] = mb_c & 0xff; |
3118 } | 3190 } |
3119 else if (enc_utf8) | 3191 else if (enc_utf8) |
3120 { | 3192 { |
3121 if (mb_utf8) | 3193 if (mb_utf8) |
3122 { | 3194 { |
3123 int i; | 3195 int i; |
3124 | 3196 |
3125 ScreenLinesUC[off] = mb_c; | 3197 ScreenLinesUC[wlv.off] = mb_c; |
3126 if ((c & 0xff) == 0) | 3198 if ((c & 0xff) == 0) |
3127 ScreenLines[off] = 0x80; // avoid storing zero | 3199 ScreenLines[wlv.off] = 0x80; // avoid storing zero |
3128 for (i = 0; i < Screen_mco; ++i) | 3200 for (i = 0; i < Screen_mco; ++i) |
3129 { | 3201 { |
3130 ScreenLinesC[i][off] = u8cc[i]; | 3202 ScreenLinesC[i][wlv.off] = u8cc[i]; |
3131 if (u8cc[i] == 0) | 3203 if (u8cc[i] == 0) |
3132 break; | 3204 break; |
3133 } | 3205 } |
3134 } | 3206 } |
3135 else | 3207 else |
3136 ScreenLinesUC[off] = 0; | 3208 ScreenLinesUC[wlv.off] = 0; |
3137 } | 3209 } |
3138 if (multi_attr) | 3210 if (multi_attr) |
3139 { | 3211 { |
3140 ScreenAttrs[off] = multi_attr; | 3212 ScreenAttrs[wlv.off] = multi_attr; |
3141 multi_attr = 0; | 3213 multi_attr = 0; |
3142 } | 3214 } |
3143 else | 3215 else |
3144 ScreenAttrs[off] = char_attr; | 3216 ScreenAttrs[wlv.off] = char_attr; |
3145 | 3217 |
3146 ScreenCols[off] = (colnr_T)(prev_ptr - line); | 3218 ScreenCols[wlv.off] = (colnr_T)(prev_ptr - line); |
3147 | 3219 |
3148 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) | 3220 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) |
3149 { | 3221 { |
3150 // Need to fill two screen columns. | 3222 // Need to fill two screen columns. |
3151 ++off; | 3223 ++wlv.off; |
3152 ++col; | 3224 ++wlv.col; |
3153 if (enc_utf8) | 3225 if (enc_utf8) |
3154 // UTF-8: Put a 0 in the second screen char. | 3226 // UTF-8: Put a 0 in the second screen char. |
3155 ScreenLines[off] = 0; | 3227 ScreenLines[wlv.off] = 0; |
3156 else | 3228 else |
3157 // DBCS: Put second byte in the second screen char. | 3229 // DBCS: Put second byte in the second screen char. |
3158 ScreenLines[off] = mb_c & 0xff; | 3230 ScreenLines[wlv.off] = mb_c & 0xff; |
3159 if (draw_state > WL_NR | 3231 if (draw_state > WL_NR |
3160 #ifdef FEAT_DIFF | 3232 #ifdef FEAT_DIFF |
3161 && filler_todo <= 0 | 3233 && filler_todo <= 0 |
3162 #endif | 3234 #endif |
3163 ) | 3235 ) |
3164 ++vcol; | 3236 ++wlv.vcol; |
3165 // When "tocol" is halfway a character, set it to the end of | 3237 // When "tocol" is halfway a character, set it to the end of |
3166 // the character, otherwise highlighting won't stop. | 3238 // the character, otherwise highlighting won't stop. |
3167 if (tocol == vcol) | 3239 if (tocol == wlv.vcol) |
3168 ++tocol; | 3240 ++tocol; |
3169 | 3241 |
3170 ScreenCols[off] = (colnr_T)(prev_ptr - line); | 3242 ScreenCols[wlv.off] = (colnr_T)(prev_ptr - line); |
3171 | 3243 |
3172 #ifdef FEAT_RIGHTLEFT | 3244 #ifdef FEAT_RIGHTLEFT |
3173 if (wp->w_p_rl) | 3245 if (wp->w_p_rl) |
3174 { | 3246 { |
3175 // now it's time to backup one cell | 3247 // now it's time to backup one cell |
3176 --off; | 3248 --wlv.off; |
3177 --col; | 3249 --wlv.col; |
3178 } | 3250 } |
3179 #endif | 3251 #endif |
3180 } | 3252 } |
3181 #ifdef FEAT_RIGHTLEFT | 3253 #ifdef FEAT_RIGHTLEFT |
3182 if (wp->w_p_rl) | 3254 if (wp->w_p_rl) |
3183 { | 3255 { |
3184 --off; | 3256 --wlv.off; |
3185 --col; | 3257 --wlv.col; |
3186 } | 3258 } |
3187 else | 3259 else |
3188 #endif | 3260 #endif |
3189 { | 3261 { |
3190 ++off; | 3262 ++wlv.off; |
3191 ++col; | 3263 ++wlv.col; |
3192 } | 3264 } |
3193 } | 3265 } |
3194 #ifdef FEAT_CONCEAL | 3266 #ifdef FEAT_CONCEAL |
3195 else if (wp->w_p_cole > 0 && is_concealing) | 3267 else if (wp->w_p_cole > 0 && is_concealing) |
3196 { | 3268 { |
3197 --n_skip; | 3269 --n_skip; |
3198 ++vcol_off; | 3270 ++wlv.vcol_off; |
3199 if (n_extra > 0) | 3271 if (n_extra > 0) |
3200 vcol_off += n_extra; | 3272 wlv.vcol_off += n_extra; |
3201 if (wp->w_p_wrap) | 3273 if (wp->w_p_wrap) |
3202 { | 3274 { |
3203 // Special voodoo required if 'wrap' is on. | 3275 // Special voodoo required if 'wrap' is on. |
3204 // | 3276 // |
3205 // Advance the column indicator to force the line | 3277 // Advance the column indicator to force the line |
3206 // drawing to wrap early. This will make the line | 3278 // drawing to wrap early. This will make the line |
3207 // take up the same screen space when parts are concealed, | 3279 // take up the same screen space when parts are concealed, |
3208 // so that cursor line computations aren't messed up. | 3280 // so that cursor line computations aren't messed up. |
3209 // | 3281 // |
3210 // To avoid the fictitious advance of 'col' causing | 3282 // To avoid the fictitious advance of 'wlv.col' causing |
3211 // trailing junk to be written out of the screen line | 3283 // trailing junk to be written out of the screen line |
3212 // we are building, 'boguscols' keeps track of the number | 3284 // we are building, 'boguscols' keeps track of the number |
3213 // of bad columns we have advanced. | 3285 // of bad columns we have advanced. |
3214 if (n_extra > 0) | 3286 if (n_extra > 0) |
3215 { | 3287 { |
3216 vcol += n_extra; | 3288 wlv.vcol += n_extra; |
3217 # ifdef FEAT_RIGHTLEFT | 3289 # ifdef FEAT_RIGHTLEFT |
3218 if (wp->w_p_rl) | 3290 if (wp->w_p_rl) |
3219 { | 3291 { |
3220 col -= n_extra; | 3292 wlv.col -= n_extra; |
3221 boguscols -= n_extra; | 3293 wlv.boguscols -= n_extra; |
3222 } | 3294 } |
3223 else | 3295 else |
3224 # endif | 3296 # endif |
3225 { | 3297 { |
3226 col += n_extra; | 3298 wlv.col += n_extra; |
3227 boguscols += n_extra; | 3299 wlv.boguscols += n_extra; |
3228 } | 3300 } |
3229 n_extra = 0; | 3301 n_extra = 0; |
3230 n_attr = 0; | 3302 n_attr = 0; |
3231 } | 3303 } |
3232 | 3304 |
3235 { | 3307 { |
3236 // Need to fill two screen columns. | 3308 // Need to fill two screen columns. |
3237 # ifdef FEAT_RIGHTLEFT | 3309 # ifdef FEAT_RIGHTLEFT |
3238 if (wp->w_p_rl) | 3310 if (wp->w_p_rl) |
3239 { | 3311 { |
3240 --boguscols; | 3312 --wlv.boguscols; |
3241 --col; | 3313 --wlv.col; |
3242 } | 3314 } |
3243 else | 3315 else |
3244 # endif | 3316 # endif |
3245 { | 3317 { |
3246 ++boguscols; | 3318 ++wlv.boguscols; |
3247 ++col; | 3319 ++wlv.col; |
3248 } | 3320 } |
3249 } | 3321 } |
3250 | 3322 |
3251 # ifdef FEAT_RIGHTLEFT | 3323 # ifdef FEAT_RIGHTLEFT |
3252 if (wp->w_p_rl) | 3324 if (wp->w_p_rl) |
3253 { | 3325 { |
3254 --boguscols; | 3326 --wlv.boguscols; |
3255 --col; | 3327 --wlv.col; |
3256 } | 3328 } |
3257 else | 3329 else |
3258 # endif | 3330 # endif |
3259 { | 3331 { |
3260 ++boguscols; | 3332 ++wlv.boguscols; |
3261 ++col; | 3333 ++wlv.col; |
3262 } | 3334 } |
3263 } | 3335 } |
3264 else | 3336 else |
3265 { | 3337 { |
3266 if (n_extra > 0) | 3338 if (n_extra > 0) |
3267 { | 3339 { |
3268 vcol += n_extra; | 3340 wlv.vcol += n_extra; |
3269 n_extra = 0; | 3341 n_extra = 0; |
3270 n_attr = 0; | 3342 n_attr = 0; |
3271 } | 3343 } |
3272 } | 3344 } |
3273 | 3345 |
3274 } | 3346 } |
3275 #endif // FEAT_CONCEAL | 3347 #endif // FEAT_CONCEAL |
3276 else | 3348 else |
3277 --n_skip; | 3349 --n_skip; |
3278 | 3350 |
3279 // Only advance the "vcol" when after the 'number' or 'relativenumber' | 3351 // Only advance the "wlv.vcol" when after the 'number' or |
3280 // column. | 3352 // 'relativenumber' column. |
3281 if (draw_state > WL_NR | 3353 if (draw_state > WL_NR |
3282 #ifdef FEAT_DIFF | 3354 #ifdef FEAT_DIFF |
3283 && filler_todo <= 0 | 3355 && filler_todo <= 0 |
3284 #endif | 3356 #endif |
3285 ) | 3357 ) |
3286 ++vcol; | 3358 ++wlv.vcol; |
3287 | 3359 |
3288 #ifdef FEAT_SYN_HL | 3360 #ifdef FEAT_SYN_HL |
3289 if (vcol_save_attr >= 0) | 3361 if (vcol_save_attr >= 0) |
3290 char_attr = vcol_save_attr; | 3362 char_attr = vcol_save_attr; |
3291 #endif | 3363 #endif |
3303 | 3375 |
3304 // At end of screen line and there is more to come: Display the line | 3376 // At end of screen line and there is more to come: Display the line |
3305 // so far. If there is no more to display it is caught above. | 3377 // so far. If there is no more to display it is caught above. |
3306 if (( | 3378 if (( |
3307 #ifdef FEAT_RIGHTLEFT | 3379 #ifdef FEAT_RIGHTLEFT |
3308 wp->w_p_rl ? (col < 0) : | 3380 wp->w_p_rl ? (wlv.col < 0) : |
3309 #endif | 3381 #endif |
3310 (col >= wp->w_width)) | 3382 (wlv.col >= wp->w_width)) |
3311 && (draw_state != WL_LINE | 3383 && (draw_state != WL_LINE |
3312 || *ptr != NUL | 3384 || *ptr != NUL |
3313 #ifdef FEAT_DIFF | 3385 #ifdef FEAT_DIFF |
3314 || filler_todo > 0 | 3386 || filler_todo > 0 |
3315 #endif | 3387 #endif |
3320 && p_extra != at_end_str) | 3392 && p_extra != at_end_str) |
3321 || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL))) | 3393 || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL))) |
3322 ) | 3394 ) |
3323 { | 3395 { |
3324 #ifdef FEAT_CONCEAL | 3396 #ifdef FEAT_CONCEAL |
3325 screen_line(wp, screen_row, wp->w_wincol, col - boguscols, | 3397 screen_line(wp, wlv.screen_row, wp->w_wincol, |
3326 wp->w_width, screen_line_flags); | 3398 wlv.col - wlv.boguscols, |
3327 boguscols = 0; | 3399 wp->w_width, wlv.screen_line_flags); |
3400 wlv.boguscols = 0; | |
3328 #else | 3401 #else |
3329 screen_line(wp, screen_row, wp->w_wincol, col, | 3402 screen_line(wp, wlv.screen_row, wp->w_wincol, wlv.col, |
3330 wp->w_width, screen_line_flags); | 3403 wp->w_width, wlv.screen_line_flags); |
3331 #endif | 3404 #endif |
3332 ++row; | 3405 ++wlv.row; |
3333 ++screen_row; | 3406 ++wlv.screen_row; |
3334 | 3407 |
3335 // When not wrapping and finished diff lines, or when displayed | 3408 // When not wrapping and finished diff lines, or when displayed |
3336 // '$' and highlighting until last column, break here. | 3409 // '$' and highlighting until last column, break here. |
3337 if ((!wp->w_p_wrap | 3410 if ((!wp->w_p_wrap |
3338 #ifdef FEAT_DIFF | 3411 #ifdef FEAT_DIFF |
3349 #ifdef FEAT_DIFF | 3422 #ifdef FEAT_DIFF |
3350 && filler_todo <= 0 | 3423 && filler_todo <= 0 |
3351 #endif | 3424 #endif |
3352 ) | 3425 ) |
3353 { | 3426 { |
3354 win_draw_end(wp, '@', ' ', TRUE, row, wp->w_height, HLF_AT); | 3427 win_draw_end(wp, '@', ' ', TRUE, wlv.row, wp->w_height, HLF_AT); |
3355 draw_vsep_win(wp, row); | 3428 draw_vsep_win(wp, wlv.row); |
3356 row = endrow; | 3429 wlv.row = endrow; |
3357 } | 3430 } |
3358 | 3431 |
3359 // When line got too long for screen break here. | 3432 // When line got too long for screen break here. |
3360 if (row == endrow) | 3433 if (wlv.row == endrow) |
3361 { | 3434 { |
3362 ++row; | 3435 ++wlv.row; |
3363 break; | 3436 break; |
3364 } | 3437 } |
3365 | 3438 |
3366 if (screen_cur_row == screen_row - 1 | 3439 if (screen_cur_row == wlv.screen_row - 1 |
3367 #ifdef FEAT_DIFF | 3440 #ifdef FEAT_DIFF |
3368 && filler_todo <= 0 | 3441 && filler_todo <= 0 |
3369 #endif | 3442 #endif |
3370 #ifdef FEAT_PROP_POPUP | 3443 #ifdef FEAT_PROP_POPUP |
3371 && !text_prop_follows | 3444 && !text_prop_follows |
3372 #endif | 3445 #endif |
3373 && wp->w_width == Columns) | 3446 && wp->w_width == Columns) |
3374 { | 3447 { |
3375 // Remember that the line wraps, used for modeless copy. | 3448 // Remember that the line wraps, used for modeless copy. |
3376 LineWraps[screen_row - 1] = TRUE; | 3449 LineWraps[wlv.screen_row - 1] = TRUE; |
3377 | 3450 |
3378 // Special trick to make copy/paste of wrapped lines work with | 3451 // Special trick to make copy/paste of wrapped lines work with |
3379 // xterm/screen: write an extra character beyond the end of | 3452 // xterm/screen: write an extra character beyond the end of |
3380 // the line. This will work with all terminal types | 3453 // the line. This will work with all terminal types |
3381 // (regardless of the xn,am settings). | 3454 // (regardless of the xn,am settings). |
3388 if (p_tf | 3461 if (p_tf |
3389 #ifdef FEAT_GUI | 3462 #ifdef FEAT_GUI |
3390 && !gui.in_use | 3463 && !gui.in_use |
3391 #endif | 3464 #endif |
3392 && !(has_mbyte | 3465 && !(has_mbyte |
3393 && ((*mb_off2cells)(LineOffset[screen_row], | 3466 && ((*mb_off2cells)(LineOffset[wlv.screen_row], |
3394 LineOffset[screen_row] + screen_Columns) | 3467 LineOffset[wlv.screen_row] + screen_Columns) |
3395 == 2 | 3468 == 2 |
3396 || (*mb_off2cells)(LineOffset[screen_row - 1] | 3469 || (*mb_off2cells)( |
3397 + (int)Columns - 2, | 3470 LineOffset[wlv.screen_row - 1] |
3398 LineOffset[screen_row] + screen_Columns) | 3471 + (int)Columns - 2, |
3399 == 2))) | 3472 LineOffset[wlv.screen_row] |
3473 + screen_Columns) == 2))) | |
3400 { | 3474 { |
3401 // First make sure we are at the end of the screen line, | 3475 // First make sure we are at the end of the screen line, |
3402 // then output the same character again to let the | 3476 // then output the same character again to let the |
3403 // terminal know about the wrap. If the terminal doesn't | 3477 // terminal know about the wrap. If the terminal doesn't |
3404 // auto-wrap, we overwrite the character. | 3478 // auto-wrap, we overwrite the character. |
3405 if (screen_cur_col != wp->w_width) | 3479 if (screen_cur_col != wp->w_width) |
3406 screen_char(LineOffset[screen_row - 1] | 3480 screen_char(LineOffset[wlv.screen_row - 1] |
3407 + (unsigned)Columns - 1, | 3481 + (unsigned)Columns - 1, |
3408 screen_row - 1, (int)(Columns - 1)); | 3482 wlv.screen_row - 1, (int)(Columns - 1)); |
3409 | 3483 |
3410 // When there is a multi-byte character, just output a | 3484 // When there is a multi-byte character, just output a |
3411 // space to keep it simple. | 3485 // space to keep it simple. |
3412 if (has_mbyte && MB_BYTE2LEN(ScreenLines[LineOffset[ | 3486 if (has_mbyte && MB_BYTE2LEN(ScreenLines[LineOffset[ |
3413 screen_row - 1] + (Columns - 1)]) > 1) | 3487 wlv.screen_row - 1] + (Columns - 1)]) > 1) |
3414 out_char(' '); | 3488 out_char(' '); |
3415 else | 3489 else |
3416 out_char(ScreenLines[LineOffset[screen_row - 1] | 3490 out_char(ScreenLines[LineOffset[wlv.screen_row - 1] |
3417 + (Columns - 1)]); | 3491 + (Columns - 1)]); |
3418 // force a redraw of the first char on the next line | 3492 // force a redraw of the first char on the next line |
3419 ScreenAttrs[LineOffset[screen_row]] = (sattr_T)-1; | 3493 ScreenAttrs[LineOffset[wlv.screen_row]] = (sattr_T)-1; |
3420 screen_start(); // don't know where cursor is now | 3494 screen_start(); // don't know where cursor is now |
3421 } | 3495 } |
3422 } | 3496 } |
3423 | 3497 |
3424 col = 0; | 3498 win_line_start(wp, &wlv); |
3425 off = (unsigned)(current_ScreenLine - ScreenLines); | |
3426 #ifdef FEAT_RIGHTLEFT | |
3427 if (wp->w_p_rl) | |
3428 { | |
3429 col = wp->w_width - 1; // col is not used if breaking! | |
3430 off += col; | |
3431 } | |
3432 #endif | |
3433 | 3499 |
3434 // reset the drawing state for the start of a wrapped line | 3500 // reset the drawing state for the start of a wrapped line |
3435 draw_state = WL_START; | 3501 draw_state = WL_START; |
3436 saved_n_extra = n_extra; | 3502 saved_n_extra = n_extra; |
3437 saved_p_extra = p_extra; | 3503 saved_p_extra = p_extra; |
3480 vim_free(text_props); | 3546 vim_free(text_props); |
3481 vim_free(text_prop_idxs); | 3547 vim_free(text_prop_idxs); |
3482 #endif | 3548 #endif |
3483 | 3549 |
3484 vim_free(p_extra_free); | 3550 vim_free(p_extra_free); |
3485 return row; | 3551 return wlv.row; |
3486 } | 3552 } |