--- a/sources/interface.cpp Mon Dec 15 03:09:26 2014 +0200 +++ b/sources/interface.cpp Mon Dec 15 04:01:58 2014 +0200 @@ -60,6 +60,32 @@ static IPAddress g_address; static String g_statusBarText; +static const struct { Color color; bool bold; } g_colorCodes['v' - 'a' + 1] = +{ + { RED, true }, // a - brick + { YELLOW, true }, // b - tan + { WHITE, false }, // c - gray + { GREEN, true }, // d - light green + { YELLOW, false }, // e - brown + { YELLOW, true }, // f - gold yellow + { RED, true }, // g - bright red + { BLUE, false }, // h - dark blue + { YELLOW, false }, // i - orange + { WHITE, true }, // j - white + { YELLOW, true }, // k - fire yellow + { DEFAULT, false }, // l - untranslated + { BLACK, false }, // m - black + { BLUE, true }, // n - light blue + { YELLOW, true }, // o - cream + { GREEN, true }, // p - olive green + { GREEN, false }, // q - dark green + { RED, false }, // r - dark red + { YELLOW, false }, // s - dark brown + { MAGENTA, false }, // t - purple + { BLACK, true }, // u - dark gray + { CYAN, true }, // v - cyan +}; + // ------------------------------------------------------------------------------------------------- // static FUNCTION @@ -262,7 +288,49 @@ for (int i = start; i < end; ++i) { mvhline (y, 0, ' ', COLS); - mvprintw (y++, 0, "%s", g_output[i].chars()); + int activeColor = -1; + bool boldActive = false; + int x = 0; + + for (int j = 0; j < g_output[i].length(); ++j) + { + char ch = g_output[i][j]; + + if (ch == '\x1C' and j + 1 < g_output[i].length()) + { + if (activeColor != -1) + attroff (activeColor); + + if (boldActive) + attroff (A_BOLD); + + char colorChar = g_output[i][j + 1]; + + if (colorChar >= 'a' and colorChar <= 'v' and colorChar != 'l') + { + auto colorInfo = g_colorCodes[colorChar - 'a']; + activeColor = interface_color_pair (colorInfo.color, DEFAULT); + boldActive = colorInfo.bold; + attron (activeColor); + + if (boldActive) + attron (A_BOLD); + } + + j++; + continue; + } + + mvaddch (y, x++, g_output[i][j]); + } + + if (activeColor != -1) + attroff (activeColor); + + if (boldActive) + attroff (A_BOLD); + + ++y; } g_needRefresh = true; @@ -614,8 +682,12 @@ // ------------------------------------------------------------------------------------------------- // -FUNCTION print_to_console (const String& a) -> void +FUNCTION print_to_console (String a) -> void { + // Zandronum is retarded and SOMETIMES sends color codes as "\\c" and sometimes as "\x1C". + // Let's correct that on our end and HOPE this won't cause conflicts. + a.replace ("\\c", "\x1C"); + for (char ch : a) { if (ch == '\n')