| 777 | } |
| 778 | |
| 779 | QTextCursor OutputWidget::fragmentCursor(int position) |
| 780 | { |
| 781 | if (position != -1) { |
| 782 | auto cursor = ui->textBrowser->textCursor(); |
| 783 | cursor.setPosition(position); |
| 784 | auto block = cursor.block(); |
| 785 | for (auto it = block.begin(); it != block.end(); it++) { |
| 786 | auto fragment = it.fragment(); |
| 787 | if (fragment.contains(position)) { |
| 788 | cursor.setPosition(fragment.position()); |
| 789 | cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, fragment.length()); |
| 790 | return cursor; |
| 791 | } |
| 792 | } |
| 793 | } |
| 794 | return QTextCursor(); |
| 795 | } |
| 796 | |
| 797 | bool OutputWidget::eventFilter(QObject* object, QEvent* event) |
| 798 | { |