NANO_SMALL is defined. Changes to usage(), main(),
statusbar(), nanorc.sample, nano.1, and nanorc.5. (DLR,
suggested by CHAO Wei-Lun)
+ - Add support for case insensitive expression matching when
+ using color syntax highlighting, via the "icolor" directive,
+ and add it to those regexes that can use it. Changes to
+ parse_colors(), parse_rcfile(), nanorc.sample, and nanorc.5.
+ (Brand Huntsman, minor tweaks by DLR)
- chars.c:
make_mbstring()
- Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
-.TH NANORC 5 "version 1.3.8" "June 17, 2005"
+.TH NANORC 5 "version 1.3.8" "June 26, 2005"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
.SH OPTIONS
The configuration file accepts a series of "set" and "unset" commands,
which can be used to configure nano on startup without using the
-command-line options. Additionally, the "syntax" and "color" keywords
-are used to define syntax highlighting rules for different text
+command-line options. Additionally, the "syntax", "color", and "icolor"
+keywords are used to define syntax highlighting rules for different text
patterns. GNU nano will read one command per line.
Options in rcfiles take precedence over nano's defaults, and command
.B syntax "\fIstr\fP" ["\fIfileregex\fP" ... ]
Defines a syntax named \fIstr\fP which can be activated via the \fB-Y\fP
flag, or will be automatically activated if the current filename matches
-\fIfileregex\fP. All following \fBcolor\fP statements will apply to
-\fIsyntax\fP until a new syntax is defined.
+\fIfileregex\fP. All following \fBcolor\fP and \fBicolor\fP statements
+will apply to \fIsyntax\fP until a new syntax is defined.
.TP
.B color \fIfgcolor\fP,\fIbgcolor\fP "\fIregex\fP" ...
For the currently defined syntax, display all expressions matching
transparency, not specifying a \fIbgcolor\fP tells \fBnano\fP to attempt
to use a transparent background.
.TP
+.B icolor \fIfgcolor\fP,\fIbgcolor\fP "\fIregex\fP" ...
+Same as above, except that the expression matching is case insensitive.
+.TP
.B color \fIfgcolor\fP,\fIbgcolor\fP start="\fIsr\fP" end="\fIer\fP"
Display expressions which start with \fIsr\fP and end with \fIer\fP
with foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
highlighting to span multiple lines. Note that all subsequent instances
of \fIsr\fP after an initial \fIsr\fP is found will be highlighted until
the first instance of \fIer\fP.
+.TP
+.B icolor \fIfgcolor\fP,\fIbgcolor\fP start="\fIsr\fP" end="\fIer\fP"
+Same as above, except that the expression matching is case insensitive.
.SH FILES
.TP
# set whitespace " "
## Color setup
+##
## Format:
+##
## syntax "short description" ["filename regex" ...]
+##
## color foreground,background "regex" ["regex"...]
+## or
+## icolor foreground,background "regex" ["regex"...]
+##
+## "color" will do case sensitive matches, while "icolor" will do case
+## insensitive matches.
##
## Legal colors: white, black, red, blue, green, yellow, magenta, cyan.
## You may use the prefix "bright" to mean a stronger color highlight
# color brightgreen "\.(data|subsection|text)"
# color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
# color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
-# color brightred "^[[:space:]]*[._A-Za-z0-9]*:"
+# icolor brightred "^[[:space:]]*[._A-Z0-9]*:"
# color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
## Highlight strings (note: VERY resource intensive)
# color brightyellow "<[^= ]*>" ""(\\.|[^\"])*""
##
# syntax "nanorc" "(\.|/|)nanorc$"
## highlight possible errors and parameters
-# color brightwhite "^[[:space:]]*(set|unset|syntax|color).*$"
+# icolor brightwhite "^[[:space:]]*(set|unset|syntax|i?color).*$"
## set, unset and syntax
-# color cyan "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|brackets|casesensitive|const|cut|fill|historylog|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|punct|quickblank|quotestr|rebinddelete)\>" "^[[:space:]]*(set|unset)[[:space:]]+(regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace)\>"
-# color green "^[[:space:]]*(set|unset|syntax)\>"
+# icolor cyan "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|brackets|casesensitive|const|cut|fill|historylog|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|punct|quickblank|quotestr|rebinddelete)\>" "^[[:space:]]*(set|unset)[[:space:]]+(regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace)\>"
+# icolor green "^[[:space:]]*(set|unset|syntax)\>"
## colors
-# color yellow "^[[:space:]]*color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
-# color magenta "^[[:space:]]*color\>" "\<(start|end)="
+# icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
+# icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
## strings
-# color white "\"(\\.|[^\"])*\""
+# icolor white "\"(\\.|[^\"])*\""
## comments
-# color blue "[[:space:]]*#.*$"
+# icolor blue "[[:space:]]*#.*$"
char *parse_next_regex(char *ptr);
bool nregcomp(regex_t *preg, const char *regex, int eflags);
void parse_syntax(char *ptr);
-void parse_colors(char *ptr);
+void parse_colors(char *ptr, bool icase);
#endif /* ENABLE_COLOR */
void parse_rcfile(FILE *rcstream);
void do_rcfile(void);
}
}
-/* Parse the color stuff into the colorstrings array. */
-void parse_colors(char *ptr)
+/* Parse the color stuff into the colorstrings array. If icase is TRUE,
+ * treat the color stuff as case insensitive. */
+void parse_colors(char *ptr, bool icase)
{
int fg, bg;
bool bright = FALSE, no_fgcolor = FALSE;
if (ptr == NULL)
break;
- if (nregcomp(&newcolor->start, fgstr, 0)) {
+ if (nregcomp(&newcolor->start, fgstr, icase ? REG_ICASE : 0)) {
free(newcolor);
cancelled = TRUE;
} else {
continue;
newcolor->end = (regex_t *)nmalloc(sizeof(regex_t));
- if (nregcomp(newcolor->end, fgstr, 0)) {
+ if (nregcomp(newcolor->end, fgstr, icase ? REG_ICASE : 0)) {
free(newcolor->end);
newcolor->end = NULL;
}
else if (strcasecmp(keyword, "syntax") == 0)
parse_syntax(ptr);
else if (strcasecmp(keyword, "color") == 0)
- parse_colors(ptr);
+ parse_colors(ptr, FALSE);
+ else if (strcasecmp(keyword, "icolor") == 0)
+ parse_colors(ptr, TRUE);
#endif /* ENABLE_COLOR */
else
rcfile_error(N_("Command %s not understood"), keyword);