Skip to content

Commit 3bfd04e

Browse files
committed
patch 8.1.1444: not using double line characters for popup border
Problem: Not using double line characters for popup border. Solution: Use double line characters if using utf-8.
1 parent 2fd8e35 commit 3bfd04e

4 files changed

Lines changed: 57 additions & 21 deletions

File tree

src/screen.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,12 @@ update_popups(void)
10311031
int total_height;
10321032
int popup_attr;
10331033
int row;
1034+
int tl_corner_char = '+';
1035+
char *tr_corner_str = "+";
1036+
int bl_corner_char = '+';
1037+
char *br_corner_str = "+";
1038+
int hor_line_char = '-';
1039+
char *ver_line_str = "|";
10341040

10351041
// Find the window with the lowest zindex that hasn't been updated yet,
10361042
// so that the window with a higher zindex is drawn later, thus goes on
@@ -1062,16 +1068,27 @@ update_popups(void)
10621068
+ wp->w_height + wp->w_popup_padding[2] + wp->w_popup_border[2];
10631069
popup_attr = get_wcr_attr(wp);
10641070

1071+
if (enc_utf8)
1072+
{
1073+
tl_corner_char = 0x2554;
1074+
tr_corner_str = "\xe2\x95\x97";
1075+
bl_corner_char = 0x255a;
1076+
br_corner_str = "\xe2\x95\x9d";
1077+
hor_line_char = 0x2550;
1078+
ver_line_str = "\xe2\x95\x91";
1079+
}
1080+
10651081
if (wp->w_popup_border[0] > 0)
10661082
{
10671083
// top border
10681084
screen_fill(wp->w_winrow, wp->w_winrow + 1,
10691085
wp->w_wincol,
10701086
wp->w_wincol + total_width,
1071-
wp->w_popup_border[3] != 0 ? '+' : '-',
1072-
'-', popup_attr);
1087+
wp->w_popup_border[3] != 0
1088+
? tl_corner_char : hor_line_char,
1089+
hor_line_char, popup_attr);
10731090
if (wp->w_popup_border[1] > 0)
1074-
screen_puts((char_u *)"+", wp->w_winrow,
1091+
screen_puts((char_u *)tr_corner_str, wp->w_winrow,
10751092
wp->w_wincol + total_width - 1, popup_attr);
10761093
}
10771094

