00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00034
00035
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
00060
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;
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
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
00301 if ( text[offset].isLetter() || text[offset] == QChar ('_') )
00302 {
00303
00304 int len2 = offset+len;
00305
00306
00307 offset++;
00308
00309
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
00324
00325 #endif
00326
00327