comparison src/misc2.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 aa44d5842d6c
children 89e1d67814a9
comparison
equal deleted inserted replaced
29450:67f31c24291b 29451:057c26b5c33a
126 int finetune, // change char offset for the exact column 126 int finetune, // change char offset for the exact column
127 colnr_T wcol_arg) // column to move to (can be negative) 127 colnr_T wcol_arg) // column to move to (can be negative)
128 { 128 {
129 colnr_T wcol = wcol_arg; 129 colnr_T wcol = wcol_arg;
130 int idx; 130 int idx;
131 char_u *ptr;
132 char_u *line; 131 char_u *line;
133 colnr_T col = 0; 132 colnr_T col = 0;
134 int csize = 0; 133 int csize = 0;
135 int one_more; 134 int one_more;
136 #ifdef FEAT_LINEBREAK 135 #ifdef FEAT_LINEBREAK
156 } 155 }
157 } 156 }
158 else 157 else
159 { 158 {
160 int width = curwin->w_width - win_col_off(curwin); 159 int width = curwin->w_width - win_col_off(curwin);
160 chartabsize_T cts;
161 161
162 if (finetune 162 if (finetune
163 && curwin->w_p_wrap 163 && curwin->w_p_wrap
164 && curwin->w_width != 0 164 && curwin->w_width != 0
165 && wcol >= (colnr_T)width 165 && wcol >= (colnr_T)width
178 // reaching the right window edge). 178 // reaching the right window edge).
179 wcol = (csize / width + 1) * width - 1; 179 wcol = (csize / width + 1) * width - 1;
180 } 180 }
181 } 181 }
182 182
183 ptr = line; 183 init_chartabsize_arg(&cts, curwin, pos->lnum, 0, line, line);
184 while (col <= wcol && *ptr != NUL) 184 while (cts.cts_vcol <= wcol && *cts.cts_ptr != NUL)
185 { 185 {
186 // Count a tab for what it's worth (if list mode not on) 186 // Count a tab for what it's worth (if list mode not on)
187 #ifdef FEAT_LINEBREAK 187 #ifdef FEAT_LINEBREAK
188 csize = win_lbr_chartabsize(curwin, line, ptr, col, &head); 188 csize = win_lbr_chartabsize(&cts, &head);
189 MB_PTR_ADV(ptr); 189 MB_PTR_ADV(cts.cts_ptr);
190 #else 190 #else
191 csize = lbr_chartabsize_adv(line, &ptr, col); 191 csize = lbr_chartabsize_adv(&cts);
192 #endif 192 #endif
193 col += csize; 193 cts.cts_vcol += csize;
194 } 194 }
195 idx = (int)(ptr - line); 195 col = cts.cts_vcol;
196 idx = (int)(cts.cts_ptr - line);
197 clear_chartabsize_arg(&cts);
198
196 /* 199 /*
197 * Handle all the special cases. The virtual_active() check 200 * Handle all the special cases. The virtual_active() check
198 * is needed to ensure that a virtual position off the end of 201 * is needed to ensure that a virtual position off the end of
199 * a line has the correct indexing. The one_more comparison 202 * a line has the correct indexing. The one_more comparison
200 * replaces an explicit add of one_more later on. 203 * replaces an explicit add of one_more later on.