display: show the guide stripe for double-width/multi-byte characters
Determine the actual number of bytes the striped character consists of, instead of assuming it's simply one, and determine the real column that the character starts in, instead of assuming it's the stripe column. This fixes https://savannah.gnu.org/bugs/?55917 and fixes https://savannah.gnu.org/bugs/?55922. Condensed-by: Benno Schulenberg <bensberg@telfort.nl>master
parent
15959346fb
commit
93ee0a8a65
15
src/winio.c
15
src/winio.c
|
@ -2687,12 +2687,19 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (stripe_column > from_col && !inhelp) {
|
if (stripe_column > from_col && !inhelp) {
|
||||||
const ssize_t target_column = stripe_column - from_col - 1;
|
ssize_t target_column = stripe_column - from_col - 1;
|
||||||
const char *text = converted + actual_x(converted, target_column);
|
size_t target_x = actual_x(converted, target_column);
|
||||||
const char *striped_char = (*text == '\0') ? " " : text;
|
char striped_char[MAXCHARLEN];
|
||||||
|
size_t charlen = 1;
|
||||||
|
|
||||||
|
if (*(converted + target_x) != '\0') {
|
||||||
|
charlen = parse_mbchar(converted + target_x, striped_char, NULL);
|
||||||
|
target_column = strnlenpt(converted, target_x);
|
||||||
|
} else
|
||||||
|
striped_char[0] = ' ';
|
||||||
|
|
||||||
wattron(edit, interface_color_pair[GUIDE_STRIPE]);
|
wattron(edit, interface_color_pair[GUIDE_STRIPE]);
|
||||||
mvwaddnstr(edit, row, margin + target_column, striped_char, 1);
|
mvwaddnstr(edit, row, margin + target_column, striped_char, charlen);
|
||||||
wattroff(edit, interface_color_pair[GUIDE_STRIPE]);
|
wattroff(edit, interface_color_pair[GUIDE_STRIPE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue