• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Kate

katehighlighthelpers.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2003, 2004 Anders Lund <anders@alweb.dk>
00003    Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
00004    Copyright (C) 2001,2002 Joseph Wenninger <jowenn@kde.org>
00005    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
00006    Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public
00010    License version 2 as published by the Free Software Foundation.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 //BEGIN INCLUDES
00024 #include "katehighlighthelpers.h"
00025 
00026 #include "katetextline.h"
00027 #include "katedocument.h"
00028 #include "katesyntaxdocument.h"
00029 #include "katerenderer.h"
00030 #include "kateglobal.h"
00031 #include "kateschema.h"
00032 #include "kateconfig.h"
00033 #include "kateextendedattribute.h"
00034 
00035 #include <QtCore/QSet>
00036 //END
00037 
00038 //BEGIN KateHlItem
00039 KateHlItem::KateHlItem(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
00040   : attr(attribute),
00041     ctx(context),
00042     region(regionId),
00043     region2(regionId2),
00044     lookAhead(false),
00045     dynamic(false),
00046     dynamicChild(false),
00047     firstNonSpace(false),
00048     onlyConsume(false),
00049     column (-1),
00050     alwaysStartEnable (true),
00051     customStartEnable (false),
00052     haveCache(false),
00053     cachingHandled(false)
00054 {
00055 }
00056 
00057 KateHlItem::~KateHlItem()
00058 {
00059 }
00060 
00061 void KateHlItem::dynamicSubstitute(QString &str, const QStringList *args)
00062 {
00063   for (int i = 0; i < str.length() - 1; ++i)
00064   {
00065     if (str[i] == '%')
00066     {
00067       char c = str[i + 1].toLatin1();
00068       if (c == '%')
00069         str.remove(i, 1);
00070       else if (c >= '0' && c <= '9')
00071       {
00072         if ((int)(c - '0') < args->size())
00073         {
00074           str.replace(i, 2, (*args)[c - '0']);
00075           i += ((*args)[c - '0']).length() - 1;
00076         }
00077         else
00078         {
00079           str.remove(i, 2);
00080           --i;
00081         }
00082       }
00083     }
00084   }
00085 }
00086 //END
00087 
00088 //BEGIN KateHlCharDetect
00089 KateHlCharDetect::KateHlCharDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, QChar c)
00090   : KateHlItem(attribute,context,regionId,regionId2)
00091   , sChar(c)
00092 {
00093 }
00094 
00095 int KateHlCharDetect::checkHgl(const QString& text, int offset, int /*len*/)
00096 {
00097   if (text[offset] == sChar)
00098     return offset + 1;
00099 
00100   return 0;
00101 }
00102 
00103 KateHlItem *KateHlCharDetect::clone(const QStringList *args)
00104 {
00105   char c = sChar.toLatin1();
00106 
00107   if (c < '0' || c > '9' || (c - '0') >= args->size())
00108     return this;
00109 
00110   KateHlCharDetect *ret = new KateHlCharDetect(attr, ctx, region, region2, (*args)[c - '0'][0]);
00111   ret->dynamicChild = true;
00112   return ret;
00113 }
00114 //END
00115 
00116 //BEGIN KateHl2CharDetect
00117 KateHl2CharDetect::KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, QChar ch1, QChar ch2)
00118   : KateHlItem(attribute,context,regionId,regionId2)
00119   , sChar1 (ch1)
00120   , sChar2 (ch2)
00121 {
00122 }
00123 
00124 int KateHl2CharDetect::checkHgl(const QString& text, int offset, int len)
00125 {
00126   if ((len >= 2) && text[offset++] == sChar1 && text[offset++] == sChar2)
00127     return offset;
00128 
00129   return 0;
00130 }
00131 
00132 KateHlItem *KateHl2CharDetect::clone(const QStringList *args)
00133 {
00134   char c1 = sChar1.toLatin1();
00135   char c2 = sChar2.toLatin1();
00136 
00137   if (c1 < '0' || c1 > '9' || (c1 - '0') >= args->size())
00138     return this;
00139 
00140   if (c2 < '0' || c2 > '9' || (c2 - '0') >= args->size())
00141     return this;
00142 
00143   KateHl2CharDetect *ret = new KateHl2CharDetect(attr, ctx, region, region2, (*args)[c1 - '0'][0], (*args)[c2 - '0'][0]);
00144   ret->dynamicChild = true;
00145   return ret;
00146 }
00147 //END
00148 
00149 //BEGIN KateHlStringDetect
00150 KateHlStringDetect::KateHlStringDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2,const QString &s, bool inSensitive)
00151   : KateHlItem(attribute, context,regionId,regionId2)
00152   , str(inSensitive ? s.toUpper() : s)
00153   , strLen (str.length())
00154   , _inSensitive(inSensitive)
00155 {
00156 }
00157 
00158 int KateHlStringDetect::checkHgl(const QString& text, int offset, int len)
00159 {
00160   if (len < strLen)
00161     return 0;
00162 
00163   if (_inSensitive)
00164   {
00165     for (int i=0; i < strLen; i++)
00166       if (text[offset++].toUpper() != str[i])
00167         return 0;
00168 
00169     return offset;
00170   }
00171   else
00172   {
00173     for (int i=0; i < strLen; i++)
00174       if (text[offset++] != str[i])
00175         return 0;
00176 
00177     return offset;
00178   }
00179 
00180   return 0;
00181 }
00182 
00183 KateHlItem *KateHlStringDetect::clone(const QStringList *args)
00184 {
00185   QString newstr = str;
00186 
00187   dynamicSubstitute(newstr, args);
00188 
00189   if (newstr == str)
00190     return this;
00191 
00192   KateHlStringDetect *ret = new KateHlStringDetect(attr, ctx, region, region2, newstr, _inSensitive);
00193   ret->dynamicChild = true;
00194   return ret;
00195 }
00196 //END
00197 
00198 //BEGIN KateHlWordDetect
00199 
00200 KateHlWordDetect::KateHlWordDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString& s, bool inSensitive)
00201   : KateHlStringDetect(attribute, context, regionId, regionId2, s, inSensitive)
00202 {
00203 }
00204 
00205 inline bool isWordCharacter(const QChar& c)
00206 {
00207   // The Qt docs say for word characters:
00208   //      \w  - Matches a word character (QChar::isLetterOrNumber(), QChar::isMark(), or '_').
00209   // see also: http://doc.trolltech.com/qregexp.html
00210   return c.isLetterOrNumber() || c.isMark() || c.unicode() == '_';
00211 }
00212 
00213 int KateHlWordDetect::checkHgl(const QString& text, int offset, int len)
00214 {
00215   //NOTE: word boundary means: any non-word character.
00216 
00217   // make sure there is no letter or number before the word starts
00218   if (offset > 0 && isWordCharacter(text.at(offset))) {
00219     return 0;
00220   }
00221   offset = KateHlStringDetect::checkHgl(text, offset, len);
00222   // make sure there is no letter or number after the word ends
00223   if (offset && offset < text.length() && isWordCharacter(text.at(offset))) {
00224     return 0;
00225   }
00226   return offset;
00227 }
00228 
00229 KateHlItem* KateHlWordDetect::clone(const QStringList* args)
00230 {
00231   QString newstr = str;
00232 
00233   dynamicSubstitute(newstr, args);
00234 
00235   if (newstr == str)
00236     return this;
00237 
00238   KateHlWordDetect *ret = new KateHlWordDetect(attr, ctx, region, region2, newstr, _inSensitive);
00239   ret->dynamicChild = true;
00240   return ret;
00241 }
00242 
00243 
00244 //END KateHlWordDetect
00245 
00246 //BEGIN KateHlRangeDetect
00247 KateHlRangeDetect::KateHlRangeDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, QChar ch1, QChar ch2)
00248   : KateHlItem(attribute,context,regionId,regionId2)
00249   , sChar1 (ch1)
00250   , sChar2 (ch2)
00251 {
00252 }
00253 
00254 int KateHlRangeDetect::checkHgl(const QString& text, int offset, int len)
00255 {
00256   if (text[offset] == sChar1)
00257   {
00258     do
00259     {
00260       offset++;
00261       len--;
00262       if (len < 1) return 0;
00263     }
00264     while (text[offset] != sChar2);
00265 
00266     return offset + 1;
00267   }
00268   return 0;
00269 }
00270 //END
00271 
00272 //BEGIN KateHlKeyword
00273 KateHlKeyword::KateHlKeyword (int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, bool insensitive, const QString& delims)
00274   : KateHlItem(attribute,context,regionId,regionId2)
00275   , _insensitive(insensitive)
00276   , minLen (0xFFFFFF)
00277   , maxLen (0)
00278 {
00279   alwaysStartEnable = false;
00280   customStartEnable = true;
00281   foreach (const QChar &c, delims)
00282     deliminators << c;
00283 }
00284 
00285 KateHlKeyword::~KateHlKeyword ()
00286 {
00287   for (int i=0; i < dict.size(); ++i)
00288     delete dict[i];
00289 }
00290 
00291 void KateHlKeyword::addList(const QStringList& list)
00292 {
00293   for(int i=0; i < list.count(); ++i)
00294   {
00295     int len = list[i].length();
00296 
00297     if (minLen > len)
00298       minLen = len;
00299 
00300     if (maxLen < len)
00301       maxLen = len;
00302 
00303     if (len >= dict.size())
00304     {
00305       uint oldSize = dict.size();
00306       dict.resize (len+1);
00307 
00308       for (int m=oldSize; m < dict.size(); ++m)
00309         dict[m] = 0;
00310     }
00311 
00312     if (!dict[len])
00313       dict[len] = new QSet<QString> ();
00314 
00315     if (!_insensitive)
00316       dict[len]->insert(list[i]);
00317     else
00318       dict[len]->insert(list[i].toLower());
00319   }
00320 }
00321 
00322 int KateHlKeyword::checkHgl(const QString& text, int offset, int len)
00323 {
00324   int offset2 = offset;
00325   int wordLen = 0;
00326 
00327   while ((len > wordLen) && !deliminators.contains(text[offset2]))
00328   {
00329     offset2++;
00330     wordLen++;
00331 
00332     if (wordLen > maxLen) return 0;
00333   }
00334 
00335   if (wordLen < minLen || !dict[wordLen]) return 0;
00336 
00337   if (!_insensitive)
00338   {
00339     if (dict[wordLen]->contains(QString::fromRawData(text.unicode() + offset, wordLen)) )
00340       return offset2;
00341   }
00342   else
00343   {
00344     if (dict[wordLen]->contains(QString::fromRawData(text.unicode() + offset, wordLen).toLower()) )
00345       return offset2;
00346   }
00347 
00348   return 0;
00349 }
00350 //END
00351 
00352 //BEGIN KateHlInt
00353 KateHlInt::KateHlInt(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
00354   : KateHlItem(attribute,context,regionId,regionId2)
00355 {
00356   alwaysStartEnable = false;
00357 }
00358 
00359 int KateHlInt::checkHgl(const QString& text, int offset, int len)
00360 {
00361   int offset2 = offset;
00362 
00363   while ((len > 0) && text[offset2].isDigit())
00364   {
00365     offset2++;
00366     len--;
00367   }
00368 
00369   if (offset2 > offset)
00370   {
00371     if (len > 0)
00372     {
00373       for (int i=0; i < subItems.size(); i++)
00374       {
00375         if ( (offset = subItems[i]->checkHgl(text, offset2, len)) )
00376           return offset;
00377       }
00378     }
00379 
00380     return offset2;
00381   }
00382 
00383   return 0;
00384 }
00385 //END
00386 
00387 //BEGIN KateHlFloat
00388 KateHlFloat::KateHlFloat(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
00389   : KateHlItem(attribute,context, regionId,regionId2)
00390 {
00391   alwaysStartEnable = false;
00392 }
00393 
00394 int KateHlFloat::checkHgl(const QString& text, int offset, int len)
00395 {
00396   bool b = false;
00397   bool p = false;
00398 
00399   while ((len > 0) && text[offset].isDigit())
00400   {
00401     offset++;
00402     len--;
00403     b = true;
00404   }
00405 
00406   if ((len > 0) && (p = (text[offset] == '.')))
00407   {
00408     offset++;
00409     len--;
00410 
00411     while ((len > 0) && text[offset].isDigit())
00412     {
00413       offset++;
00414       len--;
00415       b = true;
00416     }
00417   }
00418 
00419   if (!b)
00420     return 0;
00421 
00422   if ((len > 0) && ((text[offset].toAscii() & 0xdf) == 'E'))
00423   {
00424     offset++;
00425     len--;
00426   }
00427   else
00428   {
00429     if (!p)
00430       return 0;
00431     else
00432     {
00433       if (len > 0)
00434       {
00435         for (int i=0; i < subItems.size(); ++i)
00436         {
00437           int offset2 = subItems[i]->checkHgl(text, offset, len);
00438 
00439           if (offset2)
00440             return offset2;
00441         }
00442       }
00443 
00444       return offset;
00445     }
00446   }
00447 
00448   if ((len > 0) && (text[offset] == '-' || text[offset] =='+'))
00449   {
00450     offset++;
00451     len--;
00452   }
00453 
00454   b = false;
00455 
00456   while ((len > 0) && text[offset].isDigit())
00457   {
00458     offset++;
00459     len--;
00460     b = true;
00461   }
00462 
00463   if (b)
00464   {
00465     if (len > 0)
00466     {
00467       for (int i=0; i < subItems.size(); ++i)
00468       {
00469         int offset2 = subItems[i]->checkHgl(text, offset, len);
00470 
00471         if (offset2)
00472           return offset2;
00473       }
00474     }
00475 
00476     return offset;
00477   }
00478 
00479   return 0;
00480 }
00481 //END
00482 
00483 //BEGIN KateHlCOct
00484 KateHlCOct::KateHlCOct(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
00485   : KateHlItem(attribute,context,regionId,regionId2)
00486 {
00487   alwaysStartEnable = false;
00488 }
00489 
00490 int KateHlCOct::checkHgl(const QString& text, int offset, int len)
00491 {
00492   if (text[offset].toAscii() == '0')
00493   {
00494     offset++;
00495     len--;
00496 
00497     int offset2 = offset;
00498 
00499     while ((len > 0) && (text[offset2].toAscii() >= '0' && text[offset2].toAscii() <= '7'))
00500     {
00501       offset2++;
00502       len--;
00503     }
00504 
00505     if (offset2 > offset)
00506     {
00507       if ((len > 0) && ((text[offset2].toAscii() & 0xdf) == 'L' || (text[offset].toAscii() & 0xdf) == 'U' ))
00508         offset2++;
00509 
00510       return offset2;
00511     }
00512   }
00513 
00514   return 0;
00515 }
00516 //END
00517 
00518 //BEGIN KateHlCHex
00519 KateHlCHex::KateHlCHex(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
00520   : KateHlItem(attribute,context,regionId,regionId2)
00521 {
00522   alwaysStartEnable = false;
00523 }
00524 
00525 int KateHlCHex::checkHgl(const QString& text, int offset, int len)
00526 {
00527   if ((len > 1) && (text[offset++].toAscii() == '0') && ((text[offset++].toAscii() & 0xdf) == 'X' ))
00528   {
00529     len -= 2;
00530 
00531     int offset2 = offset;
00532 
00533     while ((len > 0) && (text[offset2].isDigit() || ((text[offset2].toAscii() & 0xdf) >= 'A' && (text[offset2].toAscii() & 0xdf) <= 'F')))
00534     {
00535       offset2++;
00536       len--;
00537     }
00538 
00539     if (offset2 > offset)
00540     {
00541       if ((len > 0) && ((text[offset2].toAscii() & 0xdf) == 'L' || (text[offset2].toAscii() & 0xdf) == 'U' ))
00542         offset2++;
00543 
00544       return offset2;
00545     }
00546   }
00547 
00548   return 0;
00549 }
00550 //END
00551 
00552 //BEGIN KateHlCFloat
00553 KateHlCFloat::KateHlCFloat(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
00554   : KateHlFloat(attribute,context,regionId,regionId2)
00555 {
00556   alwaysStartEnable = false;
00557 }
00558 
00559 int KateHlCFloat::checkIntHgl(const QString& text, int offset, int len)
00560 {
00561   int offset2 = offset;
00562 
00563   while ((len > 0) && text[offset].isDigit()) {
00564     offset2++;
00565     len--;
00566   }
00567 
00568   if (offset2 > offset)
00569      return offset2;
00570 
00571   return 0;
00572 }
00573 
00574 int KateHlCFloat::checkHgl(const QString& text, int offset, int len)
00575 {
00576   int offset2 = KateHlFloat::checkHgl(text, offset, len);
00577 
00578   if (offset2)
00579   {
00580     if ((text[offset2].toAscii() & 0xdf) == 'F' )
00581       offset2++;
00582 
00583     return offset2;
00584   }
00585   else
00586   {
00587     offset2 = checkIntHgl(text, offset, len);
00588 
00589     if (offset2 && ((text[offset2].toAscii() & 0xdf) == 'F' ))
00590       return ++offset2;
00591     else
00592       return 0;
00593   }
00594 }
00595 //END
00596 
00597 //BEGIN KateHlAnyChar
00598 KateHlAnyChar::KateHlAnyChar(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QString& charList)
00599   : KateHlItem(attribute, context,regionId,regionId2)
00600   , _charList(charList)
00601 {
00602 }
00603 
00604 int KateHlAnyChar::checkHgl(const QString& text, int offset, int)
00605 {
00606   if (_charList.contains(text[offset]))
00607     return ++offset;
00608 
00609   return 0;
00610 }
00611 //END
00612 
00613 //BEGIN KateHlRegExpr
00614 KateHlRegExpr::KateHlRegExpr( int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QString &regexp, bool insensitive, bool minimal)
00615   : KateHlItem(attribute, context, regionId,regionId2)
00616   , handlesLinestart (regexp.startsWith('^'))
00617   , _regexp(regexp)
00618   , _insensitive(insensitive)
00619   , _minimal(minimal)
00620   , _lastOffset(-2) // -2 is start value, -1 is "not found at all"
00621   , Expr (regexp, _insensitive ? Qt::CaseInsensitive : Qt::CaseSensitive)
00622 {
00623   // minimal or not ;)
00624   Expr.setMinimal(_minimal);
00625 }
00626 
00627 int KateHlRegExpr::checkHgl(const QString& text, int offset, int /*len*/)
00628 {
00629   if (offset && handlesLinestart)
00630     return 0;
00631 
00632   // optimization: if we check something on the same text as the last time,
00633   //               try to reuse what we got that time
00634   if ( haveCache ) {
00635     if ( offset < _lastOffset || _lastOffset == -1 ) {
00636       // reuse last match: not found or offset before match
00637       return 0;
00638     } else if ( offset == _lastOffset ) {
00639       // reuse last match: found at this position
00640       return (_lastOffset + _lastOffsetLength);
00641     }
00642   }
00643 
00644   haveCache = true;
00645   _lastOffset = Expr.indexIn( text, offset, QRegExp::CaretAtOffset );
00646 
00647   if (_lastOffset == -1) return 0;
00648 
00649   _lastOffsetLength = Expr.matchedLength();
00650 
00651   if ( _lastOffset == offset ) {
00652     // only valid when we match at the exact offset
00653     return (_lastOffset + _lastOffsetLength);
00654   } else {
00655     return 0;
00656   }
00657 }
00658 
00659 void KateHlRegExpr::capturedTexts (QStringList &list)
00660 {
00661   list = Expr.capturedTexts();
00662 }
00663 
00664 KateHlItem *KateHlRegExpr::clone(const QStringList *args)
00665 {
00666   QString regexp = _regexp;
00667   QStringList escArgs = *args;
00668 
00669   for (QStringList::Iterator it = escArgs.begin(); it != escArgs.end(); ++it)
00670   {
00671     (*it).replace(QRegExp("(\\W)"), "\\\\1");
00672   }
00673 
00674   dynamicSubstitute(regexp, &escArgs);
00675 
00676   if (regexp == _regexp)
00677     return this;
00678 
00679   // kDebug (13010) << "clone regexp: " << regexp;
00680 
00681   KateHlRegExpr *ret = new KateHlRegExpr(attr, ctx, region, region2, regexp, _insensitive, _minimal);
00682   ret->dynamicChild = true;
00683   return ret;
00684 }
00685 //END
00686 
00687 //BEGIN KateHlLineContinue
00688 KateHlLineContinue::KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
00689   : KateHlItem(attribute,context,regionId,regionId2) {
00690 }
00691 
00692 int KateHlLineContinue::checkHgl(const QString& text, int offset, int len)
00693 {
00694   if ((len == 1) && (text[offset] == '\\'))
00695     return ++offset;
00696 
00697   return 0;
00698 }
00699 //END
00700 
00701 //BEGIN KateHlCStringChar
00702 KateHlCStringChar::KateHlCStringChar(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
00703   : KateHlItem(attribute,context,regionId,regionId2) {
00704 }
00705 
00706 // checks for C escaped chars \n and escaped hex/octal chars
00707 static int checkEscapedChar(const QString& text, int offset, int& len)
00708 {
00709   int i;
00710   if (text[offset] == '\\' && len > 1)
00711   {
00712     offset++;
00713     len--;
00714 
00715     switch(text[offset].toAscii())
00716     {
00717       case  'a': // checks for control chars
00718       case  'b': // we want to fall through
00719       case  'e':
00720       case  'f':
00721 
00722       case  'n':
00723       case  'r':
00724       case  't':
00725       case  'v':
00726       case '\'':
00727       case '\"':
00728       case '?' : // added ? ANSI C classifies this as an escaped char
00729       case '\\':
00730         offset++;
00731         len--;
00732         break;
00733 
00734       case 'x': // if it's like \xff
00735         offset++; // eat the x
00736         len--;
00737         // these for loops can probably be
00738         // replaced with something else but
00739         // for right now they work
00740         // check for hexdigits
00741         for (i = 0; (len > 0) && (i < 2); i++)
00742         {
00743           const char ch = text[offset].toAscii();
00744           if (((ch >= '0') && (ch <= '9')) || (((ch & 0xdf) >= 'A') && ((ch & 0xdf) <= 'F'))) {
00745             offset++;
00746             len--;
00747           } else {
00748             break;
00749           }
00750         }
00751 
00752         if (i == 0)
00753           return 0; // takes care of case '\x'
00754 
00755         break;
00756 
00757       case '0': case '1': case '2': case '3' :
00758       case '4': case '5': case '6': case '7' :
00759         for (i = 0; (len > 0) && (i < 3) && (text[offset] >='0'&& text[offset] <='7'); i++)
00760         {
00761           offset++;
00762           len--;
00763         }
00764         break;
00765 
00766       default:
00767         return 0;
00768     }
00769 
00770     return offset;
00771   }
00772 
00773   return 0;
00774 }
00775 
00776 int KateHlCStringChar::checkHgl(const QString& text, int offset, int len)
00777 {
00778   return checkEscapedChar(text, offset, len);
00779 }
00780 //END
00781 
00782 //BEGIN KateHlCChar
00783 KateHlCChar::KateHlCChar(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
00784   : KateHlItem(attribute,context,regionId,regionId2) {
00785 }
00786 
00787 int KateHlCChar::checkHgl(const QString& text, int offset, int len)
00788 {
00789   if ((len > 1) && (text[offset] == '\'') && (text[offset+1] != '\''))
00790   {
00791     int oldl;
00792     oldl = len;
00793 
00794     len--;
00795 
00796     int offset2 = checkEscapedChar(text, offset + 1, len);
00797 
00798     if (!offset2)
00799     {
00800       if (oldl > 2)
00801       {
00802         offset2 = offset + 2;
00803         len = oldl - 2;
00804       }
00805       else
00806       {
00807         return 0;
00808       }
00809     }
00810 
00811     if ((len > 0) && (text[offset2] == '\''))
00812       return ++offset2;
00813   }
00814 
00815   return 0;
00816 }
00817 //END
00818 
00819 //BEGIN KateHl2CharDetect
00820 KateHl2CharDetect::KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QChar *s)
00821   : KateHlItem(attribute,context,regionId,regionId2) {
00822   sChar1 = s[0];
00823   sChar2 = s[1];
00824   }
00825 //END KateHl2CharDetect
00826 
00827 //BEGIN KateHlContext
00828 KateHlContext::KateHlContext (const QString &_hlId, int attribute, KateHlContextModification _lineEndContext, KateHlContextModification _lineBeginContext, bool _fallthrough,
00829     KateHlContextModification _fallthroughContext, bool _dynamic, bool _noIndentationBasedFolding)
00830 {
00831   hlId = _hlId;
00832   attr = attribute;
00833   lineEndContext = _lineEndContext;
00834   lineBeginContext = _lineBeginContext;
00835   fallthrough = _fallthrough;
00836   ftctx = _fallthroughContext;
00837   dynamic = _dynamic;
00838   dynamicChild = false;
00839   noIndentationBasedFolding=_noIndentationBasedFolding;
00840   if (_noIndentationBasedFolding) kDebug(13010)<<QString("**********************_noIndentationBasedFolding is TRUE*****************");
00841 
00842 }
00843 
00844 KateHlContext *KateHlContext::clone(const QStringList *args)
00845 {
00846   KateHlContext *ret = new KateHlContext(hlId, attr, lineEndContext, lineBeginContext, fallthrough, ftctx, false,noIndentationBasedFolding);
00847 
00848   for (int n=0; n < items.size(); ++n)
00849   {
00850     KateHlItem *item = items[n];
00851     KateHlItem *i = (item->dynamic ? item->clone(args) : item);
00852     ret->items.append(i);
00853   }
00854 
00855   ret->dynamicChild = true;
00856 
00857   return ret;
00858 }
00859 
00860 KateHlContext::~KateHlContext()
00861 {
00862   if (dynamicChild)
00863   {
00864     for (int n=0; n < items.size(); ++n)
00865     {
00866       if (items[n]->dynamicChild)
00867         delete items[n];
00868     }
00869   }
00870 }
00871 //END
00872 
00873 // 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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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