Using a couple less #ifdefs, to mimic how this is done in set_colorpairs().
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5495 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
a77efae609
commit
8295a88ff0
|
@ -1,3 +1,6 @@
|
||||||
|
2015-12-18 Benno Schulenberg <bensberg@justemail.net>
|
||||||
|
* src/color.c (color_init): Use less #ifdefs.
|
||||||
|
|
||||||
2015-12-11 Benno Schulenberg <bensberg@justemail.net>
|
2015-12-11 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* doc/syntax/Makefile.am: Add missing autoconf and nftables syntaxes.
|
* doc/syntax/Makefile.am: Add missing autoconf and nftables syntaxes.
|
||||||
* ChangeLog: Correct a bug number, plus a few other tweaks.
|
* ChangeLog: Correct a bug number, plus a few other tweaks.
|
||||||
|
|
37
src/color.c
37
src/color.c
|
@ -101,40 +101,39 @@ void set_colorpairs(void)
|
||||||
/* Initialize the color information. */
|
/* Initialize the color information. */
|
||||||
void color_init(void)
|
void color_init(void)
|
||||||
{
|
{
|
||||||
|
colortype *tmpcolor = openfile->colorstrings;
|
||||||
|
bool using_defaults = FALSE;
|
||||||
|
short foreground, background;
|
||||||
|
|
||||||
assert(openfile != NULL);
|
assert(openfile != NULL);
|
||||||
|
|
||||||
if (has_colors()) {
|
/* If the terminal is not capable of colors, forget it. */
|
||||||
const colortype *tmpcolor;
|
if (!has_colors())
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef HAVE_USE_DEFAULT_COLORS
|
#ifdef HAVE_USE_DEFAULT_COLORS
|
||||||
/* Use the default colors, if available. */
|
/* Allow using the default colors, if available. */
|
||||||
bool defok = (use_default_colors() != ERR);
|
using_defaults = (use_default_colors() != ERR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
|
for (; tmpcolor != NULL;
|
||||||
tmpcolor = tmpcolor->next) {
|
tmpcolor = tmpcolor->next) {
|
||||||
short foreground = tmpcolor->fg, background = tmpcolor->bg;
|
foreground = tmpcolor->fg;
|
||||||
if (foreground == -1) {
|
background = tmpcolor->bg;
|
||||||
#ifdef HAVE_USE_DEFAULT_COLORS
|
|
||||||
if (!defok)
|
|
||||||
#endif
|
|
||||||
foreground = COLOR_WHITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (background == -1) {
|
if (foreground == -1 && !using_defaults)
|
||||||
#ifdef HAVE_USE_DEFAULT_COLORS
|
foreground = COLOR_WHITE;
|
||||||
if (!defok)
|
|
||||||
#endif
|
if (background == -1 && !using_defaults)
|
||||||
background = COLOR_BLACK;
|
background = COLOR_BLACK;
|
||||||
}
|
|
||||||
|
|
||||||
init_pair(tmpcolor->pairnum, foreground, background);
|
init_pair(tmpcolor->pairnum, foreground, background);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "init_pair(): fg = %hd, bg = %hd\n", tmpcolor->fg, tmpcolor->bg);
|
fprintf(stderr, "init_pair(): fg = %hd, bg = %hd\n", foreground, background);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean up a regex we previously compiled. */
|
/* Clean up a regex we previously compiled. */
|
||||||
void nfreeregex(regex_t **r)
|
void nfreeregex(regex_t **r)
|
||||||
|
|
Loading…
Reference in New Issue