MCPcopy Create free account
hub / github.com/TeXworks/texworks / goToLine

Method goToLine

src/TeXDocumentWindow.cpp:1782–1799  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1780}
1781
1782void 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
1801void TeXDocumentWindow::maybeCenterSelection(int oldScrollValue)
1802{

Callers 2

openDocumentMethod · 0.80
showEntryMethod · 0.80

Calls 3

setTextCursorMethod · 0.80
documentMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected