Global flag -Y, --syntax to specify the type on the command line, if there's no good filename regex to use. Global variable syntaxstr. Made some errors in the rc file less fatal
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1199 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
9189c1f258
commit
09900ff808
|
@ -21,7 +21,9 @@ CVS code -
|
||||||
- Added "syntax" command to .nanorc file, to allow multiple
|
- Added "syntax" command to .nanorc file, to allow multiple
|
||||||
syntaxes. New function color.c:update_color(), calls in various
|
syntaxes. New function color.c:update_color(), calls in various
|
||||||
files.c places, syntaxtype struct, global variables syntaxes,
|
files.c places, syntaxtype struct, global variables syntaxes,
|
||||||
syntaxfile_regexp and synfilematches.
|
syntaxfile_regexp and synfilematches. Global flag 'Y', "--syntax"
|
||||||
|
to specify the type on the command line, if there's no good
|
||||||
|
filename regex to use. Global variable syntaxstr.
|
||||||
- configure.ac:
|
- configure.ac:
|
||||||
- Define NDEBUG to silence asserts (David Benbennick).
|
- Define NDEBUG to silence asserts (David Benbennick).
|
||||||
- files.c:
|
- files.c:
|
||||||
|
|
9
color.c
9
color.c
|
@ -193,6 +193,15 @@ void update_color(void)
|
||||||
colorstrings = tmpsyntax->color;
|
colorstrings = tmpsyntax->color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if we haven't found a match, use the override string */
|
||||||
|
if (colorstrings == NULL && syntaxstr != NULL) {
|
||||||
|
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||||
|
tmpsyntax = tmpsyntax->next) {
|
||||||
|
if (!strcasecmp(tmpsyntax->desc, syntaxstr))
|
||||||
|
colorstrings = tmpsyntax->color;
|
||||||
|
}
|
||||||
|
}
|
||||||
do_colorinit();
|
do_colorinit();
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
}
|
}
|
||||||
|
|
1
global.c
1
global.c
|
@ -111,6 +111,7 @@ shortcut *browser_list = NULL;
|
||||||
colorstruct colors[NUM_NCOLORS];
|
colorstruct colors[NUM_NCOLORS];
|
||||||
colortype *colorstrings = NULL;
|
colortype *colorstrings = NULL;
|
||||||
syntaxtype *syntaxes = NULL;
|
syntaxtype *syntaxes = NULL;
|
||||||
|
char *syntaxstr = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined (DISABLE_HELP)
|
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined (DISABLE_HELP)
|
||||||
|
|
3
nano.1
3
nano.1
|
@ -65,6 +65,9 @@ Set the size (width) of a tab.
|
||||||
.B \-V (\-\-version)
|
.B \-V (\-\-version)
|
||||||
Show the current version number and author.
|
Show the current version number and author.
|
||||||
.TP
|
.TP
|
||||||
|
.B \-Y (\-\-syntax=[str])
|
||||||
|
Specify a specific syntax hilighting from the .nanorc to use (if available).
|
||||||
|
.TP
|
||||||
.B \-c (\-\-const)
|
.B \-c (\-\-const)
|
||||||
Constantly show the cursor position.
|
Constantly show the cursor position.
|
||||||
.TP
|
.TP
|
||||||
|
|
16
nano.c
16
nano.c
|
@ -510,11 +510,15 @@ void usage(void)
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
print1opt(_("-Q [str]"), _("--quotestr [str]"), _("Quoting string, default \"> \""));
|
print1opt(_("-Q [str]"), _("--quotestr [str]"), _("Quoting string, default \"> \""));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
print1opt("-S", "--smooth", _("Smooth scrolling"));
|
print1opt("-S", "--smooth", _("Smooth scrolling"));
|
||||||
#endif
|
#endif
|
||||||
print1opt(_("-T [num]"), _("--tabsize=[num]"), _("Set width of a tab to num"));
|
print1opt(_("-T [num]"), _("--tabsize=[num]"), _("Set width of a tab to num"));
|
||||||
print1opt("-V", "--version", _("Print version information and exit"));
|
print1opt("-V", "--version", _("Print version information and exit"));
|
||||||
|
#ifdef ENABLE_COLOR
|
||||||
|
print1opt(_("-Y [str]"), _("--syntax [str]"), _("Syntax definition to use"));
|
||||||
|
#endif
|
||||||
print1opt("-c", "--const", _("Constantly show cursor position"));
|
print1opt("-c", "--const", _("Constantly show cursor position"));
|
||||||
print1opt("-h", "--help", _("Show this message"));
|
print1opt("-h", "--help", _("Show this message"));
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
@ -2836,6 +2840,9 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
{"smooth", 0, 0, 'S'},
|
{"smooth", 0, 0, 'S'},
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_COLOR
|
||||||
|
{"syntax", 1, 0, 'Y'},
|
||||||
#endif
|
#endif
|
||||||
{"keypad", 0, 0, 'K'},
|
{"keypad", 0, 0, 'K'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
|
@ -2858,11 +2865,11 @@ int main(int argc, char *argv[])
|
||||||
#endif /* ENABLE_NANORC */
|
#endif /* ENABLE_NANORC */
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
while ((optchr = getopt_long(argc, argv, "h?DFKMNQ:RST:Vabcefgijklmo:pr:s:tvwxz",
|
while ((optchr = getopt_long(argc, argv, "h?DFKMNQ:RST:VY:abcefgijklmo:pr:s:tvwxz",
|
||||||
long_options, &option_index)) != EOF) {
|
long_options, &option_index)) != EOF) {
|
||||||
#else
|
#else
|
||||||
while ((optchr =
|
while ((optchr =
|
||||||
getopt(argc, argv, "h?DFKMNQ:RST:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
|
getopt(argc, argv, "h?DFKMNQ:RST:VY:abcefgijklmo:pr:s:tvwxz")) != EOF) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (optchr) {
|
switch (optchr) {
|
||||||
|
@ -2916,6 +2923,11 @@ int main(int argc, char *argv[])
|
||||||
case 'V':
|
case 'V':
|
||||||
version();
|
version();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
#ifdef ENABLE_COLOR
|
||||||
|
case 'Y':
|
||||||
|
syntaxstr = mallocstrcpy(syntaxstr, optarg);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'e':
|
case 'e':
|
||||||
|
|
1
proto.h
1
proto.h
|
@ -67,6 +67,7 @@ extern openfilestruct *open_files;
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
extern colortype *colorstrings;
|
extern colortype *colorstrings;
|
||||||
extern syntaxtype *syntaxes;
|
extern syntaxtype *syntaxes;
|
||||||
|
extern char *syntaxstr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern shortcut *shortcut_list;
|
extern shortcut *shortcut_list;
|
||||||
|
|
8
rcfile.c
8
rcfile.c
|
@ -197,7 +197,7 @@ void parse_syntax(FILE * rcstream, char *buf, char *ptr)
|
||||||
|
|
||||||
if (*ptr != '"') {
|
if (*ptr != '"') {
|
||||||
rcfile_error(_("regex strings must begin and end with a \" character\n"));
|
rcfile_error(_("regex strings must begin and end with a \" character\n"));
|
||||||
exit(1);
|
return;
|
||||||
}
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ void parse_syntax(FILE * rcstream, char *buf, char *ptr)
|
||||||
|
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
rcfile_error(_("Missing syntax name"));
|
rcfile_error(_("Missing syntax name"));
|
||||||
exit(1);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (syntaxes == NULL) {
|
if (syntaxes == NULL) {
|
||||||
|
@ -284,7 +284,7 @@ void parse_colors(FILE * rcstream, char *buf, char *ptr)
|
||||||
|
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
rcfile_error(_("Missing color name"));
|
rcfile_error(_("Missing color name"));
|
||||||
exit(1);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(fgstr, ",")) {
|
if (strstr(fgstr, ",")) {
|
||||||
|
@ -298,7 +298,7 @@ void parse_colors(FILE * rcstream, char *buf, char *ptr)
|
||||||
|
|
||||||
if (syntaxes == NULL) {
|
if (syntaxes == NULL) {
|
||||||
rcfile_error(_("Cannot add a color directive without a syntax line"));
|
rcfile_error(_("Cannot add a color directive without a syntax line"));
|
||||||
exit(1);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tmpsyntax = syntaxes; tmpsyntax->next != NULL;
|
for (tmpsyntax = syntaxes; tmpsyntax->next != NULL;
|
||||||
|
|
Loading…
Reference in New Issue