@@ -1091,14 +1108,14 @@ update_popups(void)
10911108
{
10921109
// left border
10931110
if (wp->w_popup_border[3] > 0)
1094-
screen_puts((char_u *)"|", row, wp->w_wincol, popup_attr);
1111+
screen_puts((char_u *)ver_line_str, row, wp->w_wincol, popup_attr);
10951112
// left padding
10961113
if (wp->w_popup_padding[3] > 0)
10971114
screen_puts(get_spaces(wp->w_popup_padding[3]), row,
10981115
wp->w_wincol + wp->w_popup_border[3], popup_attr);
10991116
// right border
11001117
if (wp->w_popup_border[1] > 0)
1101-
screen_puts((char_u *)"|", row,
1118+
screen_puts((char_u *)ver_line_str, row,
11021119
wp->w_wincol + total_width - 1, popup_attr);
11031120
// right padding
11041121
if (wp->w_popup_padding[1] > 0)
@@ -1125,10 +1142,10 @@ update_popups(void)
11251142
screen_fill(row , row + 1,
11261143
wp->w_wincol,
11271144
wp->w_wincol + total_width,
1128-
wp->w_popup_border[3] != 0 ? '+' : '-',
1129-
'-', popup_attr);
1145+
wp->w_popup_border[3] != 0 ? bl_corner_char : hor_line_char,
1146+
hor_line_char, popup_attr);
11301147
if (wp->w_popup_border[1] > 0)
1131-
screen_puts((char_u *)"+", row,
1148+
screen_puts((char_u *)br_corner_str, row,
11321149
wp->w_wincol + total_width - 1, popup_attr);
11331150
}
11341151
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
>1+0&#ffffff0| @73
2+
|2| |╔+0#0000001#ffd7ff255|═@11|╗| +0#0000000#ffffff0@5| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@4|╔+0#0000001#ffd7ff255|═@11|╗| +0#0000000#ffffff0@18
3+
|3| |║+0#0000001#ffd7ff255|h|e|l@1|o| |b|o|r|d|e|r|║| +0#0000000#ffffff0@5| +0#0000001#ffd7ff255|h|e|l@1|o| |p|a|d@1|i|n|g| | +0#0000000#ffffff0@4|║+0#0000001#ffd7ff255| @11|║| +0#0000000#ffffff0@18
4+
|4| |╚+0#0000001#ffd7ff255|═@11|╝| +0#0000000#ffffff0@5| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@4|║+0#0000001#ffd7ff255| |h|e|l@1|o| |b|o|t|h| |║| +0#0000000#ffffff0@18
5+
|5| @40|║+0#0000001#ffd7ff255| @11|║| +0#0000000#ffffff0@18
6+
|6| |╔+0#0000001#ffd7ff255|═@8| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@4|╚+0#0000001#ffd7ff255|═@11|╝| +0#0000000#ffffff0@18
7+
|7| |║+0#0000001#ffd7ff255|b|o|r|d|e|r| |T|L| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@3|p|a|d@1|i|n|g|s| @2| +0#0000000#ffffff0@37
8+
|8| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@37
9+
|9| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@37
10+
|1|0| @72
11+
|1@1| @72
12+
|1|2| @72
13+
|1|3| @72
14+
|1|4| @72
15+
@57|1|,|1| @10|T|o|p|

src/testdir/test_popupwin.vim

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,22 @@ func Test_popup_with_border_and_padding()
6060
if !CanRunVimInTerminal()
6161
return
6262
endif
63-
call writefile([
64-
\ "call setline(1, range(1, 100))",
65-
\ "call popup_create('hello border', {'line': 2, 'col': 3, 'border': []})",
66-
\ "call popup_create('hello padding', {'line': 2, 'col': 23, 'padding': []})",
67-
\ "call popup_create('hello both', {'line': 2, 'col': 43, 'border': [], 'padding': []})",
68-
\ "call popup_create('border TL', {'line': 6, 'col': 3, 'border': [1, 0, 0, 4]})",
69-
\ "call popup_create('paddings', {'line': 6, 'col': 23, 'padding': [1, 3, 2, 4]})",
70-
\], 'XtestPopupBorder')
71-
let buf = RunVimInTerminal('-S XtestPopupBorder', {'rows': 15})
72-
call VerifyScreenDump(buf, 'Test_popupwin_20', {})
7363

74-
" clean up
75-
call StopVimInTerminal(buf)
76-
call delete('XtestPopupBorder')
64+
for iter in range(0, 1)
65+
call writefile([iter == 1 ? '' : 'set enc=latin1',
66+
\ "call setline(1, range(1, 100))",
67+
\ "call popup_create('hello border', {'line': 2, 'col': 3, 'border': []})",
68+
\ "call popup_create('hello padding', {'line': 2, 'col': 23, 'padding': []})",
69+
\ "call popup_create('hello both', {'line': 2, 'col': 43, 'border': [], 'padding': []})",
70+
\ "call popup_create('border TL', {'line': 6, 'col': 3, 'border': [1, 0, 0, 4]})",
71+
\ "call popup_create('paddings', {'line': 6, 'col': 23, 'padding': [1, 3, 2, 4]})",
72+
\], 'XtestPopupBorder')
73+
let buf = RunVimInTerminal('-S XtestPopupBorder', {'rows': 15})
74+
call VerifyScreenDump(buf, 'Test_popupwin_2' .. iter, {})
75+
76+
call StopVimInTerminal(buf)
77+
call delete('XtestPopupBorder')
78+
endfor
7779

7880
let with_border_or_padding = {
7981
\ 'line': 2,

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ static char *(features[]) =
767767

768768
static int included_patches[] =
769769
{ /* Add new patch number below this line */
770+
/**/
771+
1444,
770772
/**/
771773
1443,
772774
/**/

0 commit comments

Comments
 (0)