summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-23 21:44:27 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-23 21:44:27 (GMT)
commitf9bae799e5c82fdf17243cfe204d98cb2b8c6e51 (patch)
treeee29c428be6ab846dbba308d9a52820b2d82b1a1
parent270f5f85a90c1dd254223d177975585c5a6eed64 (diff)
Remove it now we use ksyntaxhighlighting
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/htmlhighlighter.cpp310
-rw-r--r--src/htmlhighlighter.h56
4 files changed, 1 insertions, 369 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ba95017..1356791 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,7 @@ include(KDECMakeSettings)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMAddTests)
-set(PIM_VERSION "5.4.40")
+set(PIM_VERSION "5.4.41")
set(KPIMTEXTEDIT_LIB_VERSION ${PIM_VERSION})
ecm_setup_version(${KPIMTEXTEDIT_LIB_VERSION} VARIABLE_PREFIX KPIMTEXTEDIT
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3ed69c1..b74d04f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -46,7 +46,6 @@ set(kpimtextedit_texttospeech_SRCS
set(kpimtextedit_SRCS
emoticontexteditaction.cpp
emoticontexteditselector.cpp
- htmlhighlighter.cpp
inserthtmldialog.cpp
insertimagedialog.cpp
insertimagewidget.cpp
@@ -108,7 +107,6 @@ ecm_generate_headers(KPimTextEdit_CamelCase_HEADERS
HEADER_NAMES
EditorUtil
EmoticonTextEditAction
- HtmlHighlighter
InsertHtmlDialog
InsertImageDialog
InsertImageWidget
diff --git a/src/htmlhighlighter.cpp b/src/htmlhighlighter.cpp
deleted file mode 100644
index ff1ef33..0000000
--- a/src/htmlhighlighter.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- Copyright (c) 2012-2015 Montel Laurent <montel@kde.org>
-
- based on code from qt-labs-graphics-dojo/htmleditor/highlighter.*
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "htmlhighlighter.h"
-
-namespace KPIMTextEdit
-{
-
-class HtmlHighlighterPrivate
-{
-public:
- enum Construct {
- DocType,
- Entity,
- Tag,
- Comment,
- AttributeName,
- AttributeValue
- };
-
- enum State {
- State_Text = -1,
- State_DocType,
- State_Comment,
- State_TagStart,
- State_TagName,
- State_InsideTag,
- State_AttributeName,
- State_SingleQuote,
- State_DoubleQuote,
- State_AttributeValue
- };
-
- HtmlHighlighterPrivate()
- {
- colors[DocType] = QColor(192, 192, 192);
- colors[Entity] = QColor(128, 128, 128);
- colors[Tag] = QColor(136, 18, 128);
- colors[Comment] = QColor(35, 110, 37);
- colors[AttributeName] = QColor(153, 69, 0);
- colors[AttributeValue] = QColor(36, 36, 170);
- }
- QHash<int, QColor> colors;
-};
-
-HtmlHighlighter::HtmlHighlighter(QTextDocument *document)
- : QSyntaxHighlighter(document), d(new HtmlHighlighterPrivate)
-{
-}
-
-HtmlHighlighter::~HtmlHighlighter()
-{
- delete d;
-}
-
-void HtmlHighlighter::highlightBlock(const QString &text)
-{
- int state = previousBlockState();
- int len = text.length();
- int start = 0;
- int pos = 0;
-
- while (pos < len) {
- switch (state) {
- case HtmlHighlighterPrivate::State_Text:
- default:
- while (pos < len) {
- QChar ch = text.at(pos);
- if (ch == QLatin1Char('<')) {
- if (text.mid(pos, 4) == QLatin1String("<!--")) {
- state = HtmlHighlighterPrivate::State_Comment;
- } else {
- if (text.mid(pos, 9).toUpper() == QLatin1String("<!DOCTYPE")) {
- state = HtmlHighlighterPrivate::State_DocType;
- } else {
- state = HtmlHighlighterPrivate::State_TagStart;
- }
- }
- break;
- } else if (ch == QLatin1Char('&')) {
- start = pos;
- while (pos < len && text.at(pos++) != QLatin1Char(';'))
- ;
- setFormat(start, pos - start, d->colors[HtmlHighlighterPrivate::Entity]);
- } else {
- ++pos;
- }
- }
- break;
-
- case HtmlHighlighterPrivate::State_Comment:
- start = pos;
- while (pos < len) {
- if (text.mid(pos, 3) == QLatin1String("-->")) {
- pos += 3;
- state = HtmlHighlighterPrivate::State_Text;
- break;
- } else {
- ++pos;
- }
- }
- setFormat(start, pos - start, d->colors[HtmlHighlighterPrivate::Comment]);
- break;
-
- case HtmlHighlighterPrivate::State_DocType:
- start = pos;
- while (pos < len) {
- QChar ch = text.at(pos);
- ++pos;
- if (ch == QLatin1Char('>')) {
- state = HtmlHighlighterPrivate::State_Text;
- break;
- }
- }
- setFormat(start, pos - start, d->colors[HtmlHighlighterPrivate::DocType]);
- break;
-
- // at '<' in e.g. "<span>foo</span>"
- case HtmlHighlighterPrivate::State_TagStart:
- start = pos + 1;
- while (pos < len) {
- QChar ch = text.at(pos);
- ++pos;
- if (ch == QLatin1Char('>')) {
- state = HtmlHighlighterPrivate::State_Text;
- break;
- }
- if (!ch.isSpace()) {
- --pos;
- state = HtmlHighlighterPrivate::State_TagName;
- break;
- }
- }
- break;
-
- // at 'b' in e.g "<blockquote>foo</blockquote>"
- case HtmlHighlighterPrivate::State_TagName:
- start = pos;
- while (pos < len) {
- QChar ch = text.at(pos);
- ++pos;
- if (ch.isSpace()) {
- --pos;
- state = HtmlHighlighterPrivate::State_InsideTag;
- break;
- }
- if (ch == QLatin1Char('>')) {
- state = HtmlHighlighterPrivate::State_Text;
- break;
- }
- }
- setFormat(start, pos - start, d->colors[HtmlHighlighterPrivate::Tag]);
- break;
-
- // anywhere after tag name and before tag closing ('>')
- case HtmlHighlighterPrivate::State_InsideTag:
- start = pos;
-
- while (pos < len) {
- QChar ch = text.at(pos);
- ++pos;
-
- if (ch == QLatin1Char('/')) {
- continue;
- }
-
- if (ch == QLatin1Char('>')) {
- state = HtmlHighlighterPrivate::State_Text;
- break;
- }
-
- if (!ch.isSpace()) {
- --pos;
- state = HtmlHighlighterPrivate::State_AttributeName;
- break;
- }
-
- }
-
- break;
-
- // at 's' in e.g. <img src=bla.png/>
- case HtmlHighlighterPrivate::State_AttributeName:
- start = pos;
-
- while (pos < len) {
- QChar ch = text.at(pos);
- ++pos;
-
- if (ch == QLatin1Char('=')) {
- state = HtmlHighlighterPrivate::State_AttributeValue;
- break;
- }
-
- if (ch == QLatin1Char('>') || ch == QLatin1Char('/')) {
- state = HtmlHighlighterPrivate::State_InsideTag;
- break;
- }
- }
-
- setFormat(start, pos - start, d->colors[HtmlHighlighterPrivate::AttributeName]);
- break;
-
- // after '=' in e.g. <img src=bla.png/>
- case HtmlHighlighterPrivate::State_AttributeValue:
- start = pos;
-
- // find first non-space character
- while (pos < len) {
- QChar ch = text.at(pos);
- ++pos;
-
- // handle opening single quote
- if (ch == QLatin1Char('\'')) {
- state = HtmlHighlighterPrivate::State_SingleQuote;
- break;
- }
-
- // handle opening double quote
- if (ch == QLatin1Char('"')) {
- state = HtmlHighlighterPrivate::State_DoubleQuote;
- break;
- }
-
- if (!ch.isSpace()) {
- break;
- }
- }
-
- if (state == HtmlHighlighterPrivate::State_AttributeValue) {
- // attribute value without quote
- // just stop at non-space or tag delimiter
- start = pos;
- while (pos < len) {
- QChar ch = text.at(pos);
- if (ch.isSpace()) {
- break;
- }
- if (ch == QLatin1Char('>') || ch == QLatin1Char('/')) {
- break;
- }
- ++pos;
- }
- state = HtmlHighlighterPrivate::State_InsideTag;
- setFormat(start, pos - start, d->colors[HtmlHighlighterPrivate::AttributeValue]);
- }
-
- break;
-
- // after the opening single quote in an attribute value
- case HtmlHighlighterPrivate::State_SingleQuote:
- start = pos;
-
- while (pos < len) {
- QChar ch = text.at(pos);
- ++pos;
- if (ch == QLatin1Char('\'')) {
- break;
- }
- }
-
- state = HtmlHighlighterPrivate::State_InsideTag;
-
- setFormat(start, pos - start, d->colors[HtmlHighlighterPrivate::AttributeValue]);
- break;
-
- // after the opening double quote in an attribute value
- case HtmlHighlighterPrivate::State_DoubleQuote:
- start = pos;
-
- while (pos < len) {
- QChar ch = text.at(pos);
- ++pos;
- if (ch == QLatin1Char('"')) {
- break;
- }
- }
-
- state = HtmlHighlighterPrivate::State_InsideTag;
-
- setFormat(start, pos - start, d->colors[HtmlHighlighterPrivate::AttributeValue]);
- break;
-
- }
- }
-
- setCurrentBlockState(state);
-}
-
-}
-
diff --git a/src/htmlhighlighter.h b/src/htmlhighlighter.h
deleted file mode 100644
index 1fa0f6d..0000000
--- a/src/htmlhighlighter.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Copyright (c) 2012-2015 Montel Laurent <montel@kde.org>
-
- based on code from qt-labs-graphics-dojo/htmleditor/highlighter.*
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef KPIMTEXTEDIT_HTMLHIGHLIGHTER_H
-#define KPIMTEXTEDIT_HTMLHIGHLIGHTER_H
-
-#include "kpimtextedit_export.h"
-
-#include <QSyntaxHighlighter>
-
-/*
- * @since 4.10
- */
-namespace KPIMTextEdit
-{
-
-class HtmlHighlighterPrivate;
-
-class KPIMTEXTEDIT_EXPORT HtmlHighlighter : public QSyntaxHighlighter
-{
- Q_OBJECT
-public:
- explicit HtmlHighlighter(QTextDocument *document);
- ~HtmlHighlighter();
-
-protected:
- void highlightBlock(const QString &text) Q_DECL_OVERRIDE;
-
-private:
- friend class HtmlHighlighterPrivate;
- HtmlHighlighterPrivate *const d;
-
-};
-
-}
-
-#endif // KPIMTEXTEDIT_HTMLHIGHLIGHTER_H