comparison src/misc1.c @ 29451:057c26b5c33a v9.0.0067

patch 9.0.0067: cannot show virtual text Commit: https://github.com/vim/vim/commit/7f9969c559b51446632ac7e8f76cde07e7d0078d Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 25 18:13:54 2022 +0100 patch 9.0.0067: cannot show virtual text Problem: Cannot show virtual text. Solution: Initial changes for virtual text support, using text properties.
author Bram Moolenaar <Bram@vim.org>
date Mon, 25 Jul 2022 19:15:06 +0200
parents f8b07c537036
children f1ed6f520d09
comparison
equal deleted inserted replaced
29450:67f31c24291b 29451:057c26b5c33a
395 int width; 395 int width;
396 396
397 s = ml_get_buf(wp->w_buffer, lnum, FALSE); 397 s = ml_get_buf(wp->w_buffer, lnum, FALSE);
398 if (*s == NUL) // empty line 398 if (*s == NUL) // empty line
399 return 1; 399 return 1;
400 col = win_linetabsize(wp, s, (colnr_T)MAXCOL); 400 col = win_linetabsize(wp, lnum, s, (colnr_T)MAXCOL);
401 401
402 /* 402 /*
403 * If list mode is on, then the '$' at the end of the line may take up one 403 * If list mode is on, then the '$' at the end of the line may take up one
404 * extra column. 404 * extra column.
405 */ 405 */
425 */ 425 */
426 int 426 int
427 plines_win_col(win_T *wp, linenr_T lnum, long column) 427 plines_win_col(win_T *wp, linenr_T lnum, long column)
428 { 428 {
429 long col; 429 long col;
430 char_u *s;
431 int lines = 0; 430 int lines = 0;
432 int width; 431 int width;
433 char_u *line; 432 char_u *line;
433 chartabsize_T cts;
434 434
435 #ifdef FEAT_DIFF 435 #ifdef FEAT_DIFF
436 // Check for filler lines above this buffer line. When folded the result 436 // Check for filler lines above this buffer line. When folded the result
437 // is one line anyway. 437 // is one line anyway.
438 lines = diff_check_fill(wp, lnum); 438 lines = diff_check_fill(wp, lnum);
442 return lines + 1; 442 return lines + 1;
443 443
444 if (wp->w_width == 0) 444 if (wp->w_width == 0)
445 return lines + 1; 445 return lines + 1;
446 446
447 line = s = ml_get_buf(wp->w_buffer, lnum, FALSE); 447 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
448 448
449 col = 0; 449 init_chartabsize_arg(&cts, wp, lnum, 0, line, line);
450 while (*s != NUL && --column >= 0) 450 while (*cts.cts_ptr != NUL && --column >= 0)
451 { 451 {
452 col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL); 452 cts.cts_vcol += win_lbr_chartabsize(&cts, NULL);
453 MB_PTR_ADV(s); 453 MB_PTR_ADV(cts.cts_ptr);
454 } 454 }
455 455
456 /* 456 /*
457 * If *s is a TAB, and the TAB is not displayed as ^I, and we're not in 457 * If *cts.cts_ptr is a TAB, and the TAB is not displayed as ^I, and we're
458 * MODE_INSERT state, then col must be adjusted so that it represents the 458 * not in MODE_INSERT state, then col must be adjusted so that it
459 * last screen position of the TAB. This only fixes an error when the TAB 459 * represents the last screen position of the TAB. This only fixes an
460 * wraps from one screen line to the next (when 'columns' is not a multiple 460 * error when the TAB wraps from one screen line to the next (when
461 * of 'ts') -- webb. 461 * 'columns' is not a multiple of 'ts') -- webb.
462 */ 462 */
463 if (*s == TAB && (State & MODE_NORMAL) 463 col = cts.cts_vcol;
464 if (*cts.cts_ptr == TAB && (State & MODE_NORMAL)
464 && (!wp->w_p_list || wp->w_lcs_chars.tab1)) 465 && (!wp->w_p_list || wp->w_lcs_chars.tab1))
465 col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL) - 1; 466 col += win_lbr_chartabsize(&cts, NULL) - 1;
467 clear_chartabsize_arg(&cts);
466 468
467 /* 469 /*
468 * Add column offset for 'number', 'relativenumber', 'foldcolumn', etc. 470 * Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
469 */ 471 */
470 width = wp->w_width - win_col_off(wp); 472 width = wp->w_width - win_col_off(wp);