7049
|
1 |
Repository:
|
|
2 |
https://github.com/chrisbra/vim-mq-patches
|
|
3 |
git://github.com/chrisbra/vim-mq-patches.git
|
|
4 |
|
|
5 |
Filename:
|
|
6 |
var_tabstops
|
|
7 |
|
|
8 |
Latest update for:
|
|
9 |
vim-7.4.796
|
|
10 |
|
|
11 |
Bug reports:
|
|
12 |
http://www.vim.org/maillist.php
|
|
13 |
|
|
14 |
License & Copyright:
|
|
15 |
© 2008 Matthew Winn
|
|
16 |
─────────────────────────────────────────────────────────────────────────────
|
|
17 |
|
|
18 |
Christian Brabandt 20150725
|
|
19 |
- fix offsets, fix compiler warnings (option not correctly initialized)
|
|
20 |
|
|
21 |
Christian Brabandt 20150609
|
|
22 |
- updated offsets and have the tests apply cleanly
|
|
23 |
|
|
24 |
Christian Brabandt 20141102:
|
|
25 |
- correctly cache vts values when calculating the breakindent
|
|
26 |
|
|
27 |
Christian Brabandt 20141030
|
|
28 |
[DONE] TODO: test_breakindent.out breaks, if instead of using 'ts' setting 'vts' setting is used.
|
|
29 |
[DONE] TODO: get_breakindent_win should use vts value
|
|
30 |
[DONE] TODO: get_indent_str_vtab should also use the true/false variable for checking screen size of a tab!
|
|
31 |
|
|
32 |
Roland Eggner 2014-10-23 vim-7.4.488
|
|
33 |
Fixed insertion of 4 lines after src/option.c:5439 -- due to context change in
|
|
34 |
vim-7.4.456, “hg qrefresh” inserted erroneously with fuzz 2 and -111 lines offset.
|
|
35 |
Fixed rejections of src/testdir/Make{_{{amiga,dos,ming,os2}.mak,vms.mms},file} .
|
|
36 |
|
|
37 |
Roland Eggner 2014-09-09 vim-7.4.430
|
|
38 |
Readded src/testdir/test_vartabs.{in,ok} based on an older version of this patch.
|
|
39 |
Fixed rejections of src/testdir/Make{_{{amiga,dos,ming,os2}.mak,vms.mms},file} .
|
|
40 |
|
|
41 |
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
|
|
42 |
index e2148b3..8ac07bd 100644
|
|
43 |
--- a/runtime/doc/change.txt
|
|
44 |
+++ b/runtime/doc/change.txt
|
|
45 |
@@ -984,6 +984,11 @@ This replaces each 'E' character with a euro sign. Read more in |<Char->|.
|
|
46 |
this (that's a good habit anyway).
|
|
47 |
`:retab!` may also change a sequence of spaces by
|
|
48 |
<Tab> characters, which can mess up a printf().
|
|
49 |
+ If the |+vartabs| feature is enabled then a list of
|
|
50 |
+ tab widths separated by commas may be used in place of
|
|
51 |
+ a single tabstop. Each value in the list represents
|
|
52 |
+ the width of one tabstop, except the final value which
|
|
53 |
+ applies to all following tabstops.
|
|
54 |
{not in Vi}
|
|
55 |
|
|
56 |
*retab-example*
|
|
57 |
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
|
|
58 |
index 30ea88d..80f658c 100644
|
|
59 |
--- a/runtime/doc/options.txt
|
|
60 |
+++ b/runtime/doc/options.txt
|
|
61 |
@@ -6853,6 +6853,10 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|
62 |
set.
|
|
63 |
NOTE: This option is set to 0 when 'compatible' is set.
|
|
64 |
|
|
65 |
+ If Vim is compiled with the |+vartabs| feature then the value of
|
|
66 |
+ 'softtabstop' will be ignored if |'varsofttabstop'| is set to
|
|
67 |
+ anything other than an empty string.
|
|
68 |
+
|
|
69 |
*'spell'* *'nospell'*
|
|
70 |
'spell' boolean (default off)
|
|
71 |
local to window
|
|
72 |
@@ -7402,6 +7406,10 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|
73 |
though. Otherwise aligned comments will be wrong when 'tabstop' is
|
|
74 |
changed.
|
|
75 |
|
|
76 |
+ If Vim is compiled with the |+vartabs| feature then the value of
|
|
77 |
+ 'tabstop' will be ignored if |'vartabstop'| is set to anything other
|
|
78 |
+ than an empty string.
|
|
79 |
+
|
|
80 |
*'tagbsearch'* *'tbs'* *'notagbsearch'* *'notbs'*
|
|
81 |
'tagbsearch' 'tbs' boolean (default on)
|
|
82 |
global
|
|
83 |
@@ -8086,6 +8094,44 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|
84 |
written to disk (see |crash-recovery|). Also used for the
|
|
85 |
|CursorHold| autocommand event.
|
|
86 |
|
|
87 |
+ *'varsofttabstop'* *'vsts'*
|
|
88 |
+'varsofttabstop' 'vsts' string (default "")
|
|
89 |
+ local to buffer
|
|
90 |
+ {only available when compiled with the |+vartabs|
|
|
91 |
+ feature}
|
|
92 |
+ {not in Vi}
|
|
93 |
+ A list of the number of spaces that a <Tab> counts for while editing,
|
|
94 |
+ such as inserting a <Tab> or using <BS>. It "feels" like variable-
|
|
95 |
+ width <Tab>s are being inserted, while in fact a mixture of spaces
|
|
96 |
+ and <Tab>s is used. Tab widths are separated with commas, with the
|
|
97 |
+ final value applying to all subsequent tabs.
|
|
98 |
+
|
|
99 |
+ For example, when editing assembly language files where statements
|
|
100 |
+ start in the 8th column and comments in the 40th, it may be useful
|
|
101 |
+ to use the following: >
|
|
102 |
+ :set varsofttabstop=8,32,8
|
|
103 |
+< This will set soft tabstops at the 8th and 40th columns, and at every
|
|
104 |
+ 8th column thereafter.
|
|
105 |
+
|
|
106 |
+ Note that the value of |'softtabstop'| will be ignored while
|
|
107 |
+ 'varsofttabstop' is set.
|
|
108 |
+
|
|
109 |
+ *'vartabstop'* *'vts'*
|
|
110 |
+'vartabstop' 'vts' string (default "")
|
|
111 |
+ local to buffer
|
|
112 |
+ {only available when compiled with the |+vartabs|
|
|
113 |
+ feature}
|
|
114 |
+ {not in Vi}
|
|
115 |
+ A list of the number of spaces that a <Tab> in the file counts for,
|
|
116 |
+ separated by commas. Each value corresponds to one tab, with the
|
|
117 |
+ final value applying to all subsequent tabs. For example: >
|
|
118 |
+ :set vartabstop=4,20,10,8
|
|
119 |
+< This will make the first tab 4 spaces wide, the second 20 spaces,
|
|
120 |
+ the third 10 spaces, and all following tabs 8 spaces.
|
|
121 |
+
|
|
122 |
+ Note that the value of |'tabstop'| will be ignored while 'vartabstop'
|
|
123 |
+ is set.
|
|
124 |
+
|
|
125 |
*'verbose'* *'vbs'*
|
|
126 |
'verbose' 'vbs' number (default 0)
|
|
127 |
global
|
|
128 |
diff --git a/runtime/doc/tags b/runtime/doc/tags
|
|
129 |
index 7eaf6a0..1e068b3 100644
|
|
130 |
--- a/runtime/doc/tags
|
|
131 |
+++ b/runtime/doc/tags
|
|
132 |
@@ -1105,6 +1105,8 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
|
|
133 |
'updatetime' options.txt /*'updatetime'*
|
|
134 |
'ur' options.txt /*'ur'*
|
|
135 |
'ut' options.txt /*'ut'*
|
|
136 |
+'varsofttabstop' options.txt /*'varsofttabstop'*
|
|
137 |
+'vartabstop' options.txt /*'vartabstop'*
|
|
138 |
'vb' options.txt /*'vb'*
|
|
139 |
'vbs' options.txt /*'vbs'*
|
|
140 |
'vdir' options.txt /*'vdir'*
|
|
141 |
@@ -1119,6 +1121,8 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
|
|
142 |
'virtualedit' options.txt /*'virtualedit'*
|
|
143 |
'visualbell' options.txt /*'visualbell'*
|
|
144 |
'vop' options.txt /*'vop'*
|
|
145 |
+'vsts' options.txt /*'vsts'*
|
|
146 |
+'vts' options.txt /*'vts'*
|
|
147 |
'w1200' vi_diff.txt /*'w1200'*
|
|
148 |
'w300' vi_diff.txt /*'w300'*
|
|
149 |
'w9600' vi_diff.txt /*'w9600'*
|
|
150 |
@@ -1308,6 +1312,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
|
|
151 |
+title various.txt /*+title*
|
|
152 |
+toolbar various.txt /*+toolbar*
|
|
153 |
+user_commands various.txt /*+user_commands*
|
|
154 |
++vartabs various.txt /*+vartabs*
|
|
155 |
+vertsplit various.txt /*+vertsplit*
|
|
156 |
+viminfo various.txt /*+viminfo*
|
|
157 |
+virtualedit various.txt /*+virtualedit*
|
|
158 |
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
|
|
159 |
index 729fff5..2f68370 100644
|
|
160 |
--- a/runtime/doc/various.txt
|
|
161 |
+++ b/runtime/doc/various.txt
|
|
162 |
@@ -436,6 +436,7 @@ N *+timers* the |timer_start()| function
|
|
163 |
N *+title* Setting the window 'title' and 'icon'
|
|
164 |
N *+toolbar* |gui-toolbar|
|
|
165 |
N *+user_commands* User-defined commands. |user-commands|
|
|
166 |
+B *+vartabs* Variable-width tabstops. |'vartabstop'|
|
|
167 |
N *+viminfo* |'viminfo'|
|
|
168 |
N *+vertsplit* Vertically split windows |:vsplit|
|
|
169 |
N *+virtualedit* |'virtualedit'|
|
|
170 |
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
|
|
171 |
index d759c04..ae59692 100644
|
|
172 |
--- a/runtime/optwin.vim
|
|
173 |
+++ b/runtime/optwin.vim
|
|
174 |
@@ -833,6 +833,14 @@ call <SID>OptionL("ts")
|
|
175 |
call append("$", "shiftwidth\tnumber of spaces used for each step of (auto)indent")
|
|
176 |
call append("$", "\t(local to buffer)")
|
|
177 |
call <SID>OptionL("sw")
|
|
178 |
+if has("vartabs")
|
|
179 |
+ call append("$", "vartabstop\tlist of number of spaces a tab counts for")
|
|
180 |
+ call append("$", "\t(local to buffer)")
|
|
181 |
+ call <SID>OptionL("vts")
|
|
182 |
+ call append("$", "varsofttabstop\tlist of number of spaces a soft tabsstop counts for")
|
|
183 |
+ call append("$", "\t(local to buffer)")
|
|
184 |
+ call <SID>OptionL("vsts")
|
|
185 |
+endif
|
|
186 |
call append("$", "smarttab\ta <Tab> in an indent inserts 'shiftwidth' spaces")
|
|
187 |
call <SID>BinOptionG("sta", &sta)
|
|
188 |
call append("$", "softtabstop\tif non-zero, number of spaces to insert for a <Tab>")
|
|
189 |
diff --git a/src/buffer.c b/src/buffer.c
|
|
190 |
index b013295..94bcb70 100644
|
|
191 |
--- a/src/buffer.c
|
|
192 |
+++ b/src/buffer.c
|
|
193 |
@@ -2160,6 +2160,19 @@ free_buf_options(
|
|
194 |
clear_string_option(&buf->b_p_fo);
|
|
195 |
clear_string_option(&buf->b_p_flp);
|
|
196 |
clear_string_option(&buf->b_p_isk);
|
|
197 |
+#ifdef FEAT_VARTABS
|
|
198 |
+ clear_string_option(&buf->b_p_vsts);
|
|
199 |
+ if (buf->b_p_vsts_nopaste)
|
|
200 |
+ vim_free(buf->b_p_vsts_nopaste);
|
|
201 |
+ buf->b_p_vsts_nopaste = 0;
|
|
202 |
+ if (buf->b_p_vsts_ary)
|
|
203 |
+ vim_free(buf->b_p_vsts_ary);
|
|
204 |
+ buf->b_p_vsts_ary = 0;
|
|
205 |
+ clear_string_option(&buf->b_p_vts);
|
|
206 |
+ if (buf->b_p_vts_ary)
|
|
207 |
+ vim_free(buf->b_p_vts_ary);
|
|
208 |
+ buf->b_p_vts_ary = 0;
|
|
209 |
+#endif
|
|
210 |
#ifdef FEAT_KEYMAP
|
|
211 |
clear_string_option(&buf->b_p_keymap);
|
|
212 |
ga_clear(&buf->b_kmap_ga);
|
|
213 |
diff --git a/src/charset.c b/src/charset.c
|
|
214 |
index 134cd09..ed1f526 100644
|
|
215 |
--- a/src/charset.c
|
|
216 |
+++ b/src/charset.c
|
|
217 |
@@ -812,6 +812,15 @@ vim_strnsize(char_u *s, int len)
|
|
218 |
* Also see getvcol() below.
|
|
219 |
*/
|
|
220 |
|
|
221 |
+#ifdef FEAT_VARTABS
|
|
222 |
+#define RET_WIN_BUF_CHARTABSIZE(wp, buf, p, col) \
|
|
223 |
+ if (*(p) == TAB && (!(wp)->w_p_list || lcs_tab1)) \
|
|
224 |
+ { \
|
|
225 |
+ return tabstop_padding(col, (buf)->b_p_ts, (buf)->b_p_vts_ary); \
|
|
226 |
+ } \
|
|
227 |
+ else \
|
|
228 |
+ return ptr2cells(p);
|
|
229 |
+#else
|
|
230 |
#define RET_WIN_BUF_CHARTABSIZE(wp, buf, p, col) \
|
|
231 |
if (*(p) == TAB && (!(wp)->w_p_list || lcs_tab1)) \
|
|
232 |
{ \
|
|
233 |
@@ -821,6 +830,7 @@ vim_strnsize(char_u *s, int len)
|
|
234 |
} \
|
|
235 |
else \
|
|
236 |
return ptr2cells(p);
|
|
237 |
+#endif
|
|
238 |
|
|
239 |
int
|
|
240 |
chartabsize(char_u *p, colnr_T col)
|
|
241 |
@@ -1225,8 +1235,13 @@ win_nolbr_chartabsize(
|
|
242 |
|
|
243 |
if (*s == TAB && (!wp->w_p_list || lcs_tab1))
|
|
244 |
{
|
|
245 |
+# ifdef FEAT_VARTABS
|
|
246 |
+ return tabstop_padding(col, wp->w_buffer->b_p_ts,
|
|
247 |
+ wp->w_buffer->b_p_vts_ary);
|
|
248 |
+# else
|
|
249 |
n = wp->w_buffer->b_p_ts;
|
|
250 |
return (int)(n - (col % n));
|
|
251 |
+# endif
|
|
252 |
}
|
|
253 |
n = ptr2cells(s);
|
|
254 |
/* Add one cell for a double-width character in the last column of the
|
|
255 |
@@ -1288,6 +1303,9 @@ getvcol(
|
|
256 |
char_u *line; /* start of the line */
|
|
257 |
int incr;
|
|
258 |
int head;
|
|
259 |
+#ifdef FEAT_VARTABS
|
|
260 |
+ int *vts = wp->w_buffer->b_p_vts_ary;
|
|
261 |
+#endif
|
|
262 |
int ts = wp->w_buffer->b_p_ts;
|
|
263 |
int c;
|
|
264 |
|
|
265 |
@@ -1327,7 +1345,11 @@ getvcol(
|
|
266 |
}
|
|
267 |
/* A tab gets expanded, depending on the current column */
|
|
268 |
if (c == TAB)
|
|
269 |
+#ifdef FEAT_VARTABS
|
|
270 |
+ incr = tabstop_padding(vcol, ts, vts);
|
|
271 |
+#else
|
|
272 |
incr = ts - (vcol % ts);
|
|
273 |
+#endif
|
|
274 |
else
|
|
275 |
{
|
|
276 |
#ifdef FEAT_MBYTE
|
|
277 |
diff --git a/src/edit.c b/src/edit.c
|
|
278 |
index a87c155..2d2c89a 100644
|
|
279 |
--- a/src/edit.c
|
|
280 |
+++ b/src/edit.c
|
|
281 |
@@ -716,7 +716,13 @@ edit(
|
|
282 |
mincol = curwin->w_wcol;
|
|
283 |
validate_cursor_col();
|
|
284 |
|
|
285 |
- if ((int)curwin->w_wcol < mincol - curbuf->b_p_ts
|
|
286 |
+ if (
|
|
287 |
+#ifdef FEAT_VARTABS
|
|
288 |
+ (int)curwin->w_wcol < mincol
|
|
289 |
+ - tabstop_at(get_nolist_virtcol(), curbuf->b_p_ts, curbuf->b_p_vts_ary)
|
|
290 |
+#else
|
|
291 |
+ (int)curwin->w_wcol < mincol - curbuf->b_p_ts
|
|
292 |
+#endif
|
|
293 |
&& curwin->w_wrow == W_WINROW(curwin)
|
|
294 |
+ curwin->w_height - 1 - p_so
|
|
295 |
&& (curwin->w_cursor.lnum != curwin->w_topline
|
|
296 |
@@ -9078,23 +9084,31 @@ ins_bs(
|
|
297 |
*/
|
|
298 |
if ( mode == BACKSPACE_CHAR
|
|
299 |
&& ((p_sta && in_indent)
|
|
300 |
- || (get_sts_value() != 0
|
|
301 |
+ || ((get_sts_value() != 0
|
|
302 |
+#ifdef FEAT_VARTABS
|
|
303 |
+ || tabstop_count(curbuf->b_p_vsts_ary)
|
|
304 |
+#endif
|
|
305 |
+ )
|
|
306 |
&& curwin->w_cursor.col > 0
|
|
307 |
&& (*(ml_get_cursor() - 1) == TAB
|
|
308 |
|| (*(ml_get_cursor() - 1) == ' '
|
|
309 |
&& (!*inserted_space_p
|
|
310 |
|| arrow_used))))))
|
|
311 |
{
|
|
312 |
+#ifndef FEAT_VARTABS
|
|
313 |
int ts;
|
|
314 |
+#endif
|
|
315 |
colnr_T vcol;
|
|
316 |
colnr_T want_vcol;
|
|
317 |
colnr_T start_vcol;
|
|
318 |
|
|
319 |
*inserted_space_p = FALSE;
|
|
320 |
+#ifndef FEAT_VARTABS
|
|
321 |
if (p_sta && in_indent)
|
|
322 |
ts = (int)get_sw_value(curbuf);
|
|
323 |
else
|
|
324 |
ts = (int)get_sts_value();
|
|
325 |
+#endif
|
|
326 |
/* Compute the virtual column where we want to be. Since
|
|
327 |
* 'showbreak' may get in the way, need to get the last column of
|
|
328 |
* the previous character. */
|
|
329 |
@@ -9103,7 +9117,15 @@ ins_bs(
|
|
330 |
dec_cursor();
|
|
331 |
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol);
|
|
332 |
inc_cursor();
|
|
333 |
+#ifdef FEAT_VARTABS
|
|
334 |
+ if (p_sta && in_indent)
|
|
335 |
+ want_vcol = (want_vcol / curbuf->b_p_sw) * curbuf->b_p_sw;
|
|
336 |
+ else
|
|
337 |
+ want_vcol = tabstop_start(want_vcol, curbuf->b_p_sts,
|
|
338 |
+ curbuf->b_p_vsts_ary);
|
|
339 |
+#else
|
|
340 |
want_vcol = (want_vcol / ts) * ts;
|
|
341 |
+#endif
|
|
342 |
|
|
343 |
/* delete characters until we are at or before want_vcol */
|
|
344 |
while (vcol > want_vcol
|
|
345 |
@@ -9809,7 +9831,18 @@ ins_tab(void)
|
|
346 |
* When nothing special, insert TAB like a normal character
|
|
347 |
*/
|
|
348 |
if (!curbuf->b_p_et
|
|
349 |
+#ifdef FEAT_VARTABS
|
|
350 |
+ && !(p_sta && ind
|
|
351 |
+ /* These five lines mean 'tabstop' != 'shiftwidth' */
|
|
352 |
+ && ((tabstop_count(curbuf->b_p_vts_ary) > 1)
|
|
353 |
+ || (tabstop_count(curbuf->b_p_vts_ary) == 1
|
|
354 |
+ && tabstop_first(curbuf->b_p_vts_ary) != get_sw_value(curbuf))
|
|
355 |
+ || (tabstop_count(curbuf->b_p_vts_ary) == 0
|
|
356 |
+ && curbuf->b_p_ts != get_sw_value(curbuf))))
|
|
357 |
+ && tabstop_count(curbuf->b_p_vsts_ary) == 0
|
|
358 |
+#else
|
|
359 |
&& !(p_sta && ind && curbuf->b_p_ts != get_sw_value(curbuf))
|
|
360 |
+#endif
|
|
361 |
&& get_sts_value() == 0)
|
|
362 |
return TRUE;
|
|
363 |
|
|
364 |
@@ -9824,6 +9857,20 @@ ins_tab(void)
|
|
365 |
#endif
|
|
366 |
AppendToRedobuff((char_u *)"\t");
|
|
367 |
|
|
368 |
+#ifdef FEAT_VARTABS
|
|
369 |
+ if (p_sta && ind) /* insert tab in indent, use 'shiftwidth' */
|
|
370 |
+ {
|
|
371 |
+ temp = (int)curbuf->b_p_sw;
|
|
372 |
+ temp -= get_nolist_virtcol() % temp;
|
|
373 |
+ }
|
|
374 |
+ else if (tabstop_count(curbuf->b_p_vsts_ary) > 0 || curbuf->b_p_sts > 0)
|
|
375 |
+ /* use 'softtabstop' when set */
|
|
376 |
+ temp = tabstop_padding(get_nolist_virtcol(), curbuf->b_p_sts,
|
|
377 |
+ curbuf->b_p_vsts_ary);
|
|
378 |
+ else /* otherwise use 'tabstop' */
|
|
379 |
+ temp = tabstop_padding(get_nolist_virtcol(), curbuf->b_p_ts,
|
|
380 |
+ curbuf->b_p_vts_ary);
|
|
381 |
+#else
|
|
382 |
if (p_sta && ind) /* insert tab in indent, use 'shiftwidth' */
|
|
383 |
temp = (int)get_sw_value(curbuf);
|
|
384 |
else if (curbuf->b_p_sts != 0) /* use 'softtabstop' when set */
|
|
385 |
@@ -9831,6 +9878,7 @@ ins_tab(void)
|
|
386 |
else /* otherwise use 'tabstop' */
|
|
387 |
temp = (int)curbuf->b_p_ts;
|
|
388 |
temp -= get_nolist_virtcol() % temp;
|
|
389 |
+#endif
|
|
390 |
|
|
391 |
/*
|
|
392 |
* Insert the first space with ins_char(). It will delete one char in
|
|
393 |
@@ -9855,7 +9903,13 @@ ins_tab(void)
|
|
394 |
/*
|
|
395 |
* When 'expandtab' not set: Replace spaces by TABs where possible.
|
|
396 |
*/
|
|
397 |
+#ifdef FEAT_VARTABS
|
|
398 |
+ if (!curbuf->b_p_et && (tabstop_count(curbuf->b_p_vsts_ary) > 0
|
|
399 |
+ || get_sts_value() > 0
|
|
400 |
+ || (p_sta && ind)))
|
|
401 |
+#else
|
|
402 |
if (!curbuf->b_p_et && (get_sts_value() || (p_sta && ind)))
|
|
403 |
+#endif
|
|
404 |
{
|
|
405 |
char_u *ptr;
|
|
406 |
#ifdef FEAT_VREPLACE
|
|
407 |
diff --git a/src/evalfunc.c b/src/evalfunc.c
|
|
408 |
index 7dd5c2a..2edd610 100644
|
|
409 |
--- a/src/evalfunc.c
|
|
410 |
+++ b/src/evalfunc.c
|
|
411 |
@@ -5852,6 +5852,9 @@ f_has(typval_T *argvars, typval_T *rettv)
|
|
412 |
"user-commands", /* was accidentally included in 5.4 */
|
|
413 |
"user_commands",
|
|
414 |
#endif
|
|
415 |
+#ifdef FEAT_VARTABS
|
|
416 |
+ "vartabs",
|
|
417 |
+#endif
|
|
418 |
#ifdef FEAT_VIMINFO
|
|
419 |
"viminfo",
|
|
420 |
#endif
|
|
421 |
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
|
|
422 |
index 6535de1..3221ab6 100644
|
|
423 |
--- a/src/ex_cmds.c
|
|
424 |
+++ b/src/ex_cmds.c
|
|
425 |
@@ -654,12 +654,17 @@ ex_retab(exarg_T *eap)
|
|
426 |
long vcol;
|
|
427 |
long start_col = 0; /* For start of white-space string */
|
|
428 |
long start_vcol = 0; /* For start of white-space string */
|
|
429 |
- int temp;
|
|
430 |
long old_len;
|
|
431 |
char_u *ptr;
|
|
432 |
char_u *new_line = (char_u *)1; /* init to non-NULL */
|
|
433 |
int did_undo; /* called u_save for current line */
|
|
434 |
+#ifdef FEAT_VARTABS
|
|
435 |
+ int *new_ts = 0;
|
|
436 |
+ char_u *new_ts_str; /* string value of tab argument */
|
|
437 |
+#else
|
|
438 |
+ int temp;
|
|
439 |
int new_ts;
|
|
440 |
+#endif
|
|
441 |
int save_list;
|
|
442 |
linenr_T first_line = 0; /* first changed line */
|
|
443 |
linenr_T last_line = 0; /* last changed line */
|
|
444 |
@@ -667,6 +672,27 @@ ex_retab(exarg_T *eap)
|
|
445 |
save_list = curwin->w_p_list;
|
|
446 |
curwin->w_p_list = 0; /* don't want list mode here */
|
|
447 |
|
|
448 |
+#ifdef FEAT_VARTABS
|
|
449 |
+ new_ts_str = eap->arg;
|
|
450 |
+ if (vim_isdigit(*(eap->arg)) && !tabstop_set(eap->arg, &new_ts))
|
|
451 |
+ {
|
|
452 |
+ EMSG(_(e_invarg));
|
|
453 |
+ return;
|
|
454 |
+ }
|
|
455 |
+ while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',')
|
|
456 |
+ ++(eap->arg);
|
|
457 |
+
|
|
458 |
+ /* This ensures that either new_ts and new_ts_str are freshly allocated,
|
|
459 |
+ * or new_ts points to an existing array and new_ts_str is null.
|
|
460 |
+ */
|
|
461 |
+ if (new_ts == 0)
|
|
462 |
+ {
|
|
463 |
+ new_ts = curbuf->b_p_vts_ary;
|
|
464 |
+ new_ts_str = NULL;
|
|
465 |
+ }
|
|
466 |
+ else
|
|
467 |
+ new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);
|
|
468 |
+#else
|
|
469 |
new_ts = getdigits(&(eap->arg));
|
|
470 |
if (new_ts < 0)
|
|
471 |
{
|
|
472 |
@@ -675,6 +701,7 @@ ex_retab(exarg_T *eap)
|
|
473 |
}
|
|
474 |
if (new_ts == 0)
|
|
475 |
new_ts = curbuf->b_p_ts;
|
|
476 |
+#endif
|
|
477 |
for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum)
|
|
478 |
{
|
|
479 |
ptr = ml_get(lnum);
|
|
480 |
@@ -707,6 +734,15 @@ ex_retab(exarg_T *eap)
|
|
481 |
num_tabs = 0;
|
|
482 |
if (!curbuf->b_p_et)
|
|
483 |
{
|
|
484 |
+#ifdef FEAT_VARTABS
|
|
485 |
+ int t, s;
|
|
486 |
+ tabstop_fromto(start_vcol, vcol,
|
|
487 |
+ tabstop_count(new_ts)? 0: curbuf->b_p_ts,
|
|
488 |
+ new_ts,
|
|
489 |
+ &t, &s);
|
|
490 |
+ num_tabs = t;
|
|
491 |
+ num_spaces = s;
|
|
492 |
+#else
|
|
493 |
temp = new_ts - (start_vcol % new_ts);
|
|
494 |
if (num_spaces >= temp)
|
|
495 |
{
|
|
496 |
@@ -715,6 +751,7 @@ ex_retab(exarg_T *eap)
|
|
497 |
}
|
|
498 |
num_tabs += num_spaces / new_ts;
|
|
499 |
num_spaces -= (num_spaces / new_ts) * new_ts;
|
|
500 |
+#endif
|
|
501 |
}
|
|
502 |
if (curbuf->b_p_et || got_tab ||
|
|
503 |
(num_spaces + num_tabs < len))
|
|
504 |
@@ -772,14 +809,54 @@ ex_retab(exarg_T *eap)
|
|
505 |
if (got_int)
|
|
506 |
EMSG(_(e_interr));
|
|
507 |
|
|
508 |
+#ifdef FEAT_VARTABS
|
|
509 |
+ /* If a single value was given then it can be considered equal to
|
|
510 |
+ * either the value of 'tabstop' or the value of 'vartabstop'.
|
|
511 |
+ */
|
|
512 |
+ if (tabstop_count(curbuf->b_p_vts_ary) == 0
|
|
513 |
+ && tabstop_count(new_ts) == 1
|
|
514 |
+ && curbuf->b_p_ts == tabstop_first(new_ts))
|
|
515 |
+ ; /* not changed */
|
|
516 |
+ else if (tabstop_count(curbuf->b_p_vts_ary) > 0
|
|
517 |
+ && tabstop_eq(curbuf->b_p_vts_ary, new_ts))
|
|
518 |
+ ; /* not changed */
|
|
519 |
+ else
|
|
520 |
+ redraw_curbuf_later(NOT_VALID);
|
|
521 |
+#else
|
|
522 |
if (curbuf->b_p_ts != new_ts)
|
|
523 |
redraw_curbuf_later(NOT_VALID);
|
|
524 |
+#endif
|
|
525 |
if (first_line != 0)
|
|
526 |
changed_lines(first_line, 0, last_line + 1, 0L);
|
|
527 |
|
|
528 |
curwin->w_p_list = save_list; /* restore 'list' */
|
|
529 |
|
|
530 |
+#ifdef FEAT_VARTABS
|
|
531 |
+ if (new_ts_str != NULL) /* set the new tabstop */
|
|
532 |
+ {
|
|
533 |
+ /* If 'vartabstop' is in use or if the value given to retab has more
|
|
534 |
+ * than one tabstop then update 'vartabstop'.
|
|
535 |
+ */
|
|
536 |
+ int* old_vts_ary = curbuf->b_p_vts_ary;
|
|
537 |
+ if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_ts) > 1) {
|
|
538 |
+ set_string_option_direct((char_u *)"vts", -1, new_ts_str,
|
|
539 |
+ OPT_FREE|OPT_LOCAL, 0);
|
|
540 |
+ vim_free(new_ts_str);
|
|
541 |
+ curbuf->b_p_vts_ary = new_ts;
|
|
542 |
+ vim_free(old_vts_ary);
|
|
543 |
+ }
|
|
544 |
+ /* If 'vartabstop' wasn't in use and a single value was given to
|
|
545 |
+ * retab then update 'tabstop'.
|
|
546 |
+ */
|
|
547 |
+ else
|
|
548 |
+ {
|
|
549 |
+ curbuf->b_p_ts = tabstop_first(new_ts);
|
|
550 |
+ vim_free(new_ts);
|
|
551 |
+ }
|
|
552 |
+ }
|
|
553 |
+#else
|
|
554 |
curbuf->b_p_ts = new_ts;
|
|
555 |
+#endif
|
|
556 |
coladvance(curwin->w_curswant);
|
|
557 |
|
|
558 |
u_clearline();
|
|
559 |
diff --git a/src/feature.h b/src/feature.h
|
|
560 |
index 138279e..d80ec7d 100644
|
|
561 |
--- a/src/feature.h
|
|
562 |
+++ b/src/feature.h
|
|
563 |
@@ -830,6 +830,13 @@
|
|
564 |
#endif
|
|
565 |
|
|
566 |
/*
|
|
567 |
+ * +vartabs 'vartabstop' and 'varsofttabstop' options.
|
|
568 |
+ */
|
|
569 |
+#ifdef FEAT_BIG
|
|
570 |
+# define FEAT_VARTABS
|
|
571 |
+#endif
|
|
572 |
+
|
|
573 |
+/*
|
|
574 |
* Preferences:
|
|
575 |
* ============
|
|
576 |
*/
|
|
577 |
diff --git a/src/gui_beval.c b/src/gui_beval.c
|
|
578 |
index 4a7c06e..314160f 100644
|
|
579 |
--- a/src/gui_beval.c
|
|
580 |
+++ b/src/gui_beval.c
|
|
581 |
@@ -241,6 +241,9 @@ gui_mch_create_beval_area(
|
|
582 |
beval->msg = mesg;
|
|
583 |
beval->msgCB = mesgCB;
|
|
584 |
beval->clientData = clientData;
|
|
585 |
+#ifdef FEAT_VARTABS
|
|
586 |
+ beval->vts = 0;
|
|
587 |
+#endif
|
|
588 |
|
|
589 |
/*
|
|
590 |
* Set up event handler which will keep its eyes on the pointer,
|
|
591 |
@@ -283,6 +286,10 @@ gui_mch_destroy_beval_area(BalloonEval *beval)
|
|
592 |
# else
|
|
593 |
XtDestroyWidget(beval->balloonShell);
|
|
594 |
# endif
|
|
595 |
+# ifdef FEAT_VARTABS
|
|
596 |
+ if (beval->vts)
|
|
597 |
+ vim_free(beval->vts);
|
|
598 |
+# endif
|
|
599 |
vim_free(beval);
|
|
600 |
}
|
|
601 |
#endif
|
|
602 |
@@ -420,6 +427,11 @@ get_beval_info(
|
|
603 |
*lnump = lnum;
|
|
604 |
*textp = lbuf;
|
|
605 |
*colp = col;
|
|
606 |
+#ifdef FEAT_VARTABS
|
|
607 |
+ if (beval->vts)
|
|
608 |
+ vim_free(beval->vts);
|
|
609 |
+ beval->vts = tabstop_copy(wp->w_buffer->b_p_vts_ary);
|
|
610 |
+#endif
|
|
611 |
beval->ts = wp->w_buffer->b_p_ts;
|
|
612 |
return OK;
|
|
613 |
}
|
|
614 |
diff --git a/src/gui_beval.h b/src/gui_beval.h
|
|
615 |
index 4fa4c75..3f913fd 100644
|
|
616 |
--- a/src/gui_beval.h
|
|
617 |
+++ b/src/gui_beval.h
|
|
618 |
@@ -62,6 +62,9 @@ typedef struct BalloonEvalStruct
|
|
619 |
BeState showState; /* tells us whats currently going on */
|
|
620 |
# endif
|
|
621 |
#endif
|
|
622 |
+#ifdef FEAT_VARTABS
|
|
623 |
+ int *vts; /* vartabstop setting for this buffer */
|
|
624 |
+#endif
|
|
625 |
int ts; /* tabstop setting for this buffer */
|
|
626 |
char_u *msg;
|
|
627 |
void (*msgCB)(struct BalloonEvalStruct *, int);
|
|
628 |
diff --git a/src/gui_w32.c b/src/gui_w32.c
|
|
629 |
index 75d600f..7178cbd 100644
|
|
630 |
--- a/src/gui_w32.c
|
|
631 |
+++ b/src/gui_w32.c
|
|
632 |
@@ -8892,6 +8892,9 @@ gui_mch_create_beval_area(
|
|
633 |
beval->msg = mesg;
|
|
634 |
beval->msgCB = mesgCB;
|
|
635 |
beval->clientData = clientData;
|
|
636 |
+#ifdef FEAT_VARTABS
|
|
637 |
+ beval->vts = 0;
|
|
638 |
+#endif
|
|
639 |
|
|
640 |
InitCommonControls();
|
|
641 |
cur_beval = beval;
|
|
642 |
@@ -8949,6 +8952,10 @@ TrackUserActivity(UINT uMsg)
|
|
643 |
void
|
|
644 |
gui_mch_destroy_beval_area(BalloonEval *beval)
|
|
645 |
{
|
|
646 |
+#ifdef FEAT_VARTABS
|
|
647 |
+ if (beval->vts)
|
|
648 |
+ vim_free(beval->vts);
|
|
649 |
+#endif
|
|
650 |
vim_free(beval);
|
|
651 |
}
|
|
652 |
#endif /* FEAT_BEVAL */
|
|
653 |
diff --git a/src/hardcopy.c b/src/hardcopy.c
|
|
654 |
index 449bfbd..d9191f3 100644
|
|
655 |
--- a/src/hardcopy.c
|
|
656 |
+++ b/src/hardcopy.c
|
|
657 |
@@ -915,7 +915,12 @@ hardcopy_line(
|
|
658 |
if (line[col] == TAB || tab_spaces != 0)
|
|
659 |
{
|
|
660 |
if (tab_spaces == 0)
|
|
661 |
+#ifdef FEAT_VARTABS
|
|
662 |
+ tab_spaces = tabstop_padding(print_pos, curbuf->b_p_ts,
|
|
663 |
+ curbuf->b_p_vts_ary);
|
|
664 |
+#else
|
|
665 |
tab_spaces = (int)(curbuf->b_p_ts - (print_pos % curbuf->b_p_ts));
|
|
666 |
+#endif
|
|
667 |
|
|
668 |
while (tab_spaces > 0)
|
|
669 |
{
|
|
670 |
diff --git a/src/message.c b/src/message.c
|
|
671 |
index f8152a7..d0cf9da 100644
|
|
672 |
--- a/src/message.c
|
|
673 |
+++ b/src/message.c
|
|
674 |
@@ -1702,7 +1702,11 @@ msg_prt_line(char_u *s, int list)
|
|
675 |
if (c == TAB && (!list || lcs_tab1))
|
|
676 |
{
|
|
677 |
/* tab amount depends on current column */
|
|
678 |
+#ifdef FEAT_VARTABS
|
|
679 |
+ n_extra = tabstop_padding(col, curbuf->b_p_ts, curbuf->b_p_vts_ary) - 1;
|
|
680 |
+#else
|
|
681 |
n_extra = curbuf->b_p_ts - col % curbuf->b_p_ts - 1;
|
|
682 |
+#endif
|
|
683 |
if (!list)
|
|
684 |
{
|
|
685 |
c = ' ';
|
|
686 |
diff --git a/src/misc1.c b/src/misc1.c
|
|
687 |
index 79014cf..8d67a47 100644
|
|
688 |
--- a/src/misc1.c
|
|
689 |
+++ b/src/misc1.c
|
|
690 |
@@ -32,7 +32,11 @@ static garray_T ga_users;
|
|
691 |
int
|
|
692 |
get_indent(void)
|
|
693 |
{
|
|
694 |
+#ifdef FEAT_VARTABS
|
|
695 |
+ return get_indent_str_vtab(ml_get_curline(), (int)curbuf->b_p_ts, curbuf->b_p_vts_ary, FALSE);
|
|
696 |
+#else
|
|
697 |
return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts, FALSE);
|
|
698 |
+#endif
|
|
699 |
}
|
|
700 |
|
|
701 |
/*
|
|
702 |
@@ -41,7 +45,11 @@ get_indent(void)
|
|
703 |
int
|
|
704 |
get_indent_lnum(linenr_T lnum)
|
|
705 |
{
|
|
706 |
+#ifdef FEAT_VARTABS
|
|
707 |
+ return get_indent_str_vtab(ml_get(lnum), (int)curbuf->b_p_ts, curbuf->b_p_vts_ary, FALSE);
|
|
708 |
+#else
|
|
709 |
return get_indent_str(ml_get(lnum), (int)curbuf->b_p_ts, FALSE);
|
|
710 |
+#endif
|
|
711 |
}
|
|
712 |
|
|
713 |
#if defined(FEAT_FOLDING) || defined(PROTO)
|
|
714 |
@@ -52,7 +60,11 @@ get_indent_lnum(linenr_T lnum)
|
|
715 |
int
|
|
716 |
get_indent_buf(buf_T *buf, linenr_T lnum)
|
|
717 |
{
|
|
718 |
+#ifdef FEAT_VARTABS
|
|
719 |
+ return get_indent_str_vtab(ml_get_buf(buf, lnum, FALSE), (int)curbuf->b_p_ts, buf->b_p_vts_ary, FALSE);
|
|
720 |
+#else
|
|
721 |
return get_indent_str(ml_get_buf(buf, lnum, FALSE), (int)buf->b_p_ts, FALSE);
|
|
722 |
+#endif
|
|
723 |
}
|
|
724 |
#endif
|
|
725 |
|
|
726 |
@@ -87,6 +99,40 @@ get_indent_str(
|
|
727 |
return count;
|
|
728 |
}
|
|
729 |
|
|
730 |
+#ifdef FEAT_VARTABS
|
|
731 |
+/*
|
|
732 |
+ * count the size (in window cells) of the indent in line "ptr", using
|
|
733 |
+ * variable tabstops
|
|
734 |
+ */
|
|
735 |
+ int
|
|
736 |
+get_indent_str_vtab(ptr, ts, vts, list)
|
|
737 |
+ char_u *ptr;
|
|
738 |
+ int ts;
|
|
739 |
+ int *vts;
|
|
740 |
+ int list; /* if TRUE, count only screen size for tabs */
|
|
741 |
+{
|
|
742 |
+ int count = 0;
|
|
743 |
+
|
|
744 |
+ for ( ; *ptr; ++ptr)
|
|
745 |
+ {
|
|
746 |
+ if (*ptr == TAB) /* count a tab for what it is worth */
|
|
747 |
+ {
|
|
748 |
+ if (!list || lcs_tab1)
|
|
749 |
+ count += tabstop_padding(count, ts, vts);
|
|
750 |
+ else
|
|
751 |
+ /* In list mode, when tab is not set, count screen char width
|
|
752 |
+ * for Tab, displays: ^I */
|
|
753 |
+ count += ptr2cells(ptr);
|
|
754 |
+ }
|
|
755 |
+ else if (*ptr == ' ')
|
|
756 |
+ ++count; /* count a space for one */
|
|
757 |
+ else
|
|
758 |
+ break;
|
|
759 |
+ }
|
|
760 |
+ return count;
|
|
761 |
+}
|
|
762 |
+#endif
|
|
763 |
+
|
|
764 |
/*
|
|
765 |
* Set the indent of the current line.
|
|
766 |
* Leaves the cursor on the first non-blank in the line.
|
|
767 |
@@ -111,6 +157,9 @@ set_indent(
|
|
768 |
int line_len;
|
|
769 |
int doit = FALSE;
|
|
770 |
int ind_done = 0; /* measured in spaces */
|
|
771 |
+#ifdef FEAT_VARTABS
|
|
772 |
+ int ind_col = 0;
|
|
773 |
+#endif
|
|
774 |
int tab_pad;
|
|
775 |
int retval = FALSE;
|
|
776 |
int orig_char_len = -1; /* number of initial whitespace chars when
|
|
777 |
@@ -143,8 +192,13 @@ set_indent(
|
|
778 |
{
|
|
779 |
if (*p == TAB)
|
|
780 |
{
|
|
781 |
+#ifdef FEAT_VARTABS
|
|
782 |
+ tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
783 |
+ curbuf->b_p_vts_ary);
|
|
784 |
+#else
|
|
785 |
tab_pad = (int)curbuf->b_p_ts
|
|
786 |
- (ind_done % (int)curbuf->b_p_ts);
|
|
787 |
+#endif
|
|
788 |
/* stop if this tab will overshoot the target */
|
|
789 |
if (todo < tab_pad)
|
|
790 |
break;
|
|
791 |
@@ -161,23 +215,50 @@ set_indent(
|
|
792 |
++p;
|
|
793 |
}
|
|
794 |
|
|
795 |
+#ifdef FEAT_VARTABS
|
|
796 |
+ /* These diverge from this point. */
|
|
797 |
+ ind_col = ind_done;
|
|
798 |
+#endif
|
|
799 |
/* Set initial number of whitespace chars to copy if we are
|
|
800 |
* preserving indent but expandtab is set */
|
|
801 |
if (curbuf->b_p_et)
|
|
802 |
orig_char_len = ind_len;
|
|
803 |
|
|
804 |
/* Fill to next tabstop with a tab, if possible */
|
|
805 |
+#ifdef FEAT_VARTABS
|
|
806 |
+ tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
807 |
+ curbuf->b_p_vts_ary);
|
|
808 |
+#else
|
|
809 |
tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
|
|
810 |
+#endif
|
|
811 |
if (todo >= tab_pad && orig_char_len == -1)
|
|
812 |
{
|
|
813 |
doit = TRUE;
|
|
814 |
todo -= tab_pad;
|
|
815 |
++ind_len;
|
|
816 |
/* ind_done += tab_pad; */
|
|
817 |
+#ifdef FEAT_VARTABS
|
|
818 |
+ ind_col += tab_pad;
|
|
819 |
+#endif
|
|
820 |
}
|
|
821 |
}
|
|
822 |
|
|
823 |
/* count tabs required for indent */
|
|
824 |
+#ifdef FEAT_VARTABS
|
|
825 |
+ for (;;)
|
|
826 |
+ {
|
|
827 |
+ tab_pad = tabstop_padding(ind_col, curbuf->b_p_ts, curbuf->b_p_vts_ary);
|
|
828 |
+ if (todo < tab_pad)
|
|
829 |
+ break;
|
|
830 |
+ if (*p != TAB)
|
|
831 |
+ doit = TRUE;
|
|
832 |
+ else
|
|
833 |
+ ++p;
|
|
834 |
+ todo -= tab_pad;
|
|
835 |
+ ++ind_len;
|
|
836 |
+ ind_col += tab_pad;
|
|
837 |
+ }
|
|
838 |
+#else
|
|
839 |
while (todo >= (int)curbuf->b_p_ts)
|
|
840 |
{
|
|
841 |
if (*p != TAB)
|
|
842 |
@@ -188,6 +269,7 @@ set_indent(
|
|
843 |
++ind_len;
|
|
844 |
/* ind_done += (int)curbuf->b_p_ts; */
|
|
845 |
}
|
|
846 |
+#endif
|
|
847 |
}
|
|
848 |
/* count spaces required for indent */
|
|
849 |
while (todo > 0)
|
|
850 |
@@ -262,8 +344,13 @@ set_indent(
|
|
851 |
{
|
|
852 |
if (*p == TAB)
|
|
853 |
{
|
|
854 |
+#ifdef FEAT_VARTABS
|
|
855 |
+ tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
856 |
+ curbuf->b_p_vts_ary);
|
|
857 |
+#else
|
|
858 |
tab_pad = (int)curbuf->b_p_ts
|
|
859 |
- (ind_done % (int)curbuf->b_p_ts);
|
|
860 |
+#endif
|
|
861 |
/* stop if this tab will overshoot the target */
|
|
862 |
if (todo < tab_pad)
|
|
863 |
break;
|
|
864 |
@@ -279,21 +366,41 @@ set_indent(
|
|
865 |
}
|
|
866 |
|
|
867 |
/* Fill to next tabstop with a tab, if possible */
|
|
868 |
+#ifdef FEAT_VARTABS
|
|
869 |
+ tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
870 |
+ curbuf->b_p_vts_ary);
|
|
871 |
+#else
|
|
872 |
tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
|
|
873 |
+#endif
|
|
874 |
if (todo >= tab_pad)
|
|
875 |
{
|
|
876 |
*s++ = TAB;
|
|
877 |
todo -= tab_pad;
|
|
878 |
+#ifdef FEAT_VARTABS
|
|
879 |
+ ind_done += tab_pad;
|
|
880 |
+#endif
|
|
881 |
}
|
|
882 |
|
|
883 |
p = skipwhite(p);
|
|
884 |
}
|
|
885 |
|
|
886 |
+#ifdef FEAT_VARTABS
|
|
887 |
+ for (;;)
|
|
888 |
+ {
|
|
889 |
+ tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_ary);
|
|
890 |
+ if (todo < tab_pad)
|
|
891 |
+ break;
|
|
892 |
+ *s++ = TAB;
|
|
893 |
+ todo -= tab_pad;
|
|
894 |
+ ind_done += tab_pad;
|
|
895 |
+ }
|
|
896 |
+#else
|
|
897 |
while (todo >= (int)curbuf->b_p_ts)
|
|
898 |
{
|
|
899 |
*s++ = TAB;
|
|
900 |
todo -= (int)curbuf->b_p_ts;
|
|
901 |
}
|
|
902 |
+#endif
|
|
903 |
}
|
|
904 |
while (todo > 0)
|
|
905 |
{
|
|
906 |
@@ -346,6 +453,9 @@ copy_indent(int size, char_u *src)
|
|
907 |
int tab_pad;
|
|
908 |
int ind_done;
|
|
909 |
int round;
|
|
910 |
+#ifdef FEAT_VARTABS
|
|
911 |
+ int ind_col;
|
|
912 |
+#endif
|
|
913 |
|
|
914 |
/* Round 1: compute the number of characters needed for the indent
|
|
915 |
* Round 2: copy the characters. */
|
|
916 |
@@ -354,6 +464,9 @@ copy_indent(int size, char_u *src)
|
|
917 |
todo = size;
|
|
918 |
ind_len = 0;
|
|
919 |
ind_done = 0;
|
|
920 |
+#ifdef FEAT_VARTABS
|
|
921 |
+ ind_col = 0;
|
|
922 |
+#endif
|
|
923 |
s = src;
|
|
924 |
|
|
925 |
/* Count/copy the usable portion of the source line */
|
|
926 |
@@ -361,18 +474,28 @@ copy_indent(int size, char_u *src)
|
|
927 |
{
|
|
928 |
if (*s == TAB)
|
|
929 |
{
|
|
930 |
+#ifdef FEAT_VARTABS
|
|
931 |
+ tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_ary);
|
|
932 |
+#else
|
|
933 |
tab_pad = (int)curbuf->b_p_ts
|
|
934 |
- (ind_done % (int)curbuf->b_p_ts);
|
|
935 |
+#endif
|
|
936 |
/* Stop if this tab will overshoot the target */
|
|
937 |
if (todo < tab_pad)
|
|
938 |
break;
|
|
939 |
todo -= tab_pad;
|
|
940 |
ind_done += tab_pad;
|
|
941 |
+#ifdef FEAT_VARTABS
|
|
942 |
+ ind_col += tab_pad;
|
|
943 |
+#endif
|
|
944 |
}
|
|
945 |
else
|
|
946 |
{
|
|
947 |
--todo;
|
|
948 |
++ind_done;
|
|
949 |
+#ifdef FEAT_VARTABS
|
|
950 |
+ ++ind_col;
|
|
951 |
+#endif
|
|
952 |
}
|
|
953 |
++ind_len;
|
|
954 |
if (p != NULL)
|
|
955 |
@@ -381,22 +504,46 @@ copy_indent(int size, char_u *src)
|
|
956 |
}
|
|
957 |
|
|
958 |
/* Fill to next tabstop with a tab, if possible */
|
|
959 |
+#ifdef FEAT_VARTABS
|
|
960 |
+ tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_ary);
|
|
961 |
+#else
|
|
962 |
tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
|
|
963 |
+#endif
|
|
964 |
if (todo >= tab_pad && !curbuf->b_p_et)
|
|
965 |
{
|
|
966 |
todo -= tab_pad;
|
|
967 |
++ind_len;
|
|
968 |
+#ifdef FEAT_VARTABS
|
|
969 |
+ ind_col += tab_pad;
|
|
970 |
+#endif
|
|
971 |
if (p != NULL)
|
|
972 |
*p++ = TAB;
|
|
973 |
}
|
|
974 |
|
|
975 |
/* Add tabs required for indent */
|
|
976 |
- while (todo >= (int)curbuf->b_p_ts && !curbuf->b_p_et)
|
|
977 |
+ if (!curbuf->b_p_et)
|
|
978 |
{
|
|
979 |
- todo -= (int)curbuf->b_p_ts;
|
|
980 |
- ++ind_len;
|
|
981 |
- if (p != NULL)
|
|
982 |
- *p++ = TAB;
|
|
983 |
+#ifdef FEAT_VARTABS
|
|
984 |
+ for (;;)
|
|
985 |
+ {
|
|
986 |
+ tab_pad = tabstop_padding(ind_col, curbuf->b_p_ts, curbuf->b_p_vts_ary);
|
|
987 |
+ if (todo < tab_pad)
|
|
988 |
+ break;
|
|
989 |
+ todo -= tab_pad;
|
|
990 |
+ ++ind_len;
|
|
991 |
+ ind_col += tab_pad;
|
|
992 |
+ if (p != NULL)
|
|
993 |
+ *p++ = TAB;
|
|
994 |
+ }
|
|
995 |
+#else
|
|
996 |
+ while (todo >= (int)curbuf->b_p_ts)
|
|
997 |
+ {
|
|
998 |
+ todo -= (int)curbuf->b_p_ts;
|
|
999 |
+ ++ind_len;
|
|
1000 |
+ if (p != NULL)
|
|
1001 |
+ *p++ = TAB;
|
|
1002 |
+ }
|
|
1003 |
+#endif
|
|
1004 |
}
|
|
1005 |
|
|
1006 |
/* Count/add spaces required for indent */
|
|
1007 |
@@ -493,6 +640,7 @@ get_breakindent_win(
|
|
1008 |
static long prev_ts = 0L; /* cached tabstop value */
|
|
1009 |
static char_u *prev_line = NULL; /* cached pointer to line */
|
|
1010 |
static int prev_tick = 0; /* changedtick of cached value */
|
|
1011 |
+ static int *prev_vts = 0; /* cached vartabs values */
|
|
1012 |
int bri = 0;
|
|
1013 |
/* window width minus window margin space, i.e. what rests for text */
|
|
1014 |
const int eff_wwidth = W_WIDTH(wp)
|
|
1015 |
@@ -502,13 +650,24 @@ get_breakindent_win(
|
|
1016 |
|
|
1017 |
/* used cached indent, unless pointer or 'tabstop' changed */
|
|
1018 |
if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
|
|
1019 |
- || prev_tick != wp->w_buffer->b_changedtick)
|
|
1020 |
+ || prev_tick != wp->w_buffer->b_changedtick
|
|
1021 |
+#ifdef FEAT_VARTABS
|
|
1022 |
+ || prev_vts != wp->w_buffer->b_p_vts_ary
|
|
1023 |
+#endif
|
|
1024 |
+ )
|
|
1025 |
{
|
|
1026 |
prev_line = line;
|
|
1027 |
prev_ts = wp->w_buffer->b_p_ts;
|
|
1028 |
prev_tick = wp->w_buffer->b_changedtick;
|
|
1029 |
+#ifdef FEAT_VARTABS
|
|
1030 |
+ prev_vts = wp->w_buffer->b_p_vts_ary;
|
|
1031 |
+ prev_indent = get_indent_str_vtab(line,
|
|
1032 |
+ (int)wp->w_buffer->b_p_ts,
|
|
1033 |
+ wp->w_buffer->b_p_vts_ary, wp->w_p_list);
|
|
1034 |
+#else
|
|
1035 |
prev_indent = get_indent_str(line,
|
|
1036 |
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
|
|
1037 |
+#endif
|
|
1038 |
}
|
|
1039 |
bri = prev_indent + wp->w_p_brishift;
|
|
1040 |
|
|
1041 |
@@ -734,7 +893,12 @@ open_line(
|
|
1042 |
/*
|
|
1043 |
* count white space on current line
|
|
1044 |
*/
|
|
1045 |
+#ifdef FEAT_VARTABS
|
|
1046 |
+ newindent = get_indent_str_vtab(saved_line, curbuf->b_p_ts,
|
|
1047 |
+ curbuf->b_p_vts_ary, FALSE);
|
|
1048 |
+#else
|
|
1049 |
newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts, FALSE);
|
|
1050 |
+#endif
|
|
1051 |
if (newindent == 0 && !(flags & OPENLINE_COM_LIST))
|
|
1052 |
newindent = second_line_indent; /* for ^^D command in insert mode */
|
|
1053 |
|
|
1054 |
@@ -1257,7 +1421,12 @@ open_line(
|
|
1055 |
|| do_si
|
|
1056 |
#endif
|
|
1057 |
)
|
|
1058 |
+#ifdef FEAT_VARTABS
|
|
1059 |
+ newindent = get_indent_str_vtab(leader, curbuf->b_p_ts,
|
|
1060 |
+ curbuf->b_p_vts_ary, FALSE);
|
|
1061 |
+#else
|
|
1062 |
newindent = get_indent_str(leader, (int)curbuf->b_p_ts, FALSE);
|
|
1063 |
+#endif
|
|
1064 |
|
|
1065 |
/* Add the indent offset */
|
|
1066 |
if (newindent + off < 0)
|
|
1067 |
diff --git a/src/ops.c b/src/ops.c
|
|
1068 |
index 4bef6c5..2f02246 100644
|
|
1069 |
--- a/src/ops.c
|
|
1070 |
+++ b/src/ops.c
|
|
1071 |
@@ -380,6 +380,9 @@ shift_block(oparg_T *oap, int amount)
|
|
1072 |
char_u *newp, *oldp;
|
|
1073 |
int oldcol = curwin->w_cursor.col;
|
|
1074 |
int p_sw = (int)get_sw_value(curbuf);
|
|
1075 |
+#ifdef FEAT_VARTABS
|
|
1076 |
+ int *p_vts = curbuf->b_p_vts_ary;
|
|
1077 |
+#endif
|
|
1078 |
int p_ts = (int)curbuf->b_p_ts;
|
|
1079 |
struct block_def bd;
|
|
1080 |
int incr;
|
|
1081 |
@@ -438,12 +441,19 @@ shift_block(oparg_T *oap, int amount)
|
|
1082 |
}
|
|
1083 |
/* OK, now total=all the VWS reqd, and textstart points at the 1st
|
|
1084 |
* non-ws char in the block. */
|
|
1085 |
+#ifdef FEAT_VARTABS
|
|
1086 |
+ if (!curbuf->b_p_et)
|
|
1087 |
+ tabstop_fromto(ws_vcol, ws_vcol + total, p_ts, p_vts, &i, &j);
|
|
1088 |
+ else
|
|
1089 |
+ j = total;
|
|
1090 |
+#else
|
|
1091 |
if (!curbuf->b_p_et)
|
|
1092 |
i = ((ws_vcol % p_ts) + total) / p_ts; /* number of tabs */
|
|
1093 |
if (i)
|
|
1094 |
j = ((ws_vcol % p_ts) + total) % p_ts; /* number of spp */
|
|
1095 |
else
|
|
1096 |
j = total;
|
|
1097 |
+#endif
|
|
1098 |
/* if we're splitting a TAB, allow for it */
|
|
1099 |
bd.textcol -= bd.pre_whitesp_c - (bd.startspaces != 0);
|
|
1100 |
len = (int)STRLEN(bd.textstart) + 1;
|
|
1101 |
@@ -3527,10 +3537,18 @@ do_put(
|
|
1102 |
{
|
|
1103 |
/* Don't need to insert spaces when "p" on the last position of a
|
|
1104 |
* tab or "P" on the first position. */
|
|
1105 |
+#ifdef FEAT_VARTABS
|
|
1106 |
+ int viscol = getviscol();
|
|
1107 |
+ if (dir == FORWARD
|
|
1108 |
+ ? tabstop_padding(viscol, curbuf->b_p_ts, curbuf->b_p_vts_ary) != 1
|
|
1109 |
+ : curwin->w_cursor.coladd > 0)
|
|
1110 |
+ coladvance_force(viscol);
|
|
1111 |
+#else
|
|
1112 |
if (dir == FORWARD
|
|
1113 |
? (int)curwin->w_cursor.coladd < curbuf->b_p_ts - 1
|
|
1114 |
: curwin->w_cursor.coladd > 0)
|
|
1115 |
coladvance_force(getviscol());
|
|
1116 |
+#endif
|
|
1117 |
else
|
|
1118 |
curwin->w_cursor.coladd = 0;
|
|
1119 |
}
|
|
1120 |
diff --git a/src/option.c b/src/option.c
|
|
1121 |
index 93e3c39..da91f8a 100644
|
|
1122 |
--- a/src/option.c
|
|
1123 |
+++ b/src/option.c
|
|
1124 |
@@ -180,6 +180,10 @@
|
|
1125 |
# define PV_UDF OPT_BUF(BV_UDF)
|
|
1126 |
#endif
|
|
1127 |
#define PV_WM OPT_BUF(BV_WM)
|
|
1128 |
+#ifdef FEAT_VARTABS
|
|
1129 |
+#define PV_VSTS OPT_BUF(BV_VSTS)
|
|
1130 |
+#define PV_VTS OPT_BUF(BV_VTS)
|
|
1131 |
+#endif
|
|
1132 |
|
|
1133 |
/*
|
|
1134 |
* Definition of the PV_ values for window-local options.
|
|
1135 |
@@ -374,6 +378,10 @@ static int p_tx;
|
|
1136 |
static int p_udf;
|
|
1137 |
#endif
|
|
1138 |
static long p_wm;
|
|
1139 |
+#ifdef FEAT_VARTABS
|
|
1140 |
+static char_u *p_vsts;
|
|
1141 |
+static char_u *p_vts;
|
|
1142 |
+#endif
|
|
1143 |
#ifdef FEAT_KEYMAP
|
|
1144 |
static char_u *p_keymap;
|
|
1145 |
#endif
|
|
1146 |
@@ -390,6 +398,9 @@ static int p_et_nopaste;
|
|
1147 |
static long p_sts_nopaste;
|
|
1148 |
static long p_tw_nopaste;
|
|
1149 |
static long p_wm_nopaste;
|
|
1150 |
+#ifdef FEAT_VARTABS
|
|
1151 |
+static char_u *p_vsts_nopaste;
|
|
1152 |
+#endif
|
|
1153 |
|
|
1154 |
struct vimoption
|
|
1155 |
{
|
|
1156 |
@@ -2777,6 +2788,14 @@ static struct vimoption options[] =
|
|
1157 |
{"updatetime", "ut", P_NUM|P_VI_DEF,
|
|
1158 |
(char_u *)&p_ut, PV_NONE,
|
|
1159 |
{(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
|
|
1160 |
+#ifdef FEAT_VARTABS
|
|
1161 |
+ {"varsofttabstop", "vsts", P_STRING|P_VI_DEF|P_VIM|P_COMMA,
|
|
1162 |
+ (char_u *)&p_vsts, PV_VSTS,
|
|
1163 |
+ {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
|
|
1164 |
+ {"vartabstop", "vts", P_STRING|P_VI_DEF|P_VIM|P_RBUF|P_COMMA,
|
|
1165 |
+ (char_u *)&p_vts, PV_VTS,
|
|
1166 |
+ {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
|
|
1167 |
+#endif
|
|
1168 |
{"verbose", "vbs", P_NUM|P_VI_DEF,
|
|
1169 |
(char_u *)&p_verbose, PV_NONE,
|
|
1170 |
{(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
|
|
1171 |
@@ -5433,6 +5452,10 @@ didset_options2(void)
|
|
1172 |
/* Parse default for 'clipboard' */
|
|
1173 |
(void)check_clipboard_option();
|
|
1174 |
#endif
|
|
1175 |
+#ifdef FEAT_VARTABS
|
|
1176 |
+ tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_ary);
|
|
1177 |
+ tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_ary);
|
|
1178 |
+#endif
|
|
1179 |
}
|
|
1180 |
|
|
1181 |
/*
|
|
1182 |
@@ -5550,6 +5573,10 @@ check_buf_options(buf_T *buf)
|
|
1183 |
check_string_option(&buf->b_p_lw);
|
|
1184 |
#endif
|
|
1185 |
check_string_option(&buf->b_p_bkc);
|
|
1186 |
+#ifdef FEAT_VARTABS
|
|
1187 |
+ check_string_option(&buf->b_p_vsts);
|
|
1188 |
+ check_string_option(&buf->b_p_vts);
|
|
1189 |
+#endif
|
|
1190 |
}
|
|
1191 |
|
|
1192 |
/*
|
|
1193 |
@@ -7222,6 +7249,88 @@ did_set_string_option(
|
|
1194 |
}
|
|
1195 |
#endif
|
|
1196 |
|
|
1197 |
+#ifdef FEAT_VARTABS
|
|
1198 |
+ /* 'varsofttabstop' */
|
|
1199 |
+ else if (varp == &(curbuf->b_p_vsts))
|
|
1200 |
+ {
|
|
1201 |
+ char_u *cp;
|
|
1202 |
+
|
|
1203 |
+ if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1]))
|
|
1204 |
+ {
|
|
1205 |
+ if (curbuf->b_p_vsts_ary)
|
|
1206 |
+ {
|
|
1207 |
+ vim_free(curbuf->b_p_vsts_ary);
|
|
1208 |
+ curbuf->b_p_vsts_ary = 0;
|
|
1209 |
+ }
|
|
1210 |
+ }
|
|
1211 |
+ else
|
|
1212 |
+ {
|
|
1213 |
+ for (cp = *varp; *cp; ++cp)
|
|
1214 |
+ {
|
|
1215 |
+ if (vim_isdigit(*cp))
|
|
1216 |
+ continue;
|
|
1217 |
+ if (*cp == ',' && cp > *varp && *(cp-1) != ',')
|
|
1218 |
+ continue;
|
|
1219 |
+ errmsg = e_invarg;
|
|
1220 |
+ break;
|
|
1221 |
+ }
|
|
1222 |
+ if (errmsg == NULL)
|
|
1223 |
+ {
|
|
1224 |
+ int *oldarray = curbuf->b_p_vsts_ary;
|
|
1225 |
+ if (tabstop_set(*varp, &(curbuf->b_p_vsts_ary)))
|
|
1226 |
+ {
|
|
1227 |
+ if (oldarray)
|
|
1228 |
+ vim_free(oldarray);
|
|
1229 |
+ }
|
|
1230 |
+ else
|
|
1231 |
+ errmsg = e_invarg;
|
|
1232 |
+ }
|
|
1233 |
+ }
|
|
1234 |
+ }
|
|
1235 |
+
|
|
1236 |
+ /* 'vartabstop' */
|
|
1237 |
+ else if (varp == &(curbuf->b_p_vts))
|
|
1238 |
+ {
|
|
1239 |
+ char_u *cp;
|
|
1240 |
+
|
|
1241 |
+ if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1]))
|
|
1242 |
+ {
|
|
1243 |
+ if (curbuf->b_p_vts_ary)
|
|
1244 |
+ {
|
|
1245 |
+ vim_free(curbuf->b_p_vts_ary);
|
|
1246 |
+ curbuf->b_p_vts_ary = 0;
|
|
1247 |
+ }
|
|
1248 |
+ }
|
|
1249 |
+ else
|
|
1250 |
+ {
|
|
1251 |
+ for (cp = *varp; *cp; ++cp)
|
|
1252 |
+ {
|
|
1253 |
+ if (vim_isdigit(*cp))
|
|
1254 |
+ continue;
|
|
1255 |
+ if (*cp == ',' && cp > *varp && *(cp-1) != ',')
|
|
1256 |
+ continue;
|
|
1257 |
+ errmsg = e_invarg;
|
|
1258 |
+ break;
|
|
1259 |
+ }
|
|
1260 |
+ if (errmsg == NULL)
|
|
1261 |
+ {
|
|
1262 |
+ int *oldarray = curbuf->b_p_vts_ary;
|
|
1263 |
+ if (tabstop_set(*varp, &(curbuf->b_p_vts_ary)))
|
|
1264 |
+ {
|
|
1265 |
+ if (oldarray)
|
|
1266 |
+ vim_free(oldarray);
|
|
1267 |
+#ifdef FEAT_FOLDING
|
|
1268 |
+ if (foldmethodIsIndent(curwin))
|
|
1269 |
+ foldUpdateAll(curwin);
|
|
1270 |
+#endif /* FEAT_FOLDING */
|
|
1271 |
+ }
|
|
1272 |
+ else
|
|
1273 |
+ errmsg = e_invarg;
|
|
1274 |
+ }
|
|
1275 |
+ }
|
|
1276 |
+ }
|
|
1277 |
+#endif
|
|
1278 |
+
|
|
1279 |
/* Options that are a list of flags. */
|
|
1280 |
else
|
|
1281 |
{
|
|
1282 |
@@ -8489,7 +8598,14 @@ set_num_option(
|
|
1283 |
if (curbuf->b_p_sw < 0)
|
|
1284 |
{
|
|
1285 |
errmsg = e_positive;
|
|
1286 |
+#ifdef FEAT_VARTABS
|
|
1287 |
+ /* Use the first 'vartabstop' value, or 'tabstop' if vts isn't in use. */
|
|
1288 |
+ curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_ary) > 0
|
|
1289 |
+ ? tabstop_first(curbuf->b_p_vts_ary)
|
|
1290 |
+ : curbuf->b_p_ts;
|
|
1291 |
+#else
|
|
1292 |
curbuf->b_p_sw = curbuf->b_p_ts;
|
|
1293 |
+#endif
|
|
1294 |
}
|
|
1295 |
|
|
1296 |
/*
|
|
1297 |
@@ -10466,6 +10582,10 @@ get_varp(struct vimoption *p)
|
|
1298 |
#ifdef FEAT_SIGNS
|
|
1299 |
case PV_SCL: return (char_u *)&(curwin->w_p_scl);
|
|
1300 |
#endif
|
|
1301 |
+#ifdef FEAT_VARTABS
|
|
1302 |
+ case PV_VSTS: return (char_u *)&(curbuf->b_p_vsts);
|
|
1303 |
+ case PV_VTS: return (char_u *)&(curbuf->b_p_vts);
|
|
1304 |
+#endif
|
|
1305 |
default: EMSG(_("E356: get_varp ERROR"));
|
|
1306 |
}
|
|
1307 |
/* always return a valid pointer to avoid a crash! */
|
|
1308 |
@@ -10774,6 +10894,15 @@ buf_copy_options(buf_T *buf, int flags)
|
|
1309 |
#endif
|
|
1310 |
buf->b_p_sts = p_sts;
|
|
1311 |
buf->b_p_sts_nopaste = p_sts_nopaste;
|
|
1312 |
+#ifdef FEAT_VARTABS
|
|
1313 |
+ buf->b_p_vsts = vim_strsave(p_vsts);
|
|
1314 |
+ if (p_vsts && p_vsts != empty_option)
|
|
1315 |
+ tabstop_set(p_vsts, &buf->b_p_vsts_ary);
|
|
1316 |
+ else
|
|
1317 |
+ buf->b_p_vsts_ary = 0;
|
|
1318 |
+ buf->b_p_vsts_nopaste = p_vsts_nopaste
|
|
1319 |
+ ? vim_strsave(p_vsts_nopaste) : NULL;
|
|
1320 |
+#endif
|
|
1321 |
buf->b_p_sn = p_sn;
|
|
1322 |
#ifdef FEAT_COMMENTS
|
|
1323 |
buf->b_p_com = vim_strsave(p_com);
|
|
1324 |
@@ -10890,12 +11019,27 @@ buf_copy_options(buf_T *buf, int flags)
|
|
1325 |
* or to a help buffer.
|
|
1326 |
*/
|
|
1327 |
if (dont_do_help)
|
|
1328 |
+ {
|
|
1329 |
buf->b_p_isk = save_p_isk;
|
|
1330 |
+#ifdef FEAT_VARTABS
|
|
1331 |
+ if (p_vts && p_vts != empty_option && !buf->b_p_vts_ary)
|
|
1332 |
+ tabstop_set(p_vts, &buf->b_p_vts_ary);
|
|
1333 |
+ else
|
|
1334 |
+ buf->b_p_vts_ary = 0;
|
|
1335 |
+#endif
|
|
1336 |
+ }
|
|
1337 |
else
|
|
1338 |
{
|
|
1339 |
buf->b_p_isk = vim_strsave(p_isk);
|
|
1340 |
did_isk = TRUE;
|
|
1341 |
buf->b_p_ts = p_ts;
|
|
1342 |
+#ifdef FEAT_VARTABS
|
|
1343 |
+ buf->b_p_vts = vim_strsave(p_vts);
|
|
1344 |
+ if (p_vts && p_vts != empty_option && !buf->b_p_vts_ary)
|
|
1345 |
+ tabstop_set(p_vts, &buf->b_p_vts_ary);
|
|
1346 |
+ else
|
|
1347 |
+ buf->b_p_vts_ary = 0;
|
|
1348 |
+#endif
|
|
1349 |
buf->b_help = FALSE;
|
|
1350 |
#ifdef FEAT_QUICKFIX
|
|
1351 |
if (buf->b_p_bt[0] == 'h')
|
|
1352 |
@@ -11718,6 +11862,12 @@ paste_option_changed(void)
|
|
1353 |
buf->b_p_sts_nopaste = buf->b_p_sts;
|
|
1354 |
buf->b_p_ai_nopaste = buf->b_p_ai;
|
|
1355 |
buf->b_p_et_nopaste = buf->b_p_et;
|
|
1356 |
+#ifdef FEAT_VARTABS
|
|
1357 |
+ if (buf->b_p_vsts_nopaste)
|
|
1358 |
+ vim_free(buf->b_p_vsts_nopaste);
|
|
1359 |
+ buf->b_p_vsts_nopaste = buf->b_p_vsts && buf->b_p_vsts != empty_option
|
|
1360 |
+ ? vim_strsave(buf->b_p_vsts) : NULL;
|
|
1361 |
+#endif
|
|
1362 |
}
|
|
1363 |
|
|
1364 |
/* save global options */
|
|
1365 |
@@ -11736,6 +11886,11 @@ paste_option_changed(void)
|
|
1366 |
p_sts_nopaste = p_sts;
|
|
1367 |
p_tw_nopaste = p_tw;
|
|
1368 |
p_wm_nopaste = p_wm;
|
|
1369 |
+#ifdef FEAT_VARTABS
|
|
1370 |
+ if (p_vsts_nopaste)
|
|
1371 |
+ vim_free(p_vsts_nopaste);
|
|
1372 |
+ p_vsts_nopaste = p_vsts && p_vsts != empty_option ? vim_strsave(p_vsts) : NULL;
|
|
1373 |
+#endif
|
|
1374 |
}
|
|
1375 |
|
|
1376 |
/*
|
|
1377 |
@@ -11750,6 +11905,14 @@ paste_option_changed(void)
|
|
1378 |
buf->b_p_sts = 0; /* softtabstop is 0 */
|
|
1379 |
buf->b_p_ai = 0; /* no auto-indent */
|
|
1380 |
buf->b_p_et = 0; /* no expandtab */
|
|
1381 |
+#ifdef FEAT_VARTABS
|
|
1382 |
+ if (buf->b_p_vsts)
|
|
1383 |
+ free_string_option(buf->b_p_vsts);
|
|
1384 |
+ buf->b_p_vsts = empty_option;
|
|
1385 |
+ if (buf->b_p_vsts_ary)
|
|
1386 |
+ vim_free(buf->b_p_vsts_ary);
|
|
1387 |
+ buf->b_p_vsts_ary = 0;
|
|
1388 |
+#endif
|
|
1389 |
}
|
|
1390 |
|
|
1391 |
/* set global options */
|
|
1392 |
@@ -11771,6 +11934,11 @@ paste_option_changed(void)
|
|
1393 |
p_wm = 0;
|
|
1394 |
p_sts = 0;
|
|
1395 |
p_ai = 0;
|
|
1396 |
+#ifdef FEAT_VARTABS
|
|
1397 |
+ if (p_vsts)
|
|
1398 |
+ free_string_option(p_vsts);
|
|
1399 |
+ p_vsts = empty_option;
|
|
1400 |
+#endif
|
|
1401 |
}
|
|
1402 |
|
|
1403 |
/*
|
|
1404 |
@@ -11786,6 +11954,18 @@ paste_option_changed(void)
|
|
1405 |
buf->b_p_sts = buf->b_p_sts_nopaste;
|
|
1406 |
buf->b_p_ai = buf->b_p_ai_nopaste;
|
|
1407 |
buf->b_p_et = buf->b_p_et_nopaste;
|
|
1408 |
+#ifdef FEAT_VARTABS
|
|
1409 |
+ if (buf->b_p_vsts)
|
|
1410 |
+ free_string_option(buf->b_p_vsts);
|
|
1411 |
+ buf->b_p_vsts = buf->b_p_vsts_nopaste
|
|
1412 |
+ ? vim_strsave(buf->b_p_vsts_nopaste) : empty_option;
|
|
1413 |
+ if (buf->b_p_vsts_ary)
|
|
1414 |
+ vim_free(buf->b_p_vsts_ary);
|
|
1415 |
+ if (buf->b_p_vsts && buf->b_p_vsts != empty_option)
|
|
1416 |
+ tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_ary);
|
|
1417 |
+ else
|
|
1418 |
+ buf->b_p_vsts_ary = 0;
|
|
1419 |
+#endif
|
|
1420 |
}
|
|
1421 |
|
|
1422 |
/* restore global options */
|
|
1423 |
@@ -11808,6 +11988,11 @@ paste_option_changed(void)
|
|
1424 |
p_sts = p_sts_nopaste;
|
|
1425 |
p_tw = p_tw_nopaste;
|
|
1426 |
p_wm = p_wm_nopaste;
|
|
1427 |
+#ifdef FEAT_VARTABS
|
|
1428 |
+ if (p_vsts)
|
|
1429 |
+ free_string_option(p_vsts);
|
|
1430 |
+ p_vsts = p_vsts_nopaste ? vim_strsave(p_vsts_nopaste) : empty_option;
|
|
1431 |
+#endif
|
|
1432 |
}
|
|
1433 |
|
|
1434 |
old_p_paste = p_paste;
|
|
1435 |
@@ -12144,6 +12329,301 @@ check_ff_value(char_u *p)
|
|
1436 |
return check_opt_strings(p, p_ff_values, FALSE);
|
|
1437 |
}
|
|
1438 |
|
|
1439 |
+#ifdef FEAT_VARTABS
|
|
1440 |
+
|
|
1441 |
+/*
|
|
1442 |
+ * Set the integer values corresponding to the string setting of 'vartabstop'.
|
|
1443 |
+ */
|
|
1444 |
+ int
|
|
1445 |
+tabstop_set(var, array)
|
|
1446 |
+ char_u *var;
|
|
1447 |
+ int **array;
|
|
1448 |
+{
|
|
1449 |
+ int valcount = 1;
|
|
1450 |
+ int t;
|
|
1451 |
+ char_u *cp;
|
|
1452 |
+
|
|
1453 |
+ if ((!var[0] || (var[0] == '0' && !var[1])))
|
|
1454 |
+ {
|
|
1455 |
+ *array = (int *)0;
|
|
1456 |
+ return TRUE;
|
|
1457 |
+ }
|
|
1458 |
+
|
|
1459 |
+ for (cp = var; *cp; ++cp)
|
|
1460 |
+ {
|
|
1461 |
+ if (cp == var || *(cp - 1) == ',')
|
|
1462 |
+ if (atoi((char *)cp) <= 0)
|
|
1463 |
+ return FALSE;
|
|
1464 |
+
|
|
1465 |
+ if (VIM_ISDIGIT(*cp))
|
|
1466 |
+ continue;
|
|
1467 |
+ if (*cp == ',' && cp > var && *(cp - 1) != ',')
|
|
1468 |
+ {
|
|
1469 |
+ ++valcount;
|
|
1470 |
+ continue;
|
|
1471 |
+ }
|
|
1472 |
+ return FALSE;
|
|
1473 |
+ }
|
|
1474 |
+
|
|
1475 |
+ *array = (int *) alloc((unsigned) ((valcount + 1) * sizeof(int)));
|
|
1476 |
+ (*array)[0] = valcount;
|
|
1477 |
+
|
|
1478 |
+ t = 1;
|
|
1479 |
+ for (cp = var; *cp;)
|
|
1480 |
+ {
|
|
1481 |
+ (*array)[t++] = atoi((char *)cp);
|
|
1482 |
+ while (*cp && *cp != ',')
|
|
1483 |
+ ++cp;
|
|
1484 |
+ if (*cp)
|
|
1485 |
+ ++cp;
|
|
1486 |
+ }
|
|
1487 |
+
|
|
1488 |
+ return TRUE;
|
|
1489 |
+}
|
|
1490 |
+
|
|
1491 |
+/*
|
|
1492 |
+ * Calculate the number of screen spaces a tab will occupy.
|
|
1493 |
+ * If vts is set then the tab widths are taken from that array,
|
|
1494 |
+ * otherwise the value of ts is used.
|
|
1495 |
+ */
|
|
1496 |
+ int
|
|
1497 |
+tabstop_padding(col, ts, vts)
|
|
1498 |
+ colnr_T col;
|
|
1499 |
+ int ts;
|
|
1500 |
+ int *vts;
|
|
1501 |
+{
|
|
1502 |
+ int tabcount;
|
|
1503 |
+ colnr_T tabcol = 0;
|
|
1504 |
+ int t;
|
|
1505 |
+ int padding = 0;
|
|
1506 |
+
|
|
1507 |
+ if (ts == 0)
|
|
1508 |
+ ts = 8;
|
|
1509 |
+ if (vts == 0 || vts[0] == 0)
|
|
1510 |
+ return ts - (col % ts);
|
|
1511 |
+
|
|
1512 |
+ tabcount = vts[0];
|
|
1513 |
+
|
|
1514 |
+ for (t = 1; t <= tabcount; ++t)
|
|
1515 |
+ {
|
|
1516 |
+ tabcol += vts[t];
|
|
1517 |
+ if (tabcol > col)
|
|
1518 |
+ {
|
|
1519 |
+ padding = (int)(tabcol - col);
|
|
1520 |
+ break;
|
|
1521 |
+ }
|
|
1522 |
+ }
|
|
1523 |
+ if (t > tabcount)
|
|
1524 |
+ padding = vts[tabcount] - (int)((col - tabcol) % vts[tabcount]);
|
|
1525 |
+
|
|
1526 |
+ return padding;
|
|
1527 |
+}
|
|
1528 |
+
|
|
1529 |
+/*
|
|
1530 |
+ * Find the size of the tab that covers a particular column.
|
|
1531 |
+ */
|
|
1532 |
+ int
|
|
1533 |
+tabstop_at(col, ts, vts)
|
|
1534 |
+ colnr_T col;
|
|
1535 |
+ int ts;
|
|
1536 |
+ int *vts;
|
|
1537 |
+{
|
|
1538 |
+ int tabcount;
|
|
1539 |
+ colnr_T tabcol = 0;
|
|
1540 |
+ int t;
|
|
1541 |
+ int tab_size = 0;
|
|
1542 |
+
|
|
1543 |
+ if (vts == 0 || vts[0] == 0)
|
|
1544 |
+ return ts;
|
|
1545 |
+
|
|
1546 |
+ tabcount = vts[0];
|
|
1547 |
+ for (t = 1; t <= tabcount; ++t)
|
|
1548 |
+ {
|
|
1549 |
+ tabcol += vts[t];
|
|
1550 |
+ if (tabcol > col)
|
|
1551 |
+ {
|
|
1552 |
+ tab_size = vts[t];
|
|
1553 |
+ break;
|
|
1554 |
+ }
|
|
1555 |
+ }
|
|
1556 |
+ if (t > tabcount)
|
|
1557 |
+ tab_size = vts[tabcount];
|
|
1558 |
+
|
|
1559 |
+ return tab_size;
|
|
1560 |
+}
|
|
1561 |
+
|
|
1562 |
+/*
|
|
1563 |
+ * Find the column on which a tab starts.
|
|
1564 |
+ */
|
|
1565 |
+ colnr_T
|
|
1566 |
+tabstop_start(col, ts, vts)
|
|
1567 |
+ colnr_T col;
|
|
1568 |
+ int ts;
|
|
1569 |
+ int *vts;
|
|
1570 |
+{
|
|
1571 |
+ int tabcount;
|
|
1572 |
+ colnr_T tabcol = 0;
|
|
1573 |
+ int t;
|
|
1574 |
+
|
|
1575 |
+ if (vts == 0 || vts[0] == 0)
|
|
1576 |
+ return (col / ts) * ts;
|
|
1577 |
+
|
|
1578 |
+ tabcount = vts[0];
|
|
1579 |
+ for (t = 1; t <= tabcount; ++t)
|
|
1580 |
+ {
|
|
1581 |
+ tabcol += vts[t];
|
|
1582 |
+ if (tabcol > col)
|
|
1583 |
+ return tabcol - vts[t];
|
|
1584 |
+ }
|
|
1585 |
+
|
|
1586 |
+ int excess = tabcol % vts[tabcount];
|
|
1587 |
+ return excess + ((col - excess) / vts[tabcount]) * vts[tabcount];
|
|
1588 |
+}
|
|
1589 |
+
|
|
1590 |
+/*
|
|
1591 |
+ * Find the number of tabs and spaces necessary to get from one column
|
|
1592 |
+ * to another.
|
|
1593 |
+ */
|
|
1594 |
+ void
|
|
1595 |
+tabstop_fromto(start_col, end_col, ts, vts, ntabs, nspcs)
|
|
1596 |
+ colnr_T start_col;
|
|
1597 |
+ colnr_T end_col;
|
|
1598 |
+ int ts;
|
|
1599 |
+ int *vts;
|
|
1600 |
+ int *ntabs;
|
|
1601 |
+ int *nspcs;
|
|
1602 |
+{
|
|
1603 |
+ int spaces = end_col - start_col;
|
|
1604 |
+ colnr_T tabcol = 0;
|
|
1605 |
+ int padding = 0;
|
|
1606 |
+ int tabcount;
|
|
1607 |
+ int t;
|
|
1608 |
+
|
|
1609 |
+ if (vts == 0 || vts[0] == 0)
|
|
1610 |
+ {
|
|
1611 |
+ int tabs = 0;
|
|
1612 |
+ int initspc = ts - (start_col % ts);
|
|
1613 |
+ if (spaces >= initspc)
|
|
1614 |
+ {
|
|
1615 |
+ spaces -= initspc;
|
|
1616 |
+ tabs++;
|
|
1617 |
+ }
|
|
1618 |
+ tabs += spaces / ts;
|
|
1619 |
+ spaces -= (spaces / ts) * ts;
|
|
1620 |
+
|
|
1621 |
+ *ntabs = tabs;
|
|
1622 |
+ *nspcs = spaces;
|
|
1623 |
+ return;
|
|
1624 |
+ }
|
|
1625 |
+
|
|
1626 |
+ /* Find the padding needed to reach the next tabstop. */
|
|
1627 |
+ tabcount = vts[0];
|
|
1628 |
+ for (t = 1; t <= tabcount; ++t)
|
|
1629 |
+ {
|
|
1630 |
+ tabcol += vts[t];
|
|
1631 |
+ if (tabcol > start_col)
|
|
1632 |
+ {
|
|
1633 |
+ padding = (int)(tabcol - start_col);
|
|
1634 |
+ break;
|
|
1635 |
+ }
|
|
1636 |
+ }
|
|
1637 |
+ if (t > tabcount)
|
|
1638 |
+ padding = vts[tabcount] - (int)((start_col - tabcol) % vts[tabcount]);
|
|
1639 |
+
|
|
1640 |
+ /* If the space needed is less than the padding no tabs can be used. */
|
|
1641 |
+ if (spaces < padding)
|
|
1642 |
+ {
|
|
1643 |
+ *ntabs = 0;
|
|
1644 |
+ *nspcs = spaces;
|
|
1645 |
+ return;
|
|
1646 |
+ }
|
|
1647 |
+
|
|
1648 |
+ *ntabs = 1;
|
|
1649 |
+ spaces -= padding;
|
|
1650 |
+
|
|
1651 |
+ /* At least one tab has been used. See if any more will fit. */
|
|
1652 |
+ while (spaces != 0 && ++t <= tabcount)
|
|
1653 |
+ {
|
|
1654 |
+ padding = vts[t];
|
|
1655 |
+ if (spaces < padding)
|
|
1656 |
+ {
|
|
1657 |
+ *nspcs = spaces;
|
|
1658 |
+ return;
|
|
1659 |
+ }
|
|
1660 |
+ ++*ntabs;
|
|
1661 |
+ spaces -= padding;
|
|
1662 |
+ }
|
|
1663 |
+
|
|
1664 |
+ *ntabs += spaces / vts[tabcount];
|
|
1665 |
+ *nspcs = spaces % vts[tabcount];
|
|
1666 |
+}
|
|
1667 |
+
|
|
1668 |
+/*
|
|
1669 |
+ * See if two tabstop arrays contain the same values.
|
|
1670 |
+ */
|
|
1671 |
+ int
|
|
1672 |
+tabstop_eq(ts1, ts2)
|
|
1673 |
+ int *ts1;
|
|
1674 |
+ int *ts2;
|
|
1675 |
+{
|
|
1676 |
+ int t;
|
|
1677 |
+
|
|
1678 |
+ if ((ts1 == 0 && ts2) || (ts1 && ts2 == 0))
|
|
1679 |
+ return FALSE;
|
|
1680 |
+ if (ts1 == ts2)
|
|
1681 |
+ return TRUE;
|
|
1682 |
+ if (ts1[0] != ts2[0])
|
|
1683 |
+ return FALSE;
|
|
1684 |
+
|
|
1685 |
+ for (t = 1; t <= ts1[0]; ++t)
|
|
1686 |
+ if (ts1[t] != ts2[t])
|
|
1687 |
+ return FALSE;
|
|
1688 |
+
|
|
1689 |
+ return TRUE;
|
|
1690 |
+}
|
|
1691 |
+
|
|
1692 |
+/*
|
|
1693 |
+ * Copy a tabstop array, allocating space for the new array.
|
|
1694 |
+ */
|
|
1695 |
+ int *
|
|
1696 |
+tabstop_copy(oldts)
|
|
1697 |
+ int *oldts;
|
|
1698 |
+{
|
|
1699 |
+ int *newts;
|
|
1700 |
+ int t;
|
|
1701 |
+
|
|
1702 |
+ if (oldts == 0)
|
|
1703 |
+ return 0;
|
|
1704 |
+
|
|
1705 |
+ newts = (int *) alloc((unsigned) ((oldts[0] + 1) * sizeof(int)));
|
|
1706 |
+ for (t = 0; t <= oldts[0]; ++t)
|
|
1707 |
+ newts[t] = oldts[t];
|
|
1708 |
+
|
|
1709 |
+ return newts;
|
|
1710 |
+}
|
|
1711 |
+
|
|
1712 |
+/*
|
|
1713 |
+ * Return a count of the number of tabstops.
|
|
1714 |
+ */
|
|
1715 |
+ int
|
|
1716 |
+tabstop_count(ts)
|
|
1717 |
+ int *ts;
|
|
1718 |
+{
|
|
1719 |
+ return ts ? ts[0] : 0;
|
|
1720 |
+}
|
|
1721 |
+
|
|
1722 |
+/*
|
|
1723 |
+ * Return the first tabstop, or 8 if there are no tabstops defined.
|
|
1724 |
+ */
|
|
1725 |
+ int
|
|
1726 |
+tabstop_first(ts)
|
|
1727 |
+ int *ts;
|
|
1728 |
+{
|
|
1729 |
+ return ts ? ts[1] : 8;
|
|
1730 |
+}
|
|
1731 |
+
|
|
1732 |
+#endif
|
|
1733 |
+
|
|
1734 |
/*
|
|
1735 |
* Return the effective shiftwidth value for current buffer, using the
|
|
1736 |
* 'tabstop' value when 'shiftwidth' is zero.
|
|
1737 |
diff --git a/src/option.h b/src/option.h
|
|
1738 |
index 13acabf..85c9863 100644
|
|
1739 |
--- a/src/option.h
|
|
1740 |
+++ b/src/option.h
|
|
1741 |
@@ -1102,6 +1102,10 @@ enum
|
|
1742 |
, BV_UDF
|
|
1743 |
, BV_UL
|
|
1744 |
, BV_WM
|
|
1745 |
+#ifdef FEAT_VARTABS
|
|
1746 |
+ , BV_VSTS
|
|
1747 |
+ , BV_VTS
|
|
1748 |
+#endif
|
|
1749 |
, BV_COUNT /* must be the last one */
|
|
1750 |
};
|
|
1751 |
|
|
1752 |
diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro
|
|
1753 |
index cac6449..6a2388e 100644
|
|
1754 |
--- a/src/proto/misc1.pro
|
|
1755 |
+++ b/src/proto/misc1.pro
|
|
1756 |
@@ -3,6 +3,7 @@ int get_indent(void);
|
|
1757 |
int get_indent_lnum(linenr_T lnum);
|
|
1758 |
int get_indent_buf(buf_T *buf, linenr_T lnum);
|
|
1759 |
int get_indent_str(char_u *ptr, int ts, int list);
|
|
1760 |
+int get_indent_str_vtab(char_u *ptr, int ts, int *vts, int list);
|
|
1761 |
int set_indent(int size, int flags);
|
|
1762 |
int get_number_indent(linenr_T lnum);
|
|
1763 |
int get_breakindent_win(win_T *wp, char_u *line);
|
|
1764 |
diff --git a/src/proto/option.pro b/src/proto/option.pro
|
|
1765 |
index 8c9bde5..7c659b3 100644
|
|
1766 |
--- a/src/proto/option.pro
|
|
1767 |
+++ b/src/proto/option.pro
|
|
1768 |
@@ -59,6 +59,17 @@ int can_bs(int what);
|
|
1769 |
void save_file_ff(buf_T *buf);
|
|
1770 |
int file_ff_differs(buf_T *buf, int ignore_empty);
|
|
1771 |
int check_ff_value(char_u *p);
|
|
1772 |
+#ifdef FEAT_VARTABS
|
|
1773 |
+int tabstop_set(char_u *var, int **array);
|
|
1774 |
+int tabstop_padding(colnr_T col, int ts, int *vts);
|
|
1775 |
+colnr_T tabstop_start(colnr_T col, int ts, int *vts);
|
|
1776 |
+int tabstop_at(colnr_T col, int ts, int *vts);
|
|
1777 |
+void tabstop_fromto(colnr_T start_col, colnr_T end_col, int ts, int *vts, int *ntabs, int *nspcs);
|
|
1778 |
+int tabstop_eq(int *ts1, int *ts2);
|
|
1779 |
+int *tabstop_copy(int *oldts);
|
|
1780 |
+int tabstop_count(int *ts);
|
|
1781 |
+int tabstop_first(int *ts);
|
|
1782 |
+#endif
|
|
1783 |
long get_sw_value(buf_T *buf);
|
|
1784 |
long get_sts_value(void);
|
|
1785 |
void find_mps_values(int *initc, int *findc, int *backwards, int switchit);
|
|
1786 |
diff --git a/src/screen.c b/src/screen.c
|
|
1787 |
index 4604ec7..8633071 100644
|
|
1788 |
--- a/src/screen.c
|
|
1789 |
+++ b/src/screen.c
|
|
1790 |
@@ -4647,8 +4647,13 @@ win_line(
|
|
1791 |
vcol_adjusted = vcol - MB_CHARLEN(p_sbr);
|
|
1792 |
#endif
|
|
1793 |
/* tab amount depends on current column */
|
|
1794 |
+#ifdef FEAT_VARTABS
|
|
1795 |
+ tab_len = tabstop_padding(vcol_adjusted, wp->w_buffer->b_p_ts,
|
|
1796 |
+ wp->w_buffer->b_p_vts_ary) - 1;
|
|
1797 |
+#else
|
|
1798 |
tab_len = (int)wp->w_buffer->b_p_ts
|
|
1799 |
- vcol_adjusted % (int)wp->w_buffer->b_p_ts - 1;
|
|
1800 |
+#endif
|
|
1801 |
|
|
1802 |
#ifdef FEAT_LINEBREAK
|
|
1803 |
if (!wp->w_p_lbr || !wp->w_p_list)
|
|
1804 |
diff --git a/src/structs.h b/src/structs.h
|
|
1805 |
index 2a4284a..53c3abb 100644
|
|
1806 |
--- a/src/structs.h
|
|
1807 |
+++ b/src/structs.h
|
|
1808 |
@@ -2131,6 +2131,13 @@ struct file_buffer
|
|
1809 |
long b_p_wm; /* 'wrapmargin' */
|
|
1810 |
long b_p_wm_nobin; /* b_p_wm saved for binary mode */
|
|
1811 |
long b_p_wm_nopaste; /* b_p_wm saved for paste mode */
|
|
1812 |
+#ifdef FEAT_VARTABS
|
|
1813 |
+ char_u *b_p_vsts; /* 'varsofttabstop' */
|
|
1814 |
+ int *b_p_vsts_ary; /* 'varsofttabstop' in internal format */
|
|
1815 |
+ char_u *b_p_vsts_nopaste; /* b_p_vsts saved for paste mode */
|
|
1816 |
+ char_u *b_p_vts; /* 'vartabstop' */
|
|
1817 |
+ int *b_p_vts_ary; /* 'vartabstop' in internal format */
|
|
1818 |
+#endif
|
|
1819 |
#ifdef FEAT_KEYMAP
|
|
1820 |
char_u *b_p_keymap; /* 'keymap' */
|
|
1821 |
#endif
|
|
1822 |
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
|
|
1823 |
index 65ad3ee..12097e7 100644
|
|
1824 |
--- a/src/testdir/Make_all.mak
|
|
1825 |
+++ b/src/testdir/Make_all.mak
|
|
1826 |
@@ -91,6 +91,8 @@ SCRIPTS_ALL = \
|
|
1827 |
test_listlbr.out \
|
|
1828 |
test_search_mbyte.out \
|
|
1829 |
test_utf8.out \
|
|
1830 |
+ test_vartabs.out \
|
|
1831 |
+ test_vartabs_breakindent.out \
|
|
1832 |
test_wordcount.out
|
|
1833 |
|
|
1834 |
|
|
1835 |
diff --git a/src/version.c b/src/version.c
|
|
1836 |
index 103a26f..87763ba 100644
|
|
1837 |
--- a/src/version.c
|
|
1838 |
+++ b/src/version.c
|
|
1839 |
@@ -668,6 +668,11 @@ static char *(features[]) =
|
|
1840 |
#else
|
|
1841 |
"-user_commands",
|
|
1842 |
#endif
|
|
1843 |
+#ifdef FEAT_VARTABS
|
|
1844 |
+ "+vartabs",
|
|
1845 |
+#else
|
|
1846 |
+ "-vartabs",
|
|
1847 |
+#endif
|
|
1848 |
#ifdef FEAT_WINDOWS
|
|
1849 |
"+vertsplit",
|
|
1850 |
#else
|
|
1851 |
@@ -796,6 +801,10 @@ static int included_patches[] =
|
|
1852 |
static char *(extra_patches[]) =
|
|
1853 |
{ /* Add your patch description below this line */
|
|
1854 |
/**/
|
|
1855 |
+#ifdef FEAT_VARTABS
|
|
1856 |
+ "variable tabstops",
|
|
1857 |
+#endif
|
|
1858 |
+/**/
|
|
1859 |
NULL
|
|
1860 |
};
|
|
1861 |
|
|
1862 |
diff --git a/src/workshop.c b/src/workshop.c
|
|
1863 |
index c1a3198..b2acacf 100644
|
|
1864 |
--- a/src/workshop.c
|
|
1865 |
+++ b/src/workshop.c
|
|
1866 |
@@ -50,7 +50,11 @@ static void load_window(char *, int lnum);
|
|
1867 |
static void warp_to_pc(int);
|
|
1868 |
#ifdef FEAT_BEVAL
|
|
1869 |
void workshop_beval_cb(BalloonEval *, int);
|
|
1870 |
+# ifdef FEAT_VARTABS
|
|
1871 |
+static int computeIndex(int, char_u *, int, int *);
|
|
1872 |
+# else
|
|
1873 |
static int computeIndex(int, char_u *, int);
|
|
1874 |
+# endif
|
|
1875 |
#endif
|
|
1876 |
static char *fixAccelText(char *);
|
|
1877 |
static void addMenu(char *, char *, char *);
|
|
1878 |
@@ -1537,7 +1541,11 @@ workshop_beval_cb(
|
|
1879 |
* a column number. Compute the index from col. Also set
|
|
1880 |
* line to 0 because thats what dbx expects.
|
|
1881 |
*/
|
|
1882 |
+#ifdef FEAT_VARTABS
|
|
1883 |
+ idx = computeIndex(col, text, beval->ts, beval->vts);
|
|
1884 |
+#else
|
|
1885 |
idx = computeIndex(col, text, beval->ts);
|
|
1886 |
+#endif
|
|
1887 |
if (idx > 0)
|
|
1888 |
{
|
|
1889 |
lnum = 0;
|
|
1890 |
@@ -1572,7 +1580,11 @@ workshop_beval_cb(
|
|
1891 |
computeIndex(
|
|
1892 |
int wantedCol,
|
|
1893 |
char_u *line,
|
|
1894 |
- int ts)
|
|
1895 |
+ int ts
|
|
1896 |
+#ifdef FEAT_VARTABS
|
|
1897 |
+ int *vts
|
|
1898 |
+#else
|
|
1899 |
+ )
|
|
1900 |
{
|
|
1901 |
int col = 0;
|
|
1902 |
int idx = 0;
|
|
1903 |
@@ -1580,7 +1592,11 @@ computeIndex(
|
|
1904 |
while (line[idx])
|
|
1905 |
{
|
|
1906 |
if (line[idx] == '\t')
|
|
1907 |
+#ifdef FEAT_VARTABS
|
|
1908 |
+ col += tabstop_padding(col, ts, vts);
|
|
1909 |
+#else
|
|
1910 |
col += ts - (col % ts);
|
|
1911 |
+#endif
|
|
1912 |
else
|
|
1913 |
col++;
|
|
1914 |
idx++;
|