2013-03-17 Chris Allegretta <chrisa@asty.org>

* Revert r4547 as we should have a new release and the overlap code is not yet
          ready for public consumption.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4569 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Chris Allegretta 2013-03-17 22:09:38 +00:00
parent 2072b74153
commit 22c83ec7af
5 changed files with 19 additions and 56 deletions

View File

@ -1,3 +1,7 @@
2013-03-17 Chris Allegretta <chrisa@asty.org>
* Revert r4547 as we should have a new release and the overlap code is not yet
ready for public consumption.
2013-01-20 Chris Allegretta <chrisa@asty.org> 2013-01-20 Chris Allegretta <chrisa@asty.org>
* src/text.c (do_histify): Don't allow sigwinch to be received while justifying * src/text.c (do_histify): Don't allow sigwinch to be received while justifying
as that puts us into a wacky state. Fixess crash on justify by Joshua Rogers. as that puts us into a wacky state. Fixess crash on justify by Joshua Rogers.

View File

@ -192,11 +192,10 @@ typedef enum {
} undo_type; } undo_type;
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
#define COLORWIDTH short
typedef struct colortype { typedef struct colortype {
COLORWIDTH fg; short fg;
/* This syntax's foreground color. */ /* This syntax's foreground color. */
COLORWIDTH bg; short bg;
/* This syntax's background color. */ /* This syntax's background color. */
bool bright; bool bright;
/* Is this color A_BOLD? */ /* Is this color A_BOLD? */
@ -215,9 +214,7 @@ typedef struct colortype {
/* The compiled end (if any) of the regex string. */ /* The compiled end (if any) of the regex string. */
struct colortype *next; struct colortype *next;
/* Next set of colors. */ /* Next set of colors. */
bool overlap; int id;
/* Is it acceptable for other regexes to overlap this one? */
int id;
/* basic id for assigning to lines later */ /* basic id for assigning to lines later */
} colortype; } colortype;

View File

@ -556,7 +556,7 @@ char *parse_next_word(char *ptr);
char *parse_argument(char *ptr); char *parse_argument(char *ptr);
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
char *parse_next_regex(char *ptr); char *parse_next_regex(char *ptr);
bool nregcomp(const char *regex, int cflags); bool nregcomp(const char *regex, int eflags);
void parse_syntax(char *ptr); void parse_syntax(char *ptr);
void parse_magic_syntax(char *ptr); void parse_magic_syntax(char *ptr);
void parse_include(char *ptr); void parse_include(char *ptr);

View File

@ -228,11 +228,11 @@ char *parse_next_regex(char *ptr)
/* Compile the regular expression regex to see if it's valid. Return /* Compile the regular expression regex to see if it's valid. Return
* TRUE if it is, or FALSE otherwise. */ * TRUE if it is, or FALSE otherwise. */
bool nregcomp(const char *regex, int cflags) bool nregcomp(const char *regex, int eflags)
{ {
regex_t preg; regex_t preg;
const char *r = fixbounds(regex); const char *r = fixbounds(regex);
int rc = regcomp(&preg, r, REG_EXTENDED | cflags); int rc = regcomp(&preg, r, REG_EXTENDED | eflags);
if (rc != 0) { if (rc != 0) {
size_t len = regerror(rc, &preg, NULL, 0); size_t len = regerror(rc, &preg, NULL, 0);
@ -680,9 +680,9 @@ void parse_include(char *ptr)
/* Return the short value corresponding to the color named in colorname, /* Return the short value corresponding to the color named in colorname,
* and set bright to TRUE if that color is bright. */ * and set bright to TRUE if that color is bright. */
COLORWIDTH color_to_short(const char *colorname, bool *bright) short color_to_short(const char *colorname, bool *bright)
{ {
COLORWIDTH mcolor = -1; short mcolor = -1;
assert(colorname != NULL && bright != NULL); assert(colorname != NULL && bright != NULL);
@ -722,7 +722,7 @@ COLORWIDTH color_to_short(const char *colorname, bool *bright)
* as case insensitive. */ * as case insensitive. */
void parse_colors(char *ptr, bool icase) void parse_colors(char *ptr, bool icase)
{ {
COLORWIDTH fg, bg; short fg, bg;
bool bright = FALSE, no_fgcolor = FALSE; bool bright = FALSE, no_fgcolor = FALSE;
char *fgstr; char *fgstr;
@ -872,7 +872,7 @@ void parse_colors(char *ptr, bool icase)
0)) ? mallocstrcpy(NULL, fgstr) : NULL; 0)) ? mallocstrcpy(NULL, fgstr) : NULL;
/* Lame way to skip another static counter */ /* Lame way to skip another static counter */
newcolor->id = endsyntax->nmultis; newcolor->id = endsyntax->nmultis;
endsyntax->nmultis++; endsyntax->nmultis++;
} }
} }

View File

@ -2501,29 +2501,14 @@ void edit_draw(filestruct *fileptr, const char *converted, int
* them. */ * them. */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) { if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) {
const colortype *tmpcolor = openfile->colorstrings; const colortype *tmpcolor = openfile->colorstrings;
int i, coloruid = 0; /* We need a unique color ID now */
static filestruct *lastptr = NULL;
static COLORWIDTH *slmatcharray = NULL;
/* Array to track how much we've painted of the line for single line matches */
if (lastptr != fileptr || start == 0) {
if (slmatcharray != NULL)
free(slmatcharray);
slmatcharray = (COLORWIDTH *)nmalloc(strlenpt(fileptr->data) * sizeof(COLORWIDTH));
/* Init slmatcharray */
for (i = 0; i < strlenpt(fileptr->data); i++)
slmatcharray[i] = -1;
}
/* Set up multi-line color data for this line if it's not yet calculated */ /* Set up multi-line color data for this line if it's not yet calculated */
if (fileptr->multidata == NULL && openfile->syntax if (fileptr->multidata == NULL && openfile->syntax
&& openfile->syntax->nmultis > 0) { && openfile->syntax->nmultis > 0) {
int i;
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short)); fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
for (i = 0; i < openfile->syntax->nmultis; i++) for (i = 0; i < openfile->syntax->nmultis; i++)
fileptr->multidata[i] = -1; /* Assue this applies until we know otherwise */ fileptr->multidata[i] = -1; /* Assue this applies until we know otherwise */
} }
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) { for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
int x_start; int x_start;
@ -2538,7 +2523,6 @@ void edit_draw(filestruct *fileptr, const char *converted, int
regmatch_t endmatch; regmatch_t endmatch;
/* Match position for end_regex. */ /* Match position for end_regex. */
coloruid++;
if (tmpcolor->bright) if (tmpcolor->bright)
wattron(edit, A_BOLD); wattron(edit, A_BOLD);
wattron(edit, COLOR_PAIR(tmpcolor->pairnum)); wattron(edit, COLOR_PAIR(tmpcolor->pairnum));
@ -2546,7 +2530,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
* that there is a match. Also, rm_eo is the first * that there is a match. Also, rm_eo is the first
* non-matching character after the match. */ * non-matching character after the match. */
/* First case,tmpcolor is a single-line expression. */ /* First case, tmpcolor is a single-line expression. */
if (tmpcolor->end == NULL) { if (tmpcolor->end == NULL) {
size_t k = 0; size_t k = 0;
@ -2555,8 +2539,6 @@ void edit_draw(filestruct *fileptr, const char *converted, int
* want to ignore them, so that we can highlight e.g. C * want to ignore them, so that we can highlight e.g. C
* strings correctly. */ * strings correctly. */
while (k < endpos) { while (k < endpos) {
bool paintok = TRUE;
/* Note the fifth parameter to regexec(). It says /* Note the fifth parameter to regexec(). It says
* not to match the beginning-of-line character * not to match the beginning-of-line character
* unless k is zero. If regexec() returns * unless k is zero. If regexec() returns
@ -2566,8 +2548,6 @@ void edit_draw(filestruct *fileptr, const char *converted, int
&startmatch, (k == 0) ? 0 : REG_NOTBOL) == &startmatch, (k == 0) ? 0 : REG_NOTBOL) ==
REG_NOMATCH) REG_NOMATCH)
break; break;
/* Translate the match to the beginning of the /* Translate the match to the beginning of the
* line. */ * line. */
startmatch.rm_so += k; startmatch.rm_so += k;
@ -2578,8 +2558,6 @@ void edit_draw(filestruct *fileptr, const char *converted, int
startmatch.rm_eo++; startmatch.rm_eo++;
else if (startmatch.rm_so < endpos && else if (startmatch.rm_so < endpos &&
startmatch.rm_eo > startpos) { startmatch.rm_eo > startpos) {
size_t pbegin = strnlenpt(fileptr->data, startmatch.rm_so);
x_start = (startmatch.rm_so <= startpos) ? 0 : x_start = (startmatch.rm_so <= startpos) ? 0 :
strnlenpt(fileptr->data, strnlenpt(fileptr->data,
startmatch.rm_so) - start; startmatch.rm_so) - start;
@ -2592,25 +2570,10 @@ void edit_draw(filestruct *fileptr, const char *converted, int
assert(0 <= x_start && 0 <= paintlen); assert(0 <= x_start && 0 <= paintlen);
/* Check that the match is not preceeded by another previous mvwaddnstr(edit, line, x_start, converted +
(single line) match before proceeding to paint it */
if (slmatcharray[pbegin] != -1 && slmatcharray[pbegin] != coloruid)
paintok = FALSE;
if (paintok == TRUE) {
int p;
mvwaddnstr(edit, line, x_start, converted +
index, paintlen); index, paintlen);
for (p = pbegin; p < pbegin + (startmatch.rm_eo - startmatch.rm_so); p++) {
slmatcharray[p] = coloruid; /* Add to our match array for the proper length */
}
}
} }
if (paintok) k = startmatch.rm_eo;
k = startmatch.rm_eo;
else
k = startmatch.rm_so + 1;
} }
} else if (fileptr->multidata != NULL && fileptr->multidata[tmpcolor->id] != CNONE) { } else if (fileptr->multidata != NULL && fileptr->multidata[tmpcolor->id] != CNONE) {
/* This is a multi-line regex. There are two steps. /* This is a multi-line regex. There are two steps.
@ -2797,7 +2760,6 @@ void edit_draw(filestruct *fileptr, const char *converted, int
wattroff(edit, A_BOLD); wattroff(edit, A_BOLD);
wattroff(edit, COLOR_PAIR(tmpcolor->pairnum)); wattroff(edit, COLOR_PAIR(tmpcolor->pairnum));
} }
lastptr = fileptr;
} }
#endif /* ENABLE_COLOR */ #endif /* ENABLE_COLOR */