51 { |
51 { |
52 if (m_activeColor != DEFAULT) |
52 if (m_activeColor != DEFAULT) |
53 setColor(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.push_back(RLINE_OFF_BOLD); |
57 |
57 |
58 m_final = true; |
58 m_final = true; |
59 } |
59 } |
60 |
60 |
61 // ------------------------------------------------------------------------------------------------- |
61 // ------------------------------------------------------------------------------------------------- |
101 { |
101 { |
102 if (m_activeColor != DEFAULT) |
102 if (m_activeColor != DEFAULT) |
103 setColor(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.push_back(RLINE_OFF_BOLD); |
107 |
107 |
108 m_boldActive = false; |
108 m_boldActive = false; |
109 |
109 |
110 // Chars may be in uppercase |
110 // Chars may be in uppercase |
111 if (ch >= 'A' and ch <= 'V') |
111 if (ch >= 'A' and ch <= 'V') |
125 } |
125 } |
126 else if (m_colorCodeStage == 2) |
126 else if (m_colorCodeStage == 2) |
127 { |
127 { |
128 if (ch == ']') |
128 if (ch == ']') |
129 { |
129 { |
130 String color = m_incomingColorName.toLowerCase(); |
130 std::string color = to_lowercase(m_incomingColorName); |
131 |
131 |
132 for (const ColorCodeInfo &colorInfo : colorCodes) |
132 for (const ColorCodeInfo &colorInfo : colorCodes) |
133 { |
133 { |
134 if (String(colorInfo.name).toLowerCase() == color) |
134 if (to_lowercase(colorInfo.name) == color) |
135 { |
135 { |
136 activateColor(colorInfo.color, colorInfo.bold); |
136 activateColor(colorInfo.color, colorInfo.bold); |
137 m_colorCodeStage = 0; |
137 m_colorCodeStage = 0; |
138 break; |
138 break; |
139 } |
139 } |
149 } |
149 } |
150 |
150 |
151 if (isprint(ch)) |
151 if (isprint(ch)) |
152 { |
152 { |
153 m_string += ch; |
153 m_string += ch; |
154 m_data << int(ch); |
154 m_data.push_back(static_cast<int>(ch)); |
155 ++m_length; |
155 ++m_length; |
156 } |
156 } |
157 } |
157 } |
158 |
158 |
159 // ------------------------------------------------------------------------------------------------- |
159 // ------------------------------------------------------------------------------------------------- |
160 // |
160 // |
161 void ColoredLine::activateColor(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 { |
165 |
165 m_data.push_back(RLINE_OFF_BOLD); |
|
166 } |
166 m_activeColor = color; |
167 m_activeColor = color; |
167 m_boldActive = bold; |
168 m_boldActive = bold; |
168 assert(m_activeColor < 8); |
169 assert(m_activeColor < 8); |
169 setColor(m_activeColor, true); |
170 setColor(m_activeColor, true); |
170 |
|
171 if (m_boldActive) |
171 if (m_boldActive) |
172 m_data << RLINE_ON_BOLD; |
172 { |
173 } |
173 m_data.push_back(RLINE_ON_BOLD); |
174 |
174 } |
175 // ------------------------------------------------------------------------------------------------- |
175 } |
176 // |
176 |
177 void ColoredLine::addString(const String& text) |
177 // ------------------------------------------------------------------------------------------------- |
|
178 // |
|
179 void ColoredLine::addString(const std::string& text) |
178 { |
180 { |
179 for (char a : text) |
181 for (char a : text) |
180 addChar(a); |
182 addChar(a); |
181 } |
183 } |
182 |
184 |
183 // ------------------------------------------------------------------------------------------------- |
185 // ------------------------------------------------------------------------------------------------- |
184 // |
186 // |
185 void ColoredLine::setColor(Color a, bool on) |
187 void ColoredLine::setColor(Color a, bool on) |
186 { |
188 { |
187 assert(a < 8); |
189 assert(a < 8); |
188 m_data << (a +(on ? RLINE_ON_COLOR : RLINE_OFF_COLOR)); |
190 m_data.push_back(a + (on ? RLINE_ON_COLOR : RLINE_OFF_COLOR)); |
189 } |
191 } |
190 |
192 |
191 // ------------------------------------------------------------------------------------------------- |
193 // ------------------------------------------------------------------------------------------------- |
192 // How many rows does this line take up? |
194 // How many rows does this line take up? |
193 // |
195 // |