comparison src/charset.c @ 29560:14b139cbec49 v9.0.0121

patch 9.0.0121: cannot put virtual text after or below a line Commit: https://github.com/vim/vim/commit/b7963df98f9dbbb824713acad2f47c9989fcf8f3 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 31 17:12:43 2022 +0100 patch 9.0.0121: cannot put virtual text after or below a line Problem: Cannot put virtual text after or below a line. Solution: Add "text_align" and "text_wrap" arguments.
author Bram Moolenaar <Bram@vim.org>
date Sun, 31 Jul 2022 18:15:03 +0200
parents 6387e75a4a6b
children a4dcf15f8014
comparison
equal deleted inserted replaced
29559:69ceb540c619 29560:14b139cbec49
769 win_linetabsize(win_T *wp, linenr_T lnum, char_u *line, colnr_T len) 769 win_linetabsize(win_T *wp, linenr_T lnum, char_u *line, colnr_T len)
770 { 770 {
771 chartabsize_T cts; 771 chartabsize_T cts;
772 772
773 init_chartabsize_arg(&cts, wp, lnum, 0, line, line); 773 init_chartabsize_arg(&cts, wp, lnum, 0, line, line);
774 cts.cts_with_trailing = len = MAXCOL;
774 for ( ; *cts.cts_ptr != NUL && (len == MAXCOL || cts.cts_ptr < line + len); 775 for ( ; *cts.cts_ptr != NUL && (len == MAXCOL || cts.cts_ptr < line + len);
775 MB_PTR_ADV(cts.cts_ptr)) 776 MB_PTR_ADV(cts.cts_ptr))
776 cts.cts_vcol += win_lbr_chartabsize(&cts, NULL); 777 cts.cts_vcol += win_lbr_chartabsize(&cts, NULL);
777 clear_chartabsize_arg(&cts); 778 clear_chartabsize_arg(&cts);
778 return (int)cts.cts_vcol; 779 return (int)cts.cts_vcol;
1087 for (i = 0; i < cts->cts_text_prop_count; ++i) 1088 for (i = 0; i < cts->cts_text_prop_count; ++i)
1088 { 1089 {
1089 textprop_T *tp = cts->cts_text_props + i; 1090 textprop_T *tp = cts->cts_text_props + i;
1090 1091
1091 if (tp->tp_id < 0 1092 if (tp->tp_id < 0
1092 && tp->tp_col - 1 >= col && tp->tp_col - 1 < col + size 1093 && ((tp->tp_col - 1 >= col && tp->tp_col - 1 < col + size
1093 && -tp->tp_id <= wp->w_buffer->b_textprop_text.ga_len) 1094 && -tp->tp_id <= wp->w_buffer->b_textprop_text.ga_len)
1095 || (tp->tp_col == MAXCOL && (s[0] == NUL || s[1] == NUL)
1096 && cts->cts_with_trailing)))
1094 { 1097 {
1095 char_u *p = ((char_u **)wp->w_buffer->b_textprop_text.ga_data)[ 1098 char_u *p = ((char_u **)wp->w_buffer->b_textprop_text.ga_data)[
1096 -tp->tp_id - 1]; 1099 -tp->tp_id - 1];
1100 int len = (int)STRLEN(p);
1101
1097 // TODO: count screen cells 1102 // TODO: count screen cells
1098 cts->cts_cur_text_width = (int)STRLEN(p); 1103 if (tp->tp_col == MAXCOL)
1099 size += cts->cts_cur_text_width; 1104 {
1100 break; 1105 // TODO: truncating
1106 if (tp->tp_flags & TP_FLAG_ALIGN_BELOW)
1107 len += wp->w_width - (vcol + size) % wp->w_width;
1108 }
1109 cts->cts_cur_text_width += len;
1110 size += len;
1101 } 1111 }
1102 if (tp->tp_col - 1 > col) 1112 if (tp->tp_col - 1 > col)
1103 break; 1113 break;
1104 } 1114 }
1105 } 1115 }