103 set_color (m_activeColor, false); |
103 set_color (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; |
|
109 |
108 // Chars may be in uppercase |
110 // Chars may be in uppercase |
109 if (ch >= 'A' and ch <= 'V') |
111 if (ch >= 'A' and ch <= 'V') |
110 ch += 'a' - 'A'; |
112 ch += 'a' - 'A'; |
111 |
113 |
112 if (ch >= 'a' and ch <= 'v' and ch != 'l') |
114 if (ch >= 'a' and ch <= 'v' and ch != 'l') |
113 { |
115 { |
114 auto colorInfo = colorCodes[ch - 'a']; |
116 const ColorCodeInfo& colorInfo = colorCodes[ch - 'a']; |
115 m_activeColor = colorInfo.color; |
117 activate_color(colorInfo.color, colorInfo.bold); |
116 m_boldActive = colorInfo.bold; |
|
117 assert (m_activeColor < 8); |
|
118 set_color (m_activeColor, true); |
|
119 |
|
120 if (m_boldActive) |
|
121 m_data << RLINE_ON_BOLD; |
|
122 } |
118 } |
123 |
119 |
124 m_colorCodeStage = 0; |
120 if (ch == '[') |
|
121 m_colorCodeStage = 2; |
|
122 else |
|
123 m_colorCodeStage = 0; |
|
124 return; |
|
125 } |
|
126 else if (m_colorCodeStage == 2) |
|
127 { |
|
128 if (ch == ']') |
|
129 { |
|
130 String color = m_incomingColorName.to_lowercase(); |
|
131 |
|
132 for (size_t i = 0; i < countof(colorCodes); ++i) |
|
133 { |
|
134 const ColorCodeInfo& colorInfo = colorCodes[i]; |
|
135 |
|
136 if (String(colorInfo.name).to_lowercase() == color) |
|
137 { |
|
138 activate_color(colorInfo.color, colorInfo.bold); |
|
139 m_colorCodeStage = 0; |
|
140 break; |
|
141 } |
|
142 } |
|
143 |
|
144 m_incomingColorName = ""; |
|
145 m_colorCodeStage = 0; |
|
146 } |
|
147 else if (isprint(ch)) |
|
148 m_incomingColorName += ch; |
|
149 |
125 return; |
150 return; |
126 } |
151 } |
127 |
152 |
128 if (isprint (ch)) |
153 if (isprint (ch)) |
129 { |
154 { |
130 m_string += ch; |
155 m_string += ch; |
131 m_data << int (ch); |
156 m_data << int (ch); |
132 ++m_length; |
157 ++m_length; |
133 } |
158 } |
|
159 } |
|
160 |
|
161 // ------------------------------------------------------------------------------------------------- |
|
162 // |
|
163 void ColoredLine::activate_color (Color color, bool bold) |
|
164 { |
|
165 if (m_boldActive) |
|
166 m_data << RLINE_OFF_BOLD; |
|
167 |
|
168 m_activeColor = color; |
|
169 m_boldActive = bold; |
|
170 assert (m_activeColor < 8); |
|
171 set_color (m_activeColor, true); |
|
172 |
|
173 if (m_boldActive) |
|
174 m_data << RLINE_ON_BOLD; |
134 } |
175 } |
135 |
176 |
136 // ------------------------------------------------------------------------------------------------- |
177 // ------------------------------------------------------------------------------------------------- |
137 // |
178 // |
138 void ColoredLine::set_color (Color a, bool on) |
179 void ColoredLine::set_color (Color a, bool on) |