tweaks: rename six symbols, to be more straightforward
parent
85cc99a2a3
commit
3ea2694d9c
26
src/color.c
26
src/color.c
|
@ -266,17 +266,17 @@ void check_the_multis(linestruct *line)
|
||||||
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
|
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
|
||||||
|
|
||||||
/* Check whether the multidata still matches the current situation. */
|
/* Check whether the multidata still matches the current situation. */
|
||||||
if (line->multidata[ink->id] == CNONE ||
|
if (line->multidata[ink->id] == NOTHING ||
|
||||||
line->multidata[ink->id] == CWHOLELINE) {
|
line->multidata[ink->id] == WHOLELINE) {
|
||||||
if (!astart && !anend)
|
if (!astart && !anend)
|
||||||
continue;
|
continue;
|
||||||
} else if (line->multidata[ink->id] == CSTARTENDHERE) {
|
} else if (line->multidata[ink->id] == JUSTONTHIS) {
|
||||||
if (astart && anend && startmatch.rm_so < endmatch.rm_so)
|
if (astart && anend && startmatch.rm_so < endmatch.rm_so)
|
||||||
continue;
|
continue;
|
||||||
} else if (line->multidata[ink->id] == CBEGINBEFORE) {
|
} else if (line->multidata[ink->id] == ENDSHERE) {
|
||||||
if (!astart && anend)
|
if (!astart && anend)
|
||||||
continue;
|
continue;
|
||||||
} else if (line->multidata[ink->id] == CENDAFTER) {
|
} else if (line->multidata[ink->id] == STARTSHERE) {
|
||||||
if (astart && !anend)
|
if (astart && !anend)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -318,13 +318,13 @@ void precalc_multicolorinfo(void)
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
/* For an unpaired start match, mark each remaining line. */
|
/* For an unpaired start match, mark each remaining line. */
|
||||||
if (line->prev && line->prev->multidata[ink->id] == CWOULDBE) {
|
if (line->prev && line->prev->multidata[ink->id] == WOULDBE) {
|
||||||
line->multidata[ink->id] = CWOULDBE;
|
line->multidata[ink->id] = WOULDBE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Assume nothing applies until proven otherwise below. */
|
/* Assume nothing applies until proven otherwise below. */
|
||||||
line->multidata[ink->id] = CNONE;
|
line->multidata[ink->id] = NOTHING;
|
||||||
|
|
||||||
/* When the line contains a start match, look for an end,
|
/* When the line contains a start match, look for an end,
|
||||||
* and if found, mark all the lines that are affected. */
|
* and if found, mark all the lines that are affected. */
|
||||||
|
@ -337,7 +337,7 @@ void precalc_multicolorinfo(void)
|
||||||
* but continue looking for other starts after it. */
|
* but continue looking for other starts after it. */
|
||||||
if (regexec(ink->end, line->data + index, 1,
|
if (regexec(ink->end, line->data + index, 1,
|
||||||
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||||
line->multidata[ink->id] = CSTARTENDHERE;
|
line->multidata[ink->id] = JUSTONTHIS;
|
||||||
index += endmatch.rm_eo;
|
index += endmatch.rm_eo;
|
||||||
/* If both start and end are mere anchors, step ahead. */
|
/* If both start and end are mere anchors, step ahead. */
|
||||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||||
|
@ -358,18 +358,18 @@ void precalc_multicolorinfo(void)
|
||||||
tailline = tailline->next;
|
tailline = tailline->next;
|
||||||
|
|
||||||
if (tailline == NULL) {
|
if (tailline == NULL) {
|
||||||
line->multidata[ink->id] = CWOULDBE;
|
line->multidata[ink->id] = WOULDBE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We found it, we found it, la lala lala. Mark the lines. */
|
/* We found it, we found it, la lala lala. Mark the lines. */
|
||||||
line->multidata[ink->id] = CENDAFTER;
|
line->multidata[ink->id] = STARTSHERE;
|
||||||
|
|
||||||
// Note that this also advances the line in the main loop.
|
// Note that this also advances the line in the main loop.
|
||||||
for (line = line->next; line != tailline; line = line->next)
|
for (line = line->next; line != tailline; line = line->next)
|
||||||
line->multidata[ink->id] = CWHOLELINE;
|
line->multidata[ink->id] = WHOLELINE;
|
||||||
|
|
||||||
tailline->multidata[ink->id] = CBEGINBEFORE;
|
tailline->multidata[ink->id] = ENDSHERE;
|
||||||
|
|
||||||
/* Look for a possible new start after the end match. */
|
/* Look for a possible new start after the end match. */
|
||||||
index = endmatch.rm_eo;
|
index = endmatch.rm_eo;
|
||||||
|
|
|
@ -138,17 +138,17 @@
|
||||||
#define BAD_COLOR -2
|
#define BAD_COLOR -2
|
||||||
|
|
||||||
/* Flags for indicating how a multiline regex pair apply to a line. */
|
/* Flags for indicating how a multiline regex pair apply to a line. */
|
||||||
#define CNONE (1<<1)
|
#define NOTHING (1<<1)
|
||||||
/* The start/end regexes don't cover this line at all. */
|
/* The start/end regexes don't cover this line at all. */
|
||||||
#define CBEGINBEFORE (1<<2)
|
#define STARTSHERE (1<<2)
|
||||||
/* The start regex matches on an earlier line, the end regex on this one. */
|
|
||||||
#define CENDAFTER (1<<3)
|
|
||||||
/* The start regex matches on this line, the end regex on a later one. */
|
/* The start regex matches on this line, the end regex on a later one. */
|
||||||
#define CWHOLELINE (1<<4)
|
#define WHOLELINE (1<<3)
|
||||||
/* The start regex matches on an earlier line, the end regex on a later one. */
|
/* The start regex matches on an earlier line, the end regex on a later one. */
|
||||||
#define CSTARTENDHERE (1<<5)
|
#define ENDSHERE (1<<4)
|
||||||
|
/* The start regex matches on an earlier line, the end regex on this one. */
|
||||||
|
#define JUSTONTHIS (1<<5)
|
||||||
/* Both the start and end regexes match within this line. */
|
/* Both the start and end regexes match within this line. */
|
||||||
#define CWOULDBE (1<<6)
|
#define WOULDBE (1<<6)
|
||||||
/* An unpaired start match is on or before this line. */
|
/* An unpaired start match is on or before this line. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
34
src/winio.c
34
src/winio.c
|
@ -2553,18 +2553,18 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
/* Second case: varnish is a multiline expression. */
|
/* Second case: varnish is a multiline expression. */
|
||||||
|
|
||||||
/* Assume nothing gets painted until proven otherwise below. */
|
/* Assume nothing gets painted until proven otherwise below. */
|
||||||
line->multidata[varnish->id] = CNONE;
|
line->multidata[varnish->id] = NOTHING;
|
||||||
|
|
||||||
/* Apart from the first row, check the multidata of the preceding line:
|
/* Apart from the first row, check the multidata of the preceding line:
|
||||||
* it tells us about the situation so far, and thus what to do here. */
|
* it tells us about the situation so far, and thus what to do here. */
|
||||||
if (row > 0 && start_line != NULL && start_line->multidata != NULL) {
|
if (row > 0 && start_line != NULL && start_line->multidata != NULL) {
|
||||||
if (start_line->multidata[varnish->id] == CWHOLELINE ||
|
if (start_line->multidata[varnish->id] == WHOLELINE ||
|
||||||
start_line->multidata[varnish->id] == CENDAFTER ||
|
start_line->multidata[varnish->id] == STARTSHERE ||
|
||||||
start_line->multidata[varnish->id] == CWOULDBE)
|
start_line->multidata[varnish->id] == WOULDBE)
|
||||||
goto seek_an_end;
|
goto seek_an_end;
|
||||||
if (start_line->multidata[varnish->id] == CNONE ||
|
if (start_line->multidata[varnish->id] == NOTHING ||
|
||||||
start_line->multidata[varnish->id] == CBEGINBEFORE ||
|
start_line->multidata[varnish->id] == ENDSHERE ||
|
||||||
start_line->multidata[varnish->id] == CSTARTENDHERE)
|
start_line->multidata[varnish->id] == JUSTONTHIS)
|
||||||
goto step_two;
|
goto step_two;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2588,8 +2588,8 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
|
|
||||||
/* If the start has been qualified as an end earlier, believe it. */
|
/* If the start has been qualified as an end earlier, believe it. */
|
||||||
if (start_line->multidata != NULL &&
|
if (start_line->multidata != NULL &&
|
||||||
(start_line->multidata[varnish->id] == CBEGINBEFORE ||
|
(start_line->multidata[varnish->id] == ENDSHERE ||
|
||||||
start_line->multidata[varnish->id] == CSTARTENDHERE))
|
start_line->multidata[varnish->id] == JUSTONTHIS))
|
||||||
goto step_two;
|
goto step_two;
|
||||||
|
|
||||||
/* Maybe there is an end on that same line? If yes, maybe
|
/* Maybe there is an end on that same line? If yes, maybe
|
||||||
|
@ -2629,14 +2629,14 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
|
|
||||||
/* If there is no end, there is nothing to paint. */
|
/* If there is no end, there is nothing to paint. */
|
||||||
if (end_line == NULL) {
|
if (end_line == NULL) {
|
||||||
line->multidata[varnish->id] = CWOULDBE;
|
line->multidata[varnish->id] = WOULDBE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If it was already determined that there is no end... */
|
/* If it was already determined that there is no end... */
|
||||||
if (end_line != line && line->prev == start_line && line->prev->multidata &&
|
if (end_line != line && line->prev == start_line && line->prev->multidata &&
|
||||||
line->prev->multidata[varnish->id] == CWOULDBE) {
|
line->prev->multidata[varnish->id] == WOULDBE) {
|
||||||
line->multidata[varnish->id] = CWOULDBE;
|
line->multidata[varnish->id] = WOULDBE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2645,7 +2645,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
wattron(edit, varnish->attributes);
|
wattron(edit, varnish->attributes);
|
||||||
mvwaddnstr(edit, row, margin, converted, -1);
|
mvwaddnstr(edit, row, margin, converted, -1);
|
||||||
wattroff(edit, varnish->attributes);
|
wattroff(edit, varnish->attributes);
|
||||||
line->multidata[varnish->id] = CWHOLELINE;
|
line->multidata[varnish->id] = WHOLELINE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2657,7 +2657,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
mvwaddnstr(edit, row, margin, converted, paintlen);
|
mvwaddnstr(edit, row, margin, converted, paintlen);
|
||||||
wattroff(edit, varnish->attributes);
|
wattroff(edit, varnish->attributes);
|
||||||
}
|
}
|
||||||
line->multidata[varnish->id] = CBEGINBEFORE;
|
line->multidata[varnish->id] = ENDSHERE;
|
||||||
|
|
||||||
step_two:
|
step_two:
|
||||||
/* Second step: look for starts on this line, but begin
|
/* Second step: look for starts on this line, but begin
|
||||||
|
@ -2694,7 +2694,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
thetext, paintlen);
|
thetext, paintlen);
|
||||||
wattroff(edit, varnish->attributes);
|
wattroff(edit, varnish->attributes);
|
||||||
|
|
||||||
line->multidata[varnish->id] = CSTARTENDHERE;
|
line->multidata[varnish->id] = JUSTONTHIS;
|
||||||
}
|
}
|
||||||
index = endmatch.rm_eo;
|
index = endmatch.rm_eo;
|
||||||
/* If both start and end match are anchors, advance. */
|
/* If both start and end match are anchors, advance. */
|
||||||
|
@ -2716,7 +2716,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
|
|
||||||
/* If there is no end, we're done with this regex. */
|
/* If there is no end, we're done with this regex. */
|
||||||
if (end_line == NULL) {
|
if (end_line == NULL) {
|
||||||
line->multidata[varnish->id] = CWOULDBE;
|
line->multidata[varnish->id] = WOULDBE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2724,7 +2724,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
wattron(edit, varnish->attributes);
|
wattron(edit, varnish->attributes);
|
||||||
mvwaddnstr(edit, row, margin + start_col, thetext, -1);
|
mvwaddnstr(edit, row, margin + start_col, thetext, -1);
|
||||||
wattroff(edit, varnish->attributes);
|
wattroff(edit, varnish->attributes);
|
||||||
line->multidata[varnish->id] = CENDAFTER;
|
line->multidata[varnish->id] = STARTSHERE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue