startup: initialize colors only when the terminal is capable of colors

This avoids trying to show colors on a vt100, for example.
master
Benno Schulenberg 2020-04-29 12:07:31 +02:00
parent d1e1438ca0
commit 5ca2fd887a
3 changed files with 16 additions and 16 deletions

View File

@ -110,10 +110,6 @@ void prepare_palette(void)
bool using_defaults = FALSE;
short foreground, background;
/* If the terminal is not capable of colors, forget it. */
if (!has_colors())
return;
#ifdef HAVE_USE_DEFAULT_COLORS
/* Allow using the default colors, if available. */
using_defaults = (use_default_colors() != ERR);

View File

@ -2254,17 +2254,21 @@ int main(int argc, char **argv)
started_curses = TRUE;
#ifdef ENABLE_COLOR
set_interface_colorpairs();
#else
interface_color_pair[TITLE_BAR] = hilite_attribute;
interface_color_pair[LINE_NUMBER] = hilite_attribute;
interface_color_pair[GUIDE_STRIPE] = A_REVERSE;
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
interface_color_pair[STATUS_BAR] = hilite_attribute;
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
interface_color_pair[KEY_COMBO] = hilite_attribute;
interface_color_pair[FUNCTION_TAG] = A_NORMAL;
/* On capable terminals, use colors, otherwise use just reverse or bold.*/
if (has_colors())
set_interface_colorpairs();
else
#endif
{
interface_color_pair[TITLE_BAR] = hilite_attribute;
interface_color_pair[LINE_NUMBER] = hilite_attribute;
interface_color_pair[GUIDE_STRIPE] = A_REVERSE;
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
interface_color_pair[STATUS_BAR] = hilite_attribute;
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
interface_color_pair[KEY_COMBO] = hilite_attribute;
interface_color_pair[FUNCTION_TAG] = A_NORMAL;
}
/* Set up the terminal state. */
terminal_init();

View File

@ -3258,8 +3258,8 @@ void edit_refresh(void)
int row = 0;
#ifdef ENABLE_COLOR
/* When needed, initialize the colors for the current syntax. */
if (!have_palette)
/* When needed and useful, initialize the colors for the current syntax. */
if (!have_palette && has_colors())
prepare_palette();
#endif