| 1780 | } |
| 1781 | |
| 1782 | void TeXDocumentWindow::goToLine(int lineNo, int selStart, int selEnd) |
| 1783 | { |
| 1784 | QTextDocument* doc = textEdit->document(); |
| 1785 | if (lineNo < 1 || lineNo > doc->blockCount()) |
| 1786 | return; |
| 1787 | int oldScrollValue = -1; |
| 1788 | if (textEdit->verticalScrollBar()) |
| 1789 | oldScrollValue = textEdit->verticalScrollBar()->value(); |
| 1790 | QTextCursor cursor(doc->findBlockByNumber(lineNo - 1)); |
| 1791 | if (selStart >= 0 && selEnd >= selStart) { |
| 1792 | cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, selStart); |
| 1793 | cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, selEnd - selStart); |
| 1794 | } |
| 1795 | else |
| 1796 | cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); |
| 1797 | textEdit->setTextCursor(cursor); |
| 1798 | maybeCenterSelection(oldScrollValue); |
| 1799 | } |
| 1800 | |
| 1801 | void TeXDocumentWindow::maybeCenterSelection(int oldScrollValue) |
| 1802 | { |
no test coverage detected