• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

katehighlight.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2001,2002 Joseph Wenninger <jowenn@kde.org>
00003    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
00004    Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef __KATE_HIGHLIGHT_H__
00022 #define __KATE_HIGHLIGHT_H__
00023 
00024 #include "katetextline.h"
00025 #include "kateextendedattribute.h"
00026 #include "katesyntaxmanager.h"
00027 
00028 #include <kconfig.h>
00029 #include <kactionmenu.h>
00030 
00031 #include <QtCore/QVector>
00032 #include <QtCore/QList>
00033 #include <QtCore/QHash>
00034 #include <QtCore/QMap>
00035 
00036 #include <QtCore/QRegExp>
00037 #include <QtCore/QObject>
00038 #include <QtCore/QStringList>
00039 #include <QtCore/QPointer>
00040 #include <QtCore/QDate>
00041 #include <QtCore/QLinkedList>
00042 
00043 class KateHlContext;
00044 class KateHlItem;
00045 class KateHlIncludeRule;
00046 class KateTextLine;
00047 class KateSyntaxModeListItem;
00048 class KateSyntaxContextData;
00049 
00050 // same as in kmimemagic, no need to feed more data
00051 #define KATE_HL_HOWMANY 1024
00052 
00053 // min. x seconds between two dynamic contexts reset
00054 #define KATE_DYNAMIC_CONTEXTS_RESET_DELAY (30 * 1000)
00055 
00056 
00060 class KateHlContextModification
00061 {
00062   public:
00063     enum modType {
00064       doNothing = 0,
00065       doPush = 1,
00066       doPops = 2,
00067       doPopsAndPush = 3
00068     };
00069 
00075     KateHlContextModification (int _newContext = -1, int _pops = 0) : type (doNothing), newContext (_newContext), pops (_pops) //krazy:exclude=explicit
00076     {
00077       if (newContext >= 0 && pops == 0) type = doPush;
00078       else if (newContext < 0 && pops > 0) type = doPops;
00079       else if (newContext >= 0 && pops > 0) type = doPopsAndPush;
00080       else type = doNothing;
00081     }
00082 
00083   public:
00087     char type;
00088 
00093     int newContext;
00094 
00099     int pops;
00100 };
00101 
00102 class KateEmbeddedHlInfo
00103 {
00104   public:
00105     KateEmbeddedHlInfo() {loaded=false;context0=-1;}
00106     KateEmbeddedHlInfo(bool l, int ctx0) {loaded=l;context0=ctx0;}
00107 
00108   public:
00109     bool loaded;
00110     int context0;
00111 };
00112 
00113 // some typedefs
00114 typedef QList<KateHlIncludeRule*> KateHlIncludeRules;
00115 typedef QMap<QString,KateEmbeddedHlInfo> KateEmbeddedHlInfos;
00116 typedef QMap<KateHlContextModification*,QString> KateHlUnresolvedCtxRefs;
00117 
00118 class KateHighlighting
00119 {
00120   public:
00121     KateHighlighting(const KateSyntaxModeListItem *def);
00122     ~KateHighlighting();
00123 
00124   private:
00131     void cleanup ();
00132 
00133   public:
00134     void doHighlight ( KateTextLine *prevLine,
00135                        KateTextLine *textLine,
00136                        QVector<int> &foldingList,
00137                        bool &ctxChanged );
00138 
00139     void setKateExtendedAttributeList(uint schema, QList<KateExtendedAttribute::Ptr> &);
00140 
00141     const QString &name() const {return iName;}
00142     const QString &nameTranslated() const {return iNameTranslated;}
00143     const QString &section() const {return iSection;}
00144     bool hidden() const {return iHidden;}
00145     const QString &version() const {return iVersion;}
00146     const QString &style() const { return iStyle; }
00147     const QString &author () const { return iAuthor; }
00148     const QString &license () const { return iLicense; }
00149     const QString &getIdentifier() const {return identifier;}
00150     void use();
00151     void release();
00152 
00157     bool isInWord( QChar c, int attrib=0 ) const;
00158 
00163     bool canBreakAt( QChar c, int attrib=0 ) const;
00164 
00168     QLinkedList<QRegExp> emptyLines(int attribute=0) const;
00173     bool canComment( int startAttr, int endAttr ) const;
00174 
00179     signed char commentRegion(int attr) const;
00180 
00185     QString getCommentStart( int attrib=0 ) const;
00186 
00191     QString getCommentEnd( int attrib=0 ) const;
00192 
00197     QString getCommentSingleLineStart( int attrib=0 ) const;
00198 
00199 
00203     enum CSLPos { CSLPosColumn0=0,CSLPosAfterWhitespace=1};
00204 
00209     CSLPos getCommentSingleLinePosition( int attrib=0 ) const;
00210 
00214     int attribute( int context ) const;
00215 
00220     QString hlKeyForAttrib( int attrib ) const;
00221 
00222     int defaultStyleForAttribute( int attrib ) const;
00223 
00224     void clearAttributeArrays ();
00225 
00226     QList<KTextEditor::Attribute::Ptr> attributes (const QString &schema);
00227 
00228     inline bool noHighlighting () const { return noHl; }
00229 
00230     // be carefull: all documents hl should be invalidated after calling this method!
00231     void dropDynamicContexts();
00232 
00233     QString indentation () { return m_indentation; }
00234 
00235     void getKateExtendedAttributeList(const QString &schema, QList<KateExtendedAttribute::Ptr> &);
00236     void getKateExtendedAttributeListCopy(const QString &schema, QList<KateExtendedAttribute::Ptr> &);
00237 
00238   private:
00239     void init();
00240     void done();
00241     void makeContextList ();
00242     int makeDynamicContext(KateHlContext *model, const QStringList *args);
00243     void handleKateHlIncludeRules ();
00244     void handleKateHlIncludeRulesRecursive(int index, KateHlIncludeRules *list);
00245     int addToContextList(const QString &ident, int ctx0);
00246     void addToKateExtendedAttributeList();
00247     void createKateExtendedAttribute (QList<KateExtendedAttribute::Ptr> &list);
00248     void readGlobalKeywordConfig();
00249     void readWordWrapConfig();
00250     void readCommentConfig();
00251     void readEmptyLineConfig();
00252     void readIndentationConfig ();
00253     void readFoldingConfig ();
00254 
00262     KateHlContext *generateContextStack(QVector<short> &contextStack, KateHlContextModification modification, int &indexLastContextPreviousLine);
00263 
00264     KateHlItem *createKateHlItem(KateSyntaxContextData *data, QList<KateExtendedAttribute::Ptr> &iDl, QStringList *RegionList, QStringList *ContextList);
00265     int lookupAttrName(const QString& name, QList<KateExtendedAttribute::Ptr> &iDl);
00266 
00267     void createContextNameList(QStringList *ContextNameList, int ctx0);
00268     KateHlContextModification getContextModificationFromString(QStringList *ContextNameList, QString tmpLineEndContext,/*NO CONST*/ QString &unres);
00269 
00270     QList<KateExtendedAttribute::Ptr> internalIDList;
00271 
00272     QVector<KateHlContext*> m_contexts;
00273     inline KateHlContext *contextNum (int n) { if (n >= 0 && n < m_contexts.size()) return m_contexts[n]; Q_ASSERT (0); return m_contexts[0]; }
00274 
00275     QMap< QPair<KateHlContext *, QString>, short> dynamicCtxs;
00276 
00277     // make them pointers perhaps
00278     KateEmbeddedHlInfos embeddedHls;
00279     KateHlUnresolvedCtxRefs unresolvedContextReferences;
00280     QStringList RegionList;
00281     QStringList ContextNameList;
00282 
00283     bool noHl;
00284     bool folding;
00285     bool casesensitive;
00286     QString weakDeliminator;
00287     QString deliminator;
00288 
00289     QString iName;
00290     QString iNameTranslated;
00291     QString iSection;
00292     bool iHidden;
00293     QString identifier;
00294     QString iVersion;
00295     QString iStyle;
00296     QString iAuthor;
00297     QString iLicense;
00298     QString m_indentation;
00299     int refCount;
00300     int startctx, base_startctx;
00301 
00302     QString errorsAndWarnings;
00303     QString buildIdentifier;
00304     QString buildPrefix;
00305     bool building;
00306     uint itemData0;
00307     uint buildContext0Offset;
00308     KateHlIncludeRules includeRules;
00309     bool m_foldingIndentationSensitive;
00310 
00311     // map schema name to attributes...
00312     QHash< QString, QList<KTextEditor::Attribute::Ptr> > m_attributeArrays;
00313 
00314 
00327     class HighlightPropertyBag {
00328       public:
00329         QString singleLineCommentMarker;
00330         QString multiLineCommentStart;
00331         QString multiLineCommentEnd;
00332         QString multiLineRegion;
00333         CSLPos  singleLineCommentPosition;
00334         QString deliminator;
00335         QString wordWrapDeliminator;
00336     QLinkedList<QRegExp> emptyLines;
00337     };
00338 
00343     QHash<QString, HighlightPropertyBag*> m_additionalData;
00344 
00350     QMap<int, QString> m_hlIndex;
00351 
00352   public:
00353     inline bool foldingIndentationSensitive () { return m_foldingIndentationSensitive; }
00354     inline bool allowsFolding(){return folding;}
00355 };
00356 
00357 #endif
00358 
00359 // kate: space-indent on; indent-width 2; replace-tabs on;

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal