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

Method prepend

src/Gui/TextEdit.cpp:529–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527PythonTextEditor::~PythonTextEditor() = default;
528
529void PythonTextEditor::prepend(const QString& str)
530{
531 QTextCursor cursor = textCursor();
532 // for each selected block insert a tab or spaces
533 int selStart = cursor.selectionStart();
534 int selEnd = cursor.selectionEnd();
535 QTextBlock block;
536 cursor.beginEditBlock();
537 for (block = document()->begin(); block.isValid(); block = block.next()) {
538 int pos = block.position();
539 int off = block.length() - 1;
540 // at least one char of the block is part of the selection
541 if (pos >= selStart || pos + off >= selStart) {
542 if (pos + 1 > selEnd) {
543 break; // end of selection reached
544 }
545 cursor.setPosition(block.position());
546 cursor.insertText(str);
547 selEnd += str.length();
548 }
549 }
550
551 cursor.endEditBlock();
552}
553
554void PythonTextEditor::remove(const QString& str)
555{

Callers 12

validateAndInterpretMethod · 0.45
appendFileMethod · 0.45
makeCommentMethod · 0.45
confirmSaveMethod · 0.45
customEventMethod · 0.45
pixmapMethod · 0.45
setThemePathsMethod · 0.45
acceptMethod · 0.45
onlySingleInstanceFunction · 0.45
parseMethod · 0.45
validateAndInterpretMethod · 0.45

Calls 7

insertTextMethod · 0.80
beginMethod · 0.45
isValidMethod · 0.45
nextMethod · 0.45
positionMethod · 0.45
lengthMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected