From 71f0765cd9160f10aed6ef269847458055790abe Mon Sep 17 00:00:00 2001 From: Casey Langen Date: Fri, 1 Jul 2016 18:54:26 -0700 Subject: [PATCH] Fixed Terminal.app support. --- src/musikbox/cursespp/Colors.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/musikbox/cursespp/Colors.cpp b/src/musikbox/cursespp/Colors.cpp index 4137f7da1..ac992bdd9 100755 --- a/src/musikbox/cursespp/Colors.cpp +++ b/src/musikbox/cursespp/Colors.cpp @@ -65,6 +65,21 @@ static int initColor(int id, int r, int g, int b) { return id; } +/* some terminals report custom colors are supported, and also +don't error when calling init_color(), but don't actually work. */ +static bool customColorsSupported() { + if (COLORS <= 8) { + return false; + } + +#ifdef WIN32 + return true; +#else + std::string term = std::string(std::getenv("TERM_PROGRAM")); + return term != "Apple_Terminal"; +#endif +} + Colors::Colors() { } @@ -75,7 +90,7 @@ void Colors::Init() { /* the default colors are a bit harsh for my taste, so let's use custom colors if the terminal supports it. in the future we'll allow users to configure this via setting */ - if (COLORS > 8) { + if (customColorsSupported()) { red = initColor(COLOR_CUSTOM_RED, 220, 82, 86); green = initColor(COLOR_CUSTOM_GREEN, 166, 226, 46); yellow = initColor(COLOR_CUSTOM_YELLOW, 230, 220, 116);