Commit 24d784b0 authored by David Schulz's avatar David Schulz

Editor: Draw line numbers before text marks.

Task-number: QTCREATORBUG-14178
Change-Id: Id7c29d958194b1337316cd550211c5089e719ccb
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 2ccae82b
...@@ -4355,6 +4355,31 @@ void TextEditorWidget::extraAreaPaintEvent(QPaintEvent *e) ...@@ -4355,6 +4355,31 @@ void TextEditorWidget::extraAreaPaintEvent(QPaintEvent *e)
painter.setPen(pal.color(QPalette::Dark)); painter.setPen(pal.color(QPalette::Dark));
if (d->m_lineNumbersVisible) {
const QString &number = lineNumber(blockNumber);
bool selected = (
(selStart < block.position() + block.length()
&& selEnd > block.position())
|| (selStart == selEnd && selStart == block.position())
);
if (selected) {
painter.save();
QFont f = painter.font();
const QTextCharFormat &currentLineNumberFormat
= textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER);
f.setBold(currentLineNumberFormat.font().bold());
f.setItalic(currentLineNumberFormat.font().italic());
painter.setFont(f);
painter.setPen(currentLineNumberFormat.foreground().color());
if (currentLineNumberFormat.background() != Qt::NoBrush)
painter.fillRect(QRect(0, top, extraAreaWidth, height), currentLineNumberFormat.background().color());
}
painter.drawText(QRectF(markWidth, top, extraAreaWidth - markWidth - 4, height), Qt::AlignRight, number);
if (selected)
painter.restore();
}
if (d->m_codeFoldingVisible || d->m_marksVisible) { if (d->m_codeFoldingVisible || d->m_marksVisible) {
painter.save(); painter.save();
painter.setRenderHint(QPainter::Antialiasing, false); painter.setRenderHint(QPainter::Antialiasing, false);
...@@ -4452,31 +4477,6 @@ void TextEditorWidget::extraAreaPaintEvent(QPaintEvent *e) ...@@ -4452,31 +4477,6 @@ void TextEditorWidget::extraAreaPaintEvent(QPaintEvent *e)
painter.restore(); painter.restore();
} }
if (d->m_lineNumbersVisible) {
const QString &number = lineNumber(blockNumber);
bool selected = (
(selStart < block.position() + block.length()
&& selEnd > block.position())
|| (selStart == selEnd && selStart == block.position())
);
if (selected) {
painter.save();
QFont f = painter.font();
const QTextCharFormat &currentLineNumberFormat
= textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER);
f.setBold(currentLineNumberFormat.font().bold());
f.setItalic(currentLineNumberFormat.font().italic());
painter.setFont(f);
painter.setPen(currentLineNumberFormat.foreground().color());
if (currentLineNumberFormat.background() != Qt::NoBrush)
painter.fillRect(QRect(0, top, extraAreaWidth, height), currentLineNumberFormat.background().color());
}
painter.drawText(QRectF(markWidth, top, extraAreaWidth - markWidth - 4, height), Qt::AlignRight, number);
if (selected)
painter.restore();
}
block = nextVisibleBlock; block = nextVisibleBlock;
blockNumber = nextVisibleBlockNumber; blockNumber = nextVisibleBlockNumber;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment