Skip to content

Commit 85bd300

Browse files
committed
add tpl_vert in fillchars option and more tests
1 parent 598bbfe commit 85bd300

24 files changed

Lines changed: 267 additions & 164 deletions

runtime/doc/options.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3657,11 +3657,12 @@ A jump table for the options with a short description can be found at |Q_op|.
36573657
trunc '>' truncated text in the
36583658
|ins-completion-menu|.
36593659
truncrl '<' same as "trunc" in 'rightleft' mode
3660+
tpl_vert '|' vertical separators of 'tabpanel'
36603661

36613662
Any one that is omitted will fall back to the default.
36623663

36633664
Example: >
3664-
:set fillchars=stl:\ ,stlnc:\ ,vert:\|,fold:-,diff:-
3665+
:set fillchars=stl:\ ,stlnc:\ ,vert:\|,fold:-,diff:-,tpl_vert:\|
36653666
<
36663667
All items support single-byte and multibyte characters. But
36673668
double-width characters are not supported. |E1512|
@@ -8475,16 +8476,16 @@ A jump table for the options with a short description can be found at |Q_op|.
84758476
or less than the size of Vim window.
84768477
(default 20)
84778478

8478-
vert:{n} Use a vertical separator for tabpanel.
8479-
This vertical separator can contain multi-byte
8480-
characters.
8479+
vert Use a vertical separator for tabpanel.
8480+
This vertical separator is used "tpl_vert" of
8481+
'fillchars'.
84818482
(default off)
84828483

84838484
Examples: >
84848485
:set tabpanelopt=columns:16,align:right
84858486
:set tabpanelopt=
8486-
:set tabpanelopt=vert:\|,align:right
8487-
:set tabpanelopt=columns:16,vert:|
8487+
:set tabpanelopt=vert,align:right
8488+
:set tabpanelopt=columns:16
84888489
<
84898490

84908491
*'tabstop'* *'ts'*

runtime/doc/tabpage.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ wraped:
469469
|e.txt |text text text text text text text
470470
|(2) |text text text text text text text
471471
472-
The "vert:" of 'tabpanelopt' option defines the vertical separator between
473-
the tabpanel and the main window:
472+
The "vert" of 'tabpanelopt' option defines a vertical separator displayed
473+
between the tabpanel and the main window:
474474
>
475475
+------ This is
476476
|
@@ -480,6 +480,8 @@ the tabpanel and the main window:
480480
| ~/aaa.txt|text text text text text text text
481481
|(2) |text text text text text text text
482482
<
483+
The vertical separator is used "tpl_vert" of 'fillchars'.
484+
483485
You can customize the appearance of the tab page labels using the highlight
484486
groups: |hl-TabPanel| |hl-TabPanelSel| |hl-TabPanelFill|
485487

src/tabpanel.c

Lines changed: 25 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ static void do_by_tplmode(int tplmode, int col_start, int col_end,
2727

2828
#define TPL_FILLCHAR ' '
2929

30+
#define VERT_LEN 1
31+
32+
// tpl_vert's values
33+
#define VERT_OFF 0
34+
#define VERT_ON 1
35+
3036
// tpl_align's values
3137
#define ALIGN_LEFT 0
3238
#define ALIGN_RIGHT 1
@@ -35,7 +41,7 @@ static char_u *opt_name = (char_u *)"tabpanel";
3541
static int opt_scope = OPT_LOCAL;
3642
static int tpl_align = ALIGN_LEFT;
3743
static int tpl_columns = 20;
38-
static char_u *tpl_vert = NULL;
44+
static int tpl_vert = VERT_OFF;
3945

4046
typedef struct {
4147
win_T *wp;
@@ -57,7 +63,7 @@ tabpanelopt_changed(void)
5763
int vert_size = 0;
5864
int new_align = ALIGN_LEFT;
5965
int new_columns = 20;
60-
char_u *new_vert = NULL;
66+
int new_vert = VERT_OFF;
6167

6268
p = p_tplo;
6369
while (*p != NUL)
@@ -77,22 +83,10 @@ tabpanelopt_changed(void)
7783
p += 8;
7884
new_columns = getdigits(&p);
7985
}
80-
else if (STRNCMP(p, "vert:", 5) == 0)
86+
else if (STRNCMP(p, "vert", 4) == 0)
8187
{
82-
p += 5;
83-
while (*p != NUL && *p != ',')
84-
{
85-
++p;
86-
++vert_size;
87-
}
88-
if (vert_size < IOSIZE - 1)
89-
{
90-
vim_strncpy(IObuff, p - vert_size, vert_size);
91-
IObuff[vert_size] = NUL;
92-
new_vert = vim_strsave(IObuff);
93-
}
94-
else
95-
return FAIL;
88+
p += 4;
89+
new_vert = VERT_ON;
9690
}
9791

9892
if (*p != ',' && *p != NUL)
@@ -101,9 +95,6 @@ tabpanelopt_changed(void)
10195
++p;
10296
}
10397

104-
if (tpl_vert != NULL)
105-
vim_free(tpl_vert);
106-
10798
tpl_align = new_align;
10899
tpl_columns = new_columns;
109100
tpl_vert = new_vert;
@@ -157,40 +148,18 @@ draw_tabpanel(void)
157148
int saved_KeyTyped = KeyTyped;
158149
int saved_got_int = got_int;
159150
int maxwidth = tabpanel_width();
160-
int vert_len = 0;
161-
int vert_cells = 0;
162151
int vs_attr = HL_ATTR(HLF_C);
163152
int curtab_row = 0;
164153
#ifndef MSWIN
165154
int row = 0;
166155
int off = 0;
167156
#endif
168-
int vsrow = 0;
157+
int vsrow = 0;
169158
int is_right = tpl_align == ALIGN_RIGHT;
170159

171160
if (0 == maxwidth)
172161
return;
173162

174-
if (tpl_vert == NULL)
175-
tpl_vert = vim_strsave((char_u*)"");
176-
177-
vert_len = 0;
178-
vert_cells = 0;
179-
while (*(tpl_vert + vert_len) != NUL)
180-
{
181-
int cell = ptr2cells(tpl_vert + vert_len);
182-
if (vert_cells + cell <= maxwidth)
183-
{
184-
if (has_mbyte)
185-
vert_len += (*mb_ptr2len)(tpl_vert + vert_len);
186-
else
187-
vert_len += (int)STRLEN(tpl_vert + vert_len);
188-
vert_cells += cell;
189-
}
190-
else
191-
break;
192-
}
193-
194163
#ifndef MSWIN
195164
// We need this section only for the Vim running on WSL.
196165
for (row = 0; row < cmdline_row; row++)
@@ -211,38 +180,38 @@ draw_tabpanel(void)
211180
// Reset got_int to avoid build_stl_str_hl() isn't evaluted.
212181
got_int = FALSE;
213182

214-
if (0 < vert_len)
183+
if (tpl_vert == VERT_ON)
215184
{
216185
if (is_right)
217186
{
218187
// draw main contents in tabpanel
219-
do_by_tplmode(TPLMODE_GET_CURTAB_ROW, vert_cells,
220-
maxwidth - vert_cells, &curtab_row, NULL);
221-
do_by_tplmode(TPLMODE_REDRAW, vert_cells, maxwidth, &curtab_row,
188+
do_by_tplmode(TPLMODE_GET_CURTAB_ROW, VERT_LEN,
189+
maxwidth - VERT_LEN, &curtab_row, NULL);
190+
do_by_tplmode(TPLMODE_REDRAW, VERT_LEN, maxwidth, &curtab_row,
222191
NULL);
223192
// clear for multi-byte vert separater
224193
screen_fill(0, cmdline_row, COLUMNS_WITHOUT_TPL(),
225-
COLUMNS_WITHOUT_TPL() + vert_cells,
194+
COLUMNS_WITHOUT_TPL() + VERT_LEN,
226195
TPL_FILLCHAR, TPL_FILLCHAR, vs_attr);
227196
// draw vert separater in tabpanel
228-
for (vsrow = 1; vsrow < cmdline_row + 1; vsrow++)
229-
screen_puts_len(tpl_vert, vert_len, vsrow - 1,
197+
for (vsrow = 0; vsrow < cmdline_row; vsrow++)
198+
screen_putchar(curwin->w_fill_chars.tpl_vert, vsrow,
230199
COLUMNS_WITHOUT_TPL(), vs_attr);
231200
}
232201
else
233202
{
234203
// draw main contents in tabpanel
235-
do_by_tplmode(TPLMODE_GET_CURTAB_ROW, 0, maxwidth - vert_cells,
204+
do_by_tplmode(TPLMODE_GET_CURTAB_ROW, 0, maxwidth - VERT_LEN,
236205
&curtab_row, NULL);
237-
do_by_tplmode(TPLMODE_REDRAW, 0, maxwidth - vert_cells,
206+
do_by_tplmode(TPLMODE_REDRAW, 0, maxwidth - VERT_LEN,
238207
&curtab_row, NULL);
239208
// clear for multi-byte vert separater
240-
screen_fill(0, cmdline_row, maxwidth - vert_cells,
209+
screen_fill(0, cmdline_row, maxwidth - VERT_LEN,
241210
maxwidth, TPL_FILLCHAR, TPL_FILLCHAR, vs_attr);
242211
// draw vert separater in tabpanel
243-
for (vsrow = 1; vsrow < cmdline_row + 1; vsrow++)
244-
screen_puts_len(tpl_vert, vert_len, vsrow - 1,
245-
maxwidth - vert_cells, vs_attr);
212+
for (vsrow = 0; vsrow < cmdline_row; vsrow++)
213+
screen_putchar(curwin->w_fill_chars.tpl_vert, vsrow,
214+
maxwidth - VERT_LEN, vs_attr);
246215
}
247216
}
248217
else
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
|$+8#0000001#e0e0e08| |[|a@2|]| |$||+1#0000000#ffffff0|$| @13|[|c@2|]| @13|$
2-
|$+8#0000001#e0e0e08| |[|b@2|]| |$||+1#0000000#ffffff0> +0&&@34
3-
|$+2&&| |[|c@2|]| |$||+1&&|~+0#4040ff13&| @33
4-
| +1#0000000&@8|||~+0#4040ff13&| @33
5-
| +1#0000000&@8|||~+0#4040ff13&| @33
6-
| +1#0000000&@8|||~+0#4040ff13&| @33
7-
| +1#0000000&@8|||~+0#4040ff13&| @33
8-
| +1#0000000&@8|||~+0#4040ff13&| @33
9-
| +1#0000000&@8|||$+3&&| @13|[|c@2|]| @13|$
1+
|$+8#0000001#e0e0e08| |[|a@2|]| |$|+1#0000000#ffffff0|$| @13|[|c@2|]| @13|$
2+
|$+8#0000001#e0e0e08| |[|b@2|]| |$|+1#0000000#ffffff0> +0&&@34
3+
|$+2&&| |[|c@2|]| |$|+1&&|~+0#4040ff13&| @33
4+
| +1#0000000&@8||~+0#4040ff13&| @33
5+
| +1#0000000&@8||~+0#4040ff13&| @33
6+
| +1#0000000&@8||~+0#4040ff13&| @33
7+
| +1#0000000&@8||~+0#4040ff13&| @33
8+
| +1#0000000&@8||~+0#4040ff13&| @33
9+
| +1#0000000&@8||$+3&&| @13|[|c@2|]| @13|$
1010
|"+0&&|c@2|"| |[|N|e|w|]| @33
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
|$+1&#ffffff0| @13|[|c@2|]| @13|$|||$+8#0000001#e0e0e08| |[|a@2|]| |$
2-
> +0#0000000#ffffff0@34||+1&&|$+8#0000001#e0e0e08| |[|b@2|]| |$
3-
|~+0#4040ff13#ffffff0| @33||+1#0000000&|$+2&&| |[|c@2|]| |$
4-
|~+0#4040ff13&| @33||+1#0000000&| @8
5-
|~+0#4040ff13&| @33||+1#0000000&| @8
6-
|~+0#4040ff13&| @33||+1#0000000&| @8
7-
|~+0#4040ff13&| @33||+1#0000000&| @8
8-
|~+0#4040ff13&| @33||+1#0000000&| @8
9-
|$+3&&| @13|[|c@2|]| @13|$||+1&&| @8
1+
|$+1&#ffffff0| @13|[|c@2|]| @13|$||$+8#0000001#e0e0e08| |[|a@2|]| |$
2+
> +0#0000000#ffffff0@34|+1&&|$+8#0000001#e0e0e08| |[|b@2|]| |$
3+
|~+0#4040ff13#ffffff0| @33|+1#0000000&|$+2&&| |[|c@2|]| |$
4+
|~+0#4040ff13&| @33|+1#0000000&| @8
5+
|~+0#4040ff13&| @33|+1#0000000&| @8
6+
|~+0#4040ff13&| @33|+1#0000000&| @8
7+
|~+0#4040ff13&| @33|+1#0000000&| @8
8+
|~+0#4040ff13&| @33|+1#0000000&| @8
9+
|$+3&&| @13|[|c@2|]| @13|$|+1&&| @8
1010
|:+0&&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|+|=|a|l|i|g|n|:|r|i|g|h|t| @15
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
|t+8#0000001#e0e0e08|o|p| @7|a@2| @1|b@2| | +2#0000000#ffffff0|c@2| | +1&&@18|X+8#0000001#e0e0e08
2+
|$| |[|a@2|]| @1|$> +0#0000000#ffffff0@34
3+
|b+8#0000001#e0e0e08|o|t@1|o|m| @3|~+0#4040ff13#ffffff0| @33
4+
|t+8#0000001#e0e0e08|o|p| @6|~+0#4040ff13#ffffff0| @33
5+
|$+8#0000001#e0e0e08| |[|b@2|]| @1|$|~+0#4040ff13#ffffff0| @33
6+
|b+8#0000001#e0e0e08|o|t@1|o|m| @3|~+0#4040ff13#ffffff0| @33
7+
|t+2#0000000&|o|p| @6|~+0#4040ff13&| @33
8+
|$+2#0000000&| |[|c@2|]| @1|$|~+0#4040ff13&| @33
9+
|b+2#0000000&|o|t@1|o|m| @3|~+0#4040ff13&| @33
10+
|"+0#0000000&|c@2|"| |[|N|e|w|]| @25|0|,|0|-|1| @2
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
| +8#0000001#e0e0e08|a@2| @1|b@2| | +2#0000000#ffffff0|c@2| | +1&&@19|t+8#0000001#e0e0e08|o|p| @6
2+
> +0#0000000#ffffff0@34|$+8#0000001#e0e0e08| |[|a@2|]| @1|$
3+
|~+0#4040ff13#ffffff0| @33|b+8#0000001#e0e0e08|o|t@1|o|m| @3
4+
|~+0#4040ff13#ffffff0| @33|t+8#0000001#e0e0e08|o|p| @6
5+
|~+0#4040ff13#ffffff0| @33|$+8#0000001#e0e0e08| |[|b@2|]| @1|$
6+
|~+0#4040ff13#ffffff0| @33|b+8#0000001#e0e0e08|o|t@1|o|m| @3
7+
|~+0#4040ff13#ffffff0| @33|t+2#0000000&|o|p| @6
8+
|~+0#4040ff13&| @33|$+2#0000000&| |[|c@2|]| @1|$
9+
|~+0#4040ff13&| @33|b+2#0000000&|o|t@1|o|m| @3
10+
|:+0&&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|+|=|a|l|i|g|n|:|r|i|g|0|,|0|-|1| @8|A|l@1|
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
|$+8#0000001#e0e0e08| |[|a@2|]| |$|│+1#0000000#ffffff0|$| @13|[|c@2|]| @13|$
2+
|$+8#0000001#e0e0e08| |[|b@2|]| |$|│+1#0000000#ffffff0> +0&&@34
3+
|$+2&&| |[|c@2|]| |$|│+1&&|~+0#4040ff13&| @33
4+
| +1#0000000&@8|│|~+0#4040ff13&| @33
5+
| +1#0000000&@8|│|~+0#4040ff13&| @33
6+
| +1#0000000&@8|│|~+0#4040ff13&| @33
7+
| +1#0000000&@8|│|~+0#4040ff13&| @33
8+
| +1#0000000&@8|│|~+0#4040ff13&| @33
9+
| +1#0000000&@8|│|$+3&&| @13|[|c@2|]| @13|$
10+
|"+0&&|c@2|"| |[|N|e|w|]| @33
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
|$+1&#ffffff0| @13|[|c@2|]| @13|$|│|$+8#0000001#e0e0e08| |[|a@2|]| |$
2+
> +0#0000000#ffffff0@34|│+1&&|$+8#0000001#e0e0e08| |[|b@2|]| |$
3+
|~+0#4040ff13#ffffff0| @33|│+1#0000000&|$+2&&| |[|c@2|]| |$
4+
|~+0#4040ff13&| @33|│+1#0000000&| @8
5+
|~+0#4040ff13&| @33|│+1#0000000&| @8
6+
|~+0#4040ff13&| @33|│+1#0000000&| @8
7+
|~+0#4040ff13&| @33|│+1#0000000&| @8
8+
|~+0#4040ff13&| @33|│+1#0000000&| @8
9+
|$+3&&| @13|[|c@2|]| @13|$|│+1&&| @8
10+
|:+0&&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|+|=|a|l|i|g|n|:|r|i|g|h|t| @15
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
|a+8#0000001#e0e0e08@2|.|t|x|t| @1|@+1#0000000#ffffff0| +8#0000001#e0e0e08|a@2|.|t|x|t| @1|b@2|.|t|x|t| | +2#0000000#ffffff0|c@2|.|t|x|t| | +1&&@6|X+8#0000001#e0e0e08
2-
|b@2|.|t|x|t| @1|@+1#0000000#ffffff0> +0&&@34
3-
|c+2&&@2|.|t|x|t| @1|@+1&&|~+0#4040ff13&| @33
4-
| +1#0000000&@8|@|~+0#4040ff13&| @33
5-
| +1#0000000&@8|@|~+0#4040ff13&| @33
6-
| +1#0000000&@8|@|~+0#4040ff13&| @33
7-
| +1#0000000&@8|@|~+0#4040ff13&| @33
8-
| +1#0000000&@8|@|~+0#4040ff13&| @33
9-
| +1#0000000&@8|@|~+0#4040ff13&| @33
1+
|a+8#0000001#e0e0e08@2|.|t|x|t| @1|+1#0000000#ffffff0| +8#0000001#e0e0e08|a@2|.|t|x|t| @1|b@2|.|t|x|t| | +2#0000000#ffffff0|c@2|.|t|x|t| | +1&&@6|X+8#0000001#e0e0e08
2+
|b@2|.|t|x|t| @1|+1#0000000#ffffff0> +0&&@34
3+
|c+2&&@2|.|t|x|t| @1|+1&&|~+0#4040ff13&| @33
4+
| +1#0000000&@8||~+0#4040ff13&| @33
5+
| +1#0000000&@8||~+0#4040ff13&| @33
6+
| +1#0000000&@8||~+0#4040ff13&| @33
7+
| +1#0000000&@8||~+0#4040ff13&| @33
8+
| +1#0000000&@8||~+0#4040ff13&| @33
9+
| +1#0000000&@8||~+0#4040ff13&| @33
1010
|"+0#0000000&|c@2|.|t|x|t|"| |[|N|e|w|]| @21|0|,|0|-|1| @2

0 commit comments

Comments
 (0)