diff --git a/ChangeLog b/ChangeLog index d29abe6f891c79ac8c1ecb1d557e64a910afe37d..d742efa873b589471ca8150c22db3435b1ea13ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -136,6 +136,10 @@ CVS code - (DLR) - Don't set current_len until after it's been asserted that both current and current->data aren't NULL. (DLR) +- rcfile.c: + parse_colors() + - Properly parse a background color without a foreground color. + (DLR) - search.c: do_gotoline() - Properly show an error message if we try to go to line 0, @@ -197,6 +201,10 @@ CVS code - - doc/faq.html: - Update the question about the FAQ to mention the current maintainer. (DLR) +- doc/nanorc.sample: + - In the "nanorc" regexes, tweak the "color" regex to properly + color a line that specifies a background color without a + foreground color, and update the associated comments. (DLR) - doc/man/fr/Makefile.am: - Set mandir to @mandir@/fr, so French manpages get installed where they belong (Jordi). diff --git a/doc/nanorc.sample b/doc/nanorc.sample index d1596b392c8c0fa5cf5654e47397cc6c6a47d493..de77e5cf0ce4ee6218860e99831e2b062f664c2c 100644 --- a/doc/nanorc.sample +++ b/doc/nanorc.sample @@ -133,9 +133,10 @@ ## ## To use multi-line regexes use the start="regex" end="regex" format. ## -## If your system supports transparency, not specifying a background -## color will use a transparent color. If you don't want this, be sure -## to set the background color to black or white. +## Not specifying a foreground color will use the default foreground +## color. If your system supports transparency, not specifying a +## background color will use a transparent color. If you don't want the +## latter, be sure to set the background color to black or white. ## # syntax "c-file" "\.(c|C|cc|cpp|h|H|hh|hpp)$" # color red "\<[A-Z_]{2,}\>" @@ -264,7 +265,7 @@ # color cyan "^ *(set|unset) +(view|whitespace)" # color green "^ *(set|unset|syntax)\>" ## colors -# color yellow "^ *color +(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" +# color yellow "^ *color *(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" # color magenta "^ *color\>" "\<(start|end)=" ## strings # color white "\"(\\.|[^\"])*\"" diff --git a/src/rcfile.c b/src/rcfile.c index a6285124e48d84c137b16ac77b9290c5be103a4b..3e5bd78c8f079f820e66cb0af007c536d713ada9 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -353,7 +353,7 @@ void parse_syntax(char *ptr) void parse_colors(char *ptr) { int fg, bg; - bool bright = FALSE; + bool bright = FALSE, no_fgcolor = FALSE; char *fgstr; assert(ptr != NULL); @@ -368,8 +368,15 @@ void parse_colors(char *ptr) if (strchr(fgstr, ',') != NULL) { char *bgcolorname; + strtok(fgstr, ","); bgcolorname = strtok(NULL, ","); + if (bgcolorname == NULL) { + /* If we have a background color without a foreground color, + * parse it properly. */ + bgcolorname = fgstr + 1; + no_fgcolor = TRUE; + } if (strncasecmp(bgcolorname, "bright", 6) == 0) { rcfile_error( N_("Background color %s cannot be bright"), @@ -380,11 +387,14 @@ void parse_colors(char *ptr) } else bg = -1; - fg = color_to_int(fgstr, &bright); + if (!no_fgcolor) { + fg = color_to_int(fgstr, &bright); - /* Don't try to parse screwed-up foreground colors. */ - if (fg == -1) - return; + /* Don't try to parse screwed-up foreground colors. */ + if (fg == -1) + return; + } else + fg = -1; if (syntaxes == NULL) { rcfile_error(