Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
8acde74d
Commit
8acde74d
authored
Jul 09, 2010
by
Roberto Raggi
Browse files
Forked QSyntaxHighlighter from Qt 4.7.
We need our very own syntax highlighter in Qt Creator.
parent
32993f46
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
src/plugins/cmakeprojectmanager/cmakehighlighter.cpp
View file @
8acde74d
...
...
@@ -46,7 +46,7 @@ static bool isVariable(const QString &word)
CMakeHighlighter
::
CMakeHighlighter
(
QTextDocument
*
document
)
:
Q
SyntaxHighlighter
(
document
)
TextEditor
::
SyntaxHighlighter
(
document
)
{
}
...
...
src/plugins/cmakeprojectmanager/cmakehighlighter.h
View file @
8acde74d
...
...
@@ -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
Q
SyntaxHighlighter
class
CMakeHighlighter
:
public
TextEditor
::
SyntaxHighlighter
{
Q_OBJECT
public:
...
...
src/plugins/cppeditor/cpphighlighter.cpp
View file @
8acde74d
...
...
@@ -42,7 +42,7 @@ using namespace TextEditor;
using
namespace
CPlusPlus
;
CppHighlighter
::
CppHighlighter
(
QTextDocument
*
document
)
:
Q
SyntaxHighlighter
(
document
)
TextEditor
::
SyntaxHighlighter
(
document
)
{
}
...
...
src/plugins/cppeditor/cpphighlighter.h
View file @
8acde74d
...
...
@@ -31,16 +31,17 @@
#define CPPHIGHLIGHTER_H
#include
"cppeditorenums.h"
#include
<
QtGui/QS
yntax
H
ighlighter>
#include
<
texteditor/s
yntax
h
ighlighter
.h
>
#include
<QtGui/QTextCharFormat>
#include
<QtCore/QtAlgorithms>
namespace
CppEditor
{
namespace
Internal
{
class
CPPEditor
;
class
CppHighlighter
:
public
Q
SyntaxHighlighter
class
CppHighlighter
:
public
TextEditor
::
SyntaxHighlighter
{
Q_OBJECT
...
...
src/plugins/qmljseditor/qmljseditor.cpp
View file @
8acde74d
...
...
@@ -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>
...
...
src/plugins/qmljseditor/qmljshighlighter.cpp
View file @
8acde74d
...
...
@@ -39,7 +39,7 @@ using namespace QmlJSEditor;
using
namespace
QmlJS
;
Highlighter
::
Highlighter
(
QTextDocument
*
parent
)
:
Q
SyntaxHighlighter
(
parent
),
:
TextEditor
::
SyntaxHighlighter
(
parent
),
m_qmlEnabled
(
true
),
m_inMultilineComment
(
false
)
{
...
...
src/plugins/qmljseditor/qmljshighlighter.h
View file @
8acde74d
...
...
@@ -39,10 +39,11 @@
#include
<QtGui/QSyntaxHighlighter>
#include
<texteditor/basetextdocumentlayout.h>
#include
<texteditor/syntaxhighlighter.h>
namespace
QmlJSEditor
{
class
QMLJSEDITOR_EXPORT
Highlighter
:
public
Q
SyntaxHighlighter
class
QMLJSEDITOR_EXPORT
Highlighter
:
public
TextEditor
::
SyntaxHighlighter
{
Q_OBJECT
...
...
src/plugins/qt4projectmanager/profilehighlighter.cpp
View file @
8acde74d
...
...
@@ -157,7 +157,7 @@ static bool isFunction(const QString &word)
}
ProFileHighlighter
::
ProFileHighlighter
(
QTextDocument
*
document
)
:
Q
SyntaxHighlighter
(
document
)
TextEditor
::
SyntaxHighlighter
(
document
)
{
}
...
...
src/plugins/qt4projectmanager/profilehighlighter.h
View file @
8acde74d
...
...
@@ -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
Q
SyntaxHighlighter
class
ProFileHighlighter
:
public
TextEditor
::
SyntaxHighlighter
{
Q_OBJECT
public:
...
...
src/plugins/texteditor/basetextdocument.cpp
View file @
8acde74d
...
...
@@ -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
(
Q
SyntaxHighlighter
*
highlighter
)
void
BaseTextDocument
::
setSyntaxHighlighter
(
SyntaxHighlighter
*
highlighter
)
{
if
(
m_highlighter
)
delete
m_highlighter
;
...
...
src/plugins/texteditor/basetextdocument.h
View file @
8acde74d
...
...
@@ -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
(
Q
SyntaxHighlighter
*
highlighter
);
Q
SyntaxHighlighter
*
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
;
Q
SyntaxHighlighter
*
m_highlighter
;
SyntaxHighlighter
*
m_highlighter
;
enum
LineTerminatorMode
{
LFLineTerminator
,
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
8acde74d
...
...
@@ -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
(
Q
SyntaxHighlighter
*
highlighter
=
baseTextDocument
()
->
syntaxHighlighter
())
if
(
SyntaxHighlighter
*
highlighter
=
baseTextDocument
()
->
syntaxHighlighter
())
highlighter
->
rehighlight
();
QTextOption
option
=
document
()
->
defaultTextOption
();
if
(
ds
.
m_visualizeWhitespace
)
...
...
src/plugins/texteditor/generichighlighter/highlighter.cpp
View file @
8acde74d
...
...
@@ -53,7 +53,7 @@ namespace {
const
Highlighter
::
KateFormatMap
Highlighter
::
m_kateFormats
;
Highlighter
::
Highlighter
(
QTextDocument
*
parent
)
:
Q
SyntaxHighlighter
(
parent
),
TextEditor
::
SyntaxHighlighter
(
parent
),
m_regionDepth
(
0
),
m_indentationBasedFolding
(
false
),
m_tabSettings
(
0
),
...
...
src/plugins/texteditor/generichighlighter/highlighter.h
View file @
8acde74d
...
...
@@ -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
Q
SyntaxHighlighter
class
Highlighter
:
public
TextEditor
::
SyntaxHighlighter
{
Q_OBJECT
public:
Highlighter
(
QTextDocument
*
parent
=
0
);
virtual
~
Highlighter
();
...
...
src/plugins/texteditor/syntaxhighlighter.cpp
0 → 100644
View file @
8acde74d
This diff is collapsed.
Click to expand it.
src/plugins/texteditor/syntaxhighlighter.h
0 → 100644
View file @
8acde74d
/****************************************************************************
**
** 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
src/plugins/texteditor/texteditor.pro
View file @
8acde74d
...
...
@@ -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
\
...
...
src/plugins/vcsbase/baseannotationhighlighter.cpp
View file @
8acde74d
...
...
@@ -47,7 +47,7 @@ struct BaseAnnotationHighlighterPrivate {
BaseAnnotationHighlighter
::
BaseAnnotationHighlighter
(
const
ChangeNumbers
&
changeNumbers
,
QTextDocument
*
document
)
:
Q
SyntaxHighlighter
(
document
),
TextEditor
::
SyntaxHighlighter
(
document
),
m_d
(
new
BaseAnnotationHighlighterPrivate
)
{
setChangeNumbers
(
changeNumbers
);
...
...
src/plugins/vcsbase/baseannotationhighlighter.h
View file @
8acde74d
...
...
@@ -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
Q
SyntaxHighlighter
class
VCSBASE_EXPORT
BaseAnnotationHighlighter
:
public
TextEditor
::
SyntaxHighlighter
{
Q_OBJECT
public:
...
...
src/plugins/vcsbase/diffhighlighter.cpp
View file @
8acde74d
...
...
@@ -88,7 +88,7 @@ DiffFormats DiffHighlighterPrivate::analyzeLine(const QString &text) const
// --- DiffHighlighter
DiffHighlighter
::
DiffHighlighter
(
const
QRegExp
&
filePattern
,
QTextDocument
*
document
)
:
Q
SyntaxHighlighter
(
document
),
TextEditor
::
SyntaxHighlighter
(
document
),
m_d
(
new
DiffHighlighterPrivate
(
filePattern
))
{
}
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment