mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-22 12:51:23 +03:00
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 (ported from Brand Huntsman's old patch) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2774 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
a899ab185f
commit
23555f29ba
@ -114,6 +114,11 @@ CVS code -
|
||||
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
|
||||
|
@ -6,7 +6,7 @@
|
||||
.\" 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
|
||||
@ -28,8 +28,8 @@ During startup, \fBnano\fP will first read its system-wide settings from
|
||||
.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
|
||||
@ -170,8 +170,8 @@ spaces. They must be single-column characters.
|
||||
.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
|
||||
@ -183,6 +183,9 @@ stronger color highlight for the foreground. If your terminal supports
|
||||
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,
|
||||
@ -190,6 +193,9 @@ at least one of which must be specified. This allows syntax
|
||||
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
|
||||
|
@ -142,9 +142,17 @@
|
||||
# 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
|
||||
@ -280,7 +288,7 @@
|
||||
# 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 "<[^= ]*>" ""(\\.|[^\"])*""
|
||||
@ -293,14 +301,14 @@
|
||||
##
|
||||
# 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:]]*#.*$"
|
||||
|
@ -492,7 +492,7 @@ int color_to_int(const char *colorname, bool *bright);
|
||||
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);
|
||||
|
13
src/rcfile.c
13
src/rcfile.c
@ -341,8 +341,9 @@ void parse_syntax(char *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
@ -429,7 +430,7 @@ void parse_colors(char *ptr)
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
|
||||
if (nregcomp(&newcolor->start, fgstr, 0)) {
|
||||
if (nregcomp(&newcolor->start, fgstr, icase ? REG_ICASE : 0)) {
|
||||
free(newcolor);
|
||||
cancelled = TRUE;
|
||||
} else {
|
||||
@ -479,7 +480,7 @@ void parse_colors(char *ptr)
|
||||
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;
|
||||
}
|
||||
@ -525,7 +526,9 @@ void parse_rcfile(FILE *rcstream)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user