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 authored and Pavel Roskin committed Jan 15, 2020
1 parent ca0809d commit e49cee5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
21 changes: 20 additions & 1 deletion src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,30 @@ static void
redraw_display_separator(bool clear)
{
if (display_sep) {
chtype separator = opt_line_graphics ? ACS_VLINE : '|';
chtype separator;

switch (opt_line_graphics) {
case GRAPHIC_ASCII:
separator = '|';
break;
case GRAPHIC_DEFAULT:
separator = ACS_VLINE;
break;
default:
separator = ' ';
break;
}

if (clear)
wclear(display_sep);
wbkgd(display_sep, separator + get_line_attr(NULL, LINE_TITLE_BLUR));

if (opt_line_graphics == GRAPHIC_UTF_8) {
int lineno = 0;

while (mvwaddstr(display_sep, lineno++, 0, "│") == OK);
}

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 e49cee5

Please sign in to comment.