sources/coloredline.cpp

changeset 63
0da5f358f298
parent 48
02009f1ec2b7
child 69
eb4c25284a19
equal deleted inserted replaced
62:44a2c0b2e7d7 63:0da5f358f298
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "coloredline.h" 31 #include "coloredline.h"
32 32
33 static const struct { Color color; bool bold; } g_colorCodes['v' - 'a' + 1] = 33 static const struct
34 { 34 {
35 { RED, true }, // a - brick 35 const char* name;
36 { YELLOW, true }, // b - tan 36 Color color;
37 { WHITE, false }, // c - gray 37 bool bold;
38 { GREEN, true }, // d - light green 38 } g_colorCodes['v' - 'a' + 1] =
39 { YELLOW, false }, // e - brown 39 {
40 { YELLOW, true }, // f - gold yellow 40 { "Brick", RED, true }, // a
41 { RED, true }, // g - bright red 41 { "Tan", YELLOW, true }, // b
42 { BLUE, false }, // h - dark blue 42 { "Gray", WHITE, false }, // c
43 { YELLOW, false }, // i - orange 43 { "Green", GREEN, true }, // d
44 { WHITE, true }, // j - white 44 { "Brown", YELLOW, false }, // e
45 { YELLOW, true }, // k - fire yellow 45 { "Gold", YELLOW, true }, // f
46 { DEFAULT, false }, // l - untranslated 46 { "Red", RED, true }, // g
47 { BLACK, false }, // m - black 47 { "Blue", BLUE, false }, // h
48 { BLUE, true }, // n - light blue 48 { "Orange", YELLOW, false }, // i
49 { YELLOW, true }, // o - cream 49 { "White", WHITE, true }, // j
50 { GREEN, true }, // p - olive green 50 { "Yellow", YELLOW, true }, // k
51 { GREEN, false }, // q - dark green 51 { "Untranslated", DEFAULT, false }, // l
52 { RED, false }, // r - dark red 52 { "Black", BLACK, false }, // m
53 { YELLOW, false }, // s - dark brown 53 { "Blue", BLUE, true }, // n
54 { MAGENTA, false }, // t - purple 54 { "Cream", YELLOW, true }, // o
55 { BLACK, true }, // u - dark gray 55 { "Olive", GREEN, true }, // p
56 { CYAN, true }, // v - cyan 56 { "Dark Green", GREEN, false }, // q
57 { "Dark Red", RED, false }, // r
58 { "Dark Brown", YELLOW, false }, // s
59 { "Purple", MAGENTA, false }, // t
60 { "Dark Gray", BLACK, true }, // u
61 { "Cyan", CYAN, true }, // v
57 }; 62 };
58 63
59 // ------------------------------------------------------------------------------------------------- 64 // -------------------------------------------------------------------------------------------------
60 // 65 //
61 METHOD 66 METHOD
62 ColoredLine::finalize() -> void 67 ColoredLine::finalize() -> void
63 { 68 {
64 if (m_activeColor != DEFAULT) 69 if (m_activeColor != DEFAULT)
65 this->set_color (m_activeColor, false); 70 set_color (m_activeColor, false);
66 71
67 if (m_boldActive) 72 if (m_boldActive)
68 m_data << RLINE_OFF_BOLD; 73 m_data << RLINE_OFF_BOLD;
69 74
70 m_final = true; 75 m_final = true;
85 } 90 }
86 91
87 if (m_colorCodeStage == 1) 92 if (m_colorCodeStage == 1)
88 { 93 {
89 if (m_activeColor != DEFAULT) 94 if (m_activeColor != DEFAULT)
90 this->set_color (m_activeColor, false); 95 set_color (m_activeColor, false);
91 96
92 if (m_boldActive) 97 if (m_boldActive)
93 m_data << RLINE_OFF_BOLD; 98 m_data << RLINE_OFF_BOLD;
99
100 // Chars may be in uppercase
101 if (ch >= 'A' and ch <= 'V')
102 ch += 'a' - 'A';
94 103
95 if (ch >= 'a' and ch <= 'v' and ch != 'l') 104 if (ch >= 'a' and ch <= 'v' and ch != 'l')
96 { 105 {
97 auto colorInfo = g_colorCodes[ch - 'a']; 106 auto colorInfo = g_colorCodes[ch - 'a'];
98 m_activeColor = colorInfo.color; 107 m_activeColor = colorInfo.color;
99 m_boldActive = colorInfo.bold; 108 m_boldActive = colorInfo.bold;
100 assert (m_activeColor < 8); 109 assert (m_activeColor < 8);
101 this->set_color (m_activeColor, true); 110 set_color (m_activeColor, true);
102 111
103 if (m_boldActive) 112 if (m_boldActive)
104 m_data << RLINE_ON_BOLD; 113 m_data << RLINE_ON_BOLD;
105 } 114 }
106 115

mercurial