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

Method eraseText

MyGUIEngine/src/MyGUI_EditBox.cpp:1410–1511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1408 }
1409
1410 void EditBox::eraseText(size_t _start, size_t _count, bool _history)
1411 {
1412 // чета маловато
1413 if (_count == 0)
1414 return;
1415
1416 // сбрасываем выделение
1417 resetSelect();
1418
1419 // история изменений
1420 VectorChangeInfo* history = nullptr;
1421 if (_history)
1422 history = new VectorChangeInfo();
1423
1424 // итератор нашей строки
1425 TextIterator iterator(getRealString(), history);
1426
1427 // дефолтный цвет
1428 UString colour;
1429 // конец диапазона
1430 size_t end = _start + _count;
1431 bool need_colour = false;
1432
1433 // цикл прохода по строке
1434 while (iterator.moveNext())
1435 {
1436 // текущаяя позиция
1437 size_t pos = iterator.getPosition();
1438
1439 // еще рано
1440 if (pos < _start)
1441 {
1442 // берем цвет из позиции и запоминаем
1443 iterator.getTagColour(colour);
1444 continue;
1445 }
1446
1447 // сохраняем место откуда начинается
1448 if (pos == _start)
1449 {
1450 // если до диапазона был цвет, то нужно закрыть тег
1451 if (!colour.empty())
1452 {
1453 need_colour = true;
1454 colour.clear();
1455 }
1456 // берем цвет из позиции и запоминаем
1457 iterator.getTagColour(colour);
1458 iterator.saveStartPoint();
1459 }
1460
1461 // внутри диапазона
1462 else if (pos < end)
1463 {
1464 // берем цвет из позиции и запоминаем
1465 iterator.getTagColour(colour);
1466 }
1467

Callers 3

EraseTextFunction · 0.80
notifyButtonPressedMethod · 0.80

Calls 10

moveNextMethod · 0.80
getTagColourMethod · 0.80
saveStartPointMethod · 0.80
eraseFromStartMethod · 0.80
setTagColourMethod · 0.80
setCursorPositionMethod · 0.80
getPositionMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45
getTextMethod · 0.45

Tested by

no test coverage detected