forked from qt-creator/qt-creator
Editor: increase text cursor visibility on indentation depth mark
Reduce the alpha of the marker if a cursor is at the same position as the marker. Fixes: QTCREATORBUG-28645 Change-Id: I01b1825fd3f393dcc75cc58d64a31f22e50e2648 Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
@@ -4477,7 +4477,6 @@ void TextEditorWidgetPrivate::paintIndentDepth(PaintEventData &data,
|
|||||||
const qreal indentAdvance = singleAdvance * data.tabSettings.m_indentSize;
|
const qreal indentAdvance = singleAdvance * data.tabSettings.m_indentSize;
|
||||||
|
|
||||||
painter.save();
|
painter.save();
|
||||||
painter.setPen(data.visualWhitespaceFormat.foreground().color());
|
|
||||||
|
|
||||||
const QTextLine textLine = blockData.layout->lineAt(0);
|
const QTextLine textLine = blockData.layout->lineAt(0);
|
||||||
const QRectF rect = textLine.naturalTextRect();
|
const QRectF rect = textLine.naturalTextRect();
|
||||||
@@ -4485,6 +4484,16 @@ void TextEditorWidgetPrivate::paintIndentDepth(PaintEventData &data,
|
|||||||
+ singleAdvance * m_visualIndentOffset;
|
+ singleAdvance * m_visualIndentOffset;
|
||||||
int paintColumn = 0;
|
int paintColumn = 0;
|
||||||
|
|
||||||
|
QList<int> cursorPositions;
|
||||||
|
for (const QTextCursor & cursor : m_cursors) {
|
||||||
|
if (cursor.block() == data.block)
|
||||||
|
cursorPositions << cursor.positionInBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QColor normalColor = data.visualWhitespaceFormat.foreground().color();
|
||||||
|
QColor cursorColor = normalColor;
|
||||||
|
cursorColor.setAlpha(cursorColor.alpha() / 2);
|
||||||
|
|
||||||
const QString text = data.block.text().mid(m_visualIndentOffset);
|
const QString text = data.block.text().mid(m_visualIndentOffset);
|
||||||
while (paintColumn < depth) {
|
while (paintColumn < depth) {
|
||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
@@ -4493,6 +4502,10 @@ void TextEditorWidgetPrivate::paintIndentDepth(PaintEventData &data,
|
|||||||
&& blockData.layout->lineForTextPosition(paintPosition).lineNumber() != 0) {
|
&& blockData.layout->lineForTextPosition(paintPosition).lineNumber() != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (cursorPositions.contains(paintPosition))
|
||||||
|
painter.setPen(cursorColor);
|
||||||
|
else
|
||||||
|
painter.setPen(normalColor);
|
||||||
const QPointF top(x, blockData.boundingRect.top());
|
const QPointF top(x, blockData.boundingRect.top());
|
||||||
const QPointF bottom(x, blockData.boundingRect.top() + rect.height());
|
const QPointF bottom(x, blockData.boundingRect.top() + rect.height());
|
||||||
const QLineF line(top, bottom);
|
const QLineF line(top, bottom);
|
||||||
|
Reference in New Issue
Block a user