GUI: Improved scrolling in code display
This commit is contained in:
parent
4a46690990
commit
bd21d7fff6
|
@ -144,6 +144,8 @@ void CodeEditor::setError(const QString &code, int errorLine, const QStringList
|
|||
tc.setPosition(mErrorPosition);
|
||||
setTextCursor(tc);
|
||||
centerCursor();
|
||||
|
||||
highlightErrorLine();
|
||||
}
|
||||
|
||||
int CodeEditor::lineNumberAreaWidth()
|
||||
|
@ -182,12 +184,8 @@ void CodeEditor::resizeEvent(QResizeEvent *event)
|
|||
lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
|
||||
}
|
||||
|
||||
void CodeEditor::highlightCurrentLine()
|
||||
void CodeEditor::highlightErrorLine()
|
||||
{
|
||||
QTextCursor tc = textCursor();
|
||||
tc.setPosition(mErrorPosition);
|
||||
setTextCursor(tc);
|
||||
|
||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||
|
||||
QTextEdit::ExtraSelection selection;
|
||||
|
@ -196,7 +194,8 @@ void CodeEditor::highlightCurrentLine()
|
|||
|
||||
selection.format.setBackground(lineColor);
|
||||
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||
selection.cursor = textCursor();
|
||||
selection.cursor = QTextCursor(document());
|
||||
selection.cursor.setPosition(mErrorPosition);
|
||||
selection.cursor.clearSelection();
|
||||
extraSelections.append(selection);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ protected:
|
|||
|
||||
private slots:
|
||||
void updateLineNumberAreaWidth(int newBlockCount);
|
||||
void highlightCurrentLine();
|
||||
void highlightErrorLine();
|
||||
void updateLineNumberArea(const QRect &, int);
|
||||
|
||||
private:
|
||||
|
|
|
@ -140,9 +140,15 @@
|
|||
<verstretch>4</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<property name="undoRedoEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in New Issue