[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ktexteditor/syntax-highlighting] src: derive from abstract highlighter, set definition
From:       Christoph Cullmann <null () kde ! org>
Date:       2018-07-28 16:24:07
Message-ID: E1fjS0l-0007yv-Eb () code ! kde ! org
[Download RAW message or body]

Git commit 50b8f4b562134bcd67c2a1d314b4bfc7d33f2283 by Christoph Cullmann.
Committed on 28/07/2018 at 16:24.
Pushed by cullmann into branch 'syntax-highlighting'.

derive from abstract highlighter, set definition

M  +12   -0    src/syntax/katehighlight.cpp
M  +38   -1    src/syntax/katehighlight.h
M  +1    -1    src/utils/kateglobal.cpp

https://commits.kde.org/ktexteditor/50b8f4b562134bcd67c2a1d314b4bfc7d33f2283

diff --git a/src/syntax/katehighlight.cpp b/src/syntax/katehighlight.cpp
index efb06e68..4ebbb05f 100644
--- a/src/syntax/katehighlight.cpp
+++ b/src/syntax/katehighlight.cpp
@@ -94,6 +94,11 @@ KateHighlighting::KateHighlighting(const \
KSyntaxHighlighting::Definition &def)  }
 
     deliminator = stdDeliminator();
+
+    /**
+     * tell the AbstractHighlighter the definition it shall use
+     */
+    setDefinition(def);
 }
 
 KateHighlighting::~KateHighlighting()
@@ -2289,6 +2294,13 @@ KateHlContext* \
KateHighlighting::contextForLocation(KTextEditor::DocumentPrivate  return context;
 }
 
+void KateHighlighting::applyFormat(int offset, int length, const \
KSyntaxHighlighting::Format &format) +{
+}
+
+void KateHighlighting::applyFolding(int offset, int length, \
KSyntaxHighlighting::FoldingRegion region) +{
+}
 
 //END
 
diff --git a/src/syntax/katehighlight.h b/src/syntax/katehighlight.h
index 7de51139..bb89c099 100644
--- a/src/syntax/katehighlight.h
+++ b/src/syntax/katehighlight.h
@@ -22,6 +22,9 @@
 #ifndef __KATE_HIGHLIGHT_H__
 #define __KATE_HIGHLIGHT_H__
 
+#include <KSyntaxHighlighting/AbstractHighlighter>
+#include <KSyntaxHighlighting/FoldingRegion>
+
 #include "katetextline.h"
 #include "kateextendedattribute.h"
 #include "katesyntaxmanager.h"
@@ -131,12 +134,46 @@ typedef QList<KateHlIncludeRule *> KateHlIncludeRules;
 typedef QMap<QString, KateEmbeddedHlInfo> KateEmbeddedHlInfos;
 typedef QMap<KateHlContextModification *, QString> KateHlUnresolvedCtxRefs;
 
-class KateHighlighting
+class KateHighlighting : private KSyntaxHighlighting::AbstractHighlighter
 {
 public:
     KateHighlighting(const KSyntaxHighlighting::Definition &def);
     ~KateHighlighting();
 
+protected:
+    /**
+     * Reimplement this to apply formats to your output. The provided @p format
+     * is valid for the interval [@p offset, @p offset + @p length).
+     *
+     * @param offset The start column of the interval for which @p format matches
+     * @param length The length of the matching text
+     * @param format The Format that applies to the range [offset, offset + length)
+     *
+     * @note Make sure to set a valid Definition, otherwise the parameter
+     *       @p format is invalid for the entire line passed to highlightLine()
+     *       (cf. Format::isValid()).
+     *
+     * @see applyFolding(), highlightLine()
+     */
+    virtual void applyFormat(int offset, int length, const \
KSyntaxHighlighting::Format &format) override; +
+    /**
+     * Reimplement this to apply folding to your output. The provided
+     * FoldingRegion @p region either stars or ends a code folding region in the
+     * interval [@p offset, @p offset + @p length).
+     *
+     * @param offset The start column of the FoldingRegion
+     * @param length The length of the matching text that starts / ends a
+     *       folding region
+     * @param region The FoldingRegion that applies to the range [offset, offset + \
length) +     *
+     * @note The FoldingRegion @p region is @e always either of type
+     *       FoldingRegion::Type::Begin or FoldingRegion::Type::End.
+     *
+     * @see applyFormat(), highlightLine(), FoldingRegion
+     */
+    virtual void applyFolding(int offset, int length, \
KSyntaxHighlighting::FoldingRegion region) override; +
 private:
     /**
      * this method frees mem ;)
diff --git a/src/utils/kateglobal.cpp b/src/utils/kateglobal.cpp
index a95adec4..e7be13c7 100644
--- a/src/utils/kateglobal.cpp
+++ b/src/utils/kateglobal.cpp
@@ -82,7 +82,7 @@ bool KTextEditor::EditorPrivate::unitTestMode()
 
 KTextEditor::EditorPrivate::EditorPrivate(QPointer<KTextEditor::EditorPrivate> \
&staticInstance)  : KTextEditor::Editor (this)
-    , m_aboutData(QStringLiteral("katepart"), i18n("Kate Part"), \
QStringLiteral(KTEXTEDITOR_VERSION_STRING), +    , \
m_aboutData(QStringLiteral("katepart"), i18n("Kate Part (Syntax-Highlighting \
                branch)"), QStringLiteral(KTEXTEDITOR_VERSION_STRING),
                   i18n("Embeddable editor component"), KAboutLicense::LGPL_V2,
                   i18n("(c) 2000-2017 The Kate Authors"), QString(), \
QStringLiteral("http://kate-editor.org"))  , m_dummyApplication(nullptr)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic