| 641 | } |
| 642 | |
| 643 | std::tuple<QTextBlock, QTextBlock, bool> Editor::selectedBlockRange() const |
| 644 | { |
| 645 | QTextCursor cursor = textCursor(); |
| 646 | if (!cursor.hasSelection()) { |
| 647 | return std::make_tuple(cursor.block(), cursor.block(), false); |
| 648 | } |
| 649 | |
| 650 | int selectionStart = cursor.selectionStart(); |
| 651 | int selectionEnd = cursor.selectionEnd(); |
| 652 | QTextBlock startBlock = document()->findBlock(selectionStart); |
| 653 | QTextBlock endBlock = document()->findBlock(selectionEnd); |
| 654 | |
| 655 | bool fullFirstBlock = selectionStart == startBlock.position() && |
| 656 | selectionEnd >= (endBlock.position() + endBlock.length() - 1); |
| 657 | |
| 658 | return std::make_tuple(startBlock, endBlock, fullFirstBlock); |
| 659 | } |
| 660 | |
| 661 | QString Editor::getIndentString(QTextCursor cursor) const |
| 662 | { |