Tue, 16 Dec 2014 03:59:52 +0200
- now supports upper-case color codes too
sources/coloredline.cpp | file | annotate | diff | comparison | revisions |
--- a/sources/coloredline.cpp Tue Dec 16 03:53:20 2014 +0200 +++ b/sources/coloredline.cpp Tue Dec 16 03:59:52 2014 +0200 @@ -30,30 +30,35 @@ #include "coloredline.h" -static const struct { Color color; bool bold; } g_colorCodes['v' - 'a' + 1] = +static const struct +{ + const char* name; + 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 + { "Brick", RED, true }, // a + { "Tan", YELLOW, true }, // b + { "Gray", WHITE, false }, // c + { "Green", GREEN, true }, // d + { "Brown", YELLOW, false }, // e + { "Gold", YELLOW, true }, // f + { "Red", RED, true }, // g + { "Blue", BLUE, false }, // h + { "Orange", YELLOW, false }, // i + { "White", WHITE, true }, // j + { "Yellow", YELLOW, true }, // k + { "Untranslated", DEFAULT, false }, // l + { "Black", BLACK, false }, // m + { "Blue", BLUE, true }, // n + { "Cream", YELLOW, true }, // o + { "Olive", GREEN, true }, // p + { "Dark Green", GREEN, false }, // q + { "Dark Red", RED, false }, // r + { "Dark Brown", YELLOW, false }, // s + { "Purple", MAGENTA, false }, // t + { "Dark Gray", BLACK, true }, // u + { "Cyan", CYAN, true }, // v }; // ------------------------------------------------------------------------------------------------- @@ -62,7 +67,7 @@ ColoredLine::finalize() -> void { if (m_activeColor != DEFAULT) - this->set_color (m_activeColor, false); + set_color (m_activeColor, false); if (m_boldActive) m_data << RLINE_OFF_BOLD; @@ -87,18 +92,22 @@ if (m_colorCodeStage == 1) { if (m_activeColor != DEFAULT) - this->set_color (m_activeColor, false); + set_color (m_activeColor, false); if (m_boldActive) m_data << RLINE_OFF_BOLD; + // Chars may be in uppercase + if (ch >= 'A' and ch <= 'V') + ch += 'a' - 'A'; + if (ch >= 'a' and ch <= 'v' and ch != 'l') { auto colorInfo = g_colorCodes[ch - 'a']; m_activeColor = colorInfo.color; m_boldActive = colorInfo.bold; assert (m_activeColor < 8); - this->set_color (m_activeColor, true); + set_color (m_activeColor, true); if (m_boldActive) m_data << RLINE_ON_BOLD;