Skip to content

Commit 9aa42d1

Browse files
authored
Fix vertical lines in Putty with UTF-8 graphics (#983)
Putty doesn't show VT100 line drawing characters in the UTF-8 mode by default. Putty 0.70 and older doesn't even have that option. For the vertical display separator, output the vertical line character on every line. Use wbkgdset() instead of wbkgd() as the code takes care of setting the window contents. For the line number separator, use draw_graphic() in the default mode only. Use draw_chars() in the ASCII and UTF-8 modes. Add a test for vertical lines. The display separator is always captured as a line of '|' characters. The line number separators are captured correctly. 'x' corresponds to ACS_VLINE. Closes #981
1 parent a69d92f commit 9aa42d1

File tree

3 files changed

+117
-4
lines changed

3 files changed

+117
-4
lines changed

src/display.c

+15-2
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,24 @@ static void
187187
redraw_display_separator(bool clear)
188188
{
189189
if (display_sep) {
190-
chtype separator = opt_line_graphics ? ACS_VLINE : '|';
190+
int lineno = 0;
191191

192192
if (clear)
193193
wclear(display_sep);
194-
wbkgd(display_sep, separator + get_line_attr(NULL, LINE_TITLE_BLUR));
194+
wbkgdset(display_sep, get_line_attr(NULL, LINE_TITLE_BLUR));
195+
196+
switch (opt_line_graphics) {
197+
case GRAPHIC_ASCII:
198+
while (mvwaddch(display_sep, lineno++, 0, '|') == OK);
199+
break;
200+
case GRAPHIC_DEFAULT:
201+
while (mvwaddch(display_sep, lineno++, 0, ACS_VLINE) == OK);
202+
break;
203+
case GRAPHIC_UTF_8:
204+
while (mvwaddstr(display_sep, lineno++, 0, "│") == OK);
205+
break;
206+
}
207+
195208
wnoutrefresh(display_sep);
196209
}
197210
}

src/draw.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ draw_lineno_custom(struct view *view, struct view_column *column, unsigned int l
314314
unsigned long digits3 = MIN(9,MAX(3,column->width));
315315
int max = MIN(VIEW_MAX_LEN(view), digits3);
316316
char *text = NULL;
317-
chtype separator = opt_line_graphics ? ACS_VLINE : '|';
317+
chtype separator = ACS_VLINE;
318318
struct line_number_options *opts = &column->opt.line_number;
319319
int interval = opts->interval > 0 ? opts->interval : 5;
320320

@@ -332,7 +332,17 @@ draw_lineno_custom(struct view *view, struct view_column *column, unsigned int l
332332
draw_chars(view, LINE_LINE_NUMBER, text, -1, max, true);
333333
else
334334
draw_space(view, LINE_LINE_NUMBER, max, digits3);
335-
return draw_graphic(view, LINE_DEFAULT, &separator, 1, true);
335+
336+
switch (opt_line_graphics) {
337+
case GRAPHIC_ASCII:
338+
return draw_chars(view, LINE_DEFAULT, "| ", -1, 2, false);
339+
case GRAPHIC_DEFAULT:
340+
return draw_graphic(view, LINE_DEFAULT, &separator, 1, true);
341+
case GRAPHIC_UTF_8:
342+
return draw_chars(view, LINE_DEFAULT, "│ ", -1, 2, false);
343+
}
344+
345+
return false;
336346
}
337347

338348
bool

test/main/vertical-lines-test

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/sh
2+
3+
. libtest.sh
4+
. libgit.sh
5+
6+
export WIDTH=40
7+
export LINES=18
8+
9+
tigrc <<EOF
10+
set vertical-split = auto
11+
EOF
12+
13+
steps '
14+
:set main-view-line-number-display = yes
15+
:set diff-view-line-number-display = yes
16+
:enter
17+
18+
:set line-graphics = ascii
19+
:save-display main-verticals-ascii.screen
20+
21+
:set line-graphics = default
22+
:save-display main-verticals-default.screen
23+
24+
:set line-graphics = utf-8
25+
:save-display main-verticals-utf8.screen
26+
'
27+
28+
git_clone 'repo-one'
29+
30+
test_tig
31+
32+
assert_equals 'main-verticals-ascii.screen' <<EOF
33+
1| 2010-04-07 05:37 +0000 Max Power | 1| commit 5cb3412a5e06e506840495b91ac
34+
| 2010-03-29 17:15 +0000 Jørgen Thy~ | | Refs: [master], {origin/master}, {
35+
| 2010-03-21 04:53 +0000 作者 | | Author: Max Power <power123@ex
36+
| 2010-03-12 16:31 +0000 René Léves~ | | AuthorDate: Wed Apr 7 05:37:40 201
37+
5| 2010-03-04 04:09 +0000 A. U. Thor | 5| Commit: Committer <c.ommitter@
38+
| 2010-02-23 15:46 +0000 Max Power | | CommitDate: Wed Apr 7 05:37:40 201
39+
| 2010-02-15 03:24 +0000 Jørgen Thy~ | |
40+
| 2010-02-06 15:02 +0000 作者 | | Commit 10 E
41+
| 2010-01-29 02:40 +0000 René Léves~ |
42+
10| 2010-01-20 14:18 +0000 A. U. Thor |
43+
| 2010-01-12 01:56 +0000 Max Power |
44+
| 2010-01-03 13:33 +0000 Jørgen Thy~ |
45+
| 2009-12-26 01:11 +0000 作者 |
46+
| 2009-12-17 12:49 +0000 René Léves~ |
47+
15| 2009-12-09 00:27 +0000 A. U. Thor |
48+
| 2009-11-30 12:05 +0000 Max Power |
49+
[main] 5cb3412a5e06e506840495b91acc8832%|[diff] 5cb3412a5e06e506840495b91acc100%
50+
EOF
51+
52+
assert_equals 'main-verticals-default.screen' <<EOF
53+
1x 2010-04-07 05:37 +0000 Max Power | 1x commit 5cb3412a5e06e506840495b91ac
54+
x 2010-03-29 17:15 +0000 Jørgen Thy~ | x Refs: [master], {origin/master}, {
55+
x 2010-03-21 04:53 +0000 作者 | x Author: Max Power <power123@ex
56+
x 2010-03-12 16:31 +0000 René Léves~ | x AuthorDate: Wed Apr 7 05:37:40 201
57+
5x 2010-03-04 04:09 +0000 A. U. Thor | 5x Commit: Committer <c.ommitter@
58+
x 2010-02-23 15:46 +0000 Max Power | x CommitDate: Wed Apr 7 05:37:40 201
59+
x 2010-02-15 03:24 +0000 Jørgen Thy~ | x
60+
x 2010-02-06 15:02 +0000 作者 | x Commit 10 E
61+
x 2010-01-29 02:40 +0000 René Léves~ |
62+
10x 2010-01-20 14:18 +0000 A. U. Thor |
63+
x 2010-01-12 01:56 +0000 Max Power |
64+
x 2010-01-03 13:33 +0000 Jørgen Thy~ |
65+
x 2009-12-26 01:11 +0000 作者 |
66+
x 2009-12-17 12:49 +0000 René Léves~ |
67+
15x 2009-12-09 00:27 +0000 A. U. Thor |
68+
x 2009-11-30 12:05 +0000 Max Power |
69+
[main] 5cb3412a5e06e506840495b91acc8832%|[diff] 5cb3412a5e06e506840495b91acc100%
70+
EOF
71+
72+
assert_equals 'main-verticals-utf8.screen' <<EOF
73+
1│ 2010-04-07 05:37 +0000 Max Power | 1│ commit 5cb3412a5e06e506840495b91ac
74+
│ 2010-03-29 17:15 +0000 Jørgen Thy~ | │ Refs: [master], {origin/master}, {
75+
│ 2010-03-21 04:53 +0000 作者 | │ Author: Max Power <power123@ex
76+
│ 2010-03-12 16:31 +0000 René Léves~ | │ AuthorDate: Wed Apr 7 05:37:40 201
77+
5│ 2010-03-04 04:09 +0000 A. U. Thor | 5│ Commit: Committer <c.ommitter@
78+
│ 2010-02-23 15:46 +0000 Max Power | │ CommitDate: Wed Apr 7 05:37:40 201
79+
│ 2010-02-15 03:24 +0000 Jørgen Thy~ | │
80+
│ 2010-02-06 15:02 +0000 作者 | │ Commit 10 E
81+
│ 2010-01-29 02:40 +0000 René Léves~ |
82+
10│ 2010-01-20 14:18 +0000 A. U. Thor |
83+
│ 2010-01-12 01:56 +0000 Max Power |
84+
│ 2010-01-03 13:33 +0000 Jørgen Thy~ |
85+
│ 2009-12-26 01:11 +0000 作者 |
86+
│ 2009-12-17 12:49 +0000 René Léves~ |
87+
15│ 2009-12-09 00:27 +0000 A. U. Thor |
88+
│ 2009-11-30 12:05 +0000 Max Power |
89+
[main] 5cb3412a5e06e506840495b91acc8832%|[diff] 5cb3412a5e06e506840495b91acc100%
90+
EOF

0 commit comments

Comments
 (0)