tweaks: rename a bunch of variables, to become identical to others
parent
3bf04afa6d
commit
aa205f58ca
|
@ -332,7 +332,7 @@ size_t move_mbleft(const char *buf, size_t pos)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
if (use_utf8) {
|
if (use_utf8) {
|
||||||
size_t before, char_len = 0;
|
size_t before, charlen = 0;
|
||||||
|
|
||||||
if (pos < 4)
|
if (pos < 4)
|
||||||
before = 0;
|
before = 0;
|
||||||
|
@ -355,11 +355,11 @@ size_t move_mbleft(const char *buf, size_t pos)
|
||||||
/* Move forward again until we reach the original character,
|
/* Move forward again until we reach the original character,
|
||||||
* so we know the length of its preceding character. */
|
* so we know the length of its preceding character. */
|
||||||
while (before < pos) {
|
while (before < pos) {
|
||||||
char_len = parse_mbchar(buf + before, NULL, NULL);
|
charlen = parse_mbchar(buf + before, NULL, NULL);
|
||||||
before += char_len;
|
before += charlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return before - char_len;
|
return before - charlen;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
return (pos == 0 ? 0 : pos - 1);
|
return (pos == 0 ? 0 : pos - 1);
|
||||||
|
|
|
@ -35,7 +35,7 @@ void do_deletion(undo_type action)
|
||||||
|
|
||||||
/* When in the middle of a line, delete the current character. */
|
/* When in the middle of a line, delete the current character. */
|
||||||
if (openfile->current->data[openfile->current_x] != '\0') {
|
if (openfile->current->data[openfile->current_x] != '\0') {
|
||||||
int char_len = parse_mbchar(openfile->current->data +
|
int charlen = parse_mbchar(openfile->current->data +
|
||||||
openfile->current_x, NULL, NULL);
|
openfile->current_x, NULL, NULL);
|
||||||
size_t line_len = strlen(openfile->current->data +
|
size_t line_len = strlen(openfile->current->data +
|
||||||
openfile->current_x);
|
openfile->current_x);
|
||||||
|
@ -53,13 +53,13 @@ void do_deletion(undo_type action)
|
||||||
#endif
|
#endif
|
||||||
/* Move the remainder of the line "in", over the current character. */
|
/* Move the remainder of the line "in", over the current character. */
|
||||||
charmove(&openfile->current->data[openfile->current_x],
|
charmove(&openfile->current->data[openfile->current_x],
|
||||||
&openfile->current->data[openfile->current_x + char_len],
|
&openfile->current->data[openfile->current_x + charlen],
|
||||||
line_len - char_len + 1);
|
line_len - charlen + 1);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* Adjust the mark if it is after the cursor on the current line. */
|
/* Adjust the mark if it is after the cursor on the current line. */
|
||||||
if (openfile->mark == openfile->current &&
|
if (openfile->mark == openfile->current &&
|
||||||
openfile->mark_x > openfile->current_x)
|
openfile->mark_x > openfile->current_x)
|
||||||
openfile->mark_x -= char_len;
|
openfile->mark_x -= charlen;
|
||||||
#endif
|
#endif
|
||||||
/* Otherwise, when not at end of buffer, join this line with the next. */
|
/* Otherwise, when not at end of buffer, join this line with the next. */
|
||||||
} else if (openfile->current != openfile->filebot) {
|
} else if (openfile->current != openfile->filebot) {
|
||||||
|
|
20
src/nano.c
20
src/nano.c
|
@ -1780,7 +1780,7 @@ void do_input(void)
|
||||||
void do_output(char *output, size_t output_len, bool allow_cntrls)
|
void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||||
{
|
{
|
||||||
char onechar[MAXCHARLEN];
|
char onechar[MAXCHARLEN];
|
||||||
int char_len;
|
int charlen;
|
||||||
size_t current_len = strlen(openfile->current->data);
|
size_t current_len = strlen(openfile->current->data);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
@ -1799,23 +1799,23 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||||
output[i] = '\n';
|
output[i] = '\n';
|
||||||
|
|
||||||
/* Get the next multibyte character. */
|
/* Get the next multibyte character. */
|
||||||
char_len = parse_mbchar(output + i, onechar, NULL);
|
charlen = parse_mbchar(output + i, onechar, NULL);
|
||||||
|
|
||||||
i += char_len;
|
i += charlen;
|
||||||
|
|
||||||
/* If controls are not allowed, ignore an ASCII control character. */
|
/* If controls are not allowed, ignore an ASCII control character. */
|
||||||
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_len)))
|
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - charlen)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Make room for the new character and copy it into the line. */
|
/* Make room for the new character and copy it into the line. */
|
||||||
openfile->current->data = charealloc(openfile->current->data,
|
openfile->current->data = charealloc(openfile->current->data,
|
||||||
current_len + char_len + 1);
|
current_len + charlen + 1);
|
||||||
charmove(openfile->current->data + openfile->current_x + char_len,
|
charmove(openfile->current->data + openfile->current_x + charlen,
|
||||||
openfile->current->data + openfile->current_x,
|
openfile->current->data + openfile->current_x,
|
||||||
current_len - openfile->current_x + 1);
|
current_len - openfile->current_x + 1);
|
||||||
strncpy(openfile->current->data + openfile->current_x, onechar,
|
strncpy(openfile->current->data + openfile->current_x, onechar,
|
||||||
char_len);
|
charlen);
|
||||||
current_len += char_len;
|
current_len += charlen;
|
||||||
openfile->totsize++;
|
openfile->totsize++;
|
||||||
set_modified();
|
set_modified();
|
||||||
|
|
||||||
|
@ -1830,7 +1830,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||||
/* Note that current_x has not yet been incremented. */
|
/* Note that current_x has not yet been incremented. */
|
||||||
if (openfile->current == openfile->mark &&
|
if (openfile->current == openfile->mark &&
|
||||||
openfile->current_x < openfile->mark_x)
|
openfile->current_x < openfile->mark_x)
|
||||||
openfile->mark_x += char_len;
|
openfile->mark_x += charlen;
|
||||||
|
|
||||||
/* When the cursor is on the top row and not on the first chunk
|
/* When the cursor is on the top row and not on the first chunk
|
||||||
* of a line, adding text there might change the preceding chunk
|
* of a line, adding text there might change the preceding chunk
|
||||||
|
@ -1842,7 +1842,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
openfile->current_x += char_len;
|
openfile->current_x += charlen;
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
update_undo(ADD);
|
update_undo(ADD);
|
||||||
|
|
22
src/prompt.c
22
src/prompt.c
|
@ -190,7 +190,7 @@ void do_statusbar_output(int *the_input, size_t input_len,
|
||||||
{
|
{
|
||||||
char *output = charalloc(input_len + 1);
|
char *output = charalloc(input_len + 1);
|
||||||
char onechar[MAXCHARLEN];
|
char onechar[MAXCHARLEN];
|
||||||
size_t char_len, i, j = 0;
|
size_t charlen, i, j = 0;
|
||||||
|
|
||||||
/* Copy the typed stuff so it can be treated. */
|
/* Copy the typed stuff so it can be treated. */
|
||||||
for (i = 0; i < input_len; i++)
|
for (i = 0; i < input_len; i++)
|
||||||
|
@ -203,21 +203,21 @@ void do_statusbar_output(int *the_input, size_t input_len,
|
||||||
output[j] = '\n';
|
output[j] = '\n';
|
||||||
|
|
||||||
/* Interpret the next multibyte character. */
|
/* Interpret the next multibyte character. */
|
||||||
char_len = parse_mbchar(output + j, onechar, NULL);
|
charlen = parse_mbchar(output + j, onechar, NULL);
|
||||||
|
|
||||||
j += char_len;
|
j += charlen;
|
||||||
|
|
||||||
/* When filtering, skip any ASCII control character. */
|
/* When filtering, skip any ASCII control character. */
|
||||||
if (filtering && is_ascii_cntrl_char(*(output + j - char_len)))
|
if (filtering && is_ascii_cntrl_char(*(output + j - charlen)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Insert the typed character into the existing answer string. */
|
/* Insert the typed character into the existing answer string. */
|
||||||
answer = charealloc(answer, strlen(answer) + char_len + 1);
|
answer = charealloc(answer, strlen(answer) + charlen + 1);
|
||||||
charmove(answer + typing_x + char_len, answer + typing_x,
|
charmove(answer + typing_x + charlen, answer + typing_x,
|
||||||
strlen(answer) - typing_x + 1);
|
strlen(answer) - typing_x + 1);
|
||||||
strncpy(answer + typing_x, onechar, char_len);
|
strncpy(answer + typing_x, onechar, charlen);
|
||||||
|
|
||||||
typing_x += char_len;
|
typing_x += charlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(output);
|
free(output);
|
||||||
|
@ -253,10 +253,10 @@ void do_statusbar_right(void)
|
||||||
void do_statusbar_delete(void)
|
void do_statusbar_delete(void)
|
||||||
{
|
{
|
||||||
if (answer[typing_x] != '\0') {
|
if (answer[typing_x] != '\0') {
|
||||||
int char_len = parse_mbchar(answer + typing_x, NULL, NULL);
|
int charlen = parse_mbchar(answer + typing_x, NULL, NULL);
|
||||||
|
|
||||||
charmove(answer + typing_x, answer + typing_x + char_len,
|
charmove(answer + typing_x, answer + typing_x + charlen,
|
||||||
strlen(answer) - typing_x - char_len + 1);
|
strlen(answer) - typing_x - charlen + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
46
src/text.c
46
src/text.c
|
@ -1163,12 +1163,12 @@ void add_undo(undo_type action)
|
||||||
* else purposely fall into the line-joining code. */
|
* else purposely fall into the line-joining code. */
|
||||||
if (openfile->current->data[openfile->current_x] != '\0') {
|
if (openfile->current->data[openfile->current_x] != '\0') {
|
||||||
char *char_buf = charalloc(MAXCHARLEN + 1);
|
char *char_buf = charalloc(MAXCHARLEN + 1);
|
||||||
int char_len = parse_mbchar(&openfile->current->data[u->begin],
|
int charlen = parse_mbchar(&openfile->current->data[u->begin],
|
||||||
char_buf, NULL);
|
char_buf, NULL);
|
||||||
char_buf[char_len] = '\0';
|
char_buf[charlen] = '\0';
|
||||||
u->strdata = char_buf;
|
u->strdata = char_buf;
|
||||||
if (u->type == BACK)
|
if (u->type == BACK)
|
||||||
u->mark_begin_x += char_len;
|
u->mark_begin_x += charlen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JOIN:
|
case JOIN:
|
||||||
|
@ -1273,7 +1273,7 @@ void update_undo(undo_type action)
|
||||||
{
|
{
|
||||||
undo *u = openfile->undotop;
|
undo *u = openfile->undotop;
|
||||||
char *char_buf;
|
char *char_buf;
|
||||||
int char_len;
|
int charlen;
|
||||||
|
|
||||||
if (u->type != action)
|
if (u->type != action)
|
||||||
statusline(ALERT, "Mismatching undo type -- please report a bug");
|
statusline(ALERT, "Mismatching undo type -- please report a bug");
|
||||||
|
@ -1283,10 +1283,10 @@ void update_undo(undo_type action)
|
||||||
switch (u->type) {
|
switch (u->type) {
|
||||||
case ADD:
|
case ADD:
|
||||||
char_buf = charalloc(MAXCHARLEN);
|
char_buf = charalloc(MAXCHARLEN);
|
||||||
char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x],
|
charlen = parse_mbchar(&openfile->current->data[u->mark_begin_x],
|
||||||
char_buf, NULL);
|
char_buf, NULL);
|
||||||
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0,
|
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0,
|
||||||
char_buf, char_len);
|
char_buf, charlen);
|
||||||
u->mark_begin_lineno = openfile->current->lineno;
|
u->mark_begin_lineno = openfile->current->lineno;
|
||||||
u->mark_begin_x = openfile->current_x;
|
u->mark_begin_x = openfile->current_x;
|
||||||
break;
|
break;
|
||||||
|
@ -1297,15 +1297,15 @@ void update_undo(undo_type action)
|
||||||
case BACK:
|
case BACK:
|
||||||
case DEL:
|
case DEL:
|
||||||
char_buf = charalloc(MAXCHARLEN);
|
char_buf = charalloc(MAXCHARLEN);
|
||||||
char_len = parse_mbchar(&openfile->current->data[openfile->current_x],
|
charlen = parse_mbchar(&openfile->current->data[openfile->current_x],
|
||||||
char_buf, NULL);
|
char_buf, NULL);
|
||||||
if (openfile->current_x == u->begin) {
|
if (openfile->current_x == u->begin) {
|
||||||
/* They deleted more: add removed character after earlier stuff. */
|
/* They deleted more: add removed character after earlier stuff. */
|
||||||
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_len);
|
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, charlen);
|
||||||
u->mark_begin_x = openfile->current_x;
|
u->mark_begin_x = openfile->current_x;
|
||||||
} else if (openfile->current_x == u->begin - char_len) {
|
} else if (openfile->current_x == u->begin - charlen) {
|
||||||
/* They backspaced further: add removed character before earlier. */
|
/* They backspaced further: add removed character before earlier. */
|
||||||
u->strdata = addstrings(char_buf, char_len, u->strdata, strlen(u->strdata));
|
u->strdata = addstrings(char_buf, charlen, u->strdata, strlen(u->strdata));
|
||||||
u->begin = openfile->current_x;
|
u->begin = openfile->current_x;
|
||||||
} else {
|
} else {
|
||||||
/* They deleted *elsewhere* on the line: start a new undo item. */
|
/* They deleted *elsewhere* on the line: start a new undo item. */
|
||||||
|
@ -1512,7 +1512,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
|
||||||
/* The index of the character we are looking at. */
|
/* The index of the character we are looking at. */
|
||||||
size_t column = 0;
|
size_t column = 0;
|
||||||
/* The column position that corresponds with index. */
|
/* The column position that corresponds with index. */
|
||||||
int char_len = 0;
|
int charlen = 0;
|
||||||
/* The length of the current character, in bytes. */
|
/* The length of the current character, in bytes. */
|
||||||
|
|
||||||
/* Find the last blank that does not overshoot the target column. */
|
/* Find the last blank that does not overshoot the target column. */
|
||||||
|
@ -1524,9 +1524,9 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_len = parse_mbchar(line, NULL, &column);
|
charlen = parse_mbchar(line, NULL, &column);
|
||||||
line += char_len;
|
line += charlen;
|
||||||
index += char_len;
|
index += charlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the whole line displays shorter than goal, we're done. */
|
/* If the whole line displays shorter than goal, we're done. */
|
||||||
|
@ -1537,7 +1537,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
|
||||||
/* If we're wrapping a help text and no blank was found, or was
|
/* If we're wrapping a help text and no blank was found, or was
|
||||||
* found only as the first character, force a line break. */
|
* found only as the first character, force a line break. */
|
||||||
if (snap_at_nl && lastblank < 1)
|
if (snap_at_nl && lastblank < 1)
|
||||||
return (index - char_len);
|
return (index - charlen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If no blank was found within the goal width, seek one after it. */
|
/* If no blank was found within the goal width, seek one after it. */
|
||||||
|
@ -1548,9 +1548,9 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
|
||||||
else if (lastblank > 0)
|
else if (lastblank > 0)
|
||||||
return lastblank;
|
return lastblank;
|
||||||
|
|
||||||
char_len = parse_mbchar(line, NULL, NULL);
|
charlen = parse_mbchar(line, NULL, NULL);
|
||||||
line += char_len;
|
line += charlen;
|
||||||
index += char_len;
|
index += charlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1558,14 +1558,14 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
|
||||||
|
|
||||||
/* Move the pointer back to the last blank, and then step beyond it. */
|
/* Move the pointer back to the last blank, and then step beyond it. */
|
||||||
line = line - index + lastblank;
|
line = line - index + lastblank;
|
||||||
char_len = parse_mbchar(line, NULL, NULL);
|
charlen = parse_mbchar(line, NULL, NULL);
|
||||||
line += char_len;
|
line += charlen;
|
||||||
|
|
||||||
/* Skip any consecutive blanks after the last blank. */
|
/* Skip any consecutive blanks after the last blank. */
|
||||||
while (*line != '\0' && is_blank_mbchar(line)) {
|
while (*line != '\0' && is_blank_mbchar(line)) {
|
||||||
lastblank += char_len;
|
lastblank += charlen;
|
||||||
char_len = parse_mbchar(line, NULL, NULL);
|
charlen = parse_mbchar(line, NULL, NULL);
|
||||||
line += char_len;
|
line += charlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return lastblank;
|
return lastblank;
|
||||||
|
|
Loading…
Reference in New Issue