MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / remove

Method remove

src/Gui/TextEdit.cpp:554–581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552}
553
554void PythonTextEditor::remove(const QString& str)
555{
556 QTextCursor cursor = textCursor();
557 int selStart = cursor.selectionStart();
558 int selEnd = cursor.selectionEnd();
559 QTextBlock block;
560 cursor.beginEditBlock();
561 for (block = document()->begin(); block.isValid(); block = block.next()) {
562 int pos = block.position();
563 int off = block.length() - 1;
564 // at least one char of the block is part of the selection
565 if (pos >= selStart || pos + off >= selStart) {
566 if (pos + 1 > selEnd) {
567 break; // end of selection reached
568 }
569 QString text = block.text();
570 if (text.startsWith(str)) {
571 cursor.setPosition(block.position());
572 for (int i = 0; i < str.length(); i++) {
573 cursor.deleteChar();
574 selEnd--;
575 }
576 }
577 }
578 }
579
580 cursor.endEditBlock();
581}
582
583void PythonTextEditor::keyPressEvent(QKeyEvent* e)
584{

Callers 15

removeExactNameMethod · 0.45
parseStringMethod · 0.45
textFromValueMethod · 0.45
fixupMethod · 0.45
listByShortcutMethod · 0.45
onActivatedMethod · 0.45
unsetUrlHandlerMethod · 0.45
acceptMethod · 0.45
cleanupMethod · 0.45
checkDocumentDirsMethod · 0.45
clearDirectoryMethod · 0.45
onExecuteInConsoleMethod · 0.45

Calls 8

startsWithMethod · 0.80
beginMethod · 0.45
isValidMethod · 0.45
nextMethod · 0.45
positionMethod · 0.45
lengthMethod · 0.45
textMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected