MCPcopy Create free account
hub / github.com/MyGUI/mygui / _setTextColour

Method _setTextColour

MyGUIEngine/src/MyGUI_EditBox.cpp:1156–1219  ·  view source on GitHub ↗

выделяет цветом диапазон

Source from the content-addressed store, hash-verified

1154
1155 // выделяет цветом диапазон
1156 void EditBox::_setTextColour(size_t _start, size_t _count, const Colour& _colour, bool _history)
1157 {
1158 // история изменений
1159 VectorChangeInfo* history = nullptr;
1160 if (_history)
1161 history = new VectorChangeInfo();
1162
1163 // конец диапазона
1164 size_t end = _start + _count;
1165
1166 // итератор нашей строки
1167 TextIterator iterator(getRealString(), history);
1168
1169 // дефолтный цвет
1170 UString colour;
1171 if (mClientText != nullptr)
1172 colour = TextIterator::convertTagColour(mClientText->getTextColour());
1173
1174 // цикл прохода по строке
1175 while (iterator.moveNext())
1176 {
1177 // текущаяя позиция
1178 size_t pos = iterator.getPosition();
1179
1180 // берем цвет из позиции и запоминаем
1181 iterator.getTagColour(colour);
1182
1183 // еще рано
1184 if (pos < _start)
1185 continue;
1186
1187 // ставим начальный тег
1188 if (pos == _start)
1189 iterator.setTagColour(_colour);
1190
1191 // внутри диапазона очищаем все
1192 else if (pos < end)
1193 iterator.clearTagColour();
1194
1195 // на конец ставим последний найденный или дефолтный
1196 else if (pos == end)
1197 {
1198 iterator.setTagColour(colour);
1199 // и выходим из цикла
1200 break;
1201 }
1202 }
1203
1204 // сохраняем позицию для восстановления курсора
1205 commandPosition(_start, _start + _count, mTextLength, history);
1206
1207 // запоминаем в историю
1208 if (_history)
1209 {
1210 saveInHistory(history);
1211 delete history;
1212 }
1213 // сбрасываем историю

Callers

nothing calls this directly

Calls 6

moveNextMethod · 0.80
getTagColourMethod · 0.80
setTagColourMethod · 0.80
clearTagColourMethod · 0.80
getPositionMethod · 0.45
getTextMethod · 0.45

Tested by

no test coverage detected