in edit_add(), make sure we use the right variable when painting marked
selections, and add a few cosmetic tweaks git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2299 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
3e93c63e60
commit
14ace1711d
45
src/winio.c
45
src/winio.c
|
@ -3139,7 +3139,8 @@ void edit_add(const filestruct *fileptr, const char *converted, int
|
||||||
* unless k is 0. If regexec() returns REG_NOMATCH,
|
* unless k is 0. If regexec() returns REG_NOMATCH,
|
||||||
* there are no more matches in the line. */
|
* there are no more matches in the line. */
|
||||||
if (regexec(&tmpcolor->start, &fileptr->data[k], 1,
|
if (regexec(&tmpcolor->start, &fileptr->data[k], 1,
|
||||||
&startmatch, k == 0 ? 0 : REG_NOTBOL) == REG_NOMATCH)
|
&startmatch, k == 0 ? 0 :
|
||||||
|
REG_NOTBOL) == REG_NOMATCH)
|
||||||
break;
|
break;
|
||||||
/* Translate the match to the beginning of the line. */
|
/* Translate the match to the beginning of the line. */
|
||||||
startmatch.rm_so += k;
|
startmatch.rm_so += k;
|
||||||
|
@ -3176,14 +3177,14 @@ void edit_add(const filestruct *fileptr, const char *converted, int
|
||||||
*
|
*
|
||||||
* We find the first line before fileptr matching the
|
* We find the first line before fileptr matching the
|
||||||
* start. If every match on that line is followed by an
|
* start. If every match on that line is followed by an
|
||||||
* end, then go to step two. Otherwise, find the next line
|
* end, then go to step two. Otherwise, find the next
|
||||||
* after start_line matching the end. If that line is not
|
* line after start_line matching the end. If that line
|
||||||
* before fileptr, then paint the beginning of this line. */
|
* is not before fileptr, then paint the beginning of
|
||||||
|
* this line. */
|
||||||
const filestruct *start_line = fileptr->prev;
|
const filestruct *start_line = fileptr->prev;
|
||||||
/* the first line before fileptr matching start */
|
/* The first line before fileptr matching start. */
|
||||||
regoff_t start_col;
|
regoff_t start_col;
|
||||||
/* where it starts in that line */
|
/* Where it starts in that line. */
|
||||||
const filestruct *end_line;
|
const filestruct *end_line;
|
||||||
|
|
||||||
while (start_line != NULL &&
|
while (start_line != NULL &&
|
||||||
|
@ -3202,21 +3203,20 @@ void edit_add(const filestruct *fileptr, const char *converted, int
|
||||||
/* Now start_line is the first line before fileptr
|
/* Now start_line is the first line before fileptr
|
||||||
* containing a start match. Is there a start on this
|
* containing a start match. Is there a start on this
|
||||||
* line not followed by an end on this line? */
|
* line not followed by an end on this line? */
|
||||||
|
|
||||||
start_col = 0;
|
start_col = 0;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
start_col += startmatch.rm_so;
|
start_col += startmatch.rm_so;
|
||||||
startmatch.rm_eo -= startmatch.rm_so;
|
startmatch.rm_eo -= startmatch.rm_so;
|
||||||
if (regexec(tmpcolor->end,
|
if (regexec(tmpcolor->end, start_line->data +
|
||||||
start_line->data + start_col + startmatch.rm_eo,
|
start_col + startmatch.rm_eo, 0, NULL,
|
||||||
0, NULL, start_col + startmatch.rm_eo == 0 ? 0 :
|
start_col + startmatch.rm_eo == 0 ? 0 :
|
||||||
REG_NOTBOL) == REG_NOMATCH)
|
REG_NOTBOL) == REG_NOMATCH)
|
||||||
/* No end found after this start. */
|
/* No end found after this start. */
|
||||||
break;
|
break;
|
||||||
start_col++;
|
start_col++;
|
||||||
if (regexec(&tmpcolor->start,
|
if (regexec(&tmpcolor->start, start_line->data +
|
||||||
start_line->data + start_col, 1,
|
start_col, 1, &startmatch,
|
||||||
&startmatch, REG_NOTBOL) == REG_NOMATCH)
|
REG_NOTBOL) == REG_NOMATCH)
|
||||||
/* No later start on this line. */
|
/* No later start on this line. */
|
||||||
goto step_two;
|
goto step_two;
|
||||||
}
|
}
|
||||||
|
@ -3257,6 +3257,7 @@ void edit_add(const filestruct *fileptr, const char *converted, int
|
||||||
step_two:
|
step_two:
|
||||||
/* Second step, we look for starts on this line. */
|
/* Second step, we look for starts on this line. */
|
||||||
start_col = 0;
|
start_col = 0;
|
||||||
|
|
||||||
while (start_col < endpos) {
|
while (start_col < endpos) {
|
||||||
if (regexec(&tmpcolor->start,
|
if (regexec(&tmpcolor->start,
|
||||||
fileptr->data + start_col, 1, &startmatch,
|
fileptr->data + start_col, 1, &startmatch,
|
||||||
|
@ -3274,7 +3275,9 @@ void edit_add(const filestruct *fileptr, const char *converted, int
|
||||||
else
|
else
|
||||||
x_start = strnlenpt(fileptr->data,
|
x_start = strnlenpt(fileptr->data,
|
||||||
startmatch.rm_so) - start;
|
startmatch.rm_so) - start;
|
||||||
|
|
||||||
index = actual_x(converted, x_start);
|
index = actual_x(converted, x_start);
|
||||||
|
|
||||||
if (regexec(tmpcolor->end,
|
if (regexec(tmpcolor->end,
|
||||||
fileptr->data + startmatch.rm_eo, 1, &endmatch,
|
fileptr->data + startmatch.rm_eo, 1, &endmatch,
|
||||||
startmatch.rm_eo == 0 ? 0 : REG_NOTBOL) == 0) {
|
startmatch.rm_eo == 0 ? 0 : REG_NOTBOL) == 0) {
|
||||||
|
@ -3300,12 +3303,13 @@ void edit_add(const filestruct *fileptr, const char *converted, int
|
||||||
/* There is no end on this line. But we haven't
|
/* There is no end on this line. But we haven't
|
||||||
* yet looked for one on later lines. */
|
* yet looked for one on later lines. */
|
||||||
end_line = fileptr->next;
|
end_line = fileptr->next;
|
||||||
while (end_line != NULL &&
|
|
||||||
regexec(tmpcolor->end, end_line->data, 0,
|
|
||||||
NULL, 0) == REG_NOMATCH)
|
|
||||||
end_line = end_line->next;
|
|
||||||
if (end_line != NULL) {
|
|
||||||
|
|
||||||
|
while (end_line != NULL &&
|
||||||
|
regexec(tmpcolor->end, end_line->data,
|
||||||
|
0, NULL, 0) == REG_NOMATCH)
|
||||||
|
end_line = end_line->next;
|
||||||
|
|
||||||
|
if (end_line != NULL) {
|
||||||
assert(0 <= x_start && x_start < COLS);
|
assert(0 <= x_start && x_start < COLS);
|
||||||
|
|
||||||
mvwaddnstr(edit, yval, x_start,
|
mvwaddnstr(edit, yval, x_start,
|
||||||
|
@ -3385,11 +3389,12 @@ void edit_add(const filestruct *fileptr, const char *converted, int
|
||||||
assert(x_start >= 0 && x_start <= strlen(converted));
|
assert(x_start >= 0 && x_start <= strlen(converted));
|
||||||
|
|
||||||
index = actual_x(converted, x_start);
|
index = actual_x(converted, x_start);
|
||||||
|
|
||||||
if (paintlen > 0)
|
if (paintlen > 0)
|
||||||
paintlen = actual_x(converted + index, paintlen);
|
paintlen = actual_x(converted + index, paintlen);
|
||||||
|
|
||||||
wattron(edit, A_REVERSE);
|
wattron(edit, A_REVERSE);
|
||||||
mvwaddnstr(edit, yval, x_start, converted + x_start,
|
mvwaddnstr(edit, yval, x_start, converted + index,
|
||||||
paintlen);
|
paintlen);
|
||||||
wattroff(edit, A_REVERSE);
|
wattroff(edit, A_REVERSE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue