Commit b448e6e7 authored by Marius Storm-Olsen's avatar Marius Storm-Olsen Committed by Thorbjørn Lindeijer
Browse files

Enable suppressing syntax and setting a foreground color on disabled blocks

If the foreground color for the disabled text is different than the normal
text foreground, that's an indication that the user wants the disabled
block to be colored differently. If so, disable the syntax highlighting
and set uniform colors for the block.

If the foreground colors are identical apply full syntax highlighting in
the disabled block too. Some people want that.

Reviewed-by: Thorbjørn Lindeijer
parent 181b086f
......@@ -2303,6 +2303,8 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
QPointF offset(contentOffset());
bool hasMainSelection = textCursor().hasSelection();
bool suppressSyntaxInIfdefedOutBlock = (d->m_ifdefedOutFormat.foreground()
!= palette().foreground());
QRect er = e->rect();
QRect viewportRect = viewport()->rect();
......@@ -2469,17 +2471,15 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
QTextLayout *layout = block.layout();
#if 0
QTextOption option = layout->textOption();
if (TextEditDocumentLayout::ifdefedOut(block)) {
option.setFlags(option.flags() /*| QTextOption::SuppressColors*/);
if (suppressSyntaxInIfdefedOutBlock && TextEditDocumentLayout::ifdefedOut(block)) {
option.setFlags(option.flags() | QTextOption::SuppressColors);
painter.setPen(d->m_ifdefedOutFormat.foreground().color());
} else {
option.setFlags(option.flags() & ~QTextOption::SuppressColors);
painter.setPen(context.palette.text().color());
}
layout->setTextOption(option);
#endif
int blpos = block.position();
int bllen = block.length();
......
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