MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / DeleteRange

Method DeleteRange

plugins/Cardinal/src/DearImGuiColorTextEditor/TextEditor.cpp:220–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220void TextEditor::DeleteRange(const Coordinates & aStart, const Coordinates & aEnd)
221{
222 assert(aEnd >= aStart);
223 assert(!mReadOnly);
224
225 //printf("D(%d.%d)-(%d.%d)\n", aStart.mLine, aStart.mColumn, aEnd.mLine, aEnd.mColumn);
226
227 if (aEnd == aStart)
228 return;
229
230 auto start = GetCharacterIndex(aStart);
231 auto end = GetCharacterIndex(aEnd);
232
233 if (aStart.mLine == aEnd.mLine)
234 {
235 auto& line = mLines[aStart.mLine];
236 auto n = GetLineMaxColumn(aStart.mLine);
237 if (aEnd.mColumn >= n)
238 line.erase(line.begin() + start, line.end());
239 else
240 line.erase(line.begin() + start, line.begin() + end);
241 }
242 else
243 {
244 auto& firstLine = mLines[aStart.mLine];
245 auto& lastLine = mLines[aEnd.mLine];
246
247 firstLine.erase(firstLine.begin() + start, firstLine.end());
248 lastLine.erase(lastLine.begin(), lastLine.begin() + end);
249
250 if (aStart.mLine < aEnd.mLine)
251 firstLine.insert(firstLine.end(), lastLine.begin(), lastLine.end());
252
253 if (aStart.mLine < aEnd.mLine)
254 RemoveLine(aStart.mLine + 1, aEnd.mLine + 1);
255 }
256
257 mTextChanged = true;
258}
259
260int TextEditor::InsertTextAt(Coordinates& /* inout */ aWhere, const char * aValue)
261{

Callers 2

UndoMethod · 0.80
RedoMethod · 0.80

Calls 4

eraseMethod · 0.80
insertMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected