Commit 8acde74d authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Forked QSyntaxHighlighter from Qt 4.7.

We need our very own syntax highlighter in Qt Creator.
parent 32993f46
......@@ -46,7 +46,7 @@ static bool isVariable(const QString &word)
CMakeHighlighter::CMakeHighlighter(QTextDocument *document) :
QSyntaxHighlighter(document)
TextEditor::SyntaxHighlighter(document)
{
}
......
......@@ -30,6 +30,7 @@
#ifndef CMAKEHIGHLIGHTER_H
#define CMAKEHIGHLIGHTER_H
#include <texteditor/syntaxhighlighter.h>
#include <QtCore/QtAlgorithms>
#include <QtGui/QSyntaxHighlighter>
#include <QtGui/QTextCharFormat>
......@@ -40,7 +41,7 @@ namespace Internal {
/* This is a simple syntax highlighter for CMake files.
* It highlights variables, commands, strings and comments.
* Multi-line strings and variables inside strings are also recognized. */
class CMakeHighlighter : public QSyntaxHighlighter
class CMakeHighlighter : public TextEditor::SyntaxHighlighter
{
Q_OBJECT
public:
......
......@@ -42,7 +42,7 @@ using namespace TextEditor;
using namespace CPlusPlus;
CppHighlighter::CppHighlighter(QTextDocument *document) :
QSyntaxHighlighter(document)
TextEditor::SyntaxHighlighter(document)
{
}
......
......@@ -31,16 +31,17 @@
#define CPPHIGHLIGHTER_H
#include "cppeditorenums.h"
#include <QtGui/QSyntaxHighlighter>
#include <texteditor/syntaxhighlighter.h>
#include <QtGui/QTextCharFormat>
#include <QtCore/QtAlgorithms>
namespace CppEditor {
namespace Internal {
class CPPEditor;
class CppHighlighter : public QSyntaxHighlighter
class CppHighlighter : public TextEditor::SyntaxHighlighter
{
Q_OBJECT
......
......@@ -60,6 +60,7 @@
#include <texteditor/textblockiterator.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/syntaxhighlighter.h>
#include <qmldesigner/qmldesignerconstants.h>
#include <utils/changeset.h>
#include <utils/uncommentselection.h>
......
......@@ -39,7 +39,7 @@ using namespace QmlJSEditor;
using namespace QmlJS;
Highlighter::Highlighter(QTextDocument *parent)
: QSyntaxHighlighter(parent),
: TextEditor::SyntaxHighlighter(parent),
m_qmlEnabled(true),
m_inMultilineComment(false)
{
......
......@@ -39,10 +39,11 @@
#include <QtGui/QSyntaxHighlighter>
#include <texteditor/basetextdocumentlayout.h>
#include <texteditor/syntaxhighlighter.h>
namespace QmlJSEditor {
class QMLJSEDITOR_EXPORT Highlighter : public QSyntaxHighlighter
class QMLJSEDITOR_EXPORT Highlighter : public TextEditor::SyntaxHighlighter
{
Q_OBJECT
......
......@@ -157,7 +157,7 @@ static bool isFunction(const QString &word)
}
ProFileHighlighter::ProFileHighlighter(QTextDocument *document) :
QSyntaxHighlighter(document)
TextEditor::SyntaxHighlighter(document)
{
}
......
......@@ -30,6 +30,7 @@
#ifndef PROFILEHIGHLIGHTER_H
#define PROFILEHIGHLIGHTER_H
#include <texteditor/syntaxhighlighter.h>
#include <QtCore/QtAlgorithms>
#include <QtGui/QSyntaxHighlighter>
#include <QtGui/QTextCharFormat>
......@@ -37,7 +38,7 @@
namespace Qt4ProjectManager {
namespace Internal {
class ProFileHighlighter : public QSyntaxHighlighter
class ProFileHighlighter : public TextEditor::SyntaxHighlighter
{
Q_OBJECT
public:
......
......@@ -32,6 +32,7 @@
#include "basetextdocumentlayout.h"
#include "basetexteditor.h"
#include "storagesettings.h"
#include "syntaxhighlighter.h"
#include <QtCore/QFile>
#include <QtCore/QDir>
......@@ -357,7 +358,7 @@ void BaseTextDocument::reload(ReloadFlag flag, ChangeType type)
}
}
void BaseTextDocument::setSyntaxHighlighter(QSyntaxHighlighter *highlighter)
void BaseTextDocument::setSyntaxHighlighter(SyntaxHighlighter *highlighter)
{
if (m_highlighter)
delete m_highlighter;
......
......@@ -40,11 +40,12 @@
QT_BEGIN_NAMESPACE
class QTextCursor;
class QTextDocument;
class QSyntaxHighlighter;
QT_END_NAMESPACE
namespace TextEditor {
class SyntaxHighlighter;
class DocumentMarker : public ITextMarkable
{
Q_OBJECT
......@@ -101,8 +102,8 @@ public:
virtual void reload();
QTextDocument *document() const { return m_document; }
void setSyntaxHighlighter(QSyntaxHighlighter *highlighter);
QSyntaxHighlighter *syntaxHighlighter() const { return m_highlighter; }
void setSyntaxHighlighter(SyntaxHighlighter *highlighter);
SyntaxHighlighter *syntaxHighlighter() const { return m_highlighter; }
inline bool isBinaryData() const { return m_isBinaryData; }
......@@ -127,7 +128,7 @@ private:
TabSettings m_tabSettings;
QTextDocument *m_document;
DocumentMarker *m_documentMarker;
QSyntaxHighlighter *m_highlighter;
SyntaxHighlighter *m_highlighter;
enum LineTerminatorMode {
LFLineTerminator,
......
......@@ -39,6 +39,7 @@
#include "tabsettings.h"
#include "texteditorconstants.h"
#include "texteditorplugin.h"
#include "syntaxhighlighter.h"
#include <aggregation/aggregate.h>
#include <coreplugin/actionmanager/actionmanager.h>
......@@ -4940,7 +4941,7 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds)
setCenterOnScroll(ds.m_centerCursorOnScroll);
if (d->m_displaySettings.m_visualizeWhitespace != ds.m_visualizeWhitespace) {
if (QSyntaxHighlighter *highlighter = baseTextDocument()->syntaxHighlighter())
if (SyntaxHighlighter *highlighter = baseTextDocument()->syntaxHighlighter())
highlighter->rehighlight();
QTextOption option = document()->defaultTextOption();
if (ds.m_visualizeWhitespace)
......
......@@ -53,7 +53,7 @@ namespace {
const Highlighter::KateFormatMap Highlighter::m_kateFormats;
Highlighter::Highlighter(QTextDocument *parent) :
QSyntaxHighlighter(parent),
TextEditor::SyntaxHighlighter(parent),
m_regionDepth(0),
m_indentationBasedFolding(false),
m_tabSettings(0),
......
......@@ -31,6 +31,7 @@
#define HIGHLIGHTER_H
#include "basetextdocumentlayout.h"
#include <texteditor/syntaxhighlighter.h>
#include <QtCore/QString>
#include <QtCore/QVector>
......@@ -52,8 +53,10 @@ class Context;
class HighlightDefinition;
class ProgressData;
class Highlighter : public QSyntaxHighlighter
class Highlighter : public TextEditor::SyntaxHighlighter
{
Q_OBJECT
public:
Highlighter(QTextDocument *parent = 0);
virtual ~Highlighter();
......
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef TEXTEDITOR_SYNTAXHIGHLIGHTER_H
#define TEXTEDITOR_SYNTAXHIGHLIGHTER_H
#include "texteditor_global.h"
#include <QtCore/qglobal.h>
#include <QtCore/qobject.h>
#include <QtGui/qtextobject.h>
QT_BEGIN_NAMESPACE
class QTextDocument;
class QSyntaxHighlighterPrivate;
class QTextCharFormat;
class QFont;
class QColor;
class QTextBlockUserData;
class QTextEdit;
QT_END_NAMESPACE
namespace TextEditor {
class SyntaxHighlighterPrivate;
class TEXTEDITOR_EXPORT SyntaxHighlighter : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(SyntaxHighlighter)
public:
SyntaxHighlighter(QObject *parent);
SyntaxHighlighter(QTextDocument *parent);
SyntaxHighlighter(QTextEdit *parent);
virtual ~SyntaxHighlighter();
void setDocument(QTextDocument *doc);
QTextDocument *document() const;
public Q_SLOTS:
void rehighlight();
void rehighlightBlock(const QTextBlock &block);
protected:
virtual void highlightBlock(const QString &text) = 0;
void setFormat(int start, int count, const QTextCharFormat &format);
void setFormat(int start, int count, const QColor &color);
void setFormat(int start, int count, const QFont &font);
QTextCharFormat format(int pos) const;
int previousBlockState() const;
int currentBlockState() const;
void setCurrentBlockState(int newState);
void setCurrentBlockUserData(QTextBlockUserData *data);
QTextBlockUserData *currentBlockUserData() const;
QTextBlock currentBlock() const;
private:
Q_DISABLE_COPY(SyntaxHighlighter)
Q_PRIVATE_SLOT(d_ptr, void _q_reformatBlocks(int from, int charsRemoved, int charsAdded))
Q_PRIVATE_SLOT(d_ptr, void _q_delayedRehighlight())
QScopedPointer<SyntaxHighlighterPrivate> d_ptr;
};
} // end of namespace TextEditor
#endif // TEXTEDITOR_SYNTAXHIGHLIGHTER_H
......@@ -42,6 +42,7 @@ SOURCES += texteditorplugin.cpp \
normalindenter.cpp \
indenter.cpp \
quickfix.cpp \
syntaxhighlighter.cpp \
generichighlighter/itemdata.cpp \
generichighlighter/specificrules.cpp \
generichighlighter/rule.cpp \
......@@ -103,6 +104,7 @@ HEADERS += texteditorplugin.h \
normalindenter.h \
indenter.h \
quickfix.h \
syntaxhighlighter.h \
generichighlighter/reuse.h \
generichighlighter/itemdata.h \
generichighlighter/specificrules.h \
......
......@@ -47,7 +47,7 @@ struct BaseAnnotationHighlighterPrivate {
BaseAnnotationHighlighter::BaseAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document) :
QSyntaxHighlighter(document),
TextEditor::SyntaxHighlighter(document),
m_d(new BaseAnnotationHighlighterPrivate)
{
setChangeNumbers(changeNumbers);
......
......@@ -31,7 +31,7 @@
#define BASEANNOTATIONHIGHLIGHTER_H
#include "vcsbase_global.h"
#include <texteditor/syntaxhighlighter.h>
#include <QtCore/QMap>
#include <QtCore/QSet>
#include <QtGui/QSyntaxHighlighter>
......@@ -47,7 +47,7 @@ struct BaseAnnotationHighlighterPrivate;
// 112: text1 <color 1>
// 113: text2 <color 2>
// 112: text3 <color 1>
class VCSBASE_EXPORT BaseAnnotationHighlighter : public QSyntaxHighlighter
class VCSBASE_EXPORT BaseAnnotationHighlighter : public TextEditor::SyntaxHighlighter
{
Q_OBJECT
public:
......
......@@ -88,7 +88,7 @@ DiffFormats DiffHighlighterPrivate::analyzeLine(const QString &text) const
// --- DiffHighlighter
DiffHighlighter::DiffHighlighter(const QRegExp &filePattern,
QTextDocument *document) :
QSyntaxHighlighter(document),
TextEditor::SyntaxHighlighter(document),
m_d(new DiffHighlighterPrivate(filePattern))
{
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment