diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index bca53785faf..7d611193001 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -1216,21 +1216,6 @@ bool BaseTextEditor::lineSeparatorsAllowed() const
return d->m_lineSeparatorsAllowed;
}
-void BaseTextEditor::setHighlightBlocks(bool b)
-{
- if (d->m_highlightBlocks == b)
- return;
- d->m_highlightBlocks = b;
- d->extraAreaHighlightCollapseBlockNumber = -1;
- _q_highlightBlocks();
-}
-
-bool BaseTextEditor::highlightBlocks() const
-{
- return d->m_highlightBlocks;
-}
-
-
void BaseTextEditor::setCodeFoldingVisible(bool b)
{
d->m_codeFoldingVisible = b && d->m_codeFoldingSupported;
@@ -1293,7 +1278,6 @@ BaseTextEditorPrivate::BaseTextEditorPrivate()
m_marksVisible(false),
m_codeFoldingVisible(false),
m_codeFoldingSupported(false),
- m_highlightBlocks(false),
m_revisionsVisible(false),
m_lineNumbersVisible(true),
m_highlightCurrentLine(true),
@@ -2498,7 +2482,7 @@ void BaseTextEditor::slotCursorPositionChanged()
setExtraSelections(CurrentLineSelection, extraSelections);
- if (d->m_highlightBlocks) {
+ if (d->m_displaySettings.m_highlightBlocks) {
QTextCursor cursor = textCursor();
d->extraAreaHighlightCollapseBlockNumber = cursor.blockNumber();
d->extraAreaHighlightCollapseColumn = cursor.position() - cursor.block().position();
@@ -2633,7 +2617,7 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
d->extraAreaHighlightCollapseBlockNumber = -1;
d->extraAreaHighlightCollapseColumn = -1;
- if (d->m_highlightBlocks) {
+ if (d->m_displaySettings.m_highlightBlocks) {
QTextCursor cursor = textCursor();
d->extraAreaHighlightCollapseBlockNumber = cursor.blockNumber();
d->extraAreaHighlightCollapseColumn = cursor.position() - cursor.block().position();
@@ -3224,7 +3208,7 @@ bool TextBlockUserData::findPreviousOpenParenthesis(QTextCursor *cursor, bool se
bool TextBlockUserData::findPreviousBlockOpenParenthesis(QTextCursor *cursor, bool checkStartPosition)
{
QTextBlock block = cursor->block();
- int position = cursor->position() + (checkStartPosition ? 1 : 0 );
+ int position = cursor->position();
int ignore = 0;
while (block.isValid()) {
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
@@ -3234,9 +3218,12 @@ bool TextBlockUserData::findPreviousBlockOpenParenthesis(QTextCursor *cursor, bo
if (paren.chr != QLatin1Char('{') && paren.chr != QLatin1Char('}')
&& paren.chr != QLatin1Char('+') && paren.chr != QLatin1Char('-'))
continue;
- if (block == cursor->block() &&
- (position - block.position() <= paren.pos + (paren.type == Parenthesis::Closed ? 1 : 0)))
+ if (block == cursor->block()) {
+ if (position - block.position() <= paren.pos + (paren.type == Parenthesis::Closed ? 1 : 0))
continue;
+ if (checkStartPosition && paren.type == Parenthesis::Opened && position == cursor->position())
+ return true;
+ }
if (paren.type == Parenthesis::Closed) {
++ignore;
} else if (ignore > 0) {
@@ -3389,7 +3376,7 @@ BaseTextEditorAnimator::BaseTextEditorAnimator(QObject *parent)
:QObject(parent)
{
m_value = 0;
- m_timeline = new QTimeLine(500, this);
+ m_timeline = new QTimeLine(256, this);
m_timeline->setCurveShape(QTimeLine::SineCurve);
connect(m_timeline, SIGNAL(valueChanged(qreal)), this, SLOT(step(qreal)));
connect(m_timeline, SIGNAL(finished()), this, SLOT(deleteLater()));
@@ -3410,7 +3397,7 @@ void BaseTextEditorAnimator::draw(QPainter *p, const QPointF &pos)
{
p->setPen(m_palette.text().color());
QFont f = m_font;
- f.setPointSizeF(f.pointSizeF() * (1.0 + m_value));
+ f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2));
QFontMetrics fm(f);
int width = fm.width(m_text);
QRectF r((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height());
@@ -3428,7 +3415,7 @@ bool BaseTextEditorAnimator::isRunning() const
QRectF BaseTextEditorAnimator::rect() const
{
QFont f = m_font;
- f.setPointSizeF(f.pointSizeF() * (1.0 + m_value));
+ f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2));
QFontMetrics fm(f);
int width = fm.width(m_text);
return QRectF((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height());
@@ -3474,12 +3461,13 @@ void BaseTextEditor::_q_matchParentheses()
sel.format = d->m_mismatchFormat;
} else {
-// if (d->m_formatRange) {
-// sel.cursor = backwardMatch;
-// sel.format = d->m_rangeFormat;
-// extraSelections.append(sel);
-// }
- animatePosition = backwardMatch.selectionStart();
+ if (d->m_displaySettings.m_animateMatchingParentheses) {
+ animatePosition = backwardMatch.selectionStart();
+ } else if (d->m_formatRange) {
+ sel.cursor = backwardMatch;
+ sel.format = d->m_rangeFormat;
+ extraSelections.append(sel);
+ }
sel.cursor = backwardMatch;
sel.format = d->m_matchFormat;
@@ -3501,13 +3489,13 @@ void BaseTextEditor::_q_matchParentheses()
sel.format = d->m_mismatchFormat;
} else {
- animatePosition = forwardMatch.selectionEnd()-1;
-
-// if (d->m_formatRange) {
-// sel.cursor = forwardMatch;
-// sel.format = d->m_rangeFormat;
-// extraSelections.append(sel);
-// }
+ if (d->m_displaySettings.m_animateMatchingParentheses) {
+ animatePosition = forwardMatch.selectionEnd()-1;
+ } else if (d->m_formatRange) {
+ sel.cursor = forwardMatch;
+ sel.format = d->m_rangeFormat;
+ extraSelections.append(sel);
+ }
sel.cursor = forwardMatch;
sel.format = d->m_matchFormat;
@@ -3535,7 +3523,7 @@ void BaseTextEditor::_q_matchParentheses()
d->m_animator->setData(font(), pal, characterAt(d->m_animator->position()));
connect(d->m_animator, SIGNAL(updateRequest(int,QRectF)),
this, SLOT(_q_animateUpdate(int,QRectF)));
- }
+ }
}
@@ -3550,7 +3538,7 @@ void BaseTextEditor::_q_highlightBlocks()
QTextCursor cursor(block);
if (d->extraAreaHighlightCollapseColumn >= 0)
cursor.setPosition(cursor.position() + qMin(d->extraAreaHighlightCollapseColumn,
- block.length()));
+ block.length()-1));
QTextCursor closeCursor;
bool firstRun = true;
while (TextBlockUserData::findPreviousBlockOpenParenthesis(&cursor, firstRun)) {
@@ -3740,7 +3728,6 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds)
setVisibleWrapColumn(ds.m_showWrapColumn ? ds.m_wrapColumn : 0);
setCodeFoldingVisible(ds.m_displayFoldingMarkers);
setHighlightCurrentLine(ds.m_highlightCurrentLine);
- setHighlightBlocks(ds.m_highlightBlocks);
if (d->m_displaySettings.m_visualizeWhitespace != ds.m_visualizeWhitespace) {
if (QSyntaxHighlighter *highlighter = baseTextDocument()->syntaxHighlighter())
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index 5ed1fc91b7a..1c02c6ce4a6 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -310,9 +310,6 @@ public:
void setHighlightCurrentLine(bool b);
bool highlightCurrentLine() const;
- void setHighlightBlocks(bool b);
- bool highlightBlocks() const;
-
void setLineNumbersVisible(bool b);
bool lineNumbersVisible() const;
diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h
index 7d3f15402e6..80422f88a61 100644
--- a/src/plugins/texteditor/basetexteditor_p.h
+++ b/src/plugins/texteditor/basetexteditor_p.h
@@ -195,7 +195,6 @@ public:
uint m_marksVisible : 1;
uint m_codeFoldingVisible : 1;
uint m_codeFoldingSupported : 1;
- uint m_highlightBlocks : 1;
uint m_revisionsVisible : 1;
uint m_lineNumbersVisible : 1;
uint m_highlightCurrentLine : 1;
diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp
index 22b85d4f841..b0273a2c887 100644
--- a/src/plugins/texteditor/displaysettings.cpp
+++ b/src/plugins/texteditor/displaysettings.cpp
@@ -42,6 +42,7 @@ static const char * const visualizeWhitespaceKey = "VisualizeWhitespace";
static const char * const displayFoldingMarkersKey = "DisplayFoldingMarkers";
static const char * const highlightCurrentLineKey = "HighlightCurrentLineKeyV2";
static const char * const highlightBlocksKey = "HighlightBlocksKey";
+static const char * const animateMatchingParenthesesKey= "AnimateMatchingParenthesesKey";
static const char * const groupPostfix = "DisplaySettings";
namespace TextEditor {
@@ -54,7 +55,8 @@ DisplaySettings::DisplaySettings() :
m_visualizeWhitespace(false),
m_displayFoldingMarkers(true),
m_highlightCurrentLine(false),
- m_highlightBlocks(false)
+ m_highlightBlocks(false),
+ m_animateMatchingParentheses(true)
{
}
@@ -72,6 +74,7 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const
s->setValue(QLatin1String(displayFoldingMarkersKey), m_displayFoldingMarkers);
s->setValue(QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine);
s->setValue(QLatin1String(highlightBlocksKey), m_highlightBlocks);
+ s->setValue(QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses);
s->endGroup();
}
@@ -92,6 +95,7 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s)
m_displayFoldingMarkers = s->value(group + QLatin1String(displayFoldingMarkersKey), m_displayFoldingMarkers).toBool();
m_highlightCurrentLine = s->value(group + QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine).toBool();
m_highlightBlocks = s->value(group + QLatin1String(highlightBlocksKey), m_highlightBlocks).toBool();
+ m_animateMatchingParentheses = s->value(group + QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses).toBool();
}
bool DisplaySettings::equals(const DisplaySettings &ds) const
@@ -104,6 +108,7 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const
&& m_displayFoldingMarkers == ds.m_displayFoldingMarkers
&& m_highlightCurrentLine == ds.m_highlightCurrentLine
&& m_highlightBlocks == ds.m_highlightBlocks
+ && m_animateMatchingParentheses == ds.m_animateMatchingParentheses
;
}
diff --git a/src/plugins/texteditor/displaysettings.h b/src/plugins/texteditor/displaysettings.h
index 0601f905b9f..06a7d0fa381 100644
--- a/src/plugins/texteditor/displaysettings.h
+++ b/src/plugins/texteditor/displaysettings.h
@@ -53,6 +53,7 @@ struct TEXTEDITOR_EXPORT DisplaySettings
bool m_displayFoldingMarkers;
bool m_highlightCurrentLine;
bool m_highlightBlocks;
+ bool m_animateMatchingParentheses;
bool equals(const DisplaySettings &ds) const;
};
diff --git a/src/plugins/texteditor/displaysettingspage.cpp b/src/plugins/texteditor/displaysettingspage.cpp
index b1ba03ce7fc..ec7ae6a2210 100644
--- a/src/plugins/texteditor/displaysettingspage.cpp
+++ b/src/plugins/texteditor/displaysettingspage.cpp
@@ -123,6 +123,7 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
displaySettings.m_displayFoldingMarkers = m_d->m_page.displayFoldingMarkers->isChecked();
displaySettings.m_highlightCurrentLine = m_d->m_page.highlightCurrentLine->isChecked();
displaySettings.m_highlightBlocks = m_d->m_page.highlightBlocks->isChecked();
+ displaySettings.m_animateMatchingParentheses= m_d->m_page.animateMatchingParentheses->isChecked();
}
void DisplaySettingsPage::settingsToUI()
@@ -136,6 +137,7 @@ void DisplaySettingsPage::settingsToUI()
m_d->m_page.displayFoldingMarkers->setChecked(displaySettings.m_displayFoldingMarkers);
m_d->m_page.highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine);
m_d->m_page.highlightBlocks->setChecked(displaySettings.m_highlightBlocks);
+ m_d->m_page.animateMatchingParentheses->setChecked(displaySettings.m_animateMatchingParentheses);
}
DisplaySettings DisplaySettingsPage::displaySettings() const
diff --git a/src/plugins/texteditor/displaysettingspage.ui b/src/plugins/texteditor/displaysettingspage.ui
index eb6caa2a211..5524172fcfb 100644
--- a/src/plugins/texteditor/displaysettingspage.ui
+++ b/src/plugins/texteditor/displaysettingspage.ui
@@ -7,7 +7,7 @@
0
0
381
- 279
+ 302
@@ -28,7 +28,7 @@
-
-
+
Display
@@ -71,11 +71,18 @@
+ -
+
+
+ Animate matching parentheses
+
+
+
-
-
+
Text Wrapping