Diffstat (limited to 'noncore/apps/tinykate/libkate/document') (more/less context) (ignore whitespace changes)
5 files changed, 38 insertions, 45 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp index df1de8d..6807544 100644 --- a/noncore/apps/tinykate/libkate/document/katedocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp | |||
@@ -271,24 +271,25 @@ void KateDocument::doPreHighlight() | |||
271 | till = max; | 271 | till = max; |
272 | } | 272 | } |
273 | PreHighlightedTill = till; | 273 | PreHighlightedTill = till; |
274 | updateLines(from,till); | 274 | updateLines(from,till); |
275 | emit preHighlightChanged(PreHighlightedTill); | 275 | emit preHighlightChanged(PreHighlightedTill); |
276 | if (PreHighlightedTill<RequestPreHighlightTill) | 276 | if (PreHighlightedTill<RequestPreHighlightTill) |
277 | QTimer::singleShot(10,this,SLOT(doPreHighlight())); | 277 | QTimer::singleShot(10,this,SLOT(doPreHighlight())); |
278 | } | 278 | } |
279 | 279 | ||
280 | KateDocument::~KateDocument() | 280 | KateDocument::~KateDocument() |
281 | { | 281 | { |
282 | m_highlight->release(); | 282 | m_highlight->release(); |
283 | writeConfig(); | ||
283 | 284 | ||
284 | if ( !m_bSingleViewMode ) | 285 | if ( !m_bSingleViewMode ) |
285 | { | 286 | { |
286 | m_views.setAutoDelete( true ); | 287 | m_views.setAutoDelete( true ); |
287 | m_views.clear(); | 288 | m_views.clear(); |
288 | m_views.setAutoDelete( false ); | 289 | m_views.setAutoDelete( false ); |
289 | } | 290 | } |
290 | delete_d(this); | 291 | delete_d(this); |
291 | } | 292 | } |
292 | 293 | ||
293 | void KateDocument::openURL(const QString &filename) | 294 | void KateDocument::openURL(const QString &filename) |
294 | { | 295 | { |
@@ -587,77 +588,75 @@ void KateDocument::setModified(bool m) { | |||
587 | emit static_cast<KateView *>( view )->newStatus(); | 588 | emit static_cast<KateView *>( view )->newStatus(); |
588 | } | 589 | } |
589 | emit modifiedChanged (); | 590 | emit modifiedChanged (); |
590 | } | 591 | } |
591 | } | 592 | } |
592 | 593 | ||
593 | bool KateDocument::isModified() const { | 594 | bool KateDocument::isModified() const { |
594 | return modified; | 595 | return modified; |
595 | } | 596 | } |
596 | 597 | ||
597 | void KateDocument::readConfig() | 598 | void KateDocument::readConfig() |
598 | { | 599 | { |
599 | KConfig *config = KGlobal::config(); | 600 | KateConfig *config = KGlobal::config(); |
600 | config->setGroup("Kate Document"); | 601 | config->setGroup("Kate Document"); |
601 | 602 | ||
602 | myWordWrap = config->readBoolEntry("Word Wrap On", false); | 603 | myWordWrap = config->readBoolEntry("Word Wrap On", false); |
603 | myWordWrapAt = config->readNumEntry("Word Wrap At", 80); | 604 | myWordWrapAt = config->readNumEntry("Word Wrap At", 80); |
604 | if (myWordWrap) | 605 | if (myWordWrap) |
605 | wrapText (myWordWrapAt); | 606 | wrapText (myWordWrapAt); |
606 | 607 | ||
607 | setTabWidth(config->readNumEntry("TabWidth", 8)); | 608 | setTabWidth(config->readNumEntry("TabWidth", 8)); |
608 | setUndoSteps(config->readNumEntry("UndoSteps", 50)); | 609 | setUndoSteps(config->readNumEntry("UndoSteps", 50)); |
609 | m_singleSelection = config->readBoolEntry("SingleSelection", false); | 610 | m_singleSelection = config->readBoolEntry("SingleSelection", false); |
610 | myEncoding = config->readEntry("Encoding", QString::fromLatin1(QTextCodec::codecForLocale()->name())); | 611 | myEncoding = config->readEntry("Encoding", QString::fromLatin1(QTextCodec::codecForLocale()->name())); |
611 | setFont (config->readFontEntry("Font", &myFont)); | 612 | setFont (config->readFontEntry("Font", myFont)); |
612 | 613 | ||
613 | colors[0] = config->readColorEntry("Color Background", &colors[0]); | 614 | colors[0] = config->readColorEntry("Color Background", colors[0]); |
614 | colors[1] = config->readColorEntry("Color Selected", &colors[1]); | 615 | colors[1] = config->readColorEntry("Color Selected", colors[1]); |
615 | 616 | ||
616 | config->sync(); | 617 | // config->sync(); |
617 | } | 618 | } |
618 | 619 | ||
619 | void KateDocument::writeConfig() | 620 | void KateDocument::writeConfig() |
620 | { | 621 | { |
621 | KConfig *config = KGlobal::config(); | 622 | KateConfig *config = KGlobal::config(); |
622 | config->setGroup("Kate Document"); | 623 | config->setGroup("Kate Document"); |
623 | #if 0 | 624 | config->writeEntry("Word Wrap On", myWordWrap); |
624 | cofig->writeEntry("Word Wrap On", myWordWrap); | ||
625 | config->writeEntry("Word Wrap At", myWordWrapAt); | 625 | config->writeEntry("Word Wrap At", myWordWrapAt); |
626 | config->writeEntry("TabWidth", tabChars); | 626 | config->writeEntry("TabWidth", tabChars); |
627 | config->writeEntry("UndoSteps", undoSteps); | 627 | config->writeEntry("UndoSteps", undoSteps); |
628 | config->writeEntry("SingleSelection", m_singleSelection); | 628 | config->writeEntry("SingleSelection", m_singleSelection); |
629 | config->writeEntry("Encoding", myEncoding); | 629 | config->writeEntry("Encoding", myEncoding); |
630 | config->writeEntry("Font", myFont); | 630 | config->writeEntry("Font", myFont); |
631 | config->writeEntry("Color Background", colors[0]); | 631 | config->writeEntry("Color Background", colors[0]); |
632 | config->writeEntry("Color Selected", colors[1]); | 632 | config->writeEntry("Color Selected", colors[1]); |
633 | #endif | 633 | // config->sync(); |
634 | config->sync(); | ||
635 | } | 634 | } |
636 | 635 | ||
637 | void KateDocument::readSessionConfig(KConfig *config) | 636 | void KateDocument::readSessionConfig(KateConfig *config) |
638 | { | 637 | { |
639 | m_url = config->readEntry("URL"); // ### doesn't this break the encoding? (Simon) | 638 | m_url = config->readEntry("URL"); // ### doesn't this break the encoding? (Simon) |
640 | setHighlight(hlManager->nameFind(config->readEntry("Highlight"))); | 639 | setHighlight(hlManager->nameFind(config->readEntry("Highlight"))); |
641 | // anders: restore bookmarks if possible | 640 | // anders: restore bookmarks if possible |
642 | QValueList<int> l = config->readIntListEntry("Bookmarks"); | 641 | QValueList<int> l = config->readIntListEntry("Bookmarks"); |
643 | if ( l.count() ) { | 642 | if ( l.count() ) { |
644 | for (uint i=0; i < l.count(); i++) { | 643 | for (uint i=0; i < l.count(); i++) { |
645 | if ( numLines() < l[i] ) break; | 644 | if ( numLines() < l[i] ) break; |
646 | getTextLine( l[i] )->addMark( Bookmark ); | 645 | getTextLine( l[i] )->addMark( Bookmark ); |
647 | } | 646 | } |
648 | } | 647 | } |
649 | } | 648 | } |
650 | 649 | ||
651 | void KateDocument::writeSessionConfig(KConfig *config) | 650 | void KateDocument::writeSessionConfig(KateConfig *config) |
652 | { | 651 | { |
653 | #if 0 | 652 | #if 0 |
654 | config->writeEntry("URL", m_url); // ### encoding?? (Simon) | 653 | config->writeEntry("URL", m_url); // ### encoding?? (Simon) |
655 | config->writeEntry("Highlight", m_highlight->name()); | 654 | config->writeEntry("Highlight", m_highlight->name()); |
656 | // anders: save bookmarks | 655 | // anders: save bookmarks |
657 | QList<Kate::Mark> l = marks(); | 656 | QList<Kate::Mark> l = marks(); |
658 | QValueList<int> ml; | 657 | QValueList<int> ml; |
659 | for (uint i=0; i < l.count(); i++) { | 658 | for (uint i=0; i < l.count(); i++) { |
660 | if ( l.at(i)->type == 1) // only save bookmarks | 659 | if ( l.at(i)->type == 1) // only save bookmarks |
661 | ml << l.at(i)->line; | 660 | ml << l.at(i)->line; |
662 | } | 661 | } |
663 | if ( ml.count() ) | 662 | if ( ml.count() ) |
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.h b/noncore/apps/tinykate/libkate/document/katedocument.h index 356541f..9d8ec6a 100644 --- a/noncore/apps/tinykate/libkate/document/katedocument.h +++ b/noncore/apps/tinykate/libkate/document/katedocument.h | |||
@@ -220,26 +220,26 @@ class KateDocument: public Kate::Document | |||
220 | bool isReadOnly() const; | 220 | bool isReadOnly() const; |
221 | void setNewDoc( bool ); | 221 | void setNewDoc( bool ); |
222 | bool isNewDoc() const; | 222 | bool isNewDoc() const; |
223 | virtual void setReadWrite( bool ){}; | 223 | virtual void setReadWrite( bool ){}; |
224 | virtual bool isReadWrite() const {return true;} | 224 | virtual bool isReadWrite() const {return true;} |
225 | virtual void setModified(bool); | 225 | virtual void setModified(bool); |
226 | virtual bool isModified() const; | 226 | virtual bool isModified() const; |
227 | void setSingleSelection(bool ss) {m_singleSelection = ss;} | 227 | void setSingleSelection(bool ss) {m_singleSelection = ss;} |
228 | bool singleSelection() {return m_singleSelection;} | 228 | bool singleSelection() {return m_singleSelection;} |
229 | 229 | ||
230 | void readConfig(); | 230 | void readConfig(); |
231 | void writeConfig(); | 231 | void writeConfig(); |
232 | void readSessionConfig(KConfig *); | 232 | void readSessionConfig(KateConfig *); |
233 | void writeSessionConfig(KConfig *); | 233 | void writeSessionConfig(KateConfig *); |
234 | 234 | ||
235 | bool hasBrowserExtension() const { return m_bBrowserView; } | 235 | bool hasBrowserExtension() const { return m_bBrowserView; } |
236 | 236 | ||
237 | protected: | 237 | protected: |
238 | bool m_bBrowserView; | 238 | bool m_bBrowserView; |
239 | 239 | ||
240 | signals: | 240 | signals: |
241 | void selectionChanged(); | 241 | void selectionChanged(); |
242 | void highlightChanged(); | 242 | void highlightChanged(); |
243 | void modifiedChanged (); | 243 | void modifiedChanged (); |
244 | void preHighlightChanged(long); | 244 | void preHighlightChanged(long); |
245 | 245 | ||
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp index 797968b..0d2c283 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp +++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp | |||
@@ -640,89 +640,89 @@ int Highlight::doHighlight(int ctxNum, TextLine *textLine) | |||
640 | lastChar = *s1; | 640 | lastChar = *s1; |
641 | s1++; | 641 | s1++; |
642 | z++; | 642 | z++; |
643 | } | 643 | } |
644 | 644 | ||
645 | //set "end of line"-properties | 645 | //set "end of line"-properties |
646 | textLine->setAttr(context->attr); | 646 | textLine->setAttr(context->attr); |
647 | 647 | ||
648 | //return new context | 648 | //return new context |
649 | return context->ctx; | 649 | return context->ctx; |
650 | } | 650 | } |
651 | 651 | ||
652 | KConfig *Highlight::getKConfig() { | 652 | KateConfig *Highlight::getKateConfig() { |
653 | KConfig *config; | 653 | KateConfig *config; |
654 | config=KGlobal::config(); | 654 | config=KGlobal::config(); |
655 | config->setGroup(iName + QString(" Highlight")); | 655 | config->setGroup(iName + QString(" Highlight")); |
656 | return config; | 656 | return config; |
657 | } | 657 | } |
658 | 658 | ||
659 | QString Highlight::getWildcards() { | 659 | QString Highlight::getWildcards() { |
660 | KConfig *config; | 660 | KateConfig *config; |
661 | 661 | ||
662 | config = getKConfig(); | 662 | config = getKateConfig(); |
663 | 663 | ||
664 | //if wildcards not yet in config, then use iWildCards as default | 664 | //if wildcards not yet in config, then use iWildCards as default |
665 | return config->readEntry("Wildcards", iWildcards); | 665 | return config->readEntry("Wildcards", iWildcards); |
666 | } | 666 | } |
667 | 667 | ||
668 | 668 | ||
669 | QString Highlight::getMimetypes() { | 669 | QString Highlight::getMimetypes() { |
670 | KConfig *config; | 670 | KateConfig *config; |
671 | 671 | ||
672 | config = getKConfig(); | 672 | config = getKateConfig(); |
673 | 673 | ||
674 | return config->readEntry("Mimetypes", iMimetypes); | 674 | return config->readEntry("Mimetypes", iMimetypes); |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | HlData *Highlight::getData() { | 678 | HlData *Highlight::getData() { |
679 | KConfig *config; | 679 | KateConfig *config; |
680 | HlData *hlData; | 680 | HlData *hlData; |
681 | 681 | ||
682 | config = getKConfig(); | 682 | config = getKateConfig(); |
683 | 683 | ||
684 | // iWildcards = config->readEntry("Wildcards"); | 684 | // iWildcards = config->readEntry("Wildcards"); |
685 | // iMimetypes = config->readEntry("Mimetypes"); | 685 | // iMimetypes = config->readEntry("Mimetypes"); |
686 | // hlData = new HlData(iWildcards,iMimetypes); | 686 | // hlData = new HlData(iWildcards,iMimetypes); |
687 | hlData = new HlData( | 687 | hlData = new HlData( |
688 | config->readEntry("Wildcards", iWildcards), | 688 | config->readEntry("Wildcards", iWildcards), |
689 | config->readEntry("Mimetypes", iMimetypes), | 689 | config->readEntry("Mimetypes", iMimetypes), |
690 | config->readEntry("Identifier", identifier)); | 690 | config->readEntry("Identifier", identifier)); |
691 | getItemDataList(hlData->itemDataList, config); | 691 | getItemDataList(hlData->itemDataList, config); |
692 | return hlData; | 692 | return hlData; |
693 | } | 693 | } |
694 | 694 | ||
695 | void Highlight::setData(HlData *hlData) { | 695 | void Highlight::setData(HlData *hlData) { |
696 | KConfig *config; | 696 | KateConfig *config; |
697 | 697 | ||
698 | config = getKConfig(); | 698 | config = getKateConfig(); |
699 | 699 | ||
700 | // iWildcards = hlData->wildcards; | 700 | // iWildcards = hlData->wildcards; |
701 | // iMimetypes = hlData->mimetypes; | 701 | // iMimetypes = hlData->mimetypes; |
702 | 702 | ||
703 | config->writeEntry("Wildcards",hlData->wildcards); | 703 | config->writeEntry("Wildcards",hlData->wildcards); |
704 | config->writeEntry("Mimetypes",hlData->mimetypes); | 704 | config->writeEntry("Mimetypes",hlData->mimetypes); |
705 | 705 | ||
706 | setItemDataList(hlData->itemDataList,config); | 706 | setItemDataList(hlData->itemDataList,config); |
707 | } | 707 | } |
708 | 708 | ||
709 | void Highlight::getItemDataList(ItemDataList &list) { | 709 | void Highlight::getItemDataList(ItemDataList &list) { |
710 | KConfig *config; | 710 | KateConfig *config; |
711 | 711 | ||
712 | config = getKConfig(); | 712 | config = getKateConfig(); |
713 | getItemDataList(list, config); | 713 | getItemDataList(list, config); |
714 | } | 714 | } |
715 | 715 | ||
716 | void Highlight::getItemDataList(ItemDataList &list, KConfig *config) { | 716 | void Highlight::getItemDataList(ItemDataList &list, KateConfig *config) { |
717 | ItemData *p; | 717 | ItemData *p; |
718 | QString s; | 718 | QString s; |
719 | QRgb col, selCol; | 719 | QRgb col, selCol; |
720 | 720 | ||
721 | list.clear(); | 721 | list.clear(); |
722 | //JW list.setAutoDelete(true); | 722 | //JW list.setAutoDelete(true); |
723 | createItemData(list); | 723 | createItemData(list); |
724 | 724 | ||
725 | for (p = list.first(); p != 0L; p = list.next()) { | 725 | for (p = list.first(); p != 0L; p = list.next()) { |
726 | s = config->readEntry(p->name); | 726 | s = config->readEntry(p->name); |
727 | if (!s.isEmpty()) { | 727 | if (!s.isEmpty()) { |
728 | sscanf(s.latin1(),"%d,%X,%X,%d,%d", &p->defStyle,&col,&selCol,&p->bold,&p->italic); | 728 | sscanf(s.latin1(),"%d,%X,%X,%d,%d", &p->defStyle,&col,&selCol,&p->bold,&p->italic); |
@@ -730,34 +730,34 @@ void Highlight::getItemDataList(ItemDataList &list, KConfig *config) { | |||
730 | p->selCol.setRgb(selCol); | 730 | p->selCol.setRgb(selCol); |
731 | } | 731 | } |
732 | } | 732 | } |
733 | } | 733 | } |
734 | 734 | ||
735 | /******************************************************************************************* | 735 | /******************************************************************************************* |
736 | Highlight - setItemDataList | 736 | Highlight - setItemDataList |
737 | saves the ItemData / attribute / style definitions to the apps configfile. | 737 | saves the ItemData / attribute / style definitions to the apps configfile. |
738 | Especially needed for user overridden values. | 738 | Especially needed for user overridden values. |
739 | 739 | ||
740 | * input: ItemDataList &list :reference to the list, whose | 740 | * input: ItemDataList &list :reference to the list, whose |
741 | * items should be saved | 741 | * items should be saved |
742 | * KConfig *config :Pointer KDE configuration | 742 | * KateConfig *config :Pointer KDE configuration |
743 | * class, which should be used | 743 | * class, which should be used |
744 | * as storage | 744 | * as storage |
745 | ************* | 745 | ************* |
746 | * output: none | 746 | * output: none |
747 | ************* | 747 | ************* |
748 | * return value: none | 748 | * return value: none |
749 | *******************************************************************************************/ | 749 | *******************************************************************************************/ |
750 | 750 | ||
751 | void Highlight::setItemDataList(ItemDataList &list, KConfig *config) { | 751 | void Highlight::setItemDataList(ItemDataList &list, KateConfig *config) { |
752 | ItemData *p; | 752 | ItemData *p; |
753 | QString s; | 753 | QString s; |
754 | 754 | ||
755 | for (p = list.first(); p != 0L; p = list.next()) { | 755 | for (p = list.first(); p != 0L; p = list.next()) { |
756 | s.sprintf("%d,%X,%X,%d,%d", | 756 | s.sprintf("%d,%X,%X,%d,%d", |
757 | p->defStyle,p->col.rgb(),p->selCol.rgb(),p->bold,p->italic); | 757 | p->defStyle,p->col.rgb(),p->selCol.rgb(),p->bold,p->italic); |
758 | config->writeEntry(p->name,s); | 758 | config->writeEntry(p->name,s); |
759 | } | 759 | } |
760 | } | 760 | } |
761 | 761 | ||
762 | 762 | ||
763 | /******************************************************************************************* | 763 | /******************************************************************************************* |
@@ -1257,25 +1257,25 @@ HlManager *HlManager::self() | |||
1257 | { | 1257 | { |
1258 | if ( !s_pSelf ) | 1258 | if ( !s_pSelf ) |
1259 | s_pSelf = new HlManager; | 1259 | s_pSelf = new HlManager; |
1260 | return s_pSelf; | 1260 | return s_pSelf; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | Highlight *HlManager::getHl(int n) { | 1263 | Highlight *HlManager::getHl(int n) { |
1264 | if (n < 0 || n >= (int) hlList.count()) n = 0; | 1264 | if (n < 0 || n >= (int) hlList.count()) n = 0; |
1265 | return hlList.at(n); | 1265 | return hlList.at(n); |
1266 | } | 1266 | } |
1267 | 1267 | ||
1268 | int HlManager::defaultHl() { | 1268 | int HlManager::defaultHl() { |
1269 | KConfig *config; | 1269 | KateConfig *config; |
1270 | config = KGlobal::config(); | 1270 | config = KGlobal::config(); |
1271 | config->setGroup("General Options"); | 1271 | config->setGroup("General Options"); |
1272 | 1272 | ||
1273 | #warning fixme return nameFind(config->readEntry("Highlight")); | 1273 | #warning fixme return nameFind(config->readEntry("Highlight")); |
1274 | 1274 | ||
1275 | } | 1275 | } |
1276 | 1276 | ||
1277 | 1277 | ||
1278 | int HlManager::nameFind(const QString &name) { | 1278 | int HlManager::nameFind(const QString &name) { |
1279 | int z; | 1279 | int z; |
1280 | 1280 | ||
1281 | for (z = hlList.count() - 1; z > 0; z--) { | 1281 | for (z = hlList.count() - 1; z > 0; z--) { |
@@ -1365,25 +1365,25 @@ QString HlManager::defaultStyleName(int n) | |||
1365 | names << i18n("Base-N Integer"); | 1365 | names << i18n("Base-N Integer"); |
1366 | names << i18n("Floating Point"); | 1366 | names << i18n("Floating Point"); |
1367 | names << i18n("Character"); | 1367 | names << i18n("Character"); |
1368 | names << i18n("String"); | 1368 | names << i18n("String"); |
1369 | names << i18n("Comment"); | 1369 | names << i18n("Comment"); |
1370 | names << i18n("Others"); | 1370 | names << i18n("Others"); |
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | return names[n]; | 1373 | return names[n]; |
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | void HlManager::getDefaults(ItemStyleList &list) { | 1376 | void HlManager::getDefaults(ItemStyleList &list) { |
1377 | KConfig *config; | 1377 | KateConfig *config; |
1378 | int z; | 1378 | int z; |
1379 | ItemStyle *i; | 1379 | ItemStyle *i; |
1380 | QString s; | 1380 | QString s; |
1381 | QRgb col, selCol; | 1381 | QRgb col, selCol; |
1382 | 1382 | ||
1383 | list.setAutoDelete(true); | 1383 | list.setAutoDelete(true); |
1384 | //ItemStyle(color, selected color, bold, italic) | 1384 | //ItemStyle(color, selected color, bold, italic) |
1385 | list.append(new ItemStyle(black,white,false,false)); //normal | 1385 | list.append(new ItemStyle(black,white,false,false)); //normal |
1386 | list.append(new ItemStyle(black,white,true,false)); //keyword | 1386 | list.append(new ItemStyle(black,white,true,false)); //keyword |
1387 | list.append(new ItemStyle(darkRed,white,false,false)); //datatype | 1387 | list.append(new ItemStyle(darkRed,white,false,false)); //datatype |
1388 | list.append(new ItemStyle(blue,cyan,false,false)); //decimal/value | 1388 | list.append(new ItemStyle(blue,cyan,false,false)); //decimal/value |
1389 | list.append(new ItemStyle(darkCyan,cyan,false,false)); //base n | 1389 | list.append(new ItemStyle(darkCyan,cyan,false,false)); //base n |
@@ -1401,25 +1401,25 @@ void HlManager::getDefaults(ItemStyleList &list) { | |||
1401 | i = list.at(z); | 1401 | i = list.at(z); |
1402 | s = config->readEntry(defaultStyleName(z)); | 1402 | s = config->readEntry(defaultStyleName(z)); |
1403 | if (!s.isEmpty()) { | 1403 | if (!s.isEmpty()) { |
1404 | sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic); | 1404 | sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic); |
1405 | i->col.setRgb(col); | 1405 | i->col.setRgb(col); |
1406 | i->selCol.setRgb(selCol); | 1406 | i->selCol.setRgb(selCol); |
1407 | } | 1407 | } |
1408 | } | 1408 | } |
1409 | */ | 1409 | */ |
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | void HlManager::setDefaults(ItemStyleList &list) { | 1412 | void HlManager::setDefaults(ItemStyleList &list) { |
1413 | KConfig *config; | 1413 | KateConfig *config; |
1414 | int z; | 1414 | int z; |
1415 | ItemStyle *i; | 1415 | ItemStyle *i; |
1416 | char s[64]; | 1416 | char s[64]; |
1417 | #warning fixme | 1417 | #warning fixme |
1418 | /* | 1418 | /* |
1419 | config = KateFactory::instance()->config(); | 1419 | config = KateFactory::instance()->config(); |
1420 | config->setGroup("Default Item Styles"); | 1420 | config->setGroup("Default Item Styles"); |
1421 | for (z = 0; z < defaultStyles(); z++) { | 1421 | for (z = 0; z < defaultStyles(); z++) { |
1422 | i = list.at(z); | 1422 | i = list.at(z); |
1423 | sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic); | 1423 | sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic); |
1424 | config->writeEntry(defaultStyleName(z),s); | 1424 | config->writeEntry(defaultStyleName(z),s); |
1425 | } | 1425 | } |
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.h b/noncore/apps/tinykate/libkate/document/katehighlight.h index 1baddcc..fddf585 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.h +++ b/noncore/apps/tinykate/libkate/document/katehighlight.h | |||
@@ -227,54 +227,54 @@ typedef QList<ItemData> ItemDataList; | |||
227 | class HlData { | 227 | class HlData { |
228 | public: | 228 | public: |
229 | HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier); | 229 | HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier); |
230 | ItemDataList itemDataList; | 230 | ItemDataList itemDataList; |
231 | QString wildcards; | 231 | QString wildcards; |
232 | QString mimetypes; | 232 | QString mimetypes; |
233 | QString identifier; | 233 | QString identifier; |
234 | }; | 234 | }; |
235 | 235 | ||
236 | typedef QList<HlData> HlDataList; | 236 | typedef QList<HlData> HlDataList; |
237 | 237 | ||
238 | class HlManager; | 238 | class HlManager; |
239 | class KConfig; | 239 | class KateConfig; |
240 | 240 | ||
241 | //context | 241 | //context |
242 | class HlContext { | 242 | class HlContext { |
243 | public: | 243 | public: |
244 | HlContext(int attribute, int lineEndContext,int _lineBeginContext); | 244 | HlContext(int attribute, int lineEndContext,int _lineBeginContext); |
245 | QList<HlItem> items; | 245 | QList<HlItem> items; |
246 | int attr; | 246 | int attr; |
247 | int ctx; | 247 | int ctx; |
248 | int lineBeginContext; | 248 | int lineBeginContext; |
249 | }; | 249 | }; |
250 | 250 | ||
251 | class Highlight | 251 | class Highlight |
252 | { | 252 | { |
253 | friend class HlManager; | 253 | friend class HlManager; |
254 | 254 | ||
255 | public: | 255 | public: |
256 | Highlight(syntaxModeListItem *def); | 256 | Highlight(syntaxModeListItem *def); |
257 | ~Highlight(); | 257 | ~Highlight(); |
258 | 258 | ||
259 | int doHighlight(int ctxNum, TextLine *); | 259 | int doHighlight(int ctxNum, TextLine *); |
260 | 260 | ||
261 | KConfig *getKConfig(); | 261 | KateConfig *getKateConfig(); |
262 | QString getWildcards(); | 262 | QString getWildcards(); |
263 | QString getMimetypes(); | 263 | QString getMimetypes(); |
264 | HlData *getData(); | 264 | HlData *getData(); |
265 | void setData(HlData *); | 265 | void setData(HlData *); |
266 | void getItemDataList(ItemDataList &); | 266 | void getItemDataList(ItemDataList &); |
267 | void getItemDataList(ItemDataList &, KConfig *); | 267 | void getItemDataList(ItemDataList &, KateConfig *); |
268 | void setItemDataList(ItemDataList &, KConfig *); | 268 | void setItemDataList(ItemDataList &, KateConfig *); |
269 | QString name() {return iName;} | 269 | QString name() {return iName;} |
270 | QString section() {return iSection;} | 270 | QString section() {return iSection;} |
271 | void use(); | 271 | void use(); |
272 | void release(); | 272 | void release(); |
273 | bool isInWord(QChar c); | 273 | bool isInWord(QChar c); |
274 | 274 | ||
275 | QString getCommentStart() {return cmlStart;}; | 275 | QString getCommentStart() {return cmlStart;}; |
276 | QString getCommentEnd() {return cmlEnd;}; | 276 | QString getCommentEnd() {return cmlEnd;}; |
277 | QString getCommentSingleLineStart() { return cslStart;}; | 277 | QString getCommentSingleLineStart() { return cslStart;}; |
278 | 278 | ||
279 | protected: | 279 | protected: |
280 | void init(); | 280 | void init(); |
diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp index e45daa4..844f27d 100644 --- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp | |||
@@ -7,31 +7,31 @@ | |||
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "katesyntaxdocument.h" | 18 | #include "katesyntaxdocument.h" |
19 | #include <kateconfig.h> | ||
19 | #include <qfile.h> | 20 | #include <qfile.h> |
20 | #include <kdebug.h> | 21 | #include <kdebug.h> |
21 | #include <kstddirs.h> | 22 | #include <kstddirs.h> |
22 | #include <klocale.h> | 23 | #include <klocale.h> |
23 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
24 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
25 | #include <kconfig.h> | ||
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | 29 | ||
30 | SyntaxDocument::SyntaxDocument() | 30 | SyntaxDocument::SyntaxDocument() |
31 | { | 31 | { |
32 | m_root=0; | 32 | m_root=0; |
33 | currentFile=""; | 33 | currentFile=""; |
34 | setupModeList(); | 34 | setupModeList(); |
35 | } | 35 | } |
36 | 36 | ||
37 | void SyntaxDocument::setIdentifier(const QString& identifier) | 37 | void SyntaxDocument::setIdentifier(const QString& identifier) |
@@ -42,37 +42,36 @@ void SyntaxDocument::setIdentifier(const QString& identifier) | |||
42 | 42 | ||
43 | } | 43 | } |
44 | 44 | ||
45 | SyntaxDocument::~SyntaxDocument() | 45 | SyntaxDocument::~SyntaxDocument() |
46 | { | 46 | { |
47 | } | 47 | } |
48 | 48 | ||
49 | void SyntaxDocument::setupModeList(bool force) | 49 | void SyntaxDocument::setupModeList(bool force) |
50 | { | 50 | { |
51 | 51 | ||
52 | if (myModeList.count() > 0) return; | 52 | if (myModeList.count() > 0) return; |
53 | 53 | ||
54 | KConfig *config=KGlobal::config(); | 54 | KateConfig *config=KGlobal::config(); |
55 | KStandardDirs *dirs = KGlobal::dirs(); | 55 | KStandardDirs *dirs = KGlobal::dirs(); |
56 | 56 | ||
57 | // QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true); | 57 | // QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true); |
58 | QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/"; | 58 | QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/"; |
59 | 59 | ||
60 | QDir dir(path); | 60 | QDir dir(path); |
61 | QStringList list=dir.entryList("*.xml"); | 61 | QStringList list=dir.entryList("*.xml"); |
62 | 62 | ||
63 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 63 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
64 | { | 64 | { |
65 | QString Group="Highlighting_Cache"+path+*it; | 65 | QString Group="Highlighting_Cache"+path+*it; |
66 | |||
67 | if ((config->hasGroup(Group)) && (!force)) | 66 | if ((config->hasGroup(Group)) && (!force)) |
68 | { | 67 | { |
69 | config->setGroup(Group); | 68 | config->setGroup(Group); |
70 | syntaxModeListItem *mli=new syntaxModeListItem; | 69 | syntaxModeListItem *mli=new syntaxModeListItem; |
71 | mli->name = config->readEntry("name",""); | 70 | mli->name = config->readEntry("name",""); |
72 | mli->section = config->readEntry("section",""); | 71 | mli->section = config->readEntry("section",""); |
73 | mli->mimetype = config->readEntry("mimetype",""); | 72 | mli->mimetype = config->readEntry("mimetype",""); |
74 | mli->extension = config->readEntry("extension",""); | 73 | mli->extension = config->readEntry("extension",""); |
75 | mli->identifier = *it; | 74 | mli->identifier = *it; |
76 | myModeList.append(mli); | 75 | myModeList.append(mli); |
77 | } | 76 | } |
78 | else | 77 | else |
@@ -87,39 +86,34 @@ void SyntaxDocument::setupModeList(bool force) | |||
87 | if (e->tagName()=="language") | 86 | if (e->tagName()=="language") |
88 | { | 87 | { |
89 | syntaxModeListItem *mli=new syntaxModeListItem; | 88 | syntaxModeListItem *mli=new syntaxModeListItem; |
90 | mli->name = e->attribute("name"); | 89 | mli->name = e->attribute("name"); |
91 | mli->section = e->attribute("section"); | 90 | mli->section = e->attribute("section"); |
92 | mli->mimetype = e->attribute("mimetype"); | 91 | mli->mimetype = e->attribute("mimetype"); |
93 | mli->extension = e->attribute("extensions"); | 92 | mli->extension = e->attribute("extensions"); |
94 | qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name)); | 93 | qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name)); |
95 | if (mli->section.isEmpty()) | 94 | if (mli->section.isEmpty()) |
96 | mli->section=i18n("Other"); | 95 | mli->section=i18n("Other"); |
97 | 96 | ||
98 | mli->identifier = path+(*it); | 97 | mli->identifier = path+(*it); |
99 | #warning fixme | ||
100 | /* | ||
101 | config->setGroup(Group); | 98 | config->setGroup(Group); |
102 | config->writeEntry("name",mli->name); | 99 | config->writeEntry("name",mli->name); |
103 | config->writeEntry("section",mli->section); | 100 | config->writeEntry("section",mli->section); |
104 | config->writeEntry("mimetype",mli->mimetype); | 101 | config->writeEntry("mimetype",mli->mimetype); |
105 | config->writeEntry("extension",mli->extension); | 102 | config->writeEntry("extension",mli->extension); |
106 | */ | ||
107 | myModeList.append(mli); | 103 | myModeList.append(mli); |
108 | } | 104 | } |
109 | } | 105 | } |
110 | } | ||
111 | } | 106 | } |
112 | // } | 107 | } |
113 | |||
114 | // config->sync(); | 108 | // config->sync(); |
115 | } | 109 | } |
116 | 110 | ||
117 | SyntaxModeList SyntaxDocument::modeList() | 111 | SyntaxModeList SyntaxDocument::modeList() |
118 | { | 112 | { |
119 | return myModeList; | 113 | return myModeList; |
120 | } | 114 | } |
121 | 115 | ||
122 | bool SyntaxDocument::nextGroup( syntaxContextData* data) | 116 | bool SyntaxDocument::nextGroup( syntaxContextData* data) |
123 | { | 117 | { |
124 | if(!data) return false; | 118 | if(!data) return false; |
125 | 119 | ||