tweaks: reshuffle some lines and frob some comments
parent
cd09482231
commit
bd331b0198
32
src/winio.c
32
src/winio.c
|
@ -1924,13 +1924,11 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
while (*buf != '\0' && (column < beyond || mbwidth(buf) == 0)) {
|
while (*buf != '\0' && (column < beyond || mbwidth(buf) == 0)) {
|
||||||
int charlength, charwidth;
|
int charlength, charwidth;
|
||||||
|
|
||||||
|
/* Show a space as a visible character, or as a space. */
|
||||||
if (*buf == ' ') {
|
if (*buf == ' ') {
|
||||||
/* Show a space as a visible character, or as a space. */
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(WHITESPACE_DISPLAY)) {
|
if (ISSET(WHITESPACE_DISPLAY)) {
|
||||||
int i = whitelen[0];
|
for (int i = whitelen[0]; i < whitelen[0] + whitelen[1];)
|
||||||
|
|
||||||
while (i < whitelen[0] + whitelen[1])
|
|
||||||
converted[index++] = whitespace[i++];
|
converted[index++] = whitespace[i++];
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
@ -1938,15 +1936,15 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
column++;
|
column++;
|
||||||
buf++;
|
buf++;
|
||||||
continue;
|
continue;
|
||||||
} else if (*buf == '\t') {
|
}
|
||||||
/* Show a tab as a visible character, or as as a space. */
|
|
||||||
|
/* Show a tab as a visible character plus spaces, or as just spaces. */
|
||||||
|
if (*buf == '\t') {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(WHITESPACE_DISPLAY) && (index > 0 || !isdata ||
|
if (ISSET(WHITESPACE_DISPLAY) && (index > 0 || !isdata ||
|
||||||
!ISSET(SOFTWRAP) || column % tabsize == 0 ||
|
!ISSET(SOFTWRAP) || column % tabsize == 0 ||
|
||||||
column == start_col)) {
|
column == start_col)) {
|
||||||
int i = 0;
|
for (int i = 0; i < whitelen[0];)
|
||||||
|
|
||||||
while (i < whitelen[0])
|
|
||||||
converted[index++] = whitespace[i++];
|
converted[index++] = whitespace[i++];
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
@ -1963,12 +1961,12 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
|
|
||||||
charlength = mblen(buf, MAXCHARLEN);
|
charlength = mblen(buf, MAXCHARLEN);
|
||||||
|
|
||||||
/* If buf contains a control character, represent it. */
|
/* Represent a control character with a leading caret. */
|
||||||
if (is_cntrl_mbchar(buf)) {
|
if (is_cntrl_mbchar(buf)) {
|
||||||
converted[index++] = '^';
|
converted[index++] = '^';
|
||||||
converted[index++] = control_mbrep(buf, isdata);
|
converted[index++] = control_mbrep(buf, isdata);
|
||||||
column += 2;
|
|
||||||
buf += charlength;
|
buf += charlength;
|
||||||
|
column += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1980,21 +1978,18 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
/* For a multibyte character, check whether it is valid,
|
|
||||||
* and determine whether it occupies one or two columns. */
|
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
int length = mbtowc(&wc, buf, MAXCHARLEN);
|
|
||||||
|
|
||||||
if (charlength != length)
|
/* Convert a multibyte character to a single code. */
|
||||||
die("Different character lengths");
|
mbtowc(&wc, buf, MAXCHARLEN);
|
||||||
|
|
||||||
/* When invalid, represent it with the Replacement Character. */
|
/* Represent an invalid character with the Replacement Character. */
|
||||||
if (charlength < 0 || !is_valid_unicode(wc)) {
|
if (charlength < 0 || !is_valid_unicode(wc)) {
|
||||||
converted[index++] = '\xEF';
|
converted[index++] = '\xEF';
|
||||||
converted[index++] = '\xBF';
|
converted[index++] = '\xBF';
|
||||||
converted[index++] = '\xBD';
|
converted[index++] = '\xBD';
|
||||||
column++;
|
|
||||||
buf += (charlength > 0 ? charlength : 1);
|
buf += (charlength > 0 ? charlength : 1);
|
||||||
|
column++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2002,6 +1997,7 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
for (; charlength > 0; charlength--)
|
for (; charlength > 0; charlength--)
|
||||||
converted[index++] = *(buf++);
|
converted[index++] = *(buf++);
|
||||||
|
|
||||||
|
/* Determine whether the character occupies one or two columns. */
|
||||||
charwidth = wcwidth(wc);
|
charwidth = wcwidth(wc);
|
||||||
|
|
||||||
/* If the codepoint is unassigned, assume a width of one. */
|
/* If the codepoint is unassigned, assume a width of one. */
|
||||||
|
|
Loading…
Reference in New Issue