more color updates: add a "default" syntax that takes no extensions for
those files that don't match any other syntax's extensions (ported from Brand Huntsman's old patch, but modified to work with a syntax named "default" instead of requiring a "default-syntax" keyword, and to fit into the existing color architecture) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2959 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
eab0fd808c
commit
179b1bad87
|
@ -53,7 +53,9 @@ CVS code -
|
||||||
regex strings constantly, and to actually compile them on an
|
regex strings constantly, and to actually compile them on an
|
||||||
as-needed basis. Also, make a color syntax specified on the
|
as-needed basis. Also, make a color syntax specified on the
|
||||||
command line override the syntax associated with the current
|
command line override the syntax associated with the current
|
||||||
file extension. Changes to update_color(),
|
file extension, and add a "default" syntax that takes no
|
||||||
|
extensions for those files that don't match any other
|
||||||
|
syntax's extensions. Changes to update_color(),
|
||||||
thanks_for_all_the_fish(), nregcomp(), parse_syntax(), and
|
thanks_for_all_the_fish(), nregcomp(), parse_syntax(), and
|
||||||
parse_colors(). (Brand Huntsman and DLR)
|
parse_colors(). (Brand Huntsman and DLR)
|
||||||
- Various other color fixes. Handle unspecified foreground
|
- Various other color fixes. Handle unspecified foreground
|
||||||
|
@ -285,6 +287,7 @@ CVS code -
|
||||||
- doc/nanorc.sample:
|
- doc/nanorc.sample:
|
||||||
- Add regexes for Bourne shell scripts. (Mike Frysinger, minor
|
- Add regexes for Bourne shell scripts. (Mike Frysinger, minor
|
||||||
tweaks by DLR)
|
tweaks by DLR)
|
||||||
|
- Explain how the "default" syntax works. (DLR)
|
||||||
- doc/man/fr/nano.1, doc/man/fr/nanorc.1:
|
- doc/man/fr/nano.1, doc/man/fr/nanorc.1:
|
||||||
- Updated translation by Jean-Philippe Gérard.
|
- Updated translation by Jean-Philippe Gérard.
|
||||||
- src/Makefile.am:
|
- src/Makefile.am:
|
||||||
|
|
|
@ -147,12 +147,16 @@
|
||||||
##
|
##
|
||||||
## syntax "short description" ["filename regex" ...]
|
## syntax "short description" ["filename regex" ...]
|
||||||
##
|
##
|
||||||
|
## (The syntax "default" is reserved: it takes no filename regexes, and
|
||||||
|
## applies to files that don't match any other syntax's filename
|
||||||
|
## regexes.)
|
||||||
|
##
|
||||||
## color foreground,background "regex" ["regex"...]
|
## color foreground,background "regex" ["regex"...]
|
||||||
## or
|
## or
|
||||||
## icolor foreground,background "regex" ["regex"...]
|
## icolor foreground,background "regex" ["regex"...]
|
||||||
##
|
##
|
||||||
## "color" will do case sensitive matches, while "icolor" will do case
|
## ("color" will do case sensitive matches, while "icolor" will do case
|
||||||
## insensitive matches.
|
## insensitive matches.)
|
||||||
##
|
##
|
||||||
## Legal colors: white, black, red, blue, green, yellow, magenta, cyan.
|
## Legal colors: white, black, red, blue, green, yellow, magenta, cyan.
|
||||||
## You may use the prefix "bright" to mean a stronger color highlight
|
## You may use the prefix "bright" to mean a stronger color highlight
|
||||||
|
|
16
src/color.c
16
src/color.c
|
@ -108,7 +108,7 @@ void color_init(void)
|
||||||
void color_update(void)
|
void color_update(void)
|
||||||
{
|
{
|
||||||
const syntaxtype *tmpsyntax;
|
const syntaxtype *tmpsyntax;
|
||||||
colortype *tmpcolor;
|
colortype *tmpcolor, *defcolor = NULL;
|
||||||
|
|
||||||
assert(openfile != NULL);
|
assert(openfile != NULL);
|
||||||
|
|
||||||
|
@ -134,6 +134,15 @@ void color_update(void)
|
||||||
tmpsyntax = tmpsyntax->next) {
|
tmpsyntax = tmpsyntax->next) {
|
||||||
exttype *e;
|
exttype *e;
|
||||||
|
|
||||||
|
/* If this is the default syntax, it has no associated
|
||||||
|
* extensions. (We've checked for this and for duplicate
|
||||||
|
* syntax names elsewhere.) Skip over it here, but keep
|
||||||
|
* track of its color regexes. */
|
||||||
|
if (mbstrcasecmp(tmpsyntax->desc, "default") == 0) {
|
||||||
|
defcolor = syntaxes->color;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
|
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
|
||||||
bool not_compiled = (e->ext == NULL);
|
bool not_compiled = (e->ext == NULL);
|
||||||
|
|
||||||
|
@ -165,6 +174,11 @@ void color_update(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we didn't get a syntax based on the file extension, and we
|
||||||
|
* have a default syntax, use it. */
|
||||||
|
if (openfile->colorstrings == NULL && defcolor != NULL)
|
||||||
|
openfile->colorstrings = defcolor;
|
||||||
|
|
||||||
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
|
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
|
||||||
tmpcolor = tmpcolor->next) {
|
tmpcolor = tmpcolor->next) {
|
||||||
/* tmpcolor->start_regex and tmpcolor->end_regex have already
|
/* tmpcolor->start_regex and tmpcolor->end_regex have already
|
||||||
|
|
|
@ -322,6 +322,12 @@ void parse_syntax(char *ptr)
|
||||||
fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
|
fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* The default syntax should have no associated extensions. */
|
||||||
|
if (mbstrcasecmp(endsyntax->desc, "default") == 0 && *ptr != '\0') {
|
||||||
|
rcfile_error(N_("The default syntax must take no extensions"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Now load the extensions into their part of the struct. */
|
/* Now load the extensions into their part of the struct. */
|
||||||
while (*ptr != '\0') {
|
while (*ptr != '\0') {
|
||||||
exttype *newext;
|
exttype *newext;
|
||||||
|
|
Loading…
Reference in New Issue