forked from qt-creator/qt-creator
make auto parentheses opt-in for individual editors. Currently
its only turned on in the cpp editor.
This commit is contained in:
@@ -536,6 +536,7 @@ CPPEditor::CPPEditor(QWidget *parent)
|
|||||||
m_semanticHighlighter->start();
|
m_semanticHighlighter->start();
|
||||||
|
|
||||||
setParenthesesMatchingEnabled(true);
|
setParenthesesMatchingEnabled(true);
|
||||||
|
setAutoParenthesesEnabled(true);
|
||||||
setMarksVisible(true);
|
setMarksVisible(true);
|
||||||
setCodeFoldingSupported(true);
|
setCodeFoldingSupported(true);
|
||||||
setCodeFoldingVisible(true);
|
setCodeFoldingVisible(true);
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ BaseTextEditor::BaseTextEditor(QWidget *parent)
|
|||||||
// (void) new QShortcut(tr("F11"), this, SLOT(slotToggleBlockVisible()));
|
// (void) new QShortcut(tr("F11"), this, SLOT(slotToggleBlockVisible()));
|
||||||
|
|
||||||
|
|
||||||
|
d->m_autoParenthesesEnabled = false;
|
||||||
// parentheses matcher
|
// parentheses matcher
|
||||||
d->m_parenthesesMatchingEnabled = false;
|
d->m_parenthesesMatchingEnabled = false;
|
||||||
d->m_formatRange = true;
|
d->m_formatRange = true;
|
||||||
@@ -890,7 +891,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
|
|||||||
const TabSettings &ts = d->m_document->tabSettings();
|
const TabSettings &ts = d->m_document->tabSettings();
|
||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
|
|
||||||
if (ts.m_autoParentheses
|
if (d->m_autoParenthesesEnabled && ts.m_autoParentheses
|
||||||
&& characterAt(cursor.position()) == QLatin1Char('}')) {
|
&& characterAt(cursor.position()) == QLatin1Char('}')) {
|
||||||
int pos = cursor.position();
|
int pos = cursor.position();
|
||||||
if (ts.m_autoIndent) {
|
if (ts.m_autoIndent) {
|
||||||
@@ -1059,7 +1060,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
|
|||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
QString text = e->text();
|
QString text = e->text();
|
||||||
QString autoText;
|
QString autoText;
|
||||||
if (d->m_document->tabSettings().m_autoParentheses) {
|
if (d->m_autoParenthesesEnabled && d->m_document->tabSettings().m_autoParentheses) {
|
||||||
foreach(QChar c, text) {
|
foreach(QChar c, text) {
|
||||||
QChar close;
|
QChar close;
|
||||||
if (c == QLatin1Char('{'))
|
if (c == QLatin1Char('{'))
|
||||||
@@ -1312,6 +1313,16 @@ bool BaseTextEditor::isParenthesesMatchingEnabled() const
|
|||||||
return d->m_parenthesesMatchingEnabled;
|
return d->m_parenthesesMatchingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseTextEditor::setAutoParenthesesEnabled(bool b)
|
||||||
|
{
|
||||||
|
d->m_autoParenthesesEnabled = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BaseTextEditor::isAutoParenthesesEnabled() const
|
||||||
|
{
|
||||||
|
return d->m_autoParenthesesEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
void BaseTextEditor::setHighlightCurrentLine(bool b)
|
void BaseTextEditor::setHighlightCurrentLine(bool b)
|
||||||
{
|
{
|
||||||
d->m_highlightCurrentLine = b;
|
d->m_highlightCurrentLine = b;
|
||||||
|
|||||||
@@ -322,6 +322,9 @@ public:
|
|||||||
void setParenthesesMatchingEnabled(bool b);
|
void setParenthesesMatchingEnabled(bool b);
|
||||||
bool isParenthesesMatchingEnabled() const;
|
bool isParenthesesMatchingEnabled() const;
|
||||||
|
|
||||||
|
void setAutoParenthesesEnabled(bool b);
|
||||||
|
bool isAutoParenthesesEnabled() const;
|
||||||
|
|
||||||
void setHighlightCurrentLine(bool b);
|
void setHighlightCurrentLine(bool b);
|
||||||
bool highlightCurrentLine() const;
|
bool highlightCurrentLine() const;
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ public:
|
|||||||
|
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
bool m_parenthesesMatchingEnabled;
|
bool m_parenthesesMatchingEnabled;
|
||||||
|
bool m_autoParenthesesEnabled;
|
||||||
QTimer *m_updateTimer;
|
QTimer *m_updateTimer;
|
||||||
|
|
||||||
// parentheses matcher
|
// parentheses matcher
|
||||||
|
|||||||
Reference in New Issue
Block a user