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

Kate

katehighlighthelpers.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_HIGHLIGHTHELPERS_H__
00022 #define __KATE_HIGHLIGHTHELPERS_H__
00023 
00024 #include "katehighlight.h"
00025 
00026 class KateHlItem
00027 {
00028   public:
00029     KateHlItem(int attribute, KateHlContextModification context,signed char regionId, signed char regionId2);
00030     virtual ~KateHlItem();
00031 
00032   public:
00033     // caller must keep in mind: LEN > 0 is a must !!!!!!!!!!!!!!!!!!!!!1
00034     // Now, the function returns the offset detected, or 0 if no match is found.
00035     // bool linestart isn't needed, this is equivalent to offset == 0.
00036     virtual int checkHgl(const QString& text, int offset, int len) = 0;
00037 
00038     virtual bool lineContinue(){return false;}
00039 
00040     virtual QStringList *capturedTexts() {return 0;}
00041     virtual KateHlItem *clone(const QStringList *) {return this;}
00042 
00043     static void dynamicSubstitute(QString& str, const QStringList *args);
00044 
00045     QVector<KateHlItem*> subItems;
00046     int attr;
00047     KateHlContextModification ctx;
00048     signed char region;
00049     signed char region2;
00050 
00051     bool lookAhead;
00052 
00053     bool dynamic;
00054     bool dynamicChild;
00055     bool firstNonSpace;
00056     bool onlyConsume;
00057     int column;
00058 
00059     // start enable flags, nicer than the virtual methodes
00060     // saves function calls
00061     bool alwaysStartEnable;
00062     bool customStartEnable;
00063 };
00064 
00065 class KateHlContext
00066 {
00067   public:
00068     KateHlContext(const QString &_hlId, int attribute, KateHlContextModification _lineEndContext,KateHlContextModification _lineBeginContext,
00069                   bool _fallthrough, KateHlContextModification _fallthroughContext, bool _dynamic,bool _noIndentationBasedFolding);
00070     virtual ~KateHlContext();
00071     KateHlContext *clone(const QStringList *args);
00072 
00073     QVector<KateHlItem*> items;
00074     QString hlId; 
00075     int attr;
00076     KateHlContextModification lineEndContext;
00077     KateHlContextModification lineBeginContext;
00083     bool fallthrough;
00084     KateHlContextModification ftctx; // where to go after no rules matched
00085 
00086     bool dynamic;
00087     bool dynamicChild;
00088     bool noIndentationBasedFolding;
00089 };
00090 
00091 class KateHlIncludeRule
00092 {
00093   public:
00094     explicit KateHlIncludeRule(int ctx_=0, uint pos_=0, const QString &incCtxN_="", bool incAttrib=false)
00095       : ctx(ctx_)
00096       , pos( pos_)
00097       , incCtxN( incCtxN_ )
00098       , includeAttrib( incAttrib )
00099     {
00100       incCtx=-1;
00101     }
00102     //KateHlIncludeRule(int ctx_, uint  pos_, bool incAttrib) {ctx=ctx_;pos=pos_;incCtx=-1;incCtxN="";includeAttrib=incAttrib}
00103 
00104   public:
00105     int ctx;
00106     uint pos;
00107     KateHlContextModification incCtx;
00108     QString incCtxN;
00109     bool includeAttrib;
00110 };
00111 
00112 class KateHlCharDetect : public KateHlItem
00113 {
00114   public:
00115     KateHlCharDetect(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2, QChar);
00116 
00117     virtual int checkHgl(const QString& text, int offset, int len);
00118     virtual KateHlItem *clone(const QStringList *args);
00119 
00120   private:
00121     QChar sChar;
00122 };
00123 
00124 class KateHl2CharDetect : public KateHlItem
00125 {
00126   public:
00127     KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2,  QChar ch1, QChar ch2);
00128     KateHl2CharDetect(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2,  const QChar *ch);
00129 
00130     virtual int checkHgl(const QString& text, int offset, int len);
00131     virtual KateHlItem *clone(const QStringList *args);
00132 
00133   private:
00134     QChar sChar1;
00135     QChar sChar2;
00136 };
00137 
00138 class KateHlStringDetect : public KateHlItem
00139 {
00140   public:
00141     KateHlStringDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QString &, bool inSensitive=false);
00142 
00143     virtual int checkHgl(const QString& text, int offset, int len);
00144     virtual KateHlItem *clone(const QStringList *args);
00145 
00146   private:
00147     const QString str;
00148     const int strLen;
00149     const bool _inSensitive;
00150 };
00151 
00152 class KateHlRangeDetect : public KateHlItem
00153 {
00154   public:
00155     KateHlRangeDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, QChar ch1, QChar ch2);
00156 
00157     virtual int checkHgl(const QString& text, int offset, int len);
00158 
00159   private:
00160     QChar sChar1;
00161     QChar sChar2;
00162 };
00163 
00164 class KateHlKeyword : public KateHlItem
00165 {
00166   public:
00167     KateHlKeyword(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2, bool insensitive, const QString& delims);
00168     virtual ~KateHlKeyword ();
00169 
00170     void addList(const QStringList &);
00171     virtual int checkHgl(const QString& text, int offset, int len);
00172 
00173   private:
00174     QVector< QSet<QString>* > dict;
00175     bool _insensitive;
00176     const QString& deliminators;
00177     int minLen;
00178     int maxLen;
00179 };
00180 
00181 class KateHlInt : public KateHlItem
00182 {
00183   public:
00184     KateHlInt(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2);
00185 
00186     virtual int checkHgl(const QString& text, int offset, int len);
00187 };
00188 
00189 class KateHlFloat : public KateHlItem
00190 {
00191   public:
00192     KateHlFloat(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2);
00193     virtual ~KateHlFloat () {}
00194 
00195     virtual int checkHgl(const QString& text, int offset, int len);
00196 };
00197 
00198 class KateHlCFloat : public KateHlFloat
00199 {
00200   public:
00201     KateHlCFloat(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2);
00202 
00203     virtual int checkHgl(const QString& text, int offset, int len);
00204     int checkIntHgl(const QString& text, int offset, int len);
00205 };
00206 
00207 class KateHlCOct : public KateHlItem
00208 {
00209   public:
00210     KateHlCOct(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2);
00211 
00212     virtual int checkHgl(const QString& text, int offset, int len);
00213 };
00214 
00215 class KateHlCHex : public KateHlItem
00216 {
00217   public:
00218     KateHlCHex(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2);
00219 
00220     virtual int checkHgl(const QString& text, int offset, int len);
00221 };
00222 
00223 class KateHlLineContinue : public KateHlItem
00224 {
00225   public:
00226     KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2);
00227 
00228     virtual bool endEnable(QChar c) {return c == '\0';}
00229     virtual int checkHgl(const QString& text, int offset, int len);
00230     virtual bool lineContinue(){return true;}
00231 };
00232 
00233 class KateHlCStringChar : public KateHlItem
00234 {
00235   public:
00236     KateHlCStringChar(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2);
00237 
00238     virtual int checkHgl(const QString& text, int offset, int len);
00239 };
00240 
00241 class KateHlCChar : public KateHlItem
00242 {
00243   public:
00244     KateHlCChar(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2);
00245 
00246     virtual int checkHgl(const QString& text, int offset, int len);
00247 };
00248 
00249 class KateHlAnyChar : public KateHlItem
00250 {
00251   public:
00252     KateHlAnyChar(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QString& charList);
00253 
00254     virtual int checkHgl(const QString& text, int offset, int len);
00255 
00256   private:
00257     const QString _charList;
00258 };
00259 
00260 class KateHlRegExpr : public KateHlItem
00261 {
00262   public:
00263     KateHlRegExpr(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2 ,const QString &expr, bool insensitive, bool minimal);
00264     ~KateHlRegExpr() { delete Expr; }
00265 
00266     virtual int checkHgl(const QString& text, int offset, int len);
00267     virtual QStringList *capturedTexts();
00268     virtual KateHlItem *clone(const QStringList *args);
00269 
00270   private:
00271     QRegExp *Expr;
00272     bool handlesLinestart;
00273     QString _regexp;
00274     bool _insensitive;
00275     bool _minimal;
00276 };
00277 
00278 class KateHlDetectSpaces : public KateHlItem
00279 {
00280   public:
00281     KateHlDetectSpaces (int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
00282       : KateHlItem(attribute,context,regionId,regionId2) {}
00283 
00284     virtual int checkHgl(const QString& text, int offset, int len)
00285     {
00286       int len2 = offset + len;
00287       while ((offset < len2) && text[offset].isSpace()) offset++;
00288       return offset;
00289     }
00290 };
00291 
00292 class KateHlDetectIdentifier : public KateHlItem
00293 {
00294   public:
00295     KateHlDetectIdentifier (int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
00296       : KateHlItem(attribute,context,regionId,regionId2) { alwaysStartEnable = false; }
00297 
00298     virtual int checkHgl(const QString& text, int offset, int len)
00299     {
00300       // first char should be a letter or underscore
00301       if ( text[offset].isLetter() || text[offset] == QChar ('_') )
00302       {
00303         // memorize length
00304         int len2 = offset+len;
00305 
00306         // one char seen
00307         offset++;
00308 
00309         // now loop for all other thingies
00310         while (
00311                (offset < len2)
00312                && (text[offset].isLetterOrNumber() || (text[offset] == QChar ('_')))
00313               )
00314           offset++;
00315 
00316         return offset;
00317       }
00318 
00319       return 0;
00320     }
00321 };
00322 
00323 //END
00324 
00325 #endif
00326 
00327 // 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
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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