Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical window separator renders as "x" in Putty, but the graph is OK #981

Closed
proski opened this issue Jan 8, 2020 · 4 comments · Fixed by #983
Closed

Vertical window separator renders as "x" in Putty, but the graph is OK #981

proski opened this issue Jan 8, 2020 · 4 comments · Fixed by #983

Comments

@proski
Copy link
Contributor

proski commented Jan 8, 2020

When run inside Putty, tig renders the vertical window separator in putty using x characters. However, the version graph uses correct vertical lines.

Observed with different fonts: Consolas, DejaVu Sans Mono, Fira Mono, Fixedsys, Inconsolata, Lucida Console, Lucida Sans Typewriter. Observed with putty 0.70 and 0.73. Tig 2.4.1 and the current git versions are affected:

$ /usr/bin/tig --version
tig version 2.4.1
ncursesw version 5.9.20140118
readline version 6.3
$ src/tig --version
tig version 2.5.0-2-gca0809d
ncursesw version 5.9.20140118
readline version 6.3

The system running Putty is Windows 10, the system running tig is Ubuntu 14.04.

The described behavior corresponds to diff-view-line-graphics = utf-8. If it's ascii, the vertical bar is rendered using |, but the graph becomes less pretty. For default, x is used for the vertical bar, and the graph looks even worse than in the ascii mode. The graph is rendered using letters that don't even look like lines.

 o make-builtin-config:
 Mqk Merge pull request
 x o Add default bindin
 x o Add option to star
 oqj Introduce reflog v
 o Fix ls-tree tree-ish

I suspect that the vertical window separator is rendered using the default mode even though the utf-8 mode is in effect. Apparently, putty has an issue with diff-view-line-graphics = default.

I would consider this issue resolved if the window separator renders in the utf-8 mode correctly.

putty-tig

@proski
Copy link
Contributor Author

proski commented Jan 9, 2020

It turns opt_line_graphics is incorrectly treated like boolean in two places. One is responsible for the vertical window separator, another for the separator after line numbers that are triggered by the # key.

Here's a quick and dirty fix that makes UTF-8 mode work like the ASCII mode:

diff --git a/src/display.c b/src/display.c
index a23d41a..028bcc9 100644
--- a/src/display.c
+++ b/src/display.c
@@ -187,7 +187,7 @@ static void
 redraw_display_separator(bool clear)
 {
        if (display_sep) {
-               chtype separator = opt_line_graphics ? ACS_VLINE : '|';
+               chtype separator = (opt_line_graphics == GRAPHIC_DEFAULT) ? ACS_VLINE : '|';

                if (clear)
                        wclear(display_sep);
diff --git a/src/draw.c b/src/draw.c
index e5b651f..92af79c 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -314,7 +314,7 @@ draw_lineno_custom(struct view *view, struct view_column *column, unsigned int l
        unsigned long digits3 = MIN(9,MAX(3,column->width));
        int max = MIN(VIEW_MAX_LEN(view), digits3);
        char *text = NULL;
-       chtype separator = opt_line_graphics ? ACS_VLINE : '|';
+       chtype separator = (opt_line_graphics == GRAPHIC_DEFAULT) ? ACS_VLINE : '|';
        struct line_number_options *opts = &column->opt.line_number;
        int interval = opts->interval > 0 ? opts->interval : 5;

The proper fix would need to use the UTF-8 vertical bar in the UTF-8 mode, but the code would need to use strings instead of single characters for the separators.

Also, using TERM=putty instead of TERM=xterm fixes the vertical bars, but I would prefer to fix the issue in tig.

The Linux version of Putty exhibits the issue just like the Windows version, so Windows is not needed to work on this issue.

@koutcher
Copy link
Collaborator

koutcher commented Jan 9, 2020

There is a known issue with PuTTY when trying to mix PuTTY, UTF-8 and ncurses. It was fixed in PuTTY 0.71, but you need to select option Enable VT100 line drawing even in UTF-8 mode in Window -> Translation. With earlier versions of PuTTY, try export NCURSES_NO_UTF8_ACS=1 before running tig.

@proski
Copy link
Contributor Author

proski commented Jan 9, 2020

@koutcher Thank you, that's explain exactly what's going on! That option fixes the ugly tree display in the default mode as well.
To make things work out-of-the-box, tig should stop using VT100 line drawing in UTF-8 mode.

proski added a commit to proski/tig that referenced this issue Jan 13, 2020
Putty doesn't show VT100 line drawing characters in UTF-8 mode by
default.

Use Unicode drawing characters in UTF-8 mode for the vertical display
separator and the line number separator.

Closes jonas#981
proski added a commit to proski/tig that referenced this issue Jan 15, 2020
Putty doesn't show VT100 line drawing characters in UTF-8 mode by
default.

Use Unicode drawing characters in UTF-8 mode for the vertical display
separator and the line number separator.

Closes jonas#981
proski added a commit to proski/tig that referenced this issue Jan 16, 2020
Putty doesn't show VT100 line drawing characters in UTF-8 mode by
default.

Use Unicode drawing characters in UTF-8 mode for the vertical display
separator and the line number separator.

Closes jonas#981
proski added a commit to proski/tig that referenced this issue Jan 16, 2020
Putty doesn't show VT100 line drawing characters in UTF-8 mode by
default.

Use Unicode drawing characters in UTF-8 mode for the vertical display
separator and the line number separator.

Closes jonas#981
proski added a commit to proski/tig that referenced this issue Jan 16, 2020
Use the UTF-8 vertical line character in the UTF-8 mode. 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, use space as background in the UTF-8
mode, then output the vertical line character on every line.

For the line number separator, imitate the graph drawing code. Use
draw_graphic() in the DEFAULT mode only, draw_chars() otherwise.

Closes jonas#981
proski added a commit to proski/tig that referenced this issue Jan 16, 2020
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.

For the line number separator, use code similar to the graph drawing
code. Use draw_graphic() in the DEFAULT mode only, draw_chars()
otherwise.

Closes jonas#981
proski added a commit to proski/tig that referenced this issue Jan 19, 2020
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, use '|' as background, then output
the vertical line character on every line.

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 jonas#981
proski added a commit to proski/tig that referenced this issue Jan 27, 2020
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 jonas#981
@proski
Copy link
Contributor Author

proski commented Jan 27, 2020

I believe I have a good fix for the issue. No workarounds should be necessary anymore. Can someone take a look at #983 please?

jonas pushed a commit that referenced this issue May 31, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants