* src/rcfile.c (check_vitals_mapped): Do not allow 'set quiet'
to suppress a fatal-error message, make sure the user sees it.
* src/color.c: Comment tweaks.
+ * src/{*.h,*.c}, configure.ac:Convert all occurrences of
+ #ifdef ENABLE_COLOR to #ifndef DISABLE_COLOR.⏎
2014-04-03 Benno Schulenberg <bensberg@justemail.net>
* configure.ac: Remove unused '*_support' variables.
if test "x$enable_color" = xyes; then
AC_MSG_ERROR([--enable-color cannot work with --disable-nanorc])
else
+ # Disabling nanorc silently disables color support.
enable_color=no
fi
fi
-if test "x$enable_color" != xno; then
- if test x$ac_cv_header_regex_h = xyes; then
- enable_nanorc=yes
- AC_DEFINE(ENABLE_COLOR, 1, [Define this to have syntax highlighting, requires regex.h and ENABLE_NANORC too!])
- color_support=yes
- elif test "x$enable_color" = xyes; then
+if test "x$enable_color" = xno; then
+ AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
+else
+ if test x$ac_cv_header_regex_h != xyes; then
AC_MSG_ERROR([
-*** The header file regex.h was not found. If you wish to use color
-*** support this header file is required. Please either install C
-*** libraries that include the regex.h file or call the configure
-*** script with --disable-color.])
+*** The header file regex.h was not found. If you wish to have
+*** color support, this header file is required. Please either
+*** install C libraries that include the regex.h file, or call
+*** the configure script with --disable-color.])
+ else
+ color_support=yes
fi
fi
#include <magic.h>
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* For each syntax list entry, go through the list of colors and assign
* the color pairs. */
reset_multis_for_id(fileptr, tmpcolor->id);
}
}
-#endif /* ENABLE_COLOR */
+
+#endif /* !DISABLE_COLOR */
/* Update the screen. */
edit_refresh_needed = TRUE;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
reset_multis(openfile->current, FALSE);
#endif
/* Update the screen. */
edit_refresh_needed = TRUE;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
reset_multis(openfile->current, FALSE);
#endif
openfile->current_undo = NULL;
openfile->lock_filename = NULL;
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
openfile->colorstrings = NULL;
#endif
}
openfile->edittop = openfile->fileage;
openfile->current = openfile->fileage;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
openfile->fileage->multidata = NULL;
#endif
openfile->placewewant = 0;
}
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* If we're loading into a new buffer, update the colors to account
* for it, if applicable. */
if (new_buffer)
/* Update the titlebar, since the filename may have changed. */
titlebar(NULL);
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* Make sure we're using the buffer's associated colors, if
* applicable. */
color_init();
fileptr->data[buf_len - 1] = '\0';
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
fileptr->multidata = NULL;
#endif
if (!nonamechange) {
openfile->filename = mallocstrcpy(openfile->filename,
realname);
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* We might have changed the filename, so update the colors
* to account for it, and then make sure we're using
* them. */
/* The command to use for the alternate spell checker. */
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
syntaxtype *syntaxes = NULL;
/* The global list of color syntaxes. */
char *syntaxstr = NULL;
#ifndef DISABLE_SPELLER
const char *spell_msg = N_("To Spell");
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
const char *lint_msg = N_("To Linter");
const char *prev_lint_msg = N_("Prev Lint Msg");
const char *next_lint_msg = N_("Next Lint Msg");
const char *nano_backfile_msg = N_("Go to the previous file in the list");
const char *nano_gotodir_msg = N_("Go to directory");
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
const char *nano_lint_msg = N_("Invoke the linter, if available");
const char *nano_prevlint_msg = N_("Go to previous linter msg");
const char *nano_nextlint_msg = N_("Go to next linter msg");
add_to_funcs(do_page_down, MMAIN|MHELP|MBROWSER,
next_page_msg, IFSCHELP(nano_nextpage_msg), TRUE, VIEW);
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
add_to_funcs(do_page_up, MLINTER,
prev_lint_msg, IFSCHELP(nano_prevlint_msg), FALSE, VIEW);
add_to_funcs(do_page_down, MLINTER,
TRUE, NOVIEW);
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
add_to_funcs(do_linter, MMAIN, lint_msg, IFSCHELP(nano_lint_msg),
TRUE, NOVIEW);
#endif
#endif
}
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
void set_lint_shortcuts(void)
{
#ifndef DISABLE_SPELLER
/* Free the memory associated with each open file buffer. */
if (openfile != NULL)
free_openfilestruct(openfile);
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
if (syntaxstr != NULL)
free(syntaxstr);
while (syntaxes != NULL) {
syntaxes = syntaxes->next;
free(bill);
}
-#endif /* ENABLE_COLOR */
+#endif /* !DISABLE_COLOR */
#ifndef NANO_TINY
/* Free the search and replace history lists. */
if (searchage != NULL)
newnode->next = NULL;
newnode->lineno = (prevnode != NULL) ? prevnode->lineno + 1 : 1;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
newnode->multidata = NULL;
#endif
dst->next = src->next;
dst->prev = src->prev;
dst->lineno = src->lineno;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
dst->multidata = NULL;
#endif
if (fileptr->data != NULL)
free(fileptr->data);
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
if (fileptr->multidata)
free(fileptr->multidata);
#endif
openfile->fileage->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
openfile->fileage->multidata = NULL;
#endif
print_opt("-W", "--wordbounds",
N_("Detect word boundaries more accurately"));
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
print_opt(_("-Y <str>"), _("--syntax=<str>"),
N_("Syntax definition to use for coloring"));
#endif
#ifdef DISABLE_ROOTWRAPPING
printf(" --disable-wrapping-as-root");
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
printf(" --enable-color");
#endif
#ifdef DEBUG
edit_refresh();
break;
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
case NO_COLOR_SYNTAX:
edit_refresh();
break;
#ifndef DISABLE_WRAPPING
|| flag == NO_WRAP
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
|| flag == NO_COLOR_SYNTAX
#endif
)
{
#endif
s->scfunc();
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
if (f && !f->viewok && openfile->syntax != NULL
&& openfile->syntax->nmultis > 0) {
reset_multis(openfile->current, FALSE);
}
#endif /* !DISABLE_MOUSE */
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
void alloc_multidata_if_needed(filestruct *fileptr)
{
if (!fileptr->multidata)
precalc_cleanup:
nodelay(edit, FALSE);
}
-#endif /* ENABLE_COLOR */
+#endif /* !DISABLE_COLOR */
/* The user typed output_len multibyte characters. Add them to the edit
* buffer, filtering out all ASCII control characters if allow_cntrls is
edit_refresh_needed = TRUE;
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* If color syntaxes are available and turned on, we need to
* call edit_refresh(). */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
openfile->placewewant = xplustabs();
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
reset_multis(openfile->current, FALSE);
#endif
if (edit_refresh_needed == TRUE) {
{"restricted", 0, NULL, 'R'},
{"tabsize", 1, NULL, 'T'},
{"version", 0, NULL, 'V'},
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
{"syntax", 1, NULL, 'Y'},
#endif
{"const", 0, NULL, 'c'},
SET(WORD_BOUNDS);
break;
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
case 'Y':
syntaxstr = mallocstrcpy(syntaxstr, optarg);
break;
fprintf(stderr, "Main: top and bottom win\n");
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
if (openfile->syntax)
if (openfile->syntax->nmultis > 0)
precalc_multicolorinfo();
ADD, DEL, REPLACE, SPLIT, UNSPLIT, CUT, UNCUT, ENTER, INSERT, OTHER
} undo_type;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
typedef struct colortype {
short fg;
/* This syntax's foreground color. */
#define CWTF (1<<6)
/* Something else */
-#endif /* ENABLE_COLOR */
+#endif /* !DISABLE_COLOR */
/* Structure types. */
/* Next node. */
struct filestruct *prev;
/* Previous node. */
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
short *multidata; /* Array of which multi-line regexes apply to this line */
#endif
} filestruct;
const char *lock_filename;
/* The path of the lockfile, if we created one */
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
syntaxtype *syntax;
/* The syntax struct for this file, if any */
colortype *colorstrings;
extern sc *sclist;
extern subnfunc *allfuncs;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
extern syntaxtype *syntaxes;
extern char *syntaxstr;
#endif
#endif
/* All functions in color.c. */
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
void set_colorpairs(void);
void color_init(void);
void color_update(void);
void save_poshistory(void);
int check_poshistory(const char *file, ssize_t *line, ssize_t *column);
#endif
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
void do_linter(void);
void set_lint_shortcuts(void);
void set_spell_shortcuts(void);
void rcfile_error(const char *msg, ...);
char *parse_next_word(char *ptr);
char *parse_argument(char *ptr);
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
char *parse_next_regex(char *ptr);
bool nregcomp(const char *regex, int eflags);
void parse_syntax(char *ptr);
void alloc_multidata_if_needed(filestruct *fileptr);
#endif
void parse_rcfile(FILE *rcstream
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
, bool syntax_only
#endif
);
/* If we did, the line number where the last error occurred. */
static char *nanorc = NULL;
/* The path to the rcfile we're parsing. */
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
static syntaxtype *endsyntax = NULL;
/* The end of the list of syntaxes. */
static exttype *endheader = NULL;
/* End of header list */
static colortype *endcolor = NULL;
/* The end of the color list for the current syntax. */
-
#endif
/* We have an error in some part of the rcfile. Print the error message
return ptr;
}
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* Parse the next regex string from the line at ptr, and return it. */
char *parse_next_regex(char *ptr)
{
} else
free(newext);
}
-
}
}
#endif /* HAVE_LIBMAGIC */
}
-#endif /* ENABLE_COLOR */
+#endif /* !DISABLE_COLOR */
int check_bad_binding(sc *s)
}
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* Read and parse additional syntax files. */
static void _parse_include(char *file)
{
#endif
parse_rcfile(rcstream
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
, TRUE
#endif
);
endheader = newheader;
} else
free(newheader);
-
}
}
else
endsyntax->linter = mallocstrcpy(syntaxes->linter, ptr);
}
-#endif /* ENABLE_COLOR */
-
+#endif /* !DISABLE_COLOR */
/* Check whether the user has unmapped every shortcut for a
-sequence we consider 'vital', like the exit function */
+ * sequence we consider 'vital', like the exit function. */
static void check_vitals_mapped(void)
{
subnfunc *f;
* and close it afterwards. If syntax_only is TRUE, only allow the file
* to contain color syntax commands: syntax, color, and icolor. */
void parse_rcfile(FILE *rcstream
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
, bool syntax_only
#endif
)
char *buf = NULL;
ssize_t len;
size_t n = 0;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
syntaxtype *end_syn_save = NULL;
#endif
ptr = parse_next_word(ptr);
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* Handle extending first... */
if (strcasecmp(keyword, "extendsyntax") == 0) {
char *syntaxname = ptr;
/* Try to parse the keyword. */
if (strcasecmp(keyword, "set") == 0) {
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
if (syntax_only)
rcfile_error(
N_("Command \"%s\" not allowed in included file"),
#endif
set = 1;
} else if (strcasecmp(keyword, "unset") == 0) {
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
if (syntax_only)
rcfile_error(
N_("Command \"%s\" not allowed in included file"),
#endif
set = -1;
}
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
else if (strcasecmp(keyword, "include") == 0) {
if (syntax_only)
rcfile_error(
parse_colors(ptr, TRUE);
else if (strcasecmp(keyword, "linter") == 0)
parse_linter(ptr);
-#endif /* ENABLE_COLOR */
+#endif /* !DISABLE_COLOR */
else if (strcasecmp(keyword, "bind") == 0)
parse_keybinding(ptr);
else if (strcasecmp(keyword, "unbind") == 0)
else
rcfile_error(N_("Command \"%s\" not understood"), keyword);
-#ifdef ENABLE_COLOR
- /* If we temporarily reset emdsyntax to allow extending, reset
- the value here */
+#ifndef DISABLE_COLOR
+ /* If we temporarily reset endsyntax to allow extending,
+ * restore the value here. */
if (end_syn_save != NULL) {
endsyntax = end_syn_save;
end_syn_save = NULL;
rcfile_error(N_("Unknown flag \"%s\""), option);
}
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
if (endsyntax != NULL && endcolor == NULL)
rcfile_error(N_("Syntax \"%s\" has no color commands"),
endsyntax->desc);
rcstream = fopen(nanorc, "rb");
if (rcstream != NULL)
parse_rcfile(rcstream
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
, FALSE
#endif
);
strerror(errno));
} else
parse_rcfile(rcstream
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
, FALSE
#endif
);
;
}
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
set_colorpairs();
#endif
}
filepart = partition_filestruct(top, top_x, bot, bot_x);
openfile->edittop = openfile->fileage;
openfile->mark_set = FALSE;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
reset_multis(openfile->current, TRUE);
#endif
edit_refresh();
free(openfile->current->data);
openfile->current->data = copy;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
reset_multis(openfile->current, TRUE);
#endif
edit_refresh();
if (!replaceall) {
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* If color syntaxes are available and turned on, we
* need to call edit_refresh(). */
if (openfile->colorstrings != NULL &&
}
#endif /* !DISABLE_SPELLER */
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* Run linter. Based on alt-speller code. Return NULL for normal
* termination, and the error string otherwise. */
void do_linter(void)
currmenu = MMAIN;
display_main_list();
}
-#endif /* ENABLE_COLOR */
+#endif /* !DISABLE_COLOR */
#ifndef NANO_TINY
/* Our own version of "wc". Note that its character counts are in
openfile->filebot->next->prev = openfile->filebot;
openfile->filebot->next->next = NULL;
openfile->filebot->next->lineno = openfile->filebot->lineno + 1;
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
openfile->filebot->next->multidata = NULL;
#endif
openfile->filebot = openfile->filebot->next;
void edit_draw(filestruct *fileptr, const char *converted, int
line, size_t start)
{
-#if !defined(NANO_TINY) || defined(ENABLE_COLOR)
+#if !defined(NANO_TINY) || !defined(DISABLE_COLOR)
size_t startpos = actual_x(fileptr->data, start);
/* The position in fileptr->data of the leftmost character
* that displays at least partially on the window. */
* just the text that needs it). */
mvwaddstr(edit, line, 0, converted);
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
/* If color syntaxes are available and turned on, we need to display
* them. */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) {
wattroff(edit, COLOR_PAIR(tmpcolor->pairnum));
}
}
-#endif /* ENABLE_COLOR */
+#endif /* !DISABLE_COLOR */
#ifndef NANO_TINY
/* If the mark is on, we need to display it. */
* portion of the window. */
void display_main_list(void)
{
-#ifdef ENABLE_COLOR
+#ifndef DISABLE_COLOR
if (openfile->syntax && openfile->syntax->linter)
set_lint_shortcuts();
else