Skip to content

Commit

Permalink
Fix vertical lines in Putty with UTF-8 graphics
Browse files Browse the repository at this point in the history
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 #981
  • Loading branch information
proski committed Jan 13, 2020
1 parent ca0809d commit 1958d5c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
17 changes: 13 additions & 4 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,20 @@ static void
redraw_display_separator(bool clear)
{
if (display_sep) {
chtype separator = opt_line_graphics ? ACS_VLINE : '|';
if (opt_line_graphics == GRAPHIC_UTF_8) {
int height, lineno;

if (clear)
wclear(display_sep);
wbkgd(display_sep, separator + get_line_attr(NULL, LINE_TITLE_BLUR));
wattrset(display_sep, get_line_attr(NULL, LINE_TITLE_BLUR));
getmaxyx(display_sep, height, lineno);
for (lineno = 0; lineno < height; lineno++)
mvwaddstr(display_sep, lineno, 0, "│");
} else {
chtype separator = (opt_line_graphics == GRAPHIC_DEFAULT) ? ACS_VLINE : '|';

if (clear)
wclear(display_sep);
wbkgd(display_sep, separator + get_line_attr(NULL, LINE_TITLE_BLUR));
}
wnoutrefresh(display_sep);
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ 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 : '|';
struct line_number_options *opts = &column->opt.line_number;
int interval = opts->interval > 0 ? opts->interval : 5;

Expand All @@ -332,7 +331,13 @@ draw_lineno_custom(struct view *view, struct view_column *column, unsigned int l
draw_chars(view, LINE_LINE_NUMBER, text, -1, max, true);
else
draw_space(view, LINE_LINE_NUMBER, max, digits3);
return draw_graphic(view, LINE_DEFAULT, &separator, 1, true);

if (opt_line_graphics == GRAPHIC_UTF_8)
return draw_chars(view, LINE_DEFAULT, "│ ", -1, 2, false);
else {
chtype separator = (opt_line_graphics == GRAPHIC_DEFAULT) ? ACS_VLINE : '|';
return draw_graphic(view, LINE_DEFAULT, &separator, 1, true);
}
}

bool
Expand Down

0 comments on commit 1958d5c

Please sign in to comment.