forked from qt-creator/qt-creator
Add Highlight Matching Parentheses setting
Task-number: QTCREATORBUG-8008 Change-Id: If1989eb850e82636c735a319bc7c4950a01dd33c Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
committed by
David Schulz
parent
f1cd57e2b2
commit
6a90a1a740
@@ -4071,7 +4071,14 @@ void BaseTextEditorWidget::updateHighlights()
|
|||||||
&& d->m_animator == 0) {
|
&& d->m_animator == 0) {
|
||||||
d->m_parenthesesMatchingTimer->start(50);
|
d->m_parenthesesMatchingTimer->start(50);
|
||||||
} else {
|
} else {
|
||||||
// use 0-timer, not direct call, to give the syntax highlighter a chance
|
// when we uncheck "highlight matching parentheses"
|
||||||
|
// we need clear current selection before viewport update
|
||||||
|
// otherwise we get sticky highlighted parentheses
|
||||||
|
if (!d->m_displaySettings.m_highlightMatchingParentheses) {
|
||||||
|
setExtraSelections(ParenthesesMatchingSelection, QList<QTextEdit::ExtraSelection>());
|
||||||
|
}
|
||||||
|
|
||||||
|
// use 0-timer, not direct call, to give the syntax highlighter a chance
|
||||||
// to update the parentheses information
|
// to update the parentheses information
|
||||||
d->m_parenthesesMatchingTimer->start(0);
|
d->m_parenthesesMatchingTimer->start(0);
|
||||||
}
|
}
|
||||||
@@ -5060,7 +5067,9 @@ void BaseTextEditorAnimator::finish()
|
|||||||
|
|
||||||
void BaseTextEditorWidget::_q_matchParentheses()
|
void BaseTextEditorWidget::_q_matchParentheses()
|
||||||
{
|
{
|
||||||
if (isReadOnly())
|
if (isReadOnly()
|
||||||
|
|| !(d->m_displaySettings.m_highlightMatchingParentheses
|
||||||
|
|| d->m_displaySettings.m_animateMatchingParentheses))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QTextCursor backwardMatch = textCursor();
|
QTextCursor backwardMatch = textCursor();
|
||||||
@@ -5149,8 +5158,8 @@ void BaseTextEditorWidget::_q_matchParentheses()
|
|||||||
connect(d->m_animator, SIGNAL(updateRequest(int,QPointF,QRectF)),
|
connect(d->m_animator, SIGNAL(updateRequest(int,QPointF,QRectF)),
|
||||||
this, SLOT(_q_animateUpdate(int,QPointF,QRectF)));
|
this, SLOT(_q_animateUpdate(int,QPointF,QRectF)));
|
||||||
}
|
}
|
||||||
|
if (d->m_displaySettings.m_highlightMatchingParentheses)
|
||||||
setExtraSelections(ParenthesesMatchingSelection, extraSelections);
|
setExtraSelections(ParenthesesMatchingSelection, extraSelections);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextEditorWidget::_q_highlightBlocks()
|
void BaseTextEditorWidget::_q_highlightBlocks()
|
||||||
|
@@ -41,6 +41,7 @@ static const char displayFoldingMarkersKey[] = "DisplayFoldingMarkers";
|
|||||||
static const char highlightCurrentLineKey[] = "HighlightCurrentLine2Key";
|
static const char highlightCurrentLineKey[] = "HighlightCurrentLine2Key";
|
||||||
static const char highlightBlocksKey[] = "HighlightBlocksKey";
|
static const char highlightBlocksKey[] = "HighlightBlocksKey";
|
||||||
static const char animateMatchingParenthesesKey[] = "AnimateMatchingParenthesesKey";
|
static const char animateMatchingParenthesesKey[] = "AnimateMatchingParenthesesKey";
|
||||||
|
static const char highlightMatchingParenthesesKey[] = "HightlightMatchingParenthesesKey";
|
||||||
static const char markTextChangesKey[] = "MarkTextChanges";
|
static const char markTextChangesKey[] = "MarkTextChanges";
|
||||||
static const char autoFoldFirstCommentKey[] = "AutoFoldFirstComment";
|
static const char autoFoldFirstCommentKey[] = "AutoFoldFirstComment";
|
||||||
static const char centerCursorOnScrollKey[] = "CenterCursorOnScroll";
|
static const char centerCursorOnScrollKey[] = "CenterCursorOnScroll";
|
||||||
@@ -58,6 +59,7 @@ DisplaySettings::DisplaySettings() :
|
|||||||
m_highlightCurrentLine(false),
|
m_highlightCurrentLine(false),
|
||||||
m_highlightBlocks(false),
|
m_highlightBlocks(false),
|
||||||
m_animateMatchingParentheses(true),
|
m_animateMatchingParentheses(true),
|
||||||
|
m_highlightMatchingParentheses(true),
|
||||||
m_markTextChanges(true),
|
m_markTextChanges(true),
|
||||||
m_autoFoldFirstComment(true),
|
m_autoFoldFirstComment(true),
|
||||||
m_centerCursorOnScroll(false)
|
m_centerCursorOnScroll(false)
|
||||||
@@ -79,6 +81,7 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const
|
|||||||
s->setValue(QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine);
|
s->setValue(QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine);
|
||||||
s->setValue(QLatin1String(highlightBlocksKey), m_highlightBlocks);
|
s->setValue(QLatin1String(highlightBlocksKey), m_highlightBlocks);
|
||||||
s->setValue(QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses);
|
s->setValue(QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses);
|
||||||
|
s->setValue(QLatin1String(highlightMatchingParenthesesKey), m_highlightMatchingParentheses);
|
||||||
s->setValue(QLatin1String(markTextChangesKey), m_markTextChanges);
|
s->setValue(QLatin1String(markTextChangesKey), m_markTextChanges);
|
||||||
s->setValue(QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment);
|
s->setValue(QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment);
|
||||||
s->setValue(QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll);
|
s->setValue(QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll);
|
||||||
@@ -103,6 +106,7 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s)
|
|||||||
m_highlightCurrentLine = s->value(group + QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine).toBool();
|
m_highlightCurrentLine = s->value(group + QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine).toBool();
|
||||||
m_highlightBlocks = s->value(group + QLatin1String(highlightBlocksKey), m_highlightBlocks).toBool();
|
m_highlightBlocks = s->value(group + QLatin1String(highlightBlocksKey), m_highlightBlocks).toBool();
|
||||||
m_animateMatchingParentheses = s->value(group + QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses).toBool();
|
m_animateMatchingParentheses = s->value(group + QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses).toBool();
|
||||||
|
m_highlightMatchingParentheses = s->value(group + QLatin1String(highlightMatchingParenthesesKey), m_highlightMatchingParentheses).toBool();
|
||||||
m_markTextChanges = s->value(group + QLatin1String(markTextChangesKey), m_markTextChanges).toBool();
|
m_markTextChanges = s->value(group + QLatin1String(markTextChangesKey), m_markTextChanges).toBool();
|
||||||
m_autoFoldFirstComment = s->value(group + QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment).toBool();
|
m_autoFoldFirstComment = s->value(group + QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment).toBool();
|
||||||
m_centerCursorOnScroll = s->value(group + QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll).toBool();
|
m_centerCursorOnScroll = s->value(group + QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll).toBool();
|
||||||
@@ -119,6 +123,7 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const
|
|||||||
&& m_highlightCurrentLine == ds.m_highlightCurrentLine
|
&& m_highlightCurrentLine == ds.m_highlightCurrentLine
|
||||||
&& m_highlightBlocks == ds.m_highlightBlocks
|
&& m_highlightBlocks == ds.m_highlightBlocks
|
||||||
&& m_animateMatchingParentheses == ds.m_animateMatchingParentheses
|
&& m_animateMatchingParentheses == ds.m_animateMatchingParentheses
|
||||||
|
&& m_highlightMatchingParentheses == ds.m_highlightMatchingParentheses
|
||||||
&& m_markTextChanges == ds.m_markTextChanges
|
&& m_markTextChanges == ds.m_markTextChanges
|
||||||
&& m_autoFoldFirstComment== ds.m_autoFoldFirstComment
|
&& m_autoFoldFirstComment== ds.m_autoFoldFirstComment
|
||||||
&& m_centerCursorOnScroll == ds.m_centerCursorOnScroll
|
&& m_centerCursorOnScroll == ds.m_centerCursorOnScroll
|
||||||
|
@@ -55,6 +55,7 @@ public:
|
|||||||
bool m_highlightCurrentLine;
|
bool m_highlightCurrentLine;
|
||||||
bool m_highlightBlocks;
|
bool m_highlightBlocks;
|
||||||
bool m_animateMatchingParentheses;
|
bool m_animateMatchingParentheses;
|
||||||
|
bool m_highlightMatchingParentheses;
|
||||||
bool m_markTextChanges;
|
bool m_markTextChanges;
|
||||||
bool m_autoFoldFirstComment;
|
bool m_autoFoldFirstComment;
|
||||||
bool m_centerCursorOnScroll;
|
bool m_centerCursorOnScroll;
|
||||||
|
@@ -82,6 +82,7 @@ QWidget *DisplaySettingsPage::createPage(QWidget *parent)
|
|||||||
<< ' ' << d->m_page->highlightBlocks->text()
|
<< ' ' << d->m_page->highlightBlocks->text()
|
||||||
<< ' ' << d->m_page->visualizeWhitespace->text()
|
<< ' ' << d->m_page->visualizeWhitespace->text()
|
||||||
<< ' ' << d->m_page->animateMatchingParentheses->text()
|
<< ' ' << d->m_page->animateMatchingParentheses->text()
|
||||||
|
<< ' ' << d->m_page->highlightMatchingParentheses->text()
|
||||||
<< ' ' << d->m_page->enableTextWrapping->text()
|
<< ' ' << d->m_page->enableTextWrapping->text()
|
||||||
<< ' ' << d->m_page->autoFoldFirstComment->text()
|
<< ' ' << d->m_page->autoFoldFirstComment->text()
|
||||||
<< ' ' << d->m_page->centerOnScroll->text();
|
<< ' ' << d->m_page->centerOnScroll->text();
|
||||||
@@ -119,6 +120,7 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
|
|||||||
displaySettings.m_highlightCurrentLine = d->m_page->highlightCurrentLine->isChecked();
|
displaySettings.m_highlightCurrentLine = d->m_page->highlightCurrentLine->isChecked();
|
||||||
displaySettings.m_highlightBlocks = d->m_page->highlightBlocks->isChecked();
|
displaySettings.m_highlightBlocks = d->m_page->highlightBlocks->isChecked();
|
||||||
displaySettings.m_animateMatchingParentheses = d->m_page->animateMatchingParentheses->isChecked();
|
displaySettings.m_animateMatchingParentheses = d->m_page->animateMatchingParentheses->isChecked();
|
||||||
|
displaySettings.m_highlightMatchingParentheses = d->m_page->highlightMatchingParentheses->isChecked();
|
||||||
displaySettings.m_markTextChanges = d->m_page->markTextChanges->isChecked();
|
displaySettings.m_markTextChanges = d->m_page->markTextChanges->isChecked();
|
||||||
displaySettings.m_autoFoldFirstComment = d->m_page->autoFoldFirstComment->isChecked();
|
displaySettings.m_autoFoldFirstComment = d->m_page->autoFoldFirstComment->isChecked();
|
||||||
displaySettings.m_centerCursorOnScroll = d->m_page->centerOnScroll->isChecked();
|
displaySettings.m_centerCursorOnScroll = d->m_page->centerOnScroll->isChecked();
|
||||||
@@ -136,6 +138,7 @@ void DisplaySettingsPage::settingsToUI()
|
|||||||
d->m_page->highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine);
|
d->m_page->highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine);
|
||||||
d->m_page->highlightBlocks->setChecked(displaySettings.m_highlightBlocks);
|
d->m_page->highlightBlocks->setChecked(displaySettings.m_highlightBlocks);
|
||||||
d->m_page->animateMatchingParentheses->setChecked(displaySettings.m_animateMatchingParentheses);
|
d->m_page->animateMatchingParentheses->setChecked(displaySettings.m_animateMatchingParentheses);
|
||||||
|
d->m_page->highlightMatchingParentheses->setChecked(displaySettings.m_highlightMatchingParentheses);
|
||||||
d->m_page->markTextChanges->setChecked(displaySettings.m_markTextChanges);
|
d->m_page->markTextChanges->setChecked(displaySettings.m_markTextChanges);
|
||||||
d->m_page->autoFoldFirstComment->setChecked(displaySettings.m_autoFoldFirstComment);
|
d->m_page->autoFoldFirstComment->setChecked(displaySettings.m_autoFoldFirstComment);
|
||||||
d->m_page->centerOnScroll->setChecked(displaySettings.m_centerCursorOnScroll);
|
d->m_page->centerOnScroll->setChecked(displaySettings.m_centerCursorOnScroll);
|
||||||
|
@@ -6,11 +6,61 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>450</width>
|
<width>471</width>
|
||||||
<height>288</height>
|
<height>288</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBoxText">
|
||||||
|
<property name="title">
|
||||||
|
<string>Text Wrapping</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="enableTextWrapping">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable text &wrapping</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="showWrapColumn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Display right &margin at column:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="wrapColumn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>999</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@@ -82,13 +132,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QCheckBox" name="autoFoldFirstComment">
|
|
||||||
<property name="text">
|
|
||||||
<string>Auto-fold first &comment</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QCheckBox" name="centerOnScroll">
|
<widget class="QCheckBox" name="centerOnScroll">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -96,55 +139,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<item row="5" column="1">
|
||||||
</widget>
|
<widget class="QCheckBox" name="autoFoldFirstComment">
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QGroupBox" name="groupBoxText">
|
|
||||||
<property name="title">
|
|
||||||
<string>Text Wrapping</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QCheckBox" name="enableTextWrapping">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable text &wrapping</string>
|
<string>Auto-fold first &comment</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="4" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<widget class="QCheckBox" name="highlightMatchingParentheses">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QCheckBox" name="showWrapColumn">
|
<string>&Highlight matching parentheses</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Display right &margin at column:</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="wrapColumn">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>999</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Reference in New Issue
Block a user