@@ -250,8 +250,10 @@ void TextEditor::Advance(Coordinates & aCoordinates) const
250250
251251void TextEditor::DeleteRange (const Coordinates & aStart, const Coordinates & aEnd)
252252{
253+ #ifndef OFXVP_DEBUG
253254 assert (aEnd >= aStart);
254255 assert (!mReadOnly );
256+ #endif
255257
256258 // printf("D(%d.%d)-(%d.%d)\n", aStart.mLine, aStart.mColumn, aEnd.mLine, aEnd.mColumn);
257259
@@ -290,13 +292,17 @@ void TextEditor::DeleteRange(const Coordinates & aStart, const Coordinates & aEn
290292
291293int TextEditor::InsertTextAt (Coordinates& /* inout */ aWhere, const char * aValue)
292294{
295+ #ifndef OFXVP_DEBUG
293296 assert (!mReadOnly );
297+ #endif
294298
295299 int cindex = GetCharacterIndex (aWhere);
296300 int totalLines = 0 ;
297301 while (*aValue != ' \0 ' )
298302 {
303+ #ifndef OFXVP_DEBUG
299304 assert (!mLines .empty ());
305+ #endif
300306
301307 if (*aValue == ' \r ' )
302308 {
@@ -339,7 +345,10 @@ int TextEditor::InsertTextAt(Coordinates& /* inout */ aWhere, const char * aValu
339345
340346void TextEditor::AddUndo (UndoRecord& aValue)
341347{
348+ #ifndef OFXVP_DEBUG
342349 assert (!mReadOnly );
350+ #endif
351+
343352 // printf("AddUndo: (@%d.%d) +\'%s' [%d.%d .. %d.%d], -\'%s', [%d.%d .. %d.%d] (@%d.%d)\n",
344353 // aValue.mBefore.mCursorPosition.mLine, aValue.mBefore.mCursorPosition.mColumn,
345354 // aValue.mAdded.c_str(), aValue.mAddedStart.mLine, aValue.mAddedStart.mColumn, aValue.mAddedEnd.mLine, aValue.mAddedEnd.mColumn,
@@ -605,9 +614,11 @@ bool TextEditor::IsOnWordBoundary(const Coordinates & aAt) const
605614
606615void TextEditor::RemoveLine (int aStart, int aEnd)
607616{
617+ #ifndef OFXVP_DEBUG
608618 assert (!mReadOnly );
609619 assert (aEnd >= aStart);
610620 assert (mLines .size () > (size_t )(aEnd - aStart));
621+ #endif
611622
612623 ErrorMarkers etmp;
613624 for (auto & i : mErrorMarkers )
@@ -629,15 +640,19 @@ void TextEditor::RemoveLine(int aStart, int aEnd)
629640 mBreakpoints = std::move (btmp);
630641
631642 mLines .erase (mLines .begin () + aStart, mLines .begin () + aEnd);
643+ #ifndef OFXVP_DEBUG
632644 assert (!mLines .empty ());
645+ #endif
633646
634647 mTextChanged = true ;
635648}
636649
637650void TextEditor::RemoveLine (int aIndex)
638651{
652+ #ifndef OFXVP_DEBUG
639653 assert (!mReadOnly );
640654 assert (mLines .size () > 1 );
655+ #endif
641656
642657 ErrorMarkers etmp;
643658 for (auto & i : mErrorMarkers )
@@ -659,14 +674,18 @@ void TextEditor::RemoveLine(int aIndex)
659674 mBreakpoints = std::move (btmp);
660675
661676 mLines .erase (mLines .begin () + aIndex);
677+ #ifndef OFXVP_DEBUG
662678 assert (!mLines .empty ());
679+ #endif
663680
664681 mTextChanged = true ;
665682}
666683
667684TextEditor::Line& TextEditor::InsertLine (int aIndex)
668685{
686+ #ifndef OFXVP_DEBUG
669687 assert (!mReadOnly );
688+ #endif
670689
671690 auto & result = *mLines .insert (mLines .begin () + aIndex, Line ());
672691
@@ -930,7 +949,9 @@ void TextEditor::RenderInternal(const char* aTitle)
930949 mPalette [i] = ImGui::ColorConvertFloat4ToU32 (color);
931950 }
932951
952+ #ifndef OFXVP_DEBUG
933953 assert (mLineBuffer .empty ());
954+ #endif
934955
935956 auto contentSize = ImGui::GetContentRegionAvail () - ImGui::GetCursorPos ();
936957 auto drawList = ImGui::GetWindowDrawList ();
@@ -974,7 +995,9 @@ void TextEditor::RenderInternal(const char* aTitle)
974995 float sstart = -1 .0f ;
975996 float ssend = -1 .0f ;
976997
998+ #ifndef OFXVP_DEBUG
977999 assert (mState .mSelectionStart <= mState .mSelectionEnd );
1000+ #endif
9781001 if (mState .mSelectionStart <= lineEndCoord)
9791002 sstart = mState .mSelectionStart > lineStartCoord ? TextDistanceToLineStart (mState .mSelectionStart ) : 0 .0f ;
9801003 if (mState .mSelectionEnd > lineStartCoord)
@@ -1551,7 +1574,9 @@ void TextEditor::SetTextLines(const std::vector<std::string> & aLines)
15511574
15521575void TextEditor::EnterCharacter (ImWchar aChar, bool aShift)
15531576{
1577+ #ifndef OFXVP_DEBUG
15541578 assert (!mReadOnly );
1579+ #endif
15551580
15561581 UndoRecord u;
15571582
@@ -1658,7 +1683,9 @@ void TextEditor::EnterCharacter(ImWchar aChar, bool aShift)
16581683 auto coord = GetActualCursorCoordinates ();
16591684 u.mAddedStart = coord;
16601685
1686+ #ifndef OFXVP_DEBUG
16611687 assert (!mLines .empty ());
1688+ #endif
16621689
16631690 if (aChar == ' \n ' )
16641691 {
@@ -1823,7 +1850,9 @@ void TextEditor::InsertText(const char * aValue)
18231850
18241851void TextEditor::DeleteSelection ()
18251852{
1853+ #ifndef OFXVP_DEBUG
18261854 assert (mState .mSelectionEnd >= mState .mSelectionStart );
1855+ #endif
18271856
18281857 if (mState .mSelectionEnd == mState .mSelectionStart )
18291858 return ;
@@ -1863,7 +1892,9 @@ void TextEditor::MoveUp(int aAmount, bool aSelect)
18631892
18641893void TextEditor::MoveDown (int aAmount, bool aSelect)
18651894{
1895+ #ifndef OFXVP_DEBUG
18661896 assert (mState .mCursorPosition .mColumn >= 0 );
1897+ #endif
18671898 auto oldPos = mState .mCursorPosition ;
18681899 mState .mCursorPosition .mLine = std::max (0 , std::min ((int )mLines .size () - 1 , mState .mCursorPosition .mLine + aAmount));
18691900
@@ -1940,7 +1971,9 @@ void TextEditor::MoveLeft(int aAmount, bool aSelect, bool aWordMode)
19401971
19411972 mState .mCursorPosition = Coordinates (line, GetCharacterColumn (line, cindex));
19421973
1974+ #ifndef OFXVP_DEBUG
19431975 assert (mState .mCursorPosition .mColumn >= 0 );
1976+ #endif
19441977 if (aSelect)
19451978 {
19461979 if (oldPos == mInteractiveStart )
@@ -2096,7 +2129,9 @@ void TextEditor::MoveEnd(bool aSelect)
20962129
20972130void TextEditor::Delete ()
20982131{
2132+ #ifndef OFXVP_DEBUG
20992133 assert (!mReadOnly );
2134+ #endif
21002135
21012136 if (mLines .empty ())
21022137 return ;
@@ -2154,7 +2189,9 @@ void TextEditor::Delete()
21542189
21552190void TextEditor::Backspace ()
21562191{
2192+ #ifndef OFXVP_DEBUG
21572193 assert (!mReadOnly );
2194+ #endif
21582195
21592196 if (mLines .empty ())
21602197 return ;
@@ -2901,8 +2938,10 @@ TextEditor::UndoRecord::UndoRecord(
29012938 , mAdded(aAdded)
29022939 , mRemoved(aRemoved)
29032940{
2941+ #ifndef OFXVP_DEBUG
29042942 assert (mAddedStart <= mAddedEnd );
29052943 assert (mRemovedStart <= mRemovedEnd );
2944+ #endif
29062945}
29072946
29082947void TextEditor::UndoRecord::Undo (TextEditor * aEditor)
0 commit comments