MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / deleteChars

Method deleteChars

Engine/source/gui/controls/guiMLTextCtrl.cpp:943–973  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

941
942//--------------------------------------------------------------------------
943void GuiMLTextCtrl::deleteChars(const U32 rangeStart,
944 const U32 rangeEnd)
945{
946 AssertFatal(isSelectionActive() == false, "GuiMLTextCtrl::deleteChars: don't use this function when there's a selection active");
947 AssertFatal(rangeStart <= mTextBuffer.length() && rangeEnd <= mTextBuffer.length(),
948 avar("GuiMLTextCtrl::deleteChars: can't delete outside of current text (%d, %d, %d)",
949 rangeStart, rangeEnd, mTextBuffer.length()));
950 AssertFatal(rangeStart <= rangeEnd, "GuiMLTextCtrl::deleteChars: invalid delete range");
951
952 // Currently deleting text doesn't resize the text buffer, perhaps this should
953 // change?
954 mTextBuffer.cut(rangeStart, rangeEnd - rangeStart);
955
956 if (mCursorPosition <= rangeStart)
957 {
958 // Cursor placed before deleted text, ignore
959 }
960 else if (mCursorPosition > rangeStart && mCursorPosition <= rangeEnd)
961 {
962 // Cursor inside deleted text, set to start of range
963 mCursorPosition = rangeStart;
964 }
965 else
966 {
967 // Cursor after deleted text, decrement by number of chars deleted
968 mCursorPosition -= (rangeEnd - rangeStart) + 1;
969 }
970
971 AssertFatal(mCursorPosition <= mTextBuffer.length(), "GuiMLTextCtrl::deleteChars: bad cursor position");
972 mDirty = true;
973}
974
975//--------------------------------------------------------------------------
976void GuiMLTextCtrl::copyToClipboard(const U32 rangeStart, const U32 rangeEnd)

Callers

nothing calls this directly

Calls 3

avarFunction · 0.85
cutMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected