diff --git a/src/console_output.cc b/src/console_output.cc index 43cb24a..4dae457 100644 --- a/src/console_output.cc +++ b/src/console_output.cc @@ -41,29 +41,20 @@ std::string console_output::get_code(const int attr) { if (attr & A_UNDERLINE) result += "4;"; - if (attr & COLOR_PAIR(COLOR_BLACK)) - result += "30;"; - - if (attr & COLOR_PAIR(COLOR_RED)) - result += "31;"; - - if (attr & COLOR_PAIR(COLOR_GREEN)) - result += "32;"; - - if (attr & COLOR_PAIR(COLOR_YELLOW)) - result += "33;"; - - if (attr & COLOR_PAIR(COLOR_BLUE)) - result += "34;"; - - if (attr & COLOR_PAIR(COLOR_MAGENTA)) - result += "35;"; - - if (attr & COLOR_PAIR(COLOR_CYAN)) - result += "36;"; - - if (attr & COLOR_PAIR(COLOR_WHITE)) + if ((attr & COLOR_PAIR(COLOR_WHITE)) == COLOR_PAIR(COLOR_WHITE)) result += "37;"; + else if ((attr & COLOR_PAIR(COLOR_CYAN)) == COLOR_PAIR(COLOR_CYAN)) + result += "36;"; + else if ((attr & COLOR_PAIR(COLOR_MAGENTA)) == COLOR_PAIR(COLOR_MAGENTA)) + result += "35;"; + else if ((attr & COLOR_PAIR(COLOR_BLUE)) == COLOR_PAIR(COLOR_BLUE)) + result += "34;"; + else if ((attr & COLOR_PAIR(COLOR_YELLOW)) == COLOR_PAIR(COLOR_YELLOW)) + result += "33;"; + else if ((attr & COLOR_PAIR(COLOR_RED)) == COLOR_PAIR(COLOR_RED)) + result += "31;"; + else if ((attr & COLOR_PAIR(COLOR_GREEN)) == COLOR_PAIR(COLOR_GREEN)) + result += "32;"; result[result.length() - 1] = 'm'; return result;