48 // ------------------------------------------------------------------------------------------------- |
48 // ------------------------------------------------------------------------------------------------- |
49 // |
49 // |
50 void ColoredLine::finalize() |
50 void ColoredLine::finalize() |
51 { |
51 { |
52 if (m_activeColor != DEFAULT) |
52 if (m_activeColor != DEFAULT) |
53 set_color(m_activeColor, false); |
53 setColor(m_activeColor, false); |
54 |
54 |
55 if (m_boldActive) |
55 if (m_boldActive) |
56 m_data << RLINE_OFF_BOLD; |
56 m_data << RLINE_OFF_BOLD; |
57 |
57 |
58 m_final = true; |
58 m_final = true; |
59 } |
59 } |
60 |
60 |
61 // ------------------------------------------------------------------------------------------------- |
61 // ------------------------------------------------------------------------------------------------- |
62 // |
62 // |
63 void ColoredLine::add_char(char ch) |
63 void ColoredLine::addChar(char ch) |
64 { |
64 { |
65 static const ColorCodeInfo colorCodes[] = |
65 static const ColorCodeInfo colorCodes[] = |
66 { |
66 { |
67 { "Brick", RED, true }, // a |
67 { "Brick", RED, true }, // a |
68 { "Tan", YELLOW, true }, // b |
68 { "Tan", YELLOW, true }, // b |
98 } |
98 } |
99 |
99 |
100 if (m_colorCodeStage == 1) |
100 if (m_colorCodeStage == 1) |
101 { |
101 { |
102 if (m_activeColor != DEFAULT) |
102 if (m_activeColor != DEFAULT) |
103 set_color(m_activeColor, false); |
103 setColor(m_activeColor, false); |
104 |
104 |
105 if (m_boldActive) |
105 if (m_boldActive) |
106 m_data << RLINE_OFF_BOLD; |
106 m_data << RLINE_OFF_BOLD; |
107 |
107 |
108 m_boldActive = false; |
108 m_boldActive = false; |
156 } |
156 } |
157 } |
157 } |
158 |
158 |
159 // ------------------------------------------------------------------------------------------------- |
159 // ------------------------------------------------------------------------------------------------- |
160 // |
160 // |
161 void ColoredLine::activate_color(Color color, bool bold) |
161 void ColoredLine::activateColor(Color color, bool bold) |
162 { |
162 { |
163 if (m_boldActive) |
163 if (m_boldActive) |
164 m_data << RLINE_OFF_BOLD; |
164 m_data << RLINE_OFF_BOLD; |
165 |
165 |
166 m_activeColor = color; |
166 m_activeColor = color; |
167 m_boldActive = bold; |
167 m_boldActive = bold; |
168 assert(m_activeColor < 8); |
168 assert(m_activeColor < 8); |
169 set_color(m_activeColor, true); |
169 setColor(m_activeColor, true); |
170 |
170 |
171 if (m_boldActive) |
171 if (m_boldActive) |
172 m_data << RLINE_ON_BOLD; |
172 m_data << RLINE_ON_BOLD; |
173 } |
173 } |
174 |
174 |
175 // ------------------------------------------------------------------------------------------------- |
175 // ------------------------------------------------------------------------------------------------- |
176 // |
176 // |
177 void ColoredLine::add_string(const String& text) |
177 void ColoredLine::addString(const String& text) |
178 { |
178 { |
179 for (char a : text) |
179 for (char a : text) |
180 add_char(a); |
180 addChar(a); |
181 } |
181 } |
182 |
182 |
183 // ------------------------------------------------------------------------------------------------- |
183 // ------------------------------------------------------------------------------------------------- |
184 // |
184 // |
185 void ColoredLine::set_color(Color a, bool on) |
185 void ColoredLine::setColor(Color a, bool on) |
186 { |
186 { |
187 assert(a < 8); |
187 assert(a < 8); |
188 m_data << (a +(on ? RLINE_ON_COLOR : RLINE_OFF_COLOR)); |
188 m_data << (a +(on ? RLINE_ON_COLOR : RLINE_OFF_COLOR)); |
189 } |
189 } |
190 |
190 |