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