Diffstat (limited to 'noncore/apps/tinykate/libkate/document/katehighlight.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katehighlight.cpp | 126 |
1 files changed, 65 insertions, 61 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp index 0d2c283..539d356 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp +++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp | |||
@@ -2,6 +2,6 @@ | |||
2 | Copyright (C) 1998, 1999 Jochen Wilhelmy | 2 | Copyright (C) 1998, 1999 Jochen Wilhelmy |
3 | digisnap@cs.tu-berlin.de | 3 | digisnap@cs.tu-berlin.de |
4 | (C) 2002, 2001 The Kate Team <kwrite-devel@kde.org> | 4 | (C) 2002, 2001 The Kate Team <kwrite-devel@kde.org> |
5 | (C) 2002 Joseph Wenninger <jowenn@kde.org> | 5 | (C) 2002 Joseph Wenninger <jowenn@kde.org> |
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
@@ -20,24 +20,28 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <string.h> | ||
23 | |||
24 | #include <qtextstream.h> | ||
25 | #include <qpe/config.h> | ||
26 | #include <kglobal.h> | ||
27 | //#include <kinstance.h> | ||
28 | //#include <kmimemagic.h> | ||
29 | #include <klocale.h> | ||
30 | //#include <kregexp.h> | ||
31 | #include <kglobalsettings.h> | ||
32 | #include <kdebug.h> | ||
33 | #include <kstddirs.h> | ||
34 | |||
35 | #include "katehighlight.h" | 22 | #include "katehighlight.h" |
36 | |||
37 | |||
38 | #include "katetextline.h" | 23 | #include "katetextline.h" |
39 | #include "katedocument.h" | 24 | #include "katedocument.h" |
40 | #include "katesyntaxdocument.h" | 25 | #include "katesyntaxdocument.h" |
41 | 26 | ||
27 | #include "kglobal.h" | ||
28 | //#include "kinstance.h" | ||
29 | //#include "kmimemagic.h" | ||
30 | #include "klocale.h" | ||
31 | //#include "kregexp.h" | ||
32 | #include "kglobalsettings.h" | ||
33 | #include "kdebug.h" | ||
34 | #include "kstddirs.h" | ||
35 | |||
36 | /* OPIE */ | ||
37 | #include <opie2/odebug.h> | ||
38 | #include <qpe/config.h> | ||
39 | |||
40 | /* QT */ | ||
41 | #include <qtextstream.h> | ||
42 | |||
43 | /* STD */ | ||
44 | #include <string.h> | ||
45 | |||
42 | 46 | ||
43 | HlManager *HlManager::s_pSelf = 0; | 47 | HlManager *HlManager::s_pSelf = 0; |
@@ -121,6 +125,6 @@ const QChar *HlStringDetect::checkHgl(const QChar *s, int len, bool) { | |||
121 | else | 125 | else |
122 | { | 126 | { |
123 | QString tmp=QString(s,str.length()).upper(); | 127 | QString tmp=QString(s,str.length()).upper(); |
124 | if (tmp==str) return s+str.length(); | 128 | if (tmp==str) return s+str.length(); |
125 | } | 129 | } |
126 | return 0L; | 130 | return 0L; |
@@ -214,8 +218,8 @@ const QChar *HlInt::checkHgl(const QChar *str, int len, bool) { | |||
214 | if (subItems) | 218 | if (subItems) |
215 | { | 219 | { |
216 | for (HlItem *it=subItems->first();it;it=subItems->next()) | 220 | for (HlItem *it=subItems->first();it;it=subItems->next()) |
217 | { | 221 | { |
218 | s1=it->checkHgl(s, len, false); | 222 | s1=it->checkHgl(s, len, false); |
219 | if (s1) return s1; | 223 | if (s1) return s1; |
220 | } | 224 | } |
221 | } | 225 | } |
@@ -249,12 +253,12 @@ const QChar *HlFloat::checkHgl(const QChar *s, int len, bool) { | |||
249 | else | 253 | else |
250 | if (!p) return 0L; | 254 | if (!p) return 0L; |
251 | else | 255 | else |
252 | { | 256 | { |
253 | if (subItems) | 257 | if (subItems) |
254 | { | 258 | { |
255 | for (HlItem *it=subItems->first();it;it=subItems->next()) | 259 | for (HlItem *it=subItems->first();it;it=subItems->next()) |
256 | { | 260 | { |
257 | s1=it->checkHgl(s, len, false); | 261 | s1=it->checkHgl(s, len, false); |
258 | if (s1) return s1; | 262 | if (s1) return s1; |
259 | } | 263 | } |
260 | } | 264 | } |
@@ -346,5 +350,5 @@ const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) { | |||
346 | if(pos > -1) return str+rx.matchedLength(); | 350 | if(pos > -1) return str+rx.matchedLength(); |
347 | else | 351 | else |
348 | return 0L; | 352 | return 0L; |
349 | 353 | ||
350 | #else | 354 | #else |
@@ -401,5 +405,5 @@ const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) | |||
401 | if (pos==-1) return 0L; | 405 | if (pos==-1) return 0L; |
402 | else | 406 | else |
403 | return (s+Expr->matchedLength()); | 407 | return (s+Expr->matchedLength()); |
404 | }; | 408 | }; |
405 | 409 | ||
@@ -412,7 +416,7 @@ const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) { | |||
412 | 416 | ||
413 | if ((s[0].latin1() == '\\') && (len == 1)) | 417 | if ((s[0].latin1() == '\\') && (len == 1)) |
414 | { | 418 | { |
415 | return s + 1; | 419 | return s + 1; |
416 | } | 420 | } |
417 | return 0L; | 421 | return 0L; |
418 | } | 422 | } |
@@ -622,5 +626,5 @@ int Highlight::doHighlight(int ctxNum, TextLine *textLine) | |||
622 | if (s2 > s1) | 626 | if (s2 > s1) |
623 | { | 627 | { |
624 | qDebug("An item has been detected"); | 628 | odebug << "An item has been detected" << oendl; |
625 | textLine->setAttribs(item->attr,s1 - str,s2 - str); | 629 | textLine->setAttribs(item->attr,s1 - str,s2 - str); |
626 | ctxNum = item->ctx; | 630 | ctxNum = item->ctx; |
@@ -854,5 +858,5 @@ void Highlight::done() | |||
854 | void Highlight::createItemData(ItemDataList &list) | 858 | void Highlight::createItemData(ItemDataList &list) |
855 | { | 859 | { |
856 | qDebug("Highlight::createItemData"); | 860 | odebug << "Highlight::createItemData" << oendl; |
857 | 861 | ||
858 | // If no highlighting is selected we need only one default. | 862 | // If no highlighting is selected we need only one default. |
@@ -875,5 +879,5 @@ void Highlight::createItemData(ItemDataList &list) | |||
875 | syntaxContextData *data; | 879 | syntaxContextData *data; |
876 | 880 | ||
877 | qDebug("Trying to read itemData section"); | 881 | odebug << "Trying to read itemData section" << oendl; |
878 | 882 | ||
879 | //Tell the syntax document class which file we want to parse and which data group | 883 | //Tell the syntax document class which file we want to parse and which data group |
@@ -883,5 +887,5 @@ void Highlight::createItemData(ItemDataList &list) | |||
883 | while (HlManager::self()->syntax->nextGroup(data)) | 887 | while (HlManager::self()->syntax->nextGroup(data)) |
884 | { | 888 | { |
885 | qDebug("Setting up one itemData element"); | 889 | odebug << "Setting up one itemData element" << oendl; |
886 | // read all attributes | 890 | // read all attributes |
887 | color=HlManager::self()->syntax->groupData(data,QString("color")); | 891 | color=HlManager::self()->syntax->groupData(data,QString("color")); |
@@ -934,10 +938,10 @@ void Highlight::createItemData(ItemDataList &list) | |||
934 | int Highlight::lookupAttrName(const QString& name, ItemDataList &iDl) | 938 | int Highlight::lookupAttrName(const QString& name, ItemDataList &iDl) |
935 | { | 939 | { |
936 | for (int i=0;i<iDl.count();i++) | 940 | for (int i=0;i<iDl.count();i++) |
937 | { | 941 | { |
938 | if (iDl.at(i)->name==name) return i; | 942 | if (iDl.at(i)->name==name) return i; |
939 | } | 943 | } |
940 | kdDebug(13010)<<"Couldn't resolve itemDataName"<<endl; | 944 | kdDebug(13010)<<"Couldn't resolve itemDataName"<<endl; |
941 | return 0; | 945 | return 0; |
942 | } | 946 | } |
943 | 947 | ||
@@ -1078,9 +1082,9 @@ void Highlight::readCommentConfig() | |||
1078 | 1082 | ||
1079 | if (HlManager::self()->syntax->groupData(data,"name")=="singleLine") | 1083 | if (HlManager::self()->syntax->groupData(data,"name")=="singleLine") |
1080 | cslStart=HlManager::self()->syntax->groupData(data,"start"); | 1084 | cslStart=HlManager::self()->syntax->groupData(data,"start"); |
1081 | if (HlManager::self()->syntax->groupData(data,"name")=="multiLine") | 1085 | if (HlManager::self()->syntax->groupData(data,"name")=="multiLine") |
1082 | { | 1086 | { |
1083 | cmlStart=HlManager::self()->syntax->groupData(data,"start"); | 1087 | cmlStart=HlManager::self()->syntax->groupData(data,"start"); |
1084 | cmlEnd=HlManager::self()->syntax->groupData(data,"end"); | 1088 | cmlEnd=HlManager::self()->syntax->groupData(data,"end"); |
1085 | } | 1089 | } |
1086 | } | 1090 | } |
@@ -1113,8 +1117,8 @@ void Highlight::readGlobalKeywordConfig() | |||
1113 | if (data) | 1117 | if (data) |
1114 | { | 1118 | { |
1115 | kdDebug(13010)<<"Found global keyword config"<<endl; | 1119 | kdDebug(13010)<<"Found global keyword config"<<endl; |
1116 | 1120 | ||
1117 | if (HlManager::self()->syntax->groupItemData(data,QString("casesensitive"))!="0") | 1121 | if (HlManager::self()->syntax->groupItemData(data,QString("casesensitive"))!="0") |
1118 | casesensitive=true; else {casesensitive=false; kdDebug(13010)<<"Turning on case insensitiveness"<<endl;} | 1122 | casesensitive=true; else {casesensitive=false; kdDebug(13010)<<"Turning on case insensitiveness"<<endl;} |
1119 | //get the weak deliminators | 1123 | //get the weak deliminators |
1120 | weakDeliminator=(!HlManager::self()->syntax->groupItemData(data,QString("weakDeliminator"))); | 1124 | weakDeliminator=(!HlManager::self()->syntax->groupItemData(data,QString("weakDeliminator"))); |
@@ -1134,5 +1138,5 @@ void Highlight::readGlobalKeywordConfig() | |||
1134 | deliminatorLen = deliminator.length(); | 1138 | deliminatorLen = deliminator.length(); |
1135 | 1139 | ||
1136 | HlManager::self()->syntax->freeGroupInfo(data); | 1140 | HlManager::self()->syntax->freeGroupInfo(data); |
1137 | } | 1141 | } |
1138 | else | 1142 | else |
@@ -1205,23 +1209,23 @@ void Highlight::makeContextList() | |||
1205 | while (HlManager::self()->syntax->nextItem(data)) | 1209 | while (HlManager::self()->syntax->nextItem(data)) |
1206 | { | 1210 | { |
1207 | // kdDebug(13010)<< "In make Contextlist: Item:"<<endl; | 1211 | // kdDebug(13010)<< "In make Contextlist: Item:"<<endl; |
1208 | c=createHlItem(data,iDl); | 1212 | c=createHlItem(data,iDl); |
1209 | if (c) | 1213 | if (c) |
1210 | { | 1214 | { |
1211 | contextList[i]->items.append(c); | 1215 | contextList[i]->items.append(c); |
1212 | 1216 | ||
1213 | // Not supported completely atm and only one level. Subitems.(all have to be matched to at once) | 1217 | // Not supported completely atm and only one level. Subitems.(all have to be matched to at once) |
1214 | datasub=HlManager::self()->syntax->getSubItems(data); | 1218 | datasub=HlManager::self()->syntax->getSubItems(data); |
1215 | bool tmpbool; | 1219 | bool tmpbool; |
1216 | if (tmpbool=HlManager::self()->syntax->nextItem(datasub)) | 1220 | if (tmpbool=HlManager::self()->syntax->nextItem(datasub)) |
1217 | { | 1221 | { |
1218 | c->subItems=new QList<HlItem>; | 1222 | c->subItems=new QList<HlItem>; |
1219 | for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub)) | 1223 | for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub)) |
1220 | c->subItems->append(createHlItem(datasub,iDl)); | 1224 | c->subItems->append(createHlItem(datasub,iDl)); |
1221 | } | 1225 | } |
1222 | HlManager::self()->syntax->freeGroupInfo(datasub); | 1226 | HlManager::self()->syntax->freeGroupInfo(datasub); |
1223 | // end of sublevel | 1227 | // end of sublevel |
1224 | } | 1228 | } |
1225 | // kdDebug(13010)<<"Last line in loop"<<endl; | 1229 | // kdDebug(13010)<<"Last line in loop"<<endl; |
1226 | } | 1230 | } |
1227 | i++; | 1231 | i++; |
@@ -1313,5 +1317,5 @@ int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) { | |||
1313 | int nAttribs, z; | 1317 | int nAttribs, z; |
1314 | 1318 | ||
1315 | qDebug("HlManager::makeAttribs"); | 1319 | odebug << "HlManager::makeAttribs" << oendl; |
1316 | 1320 | ||
1317 | defaultStyleList.setAutoDelete(true); | 1321 | defaultStyleList.setAutoDelete(true); |
@@ -1322,5 +1326,5 @@ int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) { | |||
1322 | nAttribs = itemDataList.count(); | 1326 | nAttribs = itemDataList.count(); |
1323 | for (z = 0; z < nAttribs; z++) { | 1327 | for (z = 0; z < nAttribs; z++) { |
1324 | qDebug("HlManager::makeAttribs: createing one attribute definition"); | 1328 | odebug << "HlManager::makeAttribs: createing one attribute definition" << oendl; |
1325 | itemData = itemDataList.at(z); | 1329 | itemData = itemDataList.at(z); |
1326 | if (itemData->defStyle) { | 1330 | if (itemData->defStyle) { |
@@ -1416,5 +1420,5 @@ void HlManager::setDefaults(ItemStyleList &list) { | |||
1416 | char s[64]; | 1420 | char s[64]; |
1417 | #warning fixme | 1421 | #warning fixme |
1418 | /* | 1422 | /* |
1419 | config = KateFactory::instance()->config(); | 1423 | config = KateFactory::instance()->config(); |
1420 | config->setGroup("Default Item Styles"); | 1424 | config->setGroup("Default Item Styles"); |