forked from qt-creator/qt-creator
Merge remote branch 'origin/2.0'
Conflicts: src/plugins/cpptools/cppcodecompletion.cpp
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "basetexteditor_p.h"
|
||||
#include "behaviorsettings.h"
|
||||
#include "codecselector.h"
|
||||
#include "completionsettings.h"
|
||||
#include "completionsupport.h"
|
||||
#include "tabsettings.h"
|
||||
#include "texteditorconstants.h"
|
||||
@@ -179,7 +180,7 @@ static void convertToPlainText(QString &txt)
|
||||
BaseTextEditor::BaseTextEditor(QWidget *parent)
|
||||
: QPlainTextEdit(parent)
|
||||
{
|
||||
d = new BaseTextEditorPrivate();
|
||||
d = new BaseTextEditorPrivate;
|
||||
d->q = this;
|
||||
d->m_extraArea = new TextEditExtraArea(this);
|
||||
d->m_extraArea->setMouseTracking(true);
|
||||
@@ -195,8 +196,6 @@ BaseTextEditor::BaseTextEditor(QWidget *parent)
|
||||
d->m_lastScrollPos = -1;
|
||||
setCursorWidth(2);
|
||||
|
||||
d->m_allowSkippingOfBlockEnd = false;
|
||||
|
||||
// from RESEARCH
|
||||
|
||||
setLayoutDirection(Qt::LeftToRight);
|
||||
@@ -221,7 +220,6 @@ BaseTextEditor::BaseTextEditor(QWidget *parent)
|
||||
|
||||
|
||||
// parentheses matcher
|
||||
d->m_parenthesesMatchingEnabled = false;
|
||||
d->m_formatRange = true;
|
||||
d->m_matchFormat.setForeground(Qt::red);
|
||||
d->m_rangeFormat.setBackground(QColor(0xb4, 0xee, 0xb4));
|
||||
@@ -1709,6 +1707,16 @@ bool BaseTextEditor::isParenthesesMatchingEnabled() const
|
||||
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)
|
||||
{
|
||||
d->m_highlightCurrentLine = b;
|
||||
@@ -1837,8 +1845,10 @@ BaseTextEditorPrivate::BaseTextEditorPrivate()
|
||||
:
|
||||
m_contentsChanged(false),
|
||||
m_lastCursorChangeWasInteresting(false),
|
||||
m_document(new BaseTextDocument()),
|
||||
m_allowSkippingOfBlockEnd(false),
|
||||
m_document(new BaseTextDocument),
|
||||
m_parenthesesMatchingEnabled(false),
|
||||
m_autoParenthesesEnabled(true),
|
||||
m_extraArea(0),
|
||||
m_mouseOnCollapsedMarker(false),
|
||||
m_marksVisible(false),
|
||||
@@ -3889,13 +3899,16 @@ QString BaseTextEditor::autoComplete(QTextCursor &cursor, const QString &textToI
|
||||
const bool checkBlockEnd = d->m_allowSkippingOfBlockEnd;
|
||||
d->m_allowSkippingOfBlockEnd = false; // consume blockEnd.
|
||||
|
||||
if (!d->m_autoParenthesesEnabled)
|
||||
return QString();
|
||||
|
||||
if (!contextAllowsAutoParentheses(cursor, textToInsert))
|
||||
return QString();
|
||||
|
||||
const QString text = textToInsert;
|
||||
const QChar lookAhead = characterAt(cursor.selectionEnd());
|
||||
|
||||
QChar character = textToInsert.at(0);
|
||||
const QChar character = textToInsert.at(0);
|
||||
const QString parentheses = QLatin1String("()");
|
||||
const QString brackets = QLatin1String("[]");
|
||||
if (parentheses.contains(character) || brackets.contains(character)) {
|
||||
@@ -3950,17 +3963,20 @@ bool BaseTextEditor::autoBackspace(QTextCursor &cursor)
|
||||
{
|
||||
d->m_allowSkippingOfBlockEnd = false;
|
||||
|
||||
if (!d->m_autoParenthesesEnabled)
|
||||
return false;
|
||||
|
||||
int pos = cursor.position();
|
||||
if (pos == 0)
|
||||
return false;
|
||||
QTextCursor c = cursor;
|
||||
c.setPosition(pos - 1);
|
||||
|
||||
QChar lookAhead = characterAt(pos);
|
||||
QChar lookBehind = characterAt(pos-1);
|
||||
QChar lookFurtherBehind = characterAt(pos-2);
|
||||
const QChar lookAhead = characterAt(pos);
|
||||
const QChar lookBehind = characterAt(pos - 1);
|
||||
const QChar lookFurtherBehind = characterAt(pos - 2);
|
||||
|
||||
QChar character = lookBehind;
|
||||
const QChar character = lookBehind;
|
||||
if (character == QLatin1Char('(') || character == QLatin1Char('[')) {
|
||||
QTextCursor tmp = cursor;
|
||||
TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tmp);
|
||||
@@ -4005,7 +4021,10 @@ bool BaseTextEditor::autoBackspace(QTextCursor &cursor)
|
||||
|
||||
int BaseTextEditor::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
|
||||
{
|
||||
if (characterAt(cursor.position()-1) != QLatin1Char('{'))
|
||||
if (!d->m_autoParenthesesEnabled)
|
||||
return 0;
|
||||
|
||||
if (characterAt(cursor.position() - 1) != QLatin1Char('{'))
|
||||
return 0;
|
||||
|
||||
if (!contextAllowsAutoParentheses(cursor))
|
||||
@@ -4908,6 +4927,11 @@ void BaseTextEditor::setStorageSettings(const StorageSettings &storageSettings)
|
||||
d->m_document->setStorageSettings(storageSettings);
|
||||
}
|
||||
|
||||
void BaseTextEditor::setCompletionSettings(const TextEditor::CompletionSettings &completionSettings)
|
||||
{
|
||||
setAutoParenthesesEnabled(completionSettings.m_autoInsertBrackets);
|
||||
}
|
||||
|
||||
void BaseTextEditor::collapse()
|
||||
{
|
||||
QTextDocument *doc = document();
|
||||
|
||||
Reference in New Issue
Block a user