forked from qt-creator/qt-creator
Editor: Make parenthese mismatch color configurable.
Task-number: QTCREATORBUG-14357 Change-Id: I92a0d50fb8f3448195f3d38f7544a31eb695733b Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
<style name="Occurrences.Rename" foreground="#ffaaaa" background="#553636"/>
|
||||
<style name="Operator" foreground="#aaaaaa"/>
|
||||
<style name="Parentheses" foreground="#ff5555" background="#333333"/>
|
||||
<style name="ParenthesesMismatch" background="#800080"/>
|
||||
<style name="Preprocessor" foreground="#5555ff"/>
|
||||
<style name="SearchResult" background="#555500"/>
|
||||
<style name="SearchScope" background="#222200"/>
|
||||
|
@@ -24,6 +24,7 @@
|
||||
<style name="Number" foreground="#3f3f3f"/>
|
||||
<style name="Operator"/>
|
||||
<style name="Parentheses" background="#e3e3e3" bold="true"/>
|
||||
<style name="ParenthesesMismatch" background="#808080"/>
|
||||
<style name="Preprocessor" foreground="#5b5b5b" bold="true"/>
|
||||
<style name="RemovedLine" foreground="#a0a0a4"/>
|
||||
<style name="Static" italic="true"/>
|
||||
|
@@ -32,6 +32,7 @@
|
||||
<style name="Occurrences.Unused" foreground="#808000"/>
|
||||
<style name="Operator" foreground="#cfbfad"/>
|
||||
<style name="Parentheses" foreground="#ffff00" background="#4e4e8f"/>
|
||||
<style name="ParenthesesMismatch" background="#404040"/>
|
||||
<style name="Preprocessor" foreground="#409090"/>
|
||||
<style name="RemovedLine" foreground="#ff0000"/>
|
||||
<style name="SearchResult" foreground="#000000" background="#ffef0b"/>
|
||||
|
@@ -16,6 +16,7 @@
|
||||
<style name="Number" foreground="#0000ff"/>
|
||||
<style name="Operator" foreground="#000000"/>
|
||||
<style name="Parentheses" foreground="#ff0000" background="#c3e1ff"/>
|
||||
<style name="ParenthesesMismatch" background="#ff00ff"/>
|
||||
<style name="Preprocessor" foreground="#000080" bold="true"/>
|
||||
<style name="RemovedLine" foreground="#ff0000"/>
|
||||
<style name="String" foreground="#008000" bold="true"/>
|
||||
|
@@ -179,7 +179,8 @@ QTextCharFormat FontSettings::toTextCharFormat(TextStyle category) const
|
||||
&& category != C_OCCURRENCES
|
||||
&& category != C_OCCURRENCES_RENAME
|
||||
&& category != C_OCCURRENCES_UNUSED
|
||||
&& category != C_SEARCH_RESULT)
|
||||
&& category != C_SEARCH_RESULT
|
||||
&& category != C_PARENTHESES_MISMATCH)
|
||||
tf.setForeground(f.foreground());
|
||||
if (f.background().isValid() && (category == C_TEXT || f.background() != m_scheme.formatFor(C_TEXT).background()))
|
||||
tf.setBackground(f.background());
|
||||
|
@@ -271,6 +271,8 @@ QColor FormatDescription::background() const
|
||||
return QColor(0xffef0b);
|
||||
} else if (m_id == C_PARENTHESES) {
|
||||
return QColor(0xb4, 0xee, 0xb4);
|
||||
} else if (m_id == C_PARENTHESES_MISMATCH) {
|
||||
return QColor(Qt::magenta);
|
||||
} else if (m_id == C_CURRENT_LINE || m_id == C_SEARCH_SCOPE) {
|
||||
const QPalette palette = QApplication::palette();
|
||||
const QColor &fg = palette.color(QPalette::Highlight);
|
||||
|
@@ -341,7 +341,6 @@ public:
|
||||
|
||||
// parentheses matcher
|
||||
bool m_formatRange;
|
||||
QTextCharFormat m_mismatchFormat;
|
||||
QTimer m_parenthesesMatchingTimer;
|
||||
// end parentheses matcher
|
||||
|
||||
@@ -660,8 +659,6 @@ void TextEditorWidgetPrivate::ctor(const QSharedPointer<TextDocument> &doc)
|
||||
|
||||
// parentheses matcher
|
||||
m_formatRange = true;
|
||||
m_mismatchFormat.setBackground(q->palette().color(QPalette::Base).value() < 128
|
||||
? Qt::darkMagenta : Qt::magenta);
|
||||
m_parenthesesMatchingTimer.setSingleShot(true);
|
||||
QObject::connect(&m_parenthesesMatchingTimer, &QTimer::timeout,
|
||||
this, &TextEditorWidgetPrivate::_q_matchParentheses);
|
||||
@@ -5605,12 +5602,14 @@ void TextEditorWidgetPrivate::_q_matchParentheses()
|
||||
|
||||
const QTextCharFormat &matchFormat
|
||||
= q->textDocument()->fontSettings().toTextCharFormat(C_PARENTHESES);
|
||||
const QTextCharFormat &mismatchFormat
|
||||
= q->textDocument()->fontSettings().toTextCharFormat(C_PARENTHESES_MISMATCH);
|
||||
int animatePosition = -1;
|
||||
if (backwardMatch.hasSelection()) {
|
||||
QTextEdit::ExtraSelection sel;
|
||||
if (backwardMatchType == TextBlockUserData::Mismatch) {
|
||||
sel.cursor = backwardMatch;
|
||||
sel.format = m_mismatchFormat;
|
||||
sel.format = mismatchFormat;
|
||||
extraSelections.append(sel);
|
||||
} else {
|
||||
|
||||
@@ -5634,7 +5633,7 @@ void TextEditorWidgetPrivate::_q_matchParentheses()
|
||||
QTextEdit::ExtraSelection sel;
|
||||
if (forwardMatchType == TextBlockUserData::Mismatch) {
|
||||
sel.cursor = forwardMatch;
|
||||
sel.format = m_mismatchFormat;
|
||||
sel.format = mismatchFormat;
|
||||
extraSelections.append(sel);
|
||||
} else {
|
||||
|
||||
|
@@ -46,6 +46,7 @@ const char *nameForStyle(TextStyle style)
|
||||
case C_SEARCH_RESULT: return "SearchResult";
|
||||
case C_SEARCH_SCOPE: return "SearchScope";
|
||||
case C_PARENTHESES: return "Parentheses";
|
||||
case C_PARENTHESES_MISMATCH:return "ParenthesesMismatch";
|
||||
case C_CURRENT_LINE: return "CurrentLine";
|
||||
case C_CURRENT_LINE_NUMBER: return "CurrentLineNumber";
|
||||
case C_OCCURRENCES: return "Occurrences";
|
||||
|
@@ -45,6 +45,7 @@ enum TextStyle {
|
||||
C_SEARCH_RESULT,
|
||||
C_SEARCH_SCOPE,
|
||||
C_PARENTHESES,
|
||||
C_PARENTHESES_MISMATCH,
|
||||
C_CURRENT_LINE,
|
||||
C_CURRENT_LINE_NUMBER,
|
||||
C_OCCURRENCES,
|
||||
|
@@ -117,6 +117,9 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
|
||||
formatDescr.append(FormatDescription(C_PARENTHESES, tr("Parentheses"),
|
||||
tr("Displayed when matching parentheses, square brackets "
|
||||
"or curly brackets are found.")));
|
||||
formatDescr.append(FormatDescription(C_PARENTHESES_MISMATCH, tr("Mismatched Parentheses"),
|
||||
tr("Displayed when mismatched parentheses, "
|
||||
"square brackets, or curly brackets are found.")));
|
||||
formatDescr.append(FormatDescription(C_CURRENT_LINE, tr("Current Line"),
|
||||
tr("Line where the cursor is placed in.")));
|
||||
|
||||
|
Reference in New Issue
Block a user