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 | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp index 89024f7..ee6030f 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp +++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp | |||
@@ -1255,165 +1255,167 @@ HlManager::HlManager() : QObject(0L) | |||
1255 | { | 1255 | { |
1256 | hlList.append(new Highlight(modeList.at(i))); | 1256 | hlList.append(new Highlight(modeList.at(i))); |
1257 | i++; | 1257 | i++; |
1258 | } | 1258 | } |
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | HlManager::~HlManager() { | 1261 | HlManager::~HlManager() { |
1262 | if(syntax) delete syntax; | 1262 | if(syntax) delete syntax; |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | HlManager *HlManager::self() | 1265 | HlManager *HlManager::self() |
1266 | { | 1266 | { |
1267 | if ( !s_pSelf ) | 1267 | if ( !s_pSelf ) |
1268 | s_pSelf = new HlManager; | 1268 | s_pSelf = new HlManager; |
1269 | return s_pSelf; | 1269 | return s_pSelf; |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | Highlight *HlManager::getHl(int n) { | 1272 | Highlight *HlManager::getHl(int n) { |
1273 | if (n < 0 || n >= (int) hlList.count()) n = 0; | 1273 | if (n < 0 || n >= (int) hlList.count()) n = 0; |
1274 | return hlList.at(n); | 1274 | return hlList.at(n); |
1275 | } | 1275 | } |
1276 | 1276 | ||
1277 | int HlManager::defaultHl() { | 1277 | int HlManager::defaultHl() { |
1278 | KateConfig *config; | 1278 | KateConfig *config; |
1279 | config = KGlobal::config(); | 1279 | config = KGlobal::config(); |
1280 | config->setGroup("General Options"); | 1280 | config->setGroup("General Options"); |
1281 | 1281 | ||
1282 | #warning fixme return nameFind(config->readEntry("Highlight")); | 1282 | #warning fixme return nameFind(config->readEntry("Highlight")); |
1283 | 1283 | ||
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | 1286 | ||
1287 | int HlManager::nameFind(const QString &name) { | 1287 | int HlManager::nameFind(const QString &name) { |
1288 | int z; | 1288 | int z; |
1289 | 1289 | ||
1290 | for (z = hlList.count() - 1; z > 0; z--) { | 1290 | for (z = hlList.count() - 1; z > 0; z--) { |
1291 | if (hlList.at(z)->iName == name) break; | 1291 | if (hlList.at(z)->iName == name) break; |
1292 | } | 1292 | } |
1293 | return z; | 1293 | return z; |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | int HlManager::wildcardFind(const QString &fileName) { | 1296 | int HlManager::wildcardFind(const QString &fileName) { |
1297 | Highlight *highlight; | 1297 | Highlight *highlight; |
1298 | int p1, p2; | 1298 | int p1, p2; |
1299 | QString w; | 1299 | QString w; |
1300 | for (highlight = hlList.first(); highlight != 0L; highlight = hlList.next()) { | 1300 | for (highlight = hlList.first(); highlight != 0L; highlight = hlList.next()) { |
1301 | p1 = 0; | 1301 | p1 = 0; |
1302 | w = highlight->getWildcards(); | 1302 | w = highlight->getWildcards(); |
1303 | while (p1 < (int) w.length()) { | 1303 | while (p1 < (int) w.length()) { |
1304 | p2 = w.find(';',p1); | 1304 | p2 = w.find(';',p1); |
1305 | if (p2 == -1) p2 = w.length(); | 1305 | if (p2 == -1) p2 = w.length(); |
1306 | if (p1 < p2) { | 1306 | if (p1 < p2) { |
1307 | QRegExp regExp(w.mid(p1,p2 - p1),true,true); | 1307 | QRegExp regExp(w.mid(p1,p2 - p1),true,true); |
1308 | if (regExp.match(fileName) == 0) return hlList.at(); | 1308 | if (regExp.match(fileName) == 0) return hlList.at(); |
1309 | } | 1309 | } |
1310 | p1 = p2 + 1; | 1310 | p1 = p2 + 1; |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | return -1; | 1313 | return -1; |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | 1316 | ||
1317 | int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) { | 1317 | int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) { |
1318 | ItemStyleList defaultStyleList; | 1318 | ItemStyleList defaultStyleList; |
1319 | ItemStyle *defaultStyle; | 1319 | ItemStyle *defaultStyle = 0; |
1320 | ItemDataList itemDataList; | 1320 | ItemDataList itemDataList; |
1321 | ItemData *itemData; | 1321 | ItemData *itemData; |
1322 | int nAttribs, z; | 1322 | int nAttribs, z; |
1323 | 1323 | ||
1324 | odebug << "HlManager::makeAttribs" << oendl; | 1324 | odebug << "HlManager::makeAttribs" << oendl; |
1325 | 1325 | ||
1326 | defaultStyleList.setAutoDelete(true); | 1326 | defaultStyleList.setAutoDelete(true); |
1327 | getDefaults(defaultStyleList); | 1327 | getDefaults(defaultStyleList); |
1328 | 1328 | ||
1329 | // itemDataList.setAutoDelete(true); | 1329 | // itemDataList.setAutoDelete(true); |
1330 | highlight->getItemDataList(itemDataList); | 1330 | highlight->getItemDataList(itemDataList); |
1331 | nAttribs = itemDataList.count(); | 1331 | nAttribs = itemDataList.count(); |
1332 | for (z = 0; z < nAttribs; z++) { | 1332 | for (z = 0; z < nAttribs; z++) { |
1333 | odebug << "HlManager::makeAttribs: createing one attribute definition" << oendl; | 1333 | odebug << "HlManager::makeAttribs: creating an attribute definition" << oendl; |
1334 | itemData = itemDataList.at(z); | 1334 | itemData = itemDataList.at(z); |
1335 | if (itemData->defStyle) { | 1335 | if (itemData->defStyle) { |
1336 | // default style | 1336 | // default style |
1337 | defaultStyle = defaultStyleList.at(itemData->defStyleNum); | 1337 | defaultStyle = defaultStyleList.at(itemData->defStyleNum); |
1338 | a[z].col = defaultStyle->col; | 1338 | a[z].col = defaultStyle->col; |
1339 | a[z].selCol = defaultStyle->selCol; | 1339 | a[z].selCol = defaultStyle->selCol; |
1340 | a[z].bold = defaultStyle->bold; | 1340 | a[z].bold = defaultStyle->bold; |
1341 | a[z].italic = defaultStyle->italic; | 1341 | a[z].italic = defaultStyle->italic; |
1342 | } else { | 1342 | } else { |
1343 | // custom style | 1343 | // custom style |
1344 | a[z].col = itemData->col; | 1344 | a[z].col = itemData->col; |
1345 | a[z].selCol = itemData->selCol; | 1345 | a[z].selCol = itemData->selCol; |
1346 | a[z].bold = itemData->bold; | 1346 | a[z].bold = itemData->bold; |
1347 | a[z].italic = itemData->italic; | 1347 | a[z].italic = itemData->italic; |
1348 | } | 1348 | } |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | for (; z < maxAttribs; z++) { | 1351 | for (; z < maxAttribs; z++) { |
1352 | a[z].col = black; | 1352 | a[z].col = black; |
1353 | a[z].selCol = black; | 1353 | a[z].selCol = black; |
1354 | a[z].bold = defaultStyle->bold; | 1354 | if (defaultStyle) { |
1355 | a[z].italic = defaultStyle->italic; | 1355 | a[z].bold = defaultStyle->bold; |
1356 | a[z].italic = defaultStyle->italic; | ||
1357 | } | ||
1356 | } | 1358 | } |
1357 | return nAttribs; | 1359 | return nAttribs; |
1358 | } | 1360 | } |
1359 | 1361 | ||
1360 | int HlManager::defaultStyles() { | 1362 | int HlManager::defaultStyles() { |
1361 | return 10; | 1363 | return 10; |
1362 | } | 1364 | } |
1363 | 1365 | ||
1364 | QString HlManager::defaultStyleName(int n) | 1366 | QString HlManager::defaultStyleName(int n) |
1365 | { | 1367 | { |
1366 | static QStringList names; | 1368 | static QStringList names; |
1367 | 1369 | ||
1368 | if (names.isEmpty()) | 1370 | if (names.isEmpty()) |
1369 | { | 1371 | { |
1370 | names << i18n("Normal"); | 1372 | names << i18n("Normal"); |
1371 | names << i18n("Keyword"); | 1373 | names << i18n("Keyword"); |
1372 | names << i18n("Data Type"); | 1374 | names << i18n("Data Type"); |
1373 | names << i18n("Decimal/Value"); | 1375 | names << i18n("Decimal/Value"); |
1374 | names << i18n("Base-N Integer"); | 1376 | names << i18n("Base-N Integer"); |
1375 | names << i18n("Floating Point"); | 1377 | names << i18n("Floating Point"); |
1376 | names << i18n("Character"); | 1378 | names << i18n("Character"); |
1377 | names << i18n("String"); | 1379 | names << i18n("String"); |
1378 | names << i18n("Comment"); | 1380 | names << i18n("Comment"); |
1379 | names << i18n("Others"); | 1381 | names << i18n("Others"); |
1380 | } | 1382 | } |
1381 | 1383 | ||
1382 | return names[n]; | 1384 | return names[n]; |
1383 | } | 1385 | } |
1384 | 1386 | ||
1385 | void HlManager::getDefaults(ItemStyleList &list) { | 1387 | void HlManager::getDefaults(ItemStyleList &list) { |
1386 | KateConfig *config; | 1388 | KateConfig *config; |
1387 | int z; | 1389 | int z; |
1388 | ItemStyle *i; | 1390 | ItemStyle *i; |
1389 | QString s; | 1391 | QString s; |
1390 | QRgb col, selCol; | 1392 | QRgb col, selCol; |
1391 | 1393 | ||
1392 | list.setAutoDelete(true); | 1394 | list.setAutoDelete(true); |
1393 | //ItemStyle(color, selected color, bold, italic) | 1395 | //ItemStyle(color, selected color, bold, italic) |
1394 | list.append(new ItemStyle(black,white,false,false)); //normal | 1396 | list.append(new ItemStyle(black,white,false,false)); //normal |
1395 | list.append(new ItemStyle(black,white,true,false)); //keyword | 1397 | list.append(new ItemStyle(black,white,true,false)); //keyword |
1396 | list.append(new ItemStyle(darkRed,white,false,false)); //datatype | 1398 | list.append(new ItemStyle(darkRed,white,false,false)); //datatype |
1397 | list.append(new ItemStyle(blue,cyan,false,false)); //decimal/value | 1399 | list.append(new ItemStyle(blue,cyan,false,false)); //decimal/value |
1398 | list.append(new ItemStyle(darkCyan,cyan,false,false)); //base n | 1400 | list.append(new ItemStyle(darkCyan,cyan,false,false)); //base n |
1399 | list.append(new ItemStyle(darkMagenta,cyan,false,false));//float | 1401 | list.append(new ItemStyle(darkMagenta,cyan,false,false));//float |
1400 | list.append(new ItemStyle(magenta,magenta,false,false)); //char | 1402 | list.append(new ItemStyle(magenta,magenta,false,false)); //char |
1401 | list.append(new ItemStyle(red,red,false,false)); //string | 1403 | list.append(new ItemStyle(red,red,false,false)); //string |
1402 | list.append(new ItemStyle(darkGray,gray,false,true)); //comment | 1404 | list.append(new ItemStyle(darkGray,gray,false,true)); //comment |
1403 | list.append(new ItemStyle(darkGreen,green,false,false)); //others | 1405 | list.append(new ItemStyle(darkGreen,green,false,false)); //others |
1404 | 1406 | ||
1405 | #warning fixme | 1407 | #warning fixme |
1406 | /* | 1408 | /* |
1407 | config = KateFactory::instance()->config(); | 1409 | config = KateFactory::instance()->config(); |
1408 | config->setGroup("Default Item Styles"); | 1410 | config->setGroup("Default Item Styles"); |
1409 | for (z = 0; z < defaultStyles(); z++) { | 1411 | for (z = 0; z < defaultStyles(); z++) { |
1410 | i = list.at(z); | 1412 | i = list.at(z); |
1411 | s = config->readEntry(defaultStyleName(z)); | 1413 | s = config->readEntry(defaultStyleName(z)); |
1412 | if (!s.isEmpty()) { | 1414 | if (!s.isEmpty()) { |
1413 | sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic); | 1415 | sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic); |
1414 | i->col.setRgb(col); | 1416 | i->col.setRgb(col); |
1415 | i->selCol.setRgb(selCol); | 1417 | i->selCol.setRgb(selCol); |
1416 | } | 1418 | } |
1417 | } | 1419 | } |
1418 | */ | 1420 | */ |
1419 | } | 1421 | } |