tweaks: rename a variable, away from an abbreviation
parent
fd023d6dcf
commit
712b574fb7
60
src/winio.c
60
src/winio.c
|
@ -1695,20 +1695,20 @@ void set_blankdelay_to_one(void)
|
||||||
statusblank = 1;
|
statusblank = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert buf into a string that can be displayed on screen. The caller
|
/* Convert text into a string that can be displayed on screen. The caller
|
||||||
* wants to display buf starting with the given column, and extending for
|
* wants to display text starting with the given column, and extending for
|
||||||
* at most span columns. column is zero-based, and span is one-based, so
|
* at most span columns. column is zero-based, and span is one-based, so
|
||||||
* span == 0 means you get "" returned. The returned string is dynamically
|
* span == 0 means you get "" returned. The returned string is dynamically
|
||||||
* allocated, and should be freed. If isdata is TRUE, the caller might put
|
* allocated, and should be freed. If isdata is TRUE, the caller might put
|
||||||
* "<" at the beginning or ">" at the end of the line if it's too long. If
|
* "<" at the beginning or ">" at the end of the line if it's too long. If
|
||||||
* isprompt is TRUE, the caller might put ">" at the end of the line if it's
|
* isprompt is TRUE, the caller might put ">" at the end of the line if it's
|
||||||
* too long. */
|
* too long. */
|
||||||
char *display_string(const char *buf, size_t column, size_t span,
|
char *display_string(const char *text, size_t column, size_t span,
|
||||||
bool isdata, bool isprompt)
|
bool isdata, bool isprompt)
|
||||||
{
|
{
|
||||||
size_t start_index = actual_x(buf, column);
|
size_t start_index = actual_x(text, column);
|
||||||
/* The index of the first character that the caller wishes to show. */
|
/* The index of the first character that the caller wishes to show. */
|
||||||
size_t start_col = wideness(buf, start_index);
|
size_t start_col = wideness(text, start_index);
|
||||||
/* The actual column where that first character starts. */
|
/* The actual column where that first character starts. */
|
||||||
char *converted;
|
char *converted;
|
||||||
/* The expanded string we will return. */
|
/* The expanded string we will return. */
|
||||||
|
@ -1717,10 +1717,10 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
size_t beyond = column + span;
|
size_t beyond = column + span;
|
||||||
/* The column number just beyond the last shown character. */
|
/* The column number just beyond the last shown character. */
|
||||||
|
|
||||||
buf += start_index;
|
text += start_index;
|
||||||
|
|
||||||
/* Allocate enough space for converting the relevant part of the line. */
|
/* Allocate enough space for converting the relevant part of the line. */
|
||||||
converted = nmalloc(strlen(buf) * (MAXCHARLEN + tabsize) + 1);
|
converted = nmalloc(strlen(text) * (MAXCHARLEN + tabsize) + 1);
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (span > HIGHEST_POSITIVE) {
|
if (span > HIGHEST_POSITIVE) {
|
||||||
|
@ -1732,16 +1732,16 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
/* If the first character starts before the left edge, or would be
|
/* If the first character starts before the left edge, or would be
|
||||||
* overwritten by a "<" token, then show placeholders instead. */
|
* overwritten by a "<" token, then show placeholders instead. */
|
||||||
if ((start_col < column || (start_col > 0 && isdata && !ISSET(SOFTWRAP))) &&
|
if ((start_col < column || (start_col > 0 && isdata && !ISSET(SOFTWRAP))) &&
|
||||||
*buf != '\0' && *buf != '\t') {
|
*text != '\0' && *text != '\t') {
|
||||||
if (is_cntrl_char(buf)) {
|
if (is_cntrl_char(text)) {
|
||||||
if (start_col < column) {
|
if (start_col < column) {
|
||||||
converted[index++] = control_mbrep(buf, isdata);
|
converted[index++] = control_mbrep(text, isdata);
|
||||||
column++;
|
column++;
|
||||||
buf += char_length(buf);
|
text += char_length(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
else if (mbwidth(buf) == 2) {
|
else if (mbwidth(text) == 2) {
|
||||||
if (start_col == column) {
|
if (start_col == column) {
|
||||||
converted[index++] = ' ';
|
converted[index++] = ' ';
|
||||||
column++;
|
column++;
|
||||||
|
@ -1750,29 +1750,29 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
/* Display the right half of a two-column character as ']'. */
|
/* Display the right half of a two-column character as ']'. */
|
||||||
converted[index++] = ']';
|
converted[index++] = ']';
|
||||||
column++;
|
column++;
|
||||||
buf += char_length(buf);
|
text += char_length(text);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
#define ISO8859_CHAR FALSE
|
#define ISO8859_CHAR FALSE
|
||||||
#define ZEROWIDTH_CHAR (mbwidth(buf) == 0)
|
#define ZEROWIDTH_CHAR (mbwidth(text) == 0)
|
||||||
#else
|
#else
|
||||||
#define ISO8859_CHAR ((unsigned char)*buf > 0x9F)
|
#define ISO8859_CHAR ((unsigned char)*text > 0x9F)
|
||||||
#define ZEROWIDTH_CHAR FALSE
|
#define ZEROWIDTH_CHAR FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (*buf != '\0' && (column < beyond || ZEROWIDTH_CHAR)) {
|
while (*text != '\0' && (column < beyond || ZEROWIDTH_CHAR)) {
|
||||||
/* A plain printable ASCII character is one byte, one column. */
|
/* A plain printable ASCII character is one byte, one column. */
|
||||||
if (((signed char)*buf > 0x20 && *buf != DEL_CODE) || ISO8859_CHAR) {
|
if (((signed char)*text > 0x20 && *text != DEL_CODE) || ISO8859_CHAR) {
|
||||||
converted[index++] = *(buf++);
|
converted[index++] = *(text++);
|
||||||
column++;
|
column++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show a space as a visible character, or as a space. */
|
/* Show a space as a visible character, or as a space. */
|
||||||
if (*buf == ' ') {
|
if (*text == ' ') {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(WHITESPACE_DISPLAY)) {
|
if (ISSET(WHITESPACE_DISPLAY)) {
|
||||||
for (int i = whitelen[0]; i < whitelen[0] + whitelen[1];)
|
for (int i = whitelen[0]; i < whitelen[0] + whitelen[1];)
|
||||||
|
@ -1781,12 +1781,12 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
#endif
|
#endif
|
||||||
converted[index++] = ' ';
|
converted[index++] = ' ';
|
||||||
column++;
|
column++;
|
||||||
buf++;
|
text++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show a tab as a visible character plus spaces, or as just spaces. */
|
/* Show a tab as a visible character plus spaces, or as just spaces. */
|
||||||
if (*buf == '\t') {
|
if (*text == '\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 ||
|
||||||
|
@ -1802,15 +1802,15 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
converted[index++] = ' ';
|
converted[index++] = ' ';
|
||||||
column++;
|
column++;
|
||||||
}
|
}
|
||||||
buf++;
|
text++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Represent a control character with a leading caret. */
|
/* Represent a control character with a leading caret. */
|
||||||
if (is_cntrl_char(buf)) {
|
if (is_cntrl_char(text)) {
|
||||||
converted[index++] = '^';
|
converted[index++] = '^';
|
||||||
converted[index++] = control_mbrep(buf, isdata);
|
converted[index++] = control_mbrep(text, isdata);
|
||||||
buf += char_length(buf);
|
text += char_length(text);
|
||||||
column += 2;
|
column += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1820,14 +1820,14 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
|
|
||||||
/* Convert a multibyte character to a single code. */
|
/* Convert a multibyte character to a single code. */
|
||||||
charlength = mbtowide(&wc, buf);
|
charlength = mbtowide(&wc, text);
|
||||||
|
|
||||||
/* Represent an invalid character with the Replacement Character. */
|
/* Represent an invalid character with the Replacement Character. */
|
||||||
if (charlength < 0) {
|
if (charlength < 0) {
|
||||||
converted[index++] = '\xEF';
|
converted[index++] = '\xEF';
|
||||||
converted[index++] = '\xBF';
|
converted[index++] = '\xBF';
|
||||||
converted[index++] = '\xBD';
|
converted[index++] = '\xBD';
|
||||||
buf++;
|
text++;
|
||||||
column++;
|
column++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1839,13 +1839,13 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
/* On a Linux console, skip zero-width characters, as it would show
|
/* On a Linux console, skip zero-width characters, as it would show
|
||||||
* them WITH a width, thus messing up the display. See bug #52954. */
|
* them WITH a width, thus messing up the display. See bug #52954. */
|
||||||
if (on_a_vt && charwidth == 0) {
|
if (on_a_vt && charwidth == 0) {
|
||||||
buf += charlength;
|
text += charlength;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* For any valid character, just copy its bytes. */
|
/* For any valid character, just copy its bytes. */
|
||||||
for (; charlength > 0; charlength--)
|
for (; charlength > 0; charlength--)
|
||||||
converted[index++] = *(buf++);
|
converted[index++] = *(text++);
|
||||||
|
|
||||||
/* If the codepoint is unassigned, assume a width of one. */
|
/* If the codepoint is unassigned, assume a width of one. */
|
||||||
column += (charwidth < 0 ? 1 : charwidth);
|
column += (charwidth < 0 ? 1 : charwidth);
|
||||||
|
@ -1853,7 +1853,7 @@ char *display_string(const char *buf, size_t column, size_t span,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there is more text than can be shown, make room for the ">". */
|
/* If there is more text than can be shown, make room for the ">". */
|
||||||
if (column > beyond || (*buf != '\0' && (isprompt ||
|
if (column > beyond || (*text != '\0' && (isprompt ||
|
||||||
(isdata && !ISSET(SOFTWRAP))))) {
|
(isdata && !ISSET(SOFTWRAP))))) {
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
do {
|
do {
|
||||||
|
|
Loading…
Reference in New Issue