| 552 | } |
| 553 | |
| 554 | void 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 | |
| 583 | void PythonTextEditor::keyPressEvent(QKeyEvent* e) |
| 584 | { |
no test coverage detected