summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate
authorkergoth <kergoth>2003-01-28 03:23:14 (UTC)
committer kergoth <kergoth>2003-01-28 03:23:14 (UTC)
commitde1321a53998bc1d078f9492395c2a26392875ed (patch) (unidiff)
treeb36d59612da5bbafeaddd28cb88a222b699d2645 /noncore/apps/tinykate
parent728a7a4966c342be32c80c045cbae500160fc17b (diff)
downloadopie-de1321a53998bc1d078f9492395c2a26392875ed.zip
opie-de1321a53998bc1d078f9492395c2a26392875ed.tar.gz
opie-de1321a53998bc1d078f9492395c2a26392875ed.tar.bz2
Added a Config derivative.
Diffstat (limited to 'noncore/apps/tinykate') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp23
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.h4
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp36
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.h8
-rw-r--r--noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp10
-rw-r--r--noncore/apps/tinykate/libkate/interfaces/document.h6
-rw-r--r--noncore/apps/tinykate/libkate/interfaces/view.h6
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.cpp634
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.h117
-rw-r--r--noncore/apps/tinykate/libkate/libkate.pro9
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kconfig.cpp181
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kconfig.h51
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kglobal.cpp6
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kglobal.h6
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.cpp18
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.h9
-rw-r--r--noncore/apps/tinykate/tinykate.cpp10
-rw-r--r--noncore/apps/tinykate/tinykate.h3
-rw-r--r--noncore/apps/tinykate/tinykate.pro4
19 files changed, 834 insertions, 307 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
@@ -259,48 +259,49 @@ long KateDocument::needPreHighlight(long till)
259 if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); 259 if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight()));
260 } 260 }
261 return RequestPreHighlightTill; 261 return RequestPreHighlightTill;
262} 262}
263 263
264void KateDocument::doPreHighlight() 264void KateDocument::doPreHighlight()
265{ 265{
266 int from = PreHighlightedTill; 266 int from = PreHighlightedTill;
267 int till = PreHighlightedTill+200; 267 int till = PreHighlightedTill+200;
268 int max = numLines()-1; 268 int max = numLines()-1;
269 if (till > max) 269 if (till > max)
270 { 270 {
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
280KateDocument::~KateDocument() 280KateDocument::~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
293void KateDocument::openURL(const QString &filename) 294void KateDocument::openURL(const QString &filename)
294{ 295{
295 296
296 m_file=filename; 297 m_file=filename;
297 fileInfo->setFile (m_file); 298 fileInfo->setFile (m_file);
298 setMTime(); 299 setMTime();
299 300
300 if (!fileInfo->exists() || !fileInfo->isReadable()) 301 if (!fileInfo->exists() || !fileInfo->isReadable())
301 { 302 {
302 qDebug("File doesn't exit or couldn't be read"); 303 qDebug("File doesn't exit or couldn't be read");
303 return ; 304 return ;
304 } 305 }
305 306
306 buffer->clear(); 307 buffer->clear();
@@ -575,101 +576,99 @@ void KateDocument::setNewDoc( bool m )
575} 576}
576 577
577bool KateDocument::isNewDoc() const { 578bool KateDocument::isNewDoc() const {
578 return newDoc; 579 return newDoc;
579} 580}
580 581
581void KateDocument::setModified(bool m) { 582void KateDocument::setModified(bool m) {
582 KTextEditor::View *view; 583 KTextEditor::View *view;
583 584
584 if (m != modified) { 585 if (m != modified) {
585 modified = m; 586 modified = m;
586 for (view = m_views.first(); view != 0L; view = m_views.next() ) { 587 for (view = m_views.first(); view != 0L; view = m_views.next() ) {
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
593bool KateDocument::isModified() const { 594bool KateDocument::isModified() const {
594 return modified; 595 return modified;
595} 596}
596 597
597void KateDocument::readConfig() 598void 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
619void KateDocument::writeConfig() 620void 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
637void KateDocument::readSessionConfig(KConfig *config) 636void 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
651void KateDocument::writeSessionConfig(KConfig *config) 650void 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() )
664 config->writeEntry("Bookmarks", ml); 663 config->writeEntry("Bookmarks", ml);
665#endif 664#endif
666} 665}
667 666
668 667
669void KateDocument::setHighlight(int n) { 668void KateDocument::setHighlight(int n) {
670 Highlight *h; 669 Highlight *h;
671 670
672// hlNumber = n; 671// hlNumber = n;
673 672
674 h = hlManager->getHl(n); 673 h = hlManager->getHl(n);
675 if (h == m_highlight) { 674 if (h == m_highlight) {
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
@@ -208,50 +208,50 @@ class KateDocument: public Kate::Document
208 @see TextLine 208 @see TextLine
209 */ 209 */
210 TextLine::Ptr getTextLine(int line) const; 210 TextLine::Ptr getTextLine(int line) const;
211 211
212 /** 212 /**
213 get the length in pixels of the given line 213 get the length in pixels of the given line
214 */ 214 */
215 int textLength(int line); 215 int textLength(int line);
216 216
217 void setTabWidth(int); 217 void setTabWidth(int);
218 int tabWidth() {return tabChars;} 218 int tabWidth() {return tabChars;}
219 void setReadOnly(bool); 219 void setReadOnly(bool);
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
246 // search stuff 246 // search stuff
247 protected: 247 protected:
248 static QStringList searchForList; 248 static QStringList searchForList;
249 static QStringList replaceWithList; 249 static QStringList replaceWithList;
250 static uint uniqueID; 250 static uint uniqueID;
251 251
252 // highlight stuff 252 // highlight stuff
253 public: 253 public:
254 Highlight *highlight() {return m_highlight;} 254 Highlight *highlight() {return m_highlight;}
255 int highlightNum() {return hlManager->findHl(m_highlight);} 255 int highlightNum() {return hlManager->findHl(m_highlight);}
256 int numAttribs() {return m_numAttribs;} 256 int numAttribs() {return m_numAttribs;}
257 Attribute *attribs() {return m_attribs;} 257 Attribute *attribs() {return m_attribs;}
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
@@ -628,148 +628,148 @@ int Highlight::doHighlight(int ctxNum, TextLine *textLine)
628 z = z + s2 - s1 - 1; 628 z = z + s2 - s1 - 1;
629 s1 = s2 - 1; 629 s1 = s2 - 1;
630 found = true; 630 found = true;
631 break; 631 break;
632 } 632 }
633 } 633 }
634 } 634 }
635 635
636 // nothing found: set attribute of one char 636 // nothing found: set attribute of one char
637 if (!found) 637 if (!found)
638 textLine->setAttribs(context->attr,s1 - str,s1 - str + 1); 638 textLine->setAttribs(context->attr,s1 - str,s1 - str + 1);
639 639
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
652KConfig *Highlight::getKConfig() { 652KateConfig *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
659QString Highlight::getWildcards() { 659QString 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
669QString Highlight::getMimetypes() { 669QString 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
678HlData *Highlight::getData() { 678HlData *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
695void Highlight::setData(HlData *hlData) { 695void 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
709void Highlight::getItemDataList(ItemDataList &list) { 709void 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
716void Highlight::getItemDataList(ItemDataList &list, KConfig *config) { 716void 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);
729 p->col.setRgb(col); 729 p->col.setRgb(col);
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
751void Highlight::setItemDataList(ItemDataList &list, KConfig *config) { 751void 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/*******************************************************************************************
764 Highlight - use 764 Highlight - use
765 Increase the usage count and trigger initialization if needed 765 Increase the usage count and trigger initialization if needed
766 766
767 * input: none 767 * input: none
768 ************* 768 *************
769 * output: none 769 * output: none
770 ************* 770 *************
771 * return value: none 771 * return value: none
772*******************************************************************************************/ 772*******************************************************************************************/
773 773
774void Highlight::use() 774void Highlight::use()
775{ 775{
@@ -1245,49 +1245,49 @@ HlManager::HlManager() : QObject(0L)
1245 while (i < modeList.count()) 1245 while (i < modeList.count())
1246 { 1246 {
1247 hlList.append(new Highlight(modeList.at(i))); 1247 hlList.append(new Highlight(modeList.at(i)));
1248 i++; 1248 i++;
1249 } 1249 }
1250} 1250}
1251 1251
1252HlManager::~HlManager() { 1252HlManager::~HlManager() {
1253 if(syntax) delete syntax; 1253 if(syntax) delete syntax;
1254} 1254}
1255 1255
1256HlManager *HlManager::self() 1256HlManager *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
1263Highlight *HlManager::getHl(int n) { 1263Highlight *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
1268int HlManager::defaultHl() { 1268int 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
1278int HlManager::nameFind(const QString &name) { 1278int 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--) {
1282 if (hlList.at(z)->iName == name) break; 1282 if (hlList.at(z)->iName == name) break;
1283 } 1283 }
1284 return z; 1284 return z;
1285} 1285}
1286 1286
1287int HlManager::wildcardFind(const QString &fileName) { 1287int HlManager::wildcardFind(const QString &fileName) {
1288 Highlight *highlight; 1288 Highlight *highlight;
1289 int p1, p2; 1289 int p1, p2;
1290 QString w; 1290 QString w;
1291 for (highlight = hlList.first(); highlight != 0L; highlight = hlList.next()) { 1291 for (highlight = hlList.first(); highlight != 0L; highlight = hlList.next()) {
1292 p1 = 0; 1292 p1 = 0;
1293 w = highlight->getWildcards(); 1293 w = highlight->getWildcards();
@@ -1353,85 +1353,85 @@ int HlManager::defaultStyles() {
1353} 1353}
1354 1354
1355QString HlManager::defaultStyleName(int n) 1355QString HlManager::defaultStyleName(int n)
1356{ 1356{
1357 static QStringList names; 1357 static QStringList names;
1358 1358
1359 if (names.isEmpty()) 1359 if (names.isEmpty())
1360 { 1360 {
1361 names << i18n("Normal"); 1361 names << i18n("Normal");
1362 names << i18n("Keyword"); 1362 names << i18n("Keyword");
1363 names << i18n("Data Type"); 1363 names << i18n("Data Type");
1364 names << i18n("Decimal/Value"); 1364 names << i18n("Decimal/Value");
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
1376void HlManager::getDefaults(ItemStyleList &list) { 1376void 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
1390 list.append(new ItemStyle(darkMagenta,cyan,false,false));//float 1390 list.append(new ItemStyle(darkMagenta,cyan,false,false));//float
1391 list.append(new ItemStyle(magenta,magenta,false,false)); //char 1391 list.append(new ItemStyle(magenta,magenta,false,false)); //char
1392 list.append(new ItemStyle(red,red,false,false)); //string 1392 list.append(new ItemStyle(red,red,false,false)); //string
1393 list.append(new ItemStyle(darkGray,gray,false,true)); //comment 1393 list.append(new ItemStyle(darkGray,gray,false,true)); //comment
1394 list.append(new ItemStyle(darkGreen,green,false,false)); //others 1394 list.append(new ItemStyle(darkGreen,green,false,false)); //others
1395 1395
1396#warning fixme 1396#warning fixme
1397/* 1397/*
1398 config = KateFactory::instance()->config(); 1398 config = KateFactory::instance()->config();
1399 config->setGroup("Default Item Styles"); 1399 config->setGroup("Default Item Styles");
1400 for (z = 0; z < defaultStyles(); z++) { 1400 for (z = 0; z < defaultStyles(); z++) {
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
1412void HlManager::setDefaults(ItemStyleList &list) { 1412void 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 }
1426*/ 1426*/
1427 emit changed(); 1427 emit changed();
1428} 1428}
1429 1429
1430 1430
1431int HlManager::highlights() { 1431int HlManager::highlights() {
1432 return (int) hlList.count(); 1432 return (int) hlList.count();
1433} 1433}
1434 1434
1435QString HlManager::hlName(int n) { 1435QString HlManager::hlName(int n) {
1436 return hlList.at(n)->iName; 1436 return hlList.at(n)->iName;
1437} 1437}
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
@@ -215,78 +215,78 @@ class ItemData : public ItemStyle {
215 ItemData(const QString name, int defStyleNum); 215 ItemData(const QString name, int defStyleNum);
216 ItemData(const QString name, int defStyleNum, 216 ItemData(const QString name, int defStyleNum,
217 const QColor&, const QColor&, bool bold, bool italic); 217 const QColor&, const QColor&, bool bold, bool italic);
218 ItemData(ItemData 218 ItemData(ItemData
219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;} 219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;}
220 const QString name; 220 const QString name;
221 int defStyleNum; 221 int defStyleNum;
222 int defStyle; //boolean value 222 int defStyle; //boolean value
223}; 223};
224 224
225typedef QList<ItemData> ItemDataList; 225typedef QList<ItemData> ItemDataList;
226 226
227class HlData { 227class 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
236typedef QList<HlData> HlDataList; 236typedef QList<HlData> HlDataList;
237 237
238class HlManager; 238class HlManager;
239class KConfig; 239class KateConfig;
240 240
241//context 241//context
242class HlContext { 242class 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
251class Highlight 251class 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();
281 void done(); 281 void done();
282 void makeContextList (); 282 void makeContextList ();
283 void createItemData (ItemDataList &list); 283 void createItemData (ItemDataList &list);
284 void readGlobalKeywordConfig(); 284 void readGlobalKeywordConfig();
285 void readCommentConfig(); 285 void readCommentConfig();
286 HlItem *createHlItem(struct syntaxContextData *data, ItemDataList &iDl); 286 HlItem *createHlItem(struct syntaxContextData *data, ItemDataList &iDl);
287 int lookupAttrName(const QString& name, ItemDataList &iDl); 287 int lookupAttrName(const QString& name, ItemDataList &iDl);
288 ItemDataList internalIDList; 288 ItemDataList internalIDList;
289 static const int nContexts = 32; 289 static const int nContexts = 32;
290 HlContext *contextList[nContexts]; 290 HlContext *contextList[nContexts];
291 291
292 bool noHl; 292 bool noHl;
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
@@ -1,137 +1,131 @@
1/*************************************************************************** 1/***************************************************************************
2 katesyntaxdocument.cpp - description 2 katesyntaxdocument.cpp - description
3 ------------------- 3 -------------------
4 begin : Sat 31 March 2001 4 begin : Sat 31 March 2001
5 copyright : (C) 2001,2002 by Joseph Wenninger 5 copyright : (C) 2001,2002 by Joseph Wenninger
6 email : jowenn@kde.org 6 email : jowenn@kde.org
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
30SyntaxDocument::SyntaxDocument() 30SyntaxDocument::SyntaxDocument()
31{ 31{
32 m_root=0; 32 m_root=0;
33 currentFile=""; 33 currentFile="";
34 setupModeList(); 34 setupModeList();
35} 35}
36 36
37void SyntaxDocument::setIdentifier(const QString& identifier) 37void SyntaxDocument::setIdentifier(const QString& identifier)
38{ 38{
39#warning FIXME delete m_root; 39#warning FIXME delete m_root;
40 m_root=Opie::XMLElement::load(identifier); 40 m_root=Opie::XMLElement::load(identifier);
41 if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) ); 41 if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) );
42 42
43} 43}
44 44
45SyntaxDocument::~SyntaxDocument() 45SyntaxDocument::~SyntaxDocument()
46{ 46{
47} 47}
48 48
49void SyntaxDocument::setupModeList(bool force) 49void 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
79 { 78 {
80 qDebug("Found a description file:"+path+(*it)); 79 qDebug("Found a description file:"+path+(*it));
81 setIdentifier(path+(*it)); 80 setIdentifier(path+(*it));
82 Opie::XMLElement *e=m_root; 81 Opie::XMLElement *e=m_root;
83 if (e) 82 if (e)
84 { 83 {
85 e=e->firstChild(); 84 e=e->firstChild();
86 qDebug(e->tagName()); 85 qDebug(e->tagName());
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 } 106 }
111 } 107 }
112// }
113
114// config->sync(); 108// config->sync();
115} 109}
116 110
117SyntaxModeList SyntaxDocument::modeList() 111SyntaxModeList SyntaxDocument::modeList()
118{ 112{
119 return myModeList; 113 return myModeList;
120} 114}
121 115
122bool SyntaxDocument::nextGroup( syntaxContextData* data) 116bool SyntaxDocument::nextGroup( syntaxContextData* data)
123{ 117{
124 if(!data) return false; 118 if(!data) return false;
125 119
126 if (!data->currentGroup) 120 if (!data->currentGroup)
127 data->currentGroup=data->parent->firstChild(); 121 data->currentGroup=data->parent->firstChild();
128 else 122 else
129 data->currentGroup=data->currentGroup->nextChild(); 123 data->currentGroup=data->currentGroup->nextChild();
130 124
131 data->item=0; 125 data->item=0;
132 126
133 if (!data->currentGroup) 127 if (!data->currentGroup)
134 return false; 128 return false;
135 else 129 else
136 return true; 130 return true;
137} 131}
diff --git a/noncore/apps/tinykate/libkate/interfaces/document.h b/noncore/apps/tinykate/libkate/interfaces/document.h
index cbfd1b3..af885f1 100644
--- a/noncore/apps/tinykate/libkate/interfaces/document.h
+++ b/noncore/apps/tinykate/libkate/interfaces/document.h
@@ -9,85 +9,85 @@
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 This library is free software; you can redistribute it and/or 12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public 13 modify it under the terms of the GNU Library General Public
14 License as published by the Free Software Foundation; either 14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version. 15 version 2 of the License, or (at your option) any later version.
16 16
17 This library is distributed in the hope that it will be useful, 17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Library General Public License for more details. 20 Library General Public License for more details.
21 21
22 You should have received a copy of the GNU Library General Public License 22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to 23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 ***************************************************************************/ 26 ***************************************************************************/
27 27
28#ifndef _KATE_DOCUMENT_INCLUDE_ 28#ifndef _KATE_DOCUMENT_INCLUDE_
29#define _KATE_DOCUMENT_INCLUDE_ 29#define _KATE_DOCUMENT_INCLUDE_
30 30
31#include <ktexteditor.h> 31#include <ktexteditor.h>
32 32
33class KConfig; 33class KateConfig;
34 34
35namespace Kate 35namespace Kate
36{ 36{
37 37
38/** internal class for document bookmarks. */ 38/** internal class for document bookmarks. */
39class Mark 39class Mark
40{ 40{
41 public: 41 public:
42 uint line; 42 uint line;
43 uint type; 43 uint type;
44}; 44};
45 45
46/** This interface provedes access to the Kate Document class. 46/** This interface provedes access to the Kate Document class.
47*/ 47*/
48class Document : public KTextEditor::Document 48class Document : public KTextEditor::Document
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52 public: 52 public:
53 Document (); 53 Document ();
54 virtual ~Document (); 54 virtual ~Document ();
55 55
56 public: 56 public:
57 /** Read document config. 57 /** Read document config.
58 */ 58 */
59 virtual void readConfig () { ; }; 59 virtual void readConfig () { ; };
60 /** Save document config. 60 /** Save document config.
61 */ 61 */
62 virtual void writeConfig () { ; }; 62 virtual void writeConfig () { ; };
63 63
64 /** Read document session config. 64 /** Read document session config.
65 */ 65 */
66 virtual void readSessionConfig (KConfig *) { ; }; 66 virtual void readSessionConfig (KateConfig *) { ; };
67 /** Save document session config. 67 /** Save document session config.
68 */ 68 */
69 virtual void writeSessionConfig (KConfig *) { ; }; 69 virtual void writeSessionConfig (KateConfig *) { ; };
70 70
71 /** Returns the document ID. 71 /** Returns the document ID.
72 */ 72 */
73 virtual uint docID () { return 0L; }; 73 virtual uint docID () { return 0L; };
74 74
75 /** Defines possible mark types. A line can have marks of different types. 75 /** Defines possible mark types. A line can have marks of different types.
76 */ 76 */
77 enum marks 77 enum marks
78 { 78 {
79 Bookmark = 1, 79 Bookmark = 1,
80 Breakpoint = 2, 80 Breakpoint = 2,
81 markType0 = 4, 81 markType0 = 4,
82 markType1 = 8, 82 markType1 = 8,
83 markType2 = 16, 83 markType2 = 16,
84 markType3 = 32, 84 markType3 = 32,
85 markType4 = 64, 85 markType4 = 64,
86 markType5 = 128, 86 markType5 = 128,
87 markType6 = 256, 87 markType6 = 256,
88 markType7 = 512, 88 markType7 = 512,
89 markType8 = 1024 89 markType8 = 1024
90 }; 90 };
91 91
92 /** A list of all marks in a document. Use binary comparing to find marks of a specific type. 92 /** A list of all marks in a document. Use binary comparing to find marks of a specific type.
93 */ 93 */
diff --git a/noncore/apps/tinykate/libkate/interfaces/view.h b/noncore/apps/tinykate/libkate/interfaces/view.h
index 5b24bb5..5846395 100644
--- a/noncore/apps/tinykate/libkate/interfaces/view.h
+++ b/noncore/apps/tinykate/libkate/interfaces/view.h
@@ -9,99 +9,99 @@
9***************************************************************************/ 9***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 This library is free software; you can redistribute it and/or 12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public 13 modify it under the terms of the GNU Library General Public
14 License as published by the Free Software Foundation; either 14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version. 15 version 2 of the License, or (at your option) any later version.
16 16
17 This library is distributed in the hope that it will be useful, 17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Library General Public License for more details. 20 Library General Public License for more details.
21 21
22 You should have received a copy of the GNU Library General Public License 22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to 23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 ***************************************************************************/ 26 ***************************************************************************/
27 27
28#ifndef _KATE_VIEW_INCLUDE_ 28#ifndef _KATE_VIEW_INCLUDE_
29#define _KATE_VIEW_INCLUDE_ 29#define _KATE_VIEW_INCLUDE_
30 30
31#include <ktexteditor.h> 31#include <ktexteditor.h>
32 32
33class KConfig; 33class KateConfig;
34 34
35namespace Kate 35namespace Kate
36{ 36{
37 37
38class Document; 38class Document;
39class Mark; 39class Mark;
40 40
41/** This interface provides access to the view. 41/** This interface provides access to the view.
42*/ 42*/
43class View : public KTextEditor::View 43class View : public KTextEditor::View
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 46
47 public: 47 public:
48 View ( KTextEditor::Document *doc, QWidget *parent, const char *name = 0 ); 48 View ( KTextEditor::Document *doc, QWidget *parent, const char *name = 0 );
49 virtual ~View (); 49 virtual ~View ();
50 50
51 /** Returns a pointer to the document of the view. 51 /** Returns a pointer to the document of the view.
52 */ 52 */
53 virtual Document *getDoc () { return 0L; }; 53 virtual Document *getDoc () { return 0L; };
54 54
55 /** Returns the marked text in the view. 55 /** Returns the marked text in the view.
56 */ 56 */
57 virtual QString markedText () { return 0L; }; 57 virtual QString markedText () { return 0L; };
58 58
59 public slots: 59 public slots:
60 /** popup a config dialog for the editor part. 60 /** popup a config dialog for the editor part.
61 */ 61 */
62 virtual void configDialog () { ; }; 62 virtual void configDialog () { ; };
63 63
64 // Highlighting slots 64 // Highlighting slots
65 virtual void setHl (int) { ; }; 65 virtual void setHl (int) { ; };
66 virtual int getHl () { return 0; }; 66 virtual int getHl () { return 0; };
67 virtual int getHlCount () { return 0; }; 67 virtual int getHlCount () { return 0; };
68 virtual QString getHlName (int) { return 0L; }; 68 virtual QString getHlName (int) { return 0L; };
69 virtual QString getHlSection (int) { return 0L; }; 69 virtual QString getHlSection (int) { return 0L; };
70 70
71 // undo/redo stuff 71 // undo/redo stuff
72 virtual void undo () { ; }; 72 virtual void undo () { ; };
73 virtual void redo () { ; }; 73 virtual void redo () { ; };
74 virtual void undoHistory() { ; }; 74 virtual void undoHistory() { ; };
75 75
76 public: 76 public:
77 // read/save config of the view 77 // read/save config of the view
78 virtual void readConfig () { ; }; 78 virtual void readConfig () { ; };
79 virtual void writeConfig () { ; }; 79 virtual void writeConfig () { ; };
80 80
81 // read/save sessionconfig of the view 81 // read/save sessionconfig of the view
82 virtual void readSessionConfig (KConfig *) { ; }; 82 virtual void readSessionConfig (KateConfig *) { ; };
83 virtual void writeSessionConfig (KConfig *) { ; }; 83 virtual void writeSessionConfig (KateConfig *) { ; };
84 84
85 public slots: 85 public slots:
86 // some simply key commands 86 // some simply key commands
87 virtual void keyReturn () { ; }; 87 virtual void keyReturn () { ; };
88 virtual void keyDelete () { ; }; 88 virtual void keyDelete () { ; };
89 virtual void backspace () { ; }; 89 virtual void backspace () { ; };
90 virtual void killLine () { ; }; 90 virtual void killLine () { ; };
91 91
92 // move cursor in the view 92 // move cursor in the view
93 virtual void cursorLeft () { ; }; 93 virtual void cursorLeft () { ; };
94 virtual void shiftCursorLeft () { ; }; 94 virtual void shiftCursorLeft () { ; };
95 virtual void cursorRight () { ; }; 95 virtual void cursorRight () { ; };
96 virtual void shiftCursorRight () { ; }; 96 virtual void shiftCursorRight () { ; };
97 virtual void wordLeft () { ; }; 97 virtual void wordLeft () { ; };
98 virtual void shiftWordLeft () { ; }; 98 virtual void shiftWordLeft () { ; };
99 virtual void wordRight () { ; }; 99 virtual void wordRight () { ; };
100 virtual void shiftWordRight () { ; }; 100 virtual void shiftWordRight () { ; };
101 virtual void home () { ; }; 101 virtual void home () { ; };
102 virtual void shiftHome () { ; }; 102 virtual void shiftHome () { ; };
103 virtual void end () { ; }; 103 virtual void end () { ; };
104 virtual void shiftEnd () { ; }; 104 virtual void shiftEnd () { ; };
105 virtual void up () { ; }; 105 virtual void up () { ; };
106 virtual void shiftUp () { ; }; 106 virtual void shiftUp () { ; };
107 virtual void down () { ; }; 107 virtual void down () { ; };
diff --git a/noncore/apps/tinykate/libkate/kateconfig.cpp b/noncore/apps/tinykate/libkate/kateconfig.cpp
new file mode 100644
index 0000000..06ac49f
--- a/dev/null
+++ b/noncore/apps/tinykate/libkate/kateconfig.cpp
@@ -0,0 +1,634 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qdir.h>
22#include <qfile.h>
23#include <qfileinfo.h>
24#include <qmessagebox.h>
25#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
26#include <qtextcodec.h>
27#endif
28#include <qtextstream.h>
29
30#include <sys/stat.h>
31#include <sys/types.h>
32#include <fcntl.h>
33#include <stdlib.h>
34#include <unistd.h>
35
36#define QTOPIA_INTERNAL_LANGLIST
37#include "kateconfig.h"
38#include <qpe/global.h>
39
40
41/*!
42 \internal
43*/
44QString KateConfig::configFilename(const QString& name, Domain d)
45{
46 switch (d) {
47 case File:
48 return name;
49 case User: {
50 QDir dir = (QString(getenv("HOME")) + "/Settings");
51 if ( !dir.exists() )
52 mkdir(dir.path().local8Bit(),0700);
53 return dir.path() + "/" + name + ".conf";
54 }
55 }
56 return name;
57}
58
59/*!
60 \class KateConfig config.h
61 \brief The KateConfig class provides for saving application cofniguration state.
62
63 You should keep a KateConfig in existence only while you do not want others
64 to be able to change the state. There is no locking currently, but there
65 may be in the future.
66*/
67
68/*!
69 \enum KateConfig::KateConfigGroup
70 \internal
71*/
72
73/*!
74 \enum KateConfig::Domain
75
76 \value File
77 \value User
78
79 See KateConfig for details.
80*/
81
82/*!
83 Constructs a config that will load or create a configuration with the
84 given \a name in the given \a domain.
85
86 You must call setGroup() before doing much else with the KateConfig.
87
88 In the default Domain, \e User,
89 the configuration is user-specific. \a name should not contain "/" in
90 this case, and in general should be the name of the C++ class that is
91 primarily responsible for maintaining the configuration.
92
93 In the File Domain, \a name is an absolute filename.
94*/
95KateConfig::KateConfig( const QString &name, Domain domain )
96 : filename( configFilename(name,domain) )
97{
98 qWarning("KateConfig constructor\n");
99 git = groups.end();
100 read();
101 QStringList l = Global::languageList();
102 lang = l[0];
103 glang = l[1];
104}
105
106
107// Sharp ROM compatibility
108KateConfig::KateConfig ( const QString &name, bool what )
109 : filename( configFilename(name,what ? User : File) )
110{
111 git = groups.end();
112 read();
113 QStringList l = Global::languageList();
114 lang = l[0];
115 glang = l[1];
116}
117
118/*!
119 Writes any changes to disk and destroys the in-memory object.
120*/
121KateConfig::~KateConfig()
122{
123 qWarning("KateConfig destructor\n");
124 if ( changed )
125 write();
126}
127
128/*!
129 Returns whether the current group has an entry called \a key.
130*/
131bool KateConfig::hasKey( const QString &key ) const
132{
133 if ( groups.end() == git )
134 return FALSE;
135 KateConfigGroup::ConstIterator it = ( *git ).find( key );
136 return it != ( *git ).end();
137}
138
139/*!
140 Sets the current group for subsequent reading and writing of
141 entries to \a gname. Grouping allows the application to partition the namespace.
142
143 This function must be called prior to any reading or writing
144 of entries.
145
146 The \a gname must not be empty.
147*/
148void KateConfig::setGroup( const QString &gname )
149{
150 QMap< QString, KateConfigGroup>::Iterator it = groups.find( gname );
151 if ( it == groups.end() ) {
152 git = groups.insert( gname, KateConfigGroup() );
153 changed = TRUE;
154 return;
155 }
156 git = it;
157}
158
159/*!
160 Writes a (\a key, \a value) entry to the current group.
161
162 \sa readEntry()
163*/
164void KateConfig::writeEntry( const QString &key, const char* value )
165{
166 writeEntry(key,QString(value));
167}
168
169/*!
170 Writes a (\a key, \a value) entry to the current group.
171
172 \sa readEntry()
173*/
174void KateConfig::writeEntry( const QString &key, const QString &value )
175{
176 if ( git == groups.end() ) {
177 qWarning( "no group set" );
178 return;
179 }
180 if ( (*git)[key] != value ) {
181 ( *git ).insert( key, value );
182 changed = TRUE;
183 }
184}
185
186/*
187 Note that the degree of protection offered by the encryption here is
188 only sufficient to avoid the most casual observation of the configuration
189 files. People with access to the files can write down the contents and
190 decrypt it using this source code.
191
192 Conceivably, and at some burden to the user, this encryption could
193 be improved.
194*/
195static QString encipher(const QString& plain)
196{
197 // mainly, we make it long
198 QString cipher;
199 int mix=28730492;
200 for (int i=0; i<(int)plain.length(); i++) {
201 int u = plain[i].unicode();
202 int c = u ^ mix;
203 QString x = QString::number(c,36);
204 cipher.append(QChar('a'+x.length()));
205 cipher.append(x);
206 mix *= u;
207 }
208 return cipher;
209}
210
211static QString decipher(const QString& cipher)
212{
213 QString plain;
214 int mix=28730492;
215 for (int i=0; i<(int)cipher.length();) {
216 int l = cipher[i].unicode()-'a';
217 QString x = cipher.mid(i+1,l); i+=l+1;
218 int u = x.toInt(0,36) ^ mix;
219 plain.append(QChar(u));
220 mix *= u;
221 }
222 return plain;
223}
224
225/*!
226 Writes an encrypted (\a key, \a value) entry to the current group.
227
228 Note that the degree of protection offered by the encryption is
229 only sufficient to avoid the most casual observation of the configuration
230 files.
231
232 \sa readEntry()
233*/
234void KateConfig::writeEntryCrypt( const QString &key, const QString &value )
235{
236 if ( git == groups.end() ) {
237 qWarning( "no group set" );
238 return;
239 }
240 QString evalue = encipher(value);
241 if ( (*git)[key] != evalue ) {
242 ( *git ).insert( key, evalue );
243 changed = TRUE;
244 }
245}
246
247/*!
248 Writes a (\a key, \a num) entry to the current group.
249
250 \sa readNumEntry()
251*/
252void KateConfig::writeEntry( const QString &key, int num )
253{
254 QString s;
255 s.setNum( num );
256 writeEntry( key, s );
257}
258
259void KateConfig::writeEntry( const QString &key, unsigned int num )
260{
261 QString s;
262 s.setNum( num );
263 writeEntry( key, s );
264}
265
266#ifdef Q_HAS_BOOL_TYPE
267/*!
268 Writes a (\a key, \a b) entry to the current group. This is equivalent
269 to writing a 0 or 1 as an integer entry.
270
271 \sa readBoolEntry()
272*/
273void KateConfig::writeEntry( const QString &key, bool b )
274{
275 QString s;
276 s.setNum( ( int )b );
277 writeEntry( key, s );
278}
279#endif
280
281/*!
282 Writes a (\a key, \a lst) entry to the current group. The list
283 is separated by \a sep, so the strings must not contain that character.
284
285 \sa readListEntry()
286*/
287void KateConfig::writeEntry( const QString &key, const QStringList &lst, const QChar &sep )
288{
289 QString s;
290 QStringList::ConstIterator it = lst.begin();
291 for ( ; it != lst.end(); ++it )
292 s += *it + sep;
293 writeEntry( key, s );
294}
295
296void KateConfig::writeEntry( const QString &key, const QColor &val )
297{
298 QStringList l;
299 l.append( QString().setNum(val.red()) );
300 l.append( QString().setNum(val.green()) );
301 l.append( QString().setNum(val.blue()) );
302
303 writeEntry( key, l, QChar(',') );
304}
305
306void KateConfig::writeEntry( const QString &key, const QFont &val )
307{
308 QStringList l;
309 l.append( val.family() );
310 l.append( QString().setNum(val.pointSize()) );
311 l.append( QString().setNum(val.weight()) );
312 l.append( QString().setNum((int)val.italic()) );
313 l.append( QString().setNum((int)val.charSet()) );
314
315 writeEntry( key, l, QChar(',') );
316}
317
318/*!
319 Removes the \a key entry from the current group. Does nothing if
320 there is no such entry.
321*/
322
323void KateConfig::removeEntry( const QString &key )
324{
325 if ( git == groups.end() ) {
326 qWarning( "no group set" );
327 return;
328 }
329 ( *git ).remove( key );
330 changed = TRUE;
331}
332
333/*!
334 \fn bool KateConfig::operator == ( const KateConfig & other ) const
335
336 Tests for equality with \a other. KateConfig objects are equal if they refer to the same filename.
337*/
338
339/*!
340 \fn bool KateConfig::operator != ( const KateConfig & other ) const
341
342 Tests for inequality with \a other. KateConfig objects are equal if they refer to the same filename.
343*/
344
345/*!
346 \fn QString KateConfig::readEntry( const QString &key, const QString &deflt ) const
347
348 Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry.
349*/
350
351/*!
352 \internal
353 For compatibility, non-const version.
354*/
355QString KateConfig::readEntry( const QString &key, const QString &deflt )
356{
357 QString res = readEntryDirect( key+"["+lang+"]" );
358 if ( !res.isNull() )
359 return res;
360 if ( !glang.isEmpty() ) {
361 res = readEntryDirect( key+"["+glang+"]" );
362 if ( !res.isNull() )
363 return res;
364 }
365 return readEntryDirect( key, deflt );
366}
367
368/*!
369 \fn QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const
370
371 Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry.
372*/
373
374/*!
375 \internal
376 For compatibility, non-const version.
377*/
378QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt )
379{
380 QString res = readEntryDirect( key+"["+lang+"]" );
381 if ( res.isNull() && glang.isEmpty() )
382 res = readEntryDirect( key+"["+glang+"]" );
383 if ( res.isNull() )
384 res = readEntryDirect( key, QString::null );
385 if ( res.isNull() )
386 return deflt;
387 return decipher(res);
388}
389
390/*!
391 \fn QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const
392 \internal
393*/
394
395/*!
396 \internal
397 For compatibility, non-const version.
398*/
399QString KateConfig::readEntryDirect( const QString &key, const QString &deflt )
400{
401 if ( git == groups.end() ) {
402 //qWarning( "no group set" );
403 return deflt;
404 }
405 KateConfigGroup::ConstIterator it = ( *git ).find( key );
406 if ( it != ( *git ).end() )
407 return *it;
408 else
409 return deflt;
410}
411
412/*!
413 \fn int KateConfig::readNumEntry( const QString &key, int deflt ) const
414 Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry.
415*/
416
417/*!
418 \internal
419 For compatibility, non-const version.
420*/
421int KateConfig::readNumEntry( const QString &key, int deflt )
422{
423 QString s = readEntry( key );
424 if ( s.isEmpty() )
425 return deflt;
426 else
427 return s.toInt();
428}
429
430/*!
431 \fn bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const
432 Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry.
433*/
434
435/*!
436 \internal
437 For compatibility, non-const version.
438*/
439bool KateConfig::readBoolEntry( const QString &key, bool deflt )
440{
441 QString s = readEntry( key );
442 if ( s.isEmpty() )
443 return deflt;
444 else
445 return (bool)s.toInt();
446}
447
448/*!
449 \fn QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const
450 Reads a string list entry stored with \a key, and with \a sep as the separator.
451*/
452
453/*!
454 \internal
455 For compatibility, non-const version.
456*/
457QStringList KateConfig::readListEntry( const QString &key, const QChar &sep )
458{
459 QString s = readEntry( key );
460 if ( s.isEmpty() )
461 return QStringList();
462 else
463 return QStringList::split( sep, s );
464}
465
466QColor KateConfig::readColorEntry( const QString &key, const QColor &def ) const
467{
468 QStringList list = readListEntry(key, QChar(','));
469 if( list.count() != 3 )
470 return def;
471
472 return QColor(list[0].toInt(), list[1].toInt(), list[2].toInt());
473}
474
475QFont KateConfig::readFontEntry( const QString &key, const QFont &def ) const
476{
477 QStringList list = readListEntry(key, QChar(','));
478 if( list.count() != 5 )
479 return def;
480
481 return QFont(list[0], list[1].toInt(), list[2].toInt(), (bool)list[3].toInt(), (QFont::CharSet)list[4].toInt());
482}
483
484QValueList<int> KateConfig::readIntListEntry( const QString &key ) const
485{
486 QString s = readEntry( key );
487 QValueList<int> il;
488 if ( s.isEmpty() )
489 return il;
490
491 QStringList l = QStringList::split( QChar(','), s );
492
493 QStringList::Iterator l_it;
494 for( l_it = l.begin(); l_it != l.end(); ++l_it )
495 il.append( (*l_it).toInt() );
496 return il;
497}
498
499/*!
500 Removes all entries from the current group.
501*/
502void KateConfig::clearGroup()
503{
504 if ( git == groups.end() ) {
505 qWarning( "no group set" );
506 return;
507 }
508 if ( !(*git).isEmpty() ) {
509 ( *git ).clear();
510 changed = TRUE;
511 }
512}
513
514/*!
515 \internal
516*/
517void KateConfig::write( const QString &fn )
518{
519 QString strNewFile;
520 if ( !fn.isEmpty() )
521 filename = fn;
522 strNewFile = filename + ".new";
523
524 QFile f( strNewFile );
525 if ( !f.open( IO_WriteOnly|IO_Raw ) ) {
526 qWarning( "could not open for writing `%s'", strNewFile.latin1() );
527 git = groups.end();
528 return;
529 }
530
531 QString str;
532 QCString cstr;
533 QMap< QString, KateConfigGroup >::Iterator g_it = groups.begin();
534
535 for ( ; g_it != groups.end(); ++g_it ) {
536 str += "[" + g_it.key() + "]\n";
537 KateConfigGroup::Iterator e_it = ( *g_it ).begin();
538 for ( ; e_it != ( *g_it ).end(); ++e_it )
539 str += e_it.key() + " = " + *e_it + "\n";
540 }
541 cstr = str.utf8();
542
543 int total_length;
544 total_length = f.writeBlock( cstr.data(), cstr.length() );
545 if ( total_length != int(cstr.length()) ) {
546 QMessageBox::critical( 0, QObject::tr("Out of Space"),
547 QObject::tr("There was a problem creating\nKateConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") );
548 f.close();
549 QFile::remove( strNewFile );
550 return;
551 }
552
553 f.close();
554 // now rename the file...
555 if ( rename( strNewFile, filename ) < 0 ) {
556 qWarning( "problem renaming the file %s to %s", strNewFile.latin1(),
557 filename.latin1() );
558 QFile::remove( strNewFile );
559 }
560}
561
562/*!
563 Returns whether the KateConfig is in a valid state.
564*/
565bool KateConfig::isValid() const
566{
567 return groups.end() != git;
568}
569
570/*!
571 \internal
572*/
573void KateConfig::read()
574{
575 changed = FALSE;
576
577 if ( !QFileInfo( filename ).exists() ) {
578 git = groups.end();
579 return;
580 }
581
582 QFile f( filename );
583 if ( !f.open( IO_ReadOnly ) ) {
584 git = groups.end();
585 return;
586 }
587
588 QTextStream s( &f );
589#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
590 // The below should work, but doesn't in Qt 2.3.0
591 s.setCodec( QTextCodec::codecForMib( 106 ) );
592#else
593 s.setEncoding( QTextStream::UnicodeUTF8 );
594#endif
595
596 QStringList list = QStringList::split('\n', s.read() );
597 f.close();
598
599 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
600 if ( !parse( *it ) ) {
601 git = groups.end();
602 return;
603 }
604 }
605}
606
607/*!
608 \internal
609*/
610bool KateConfig::parse( const QString &l )
611{
612 QString line = l.stripWhiteSpace();
613
614 if ( line [0] == QChar ( '#' ))
615 return true; // ignore comments
616
617 if ( line[ 0 ] == QChar( '[' ) ) {
618 QString gname = line;
619 gname = gname.remove( 0, 1 );
620 if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) )
621 gname = gname.remove( gname.length() - 1, 1 );
622 git = groups.insert( gname, KateConfigGroup() );
623 } else if ( !line.isEmpty() ) {
624 if ( git == groups.end() )
625 return FALSE;
626 int eq = line.find( '=' );
627 if ( eq == -1 )
628 return FALSE;
629 QString key = line.left(eq).stripWhiteSpace();
630 QString value = line.mid(eq+1).stripWhiteSpace();
631 ( *git ).insert( key, value );
632 }
633 return TRUE;
634}
diff --git a/noncore/apps/tinykate/libkate/kateconfig.h b/noncore/apps/tinykate/libkate/kateconfig.h
new file mode 100644
index 0000000..80a4e67
--- a/dev/null
+++ b/noncore/apps/tinykate/libkate/kateconfig.h
@@ -0,0 +1,117 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef KATECONFIG_H
22#define KATECONFIG_H
23
24// ##### could use QSettings with Qt 3.0
25
26#include <qmap.h>
27#include <qstringlist.h>
28#include <qfont.h>
29#include <qcolor.h>
30
31class KateConfigPrivate;
32class KateConfig
33{
34public:
35 typedef QMap< QString, QString > KateConfigGroup;
36
37 enum Domain { File, User };
38 KateConfig( const QString &name, Domain domain=User );
39 ~KateConfig();
40
41 bool operator == ( const KateConfig & other ) const { return (filename == other.filename); }
42 bool operator != ( const KateConfig & other ) const { return (filename != other.filename); }
43
44 bool isValid() const;
45 bool hasKey( const QString &key ) const;
46
47 // inline for better SharpROM BC
48 inline bool hasGroup ( const QString &gname ) const { return ( groups. find ( gname ) != groups. end ( )); };
49 inline QStringList groupList ( ) const { QStringList sl; for ( QMap< QString, KateConfigGroup >::ConstIterator it = groups. begin ( ); it != groups. end ( ); ++it ) { sl << it.key(); } return sl; };
50
51 void setGroup( const QString &gname );
52 void writeEntry( const QString &key, const char* value );
53 void writeEntry( const QString &key, const QString &value );
54 void writeEntryCrypt( const QString &key, const QString &value );
55 void writeEntry( const QString &key, int num );
56 void writeEntry( const QString &key, unsigned int num );
57#ifdef Q_HAS_BOOL_TYPE
58 void writeEntry( const QString &key, bool b );
59#endif
60 void writeEntry( const QString &key, const QStringList &lst, const QChar &sep );
61 void writeEntry( const QString &key, const QColor & );
62 void writeEntry( const QString &key, const QFont & );
63 void removeEntry( const QString &key );
64
65 QString readEntry( const QString &key, const QString &deflt = QString::null ) const;
66 QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const;
67 QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const;
68 int readNumEntry( const QString &key, int deflt = -1 ) const;
69 bool readBoolEntry( const QString &key, bool deflt = FALSE ) const;
70 QStringList readListEntry( const QString &key, const QChar &sep ) const;
71 QColor readColorEntry( const QString &, const QColor & ) const;
72 QFont readFontEntry( const QString &, const QFont & ) const;
73 QValueList<int> readIntListEntry( const QString &key ) const;
74
75 // For compatibility, non-const versions.
76 QString readEntry( const QString &key, const QString &deflt );
77 QString readEntryCrypt( const QString &key, const QString &deflt );
78 QString readEntryDirect( const QString &key, const QString &deflt );
79 int readNumEntry( const QString &key, int deflt );
80 bool readBoolEntry( const QString &key, bool deflt );
81 QStringList readListEntry( const QString &key, const QChar &sep );
82
83 void clearGroup();
84
85 void write( const QString &fn = QString::null );
86
87protected:
88 void read();
89 bool parse( const QString &line );
90
91 QMap< QString, KateConfigGroup > groups;
92 QMap< QString, KateConfigGroup >::Iterator git;
93 QString filename;
94 QString lang;
95 QString glang;
96 bool changed;
97 KateConfigPrivate *d;
98 static QString configFilename(const QString& name, Domain);
99
100private: // Sharp ROM compatibility
101 KateConfig( const QString &name, bool what );
102};
103
104inline QString KateConfig::readEntry( const QString &key, const QString &deflt ) const
105{ return ((KateConfig*)this)->readEntry(key,deflt); }
106inline QString KateConfig::readEntryCrypt( const QString &key, const QString &deflt ) const
107{ return ((KateConfig*)this)->readEntryCrypt(key,deflt); }
108inline QString KateConfig::readEntryDirect( const QString &key, const QString &deflt ) const
109{ return ((KateConfig*)this)->readEntryDirect(key,deflt); }
110inline int KateConfig::readNumEntry( const QString &key, int deflt ) const
111{ return ((KateConfig*)this)->readNumEntry(key,deflt); }
112inline bool KateConfig::readBoolEntry( const QString &key, bool deflt ) const
113{ return ((KateConfig*)this)->readBoolEntry(key,deflt); }
114inline QStringList KateConfig::readListEntry( const QString &key, const QChar &sep ) const
115{ return ((KateConfig*)this)->readListEntry(key,sep); }
116
117#endif
diff --git a/noncore/apps/tinykate/libkate/libkate.pro b/noncore/apps/tinykate/libkate/libkate.pro
index b0354e6..0082106 100644
--- a/noncore/apps/tinykate/libkate/libkate.pro
+++ b/noncore/apps/tinykate/libkate/libkate.pro
@@ -1,90 +1,91 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 HEADERS = microkde/kapplication.h \ 3 HEADERS = microkde/kapplication.h \
4 microkde/kconfig.h \ 4 kateconfig.h \
5 microkde/kdebug.h \ 5 microkde/kdebug.h \
6 microkde/kdialog.h \ 6 microkde/kdialog.h \
7 microkde/kdialogbase.h \ 7 microkde/kdialogbase.h \
8 microkde/kfiledialog.h \ 8 microkde/kfiledialog.h \
9 microkde/kglobal.h \ 9 microkde/kglobal.h \
10 microkde/kiconloader.h \ 10 microkde/kiconloader.h \
11 microkde/klineedit.h \ 11 microkde/klineedit.h \
12 microkde/klocale.h \ 12 microkde/klocale.h \
13 microkde/kmessagebox.h \ 13 microkde/kmessagebox.h \
14 microkde/kprinter.h \ 14 microkde/kprinter.h \
15 microkde/krestrictedline.h \ 15 microkde/krestrictedline.h \
16 microkde/kseparator.h \ 16 microkde/kseparator.h \
17 microkde/ksimpleconfig.h \
18 microkde/kstandarddirs.h \ 17 microkde/kstandarddirs.h \
19 microkde/ktempfile.h \ 18 microkde/ktempfile.h \
20 microkde/kunload.h \ 19 microkde/kunload.h \
21 microkde/kurlrequester.h \ 20 microkde/kurlrequester.h \
22 microkde/kfontdialog.h \ 21 microkde/kfontdialog.h \
23 microkde/krun.h \ 22 microkde/krun.h \
24 microkde/knumvalidator.h \ 23 microkde/knumvalidator.h \
25 microkde/kstaticdeleter.h \ 24 microkde/kstaticdeleter.h \
26 microkde/klistview.h \ 25 microkde/klistview.h \
27 microkde/kglobalsettings.h \ 26 microkde/kglobalsettings.h \
28 microkde/kcolorbtn.h \ 27 microkde/kcolorbtn.h \
29 \ 28 \
30 \ 29 \
31 qt3back/qregexp3.h \ 30 qt3back/qregexp3.h \
32 kde/ksharedptr.h \ 31 kde/ksharedptr.h \
33 document/katebuffer.h document/katedialogs.h \ 32 document/katebuffer.h document/katedialogs.h \
34 document/katetextline.h \ 33 document/katetextline.h \
35 document/katecmd.h \ 34 document/katecmd.h \
36 document/katehighlight.h \ 35 document/katehighlight.h \
37 document/katecmds.h document/katedocument.h \ 36 document/katecmds.h document/katedocument.h \
38 document/katesyntaxdocument.h \ 37 document/katesyntaxdocument.h \
39 view/kateundohistory.h \ 38 view/kateundohistory.h \
40 view/kateview.h \ 39 view/kateview.h \
41 view/kateviewdialog.h \ 40 view/kateviewdialog.h \
42 interfaces/view.h \ 41 interfaces/view.h \
43 interfaces/document.h \ 42 interfaces/document.h \
44 ktexteditor/ktexteditor.h 43 ktexteditor/ktexteditor.h
45 44
46 SOURCES = microkde/kapplication.cpp \ 45 SOURCES = microkde/kapplication.cpp \
47 microkde/kdialogbase.cpp \ 46 microkde/kdialogbase.cpp \
48 microkde/kconfig.cpp \ 47 kateconfig.cpp \
49 microkde/klocale.cpp \ 48 microkde/klocale.cpp \
50 microkde/kmessagebox.cpp \ 49 microkde/kmessagebox.cpp \
51 microkde/kprocess.cpp \ 50 microkde/kprocess.cpp \
52 microkde/kstandarddirs.cpp \ 51 microkde/kstandarddirs.cpp \
53 microkde/ktempfile.cpp \ 52 microkde/ktempfile.cpp \
54 microkde/kurlrequester.cpp \ 53 microkde/kurlrequester.cpp \
55 microkde/kcolordialog.cpp \ 54 microkde/kcolordialog.cpp \
56 microkde/kfontdialog.cpp \ 55 microkde/kfontdialog.cpp \
57 microkde/krun.cpp \ 56 microkde/krun.cpp \
58 microkde/knumvalidator.cpp \ 57 microkde/knumvalidator.cpp \
59 microkde/kglobal.cpp \ 58 microkde/kglobal.cpp \
60 microkde/kglobalsettings.cpp \ 59 microkde/kglobalsettings.cpp \
61 microkde/kcolorbtn.cpp \ 60 microkde/kcolorbtn.cpp \
62 \ 61 \
63 \ 62 \
64 qt3back/qregexp3.cpp \ 63 qt3back/qregexp3.cpp \
65 ktexteditor/ktexteditor.cpp \ 64 ktexteditor/ktexteditor.cpp \
66 document/katebuffer.cpp document/katedialogs.cpp \ 65 document/katebuffer.cpp document/katedialogs.cpp \
67 document/katehighlight.cpp \ 66 document/katehighlight.cpp \
68 document/katecmd.cpp \ 67 document/katecmd.cpp \
69 document/katesyntaxdocument.cpp document/katecmds.cpp \ 68 document/katesyntaxdocument.cpp document/katecmds.cpp \
70 document/katedocument.cpp document/katetextline.cpp \ 69 document/katedocument.cpp document/katetextline.cpp \
71 view/kateundohistory.cpp \ 70 view/kateundohistory.cpp \
72 view/kateview.cpp \ 71 view/kateview.cpp \
73 view/kateviewdialog.cpp \ 72 view/kateviewdialog.cpp \
74 interfaces/interfaces.cpp 73 interfaces/interfaces.cpp
75 74
76 INTERFACES= 75 INTERFACES=
77 INCLUDEPATH+= $(OPIEDIR)/include $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ 76 INCLUDEPATH+= $(OPIEDIR)/include \
77 $(OPIEDIR)/noncore/apps/tinykate/libkate \
78 $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
78 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ 79 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \
79 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ 80 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \
80 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ 81 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
81 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ 82 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
82 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back 83 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
83 DEPENDPATH+= $(OPIEDIR)/include 84 DEPENDPATH+= $(OPIEDIR)/include
84LIBS += -lqpe -lopie 85LIBS += -lqpe -lopie
85 TARGET = tinykate 86 TARGET = tinykate
86 87
87INCLUDEPATH += $(OPIEDIR)/include 88INCLUDEPATH += $(OPIEDIR)/include
88DESTDIR = $(OPIEDIR)/lib$(PROJMAK) 89DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
89 90
90include ( $(OPIEDIR)/include.pro ) 91include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.cpp b/noncore/apps/tinykate/libkate/microkde/kconfig.cpp
deleted file mode 100644
index d88bda0..0000000
--- a/noncore/apps/tinykate/libkate/microkde/kconfig.cpp
+++ b/dev/null
@@ -1,181 +0,0 @@
1#include <qfile.h>
2#include <qtextstream.h>
3
4#include "kdebug.h"
5
6#include "kconfig.h"
7
8QString KConfig::mGroup = "";
9//QString KConfig::mGroup = "General";
10
11KConfig::KConfig( const QString &fileName )
12 : mFileName( fileName ), mDirty( false )
13{
14 kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl;
15
16 load();
17}
18
19
20KConfig::~KConfig()
21{
22 sync();
23}
24
25void KConfig::setGroup( const QString &group )
26{
27 return;
28
29// kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl;
30
31 mGroup = group;
32
33 if ( mGroup.right( 1 ) != "/" ) mGroup += "/";
34}
35
36
37QValueList<int> KConfig::readIntListEntry( const QString & )
38{
39 QValueList<int> l;
40 return l;
41}
42
43int KConfig::readNumEntry( const QString &, int def )
44{
45 return def;
46}
47
48QString KConfig::readEntry( const QString &key, const QString &def )
49{
50 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
51
52 if ( it == mStringMap.end() ) {
53 return def;
54 }
55
56 return *it;
57}
58
59QStringList KConfig::readListEntry( const QString & )
60{
61 return QStringList();
62}
63
64bool KConfig::readBoolEntry( const QString &key, bool def )
65{
66 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key );
67
68 if ( it == mBoolMap.end() ) {
69 return def;
70 }
71
72 return *it;
73}
74
75QColor KConfig::readColorEntry( const QString &, QColor *def )
76{
77 if ( def ) return *def;
78 return QColor();
79}
80
81QFont KConfig::readFontEntry( const QString &, QFont *def )
82{
83 if ( def ) return *def;
84 return QFont();
85}
86
87
88void KConfig::writeEntry( const QString &, QValueList<int> )
89{
90}
91
92void KConfig::writeEntry( const QString &, int )
93{
94}
95
96void KConfig::writeEntry( const QString &key, const QString &value )
97{
98 mStringMap.insert( mGroup + key, value );
99
100 mDirty = true;
101}
102
103void KConfig::writeEntry( const QString &, const QStringList & )
104{
105}
106
107void KConfig::writeEntry( const QString &key, bool value)
108{
109 mBoolMap.insert( mGroup + key, value );
110
111 mDirty = true;
112}
113
114void KConfig::writeEntry( const QString &, const QColor & )
115{
116}
117
118void KConfig::writeEntry( const QString &, const QFont & )
119{
120}
121
122void KConfig::load()
123{
124 mBoolMap.clear();
125 mStringMap.clear();
126
127 QFile f( mFileName );
128 if ( !f.open( IO_ReadOnly ) ) {
129 kdDebug() << "KConfig::load(): Can't open file '" << mFileName << "'"
130 << endl;
131 return;
132 }
133
134
135 QTextStream t( &f );
136
137 QString line = t.readLine();
138
139 while ( !line.isNull() ) {
140 QStringList tokens = QStringList::split( ",", line );
141 if ( tokens[0] == "bool" ) {
142 bool value = false;
143 if ( tokens[2] == "1" ) value = true;
144
145 mBoolMap.insert( tokens[1], value );
146 } else if ( tokens[0] == "QString" ) {
147 QString value = tokens[2];
148 mStringMap.insert( tokens[1], value );
149 }
150
151 line = t.readLine();
152 }
153}
154
155void KConfig::sync()
156{
157 if ( !mDirty ) return;
158
159 QFile f( mFileName );
160 if ( !f.open( IO_WriteOnly ) ) {
161 kdDebug() << "KConfig::sync(): Can't open file '" << mFileName << "'"
162 << endl;
163 return;
164 }
165
166 QTextStream t( &f );
167
168 QMap<QString,bool>::ConstIterator itBool;
169 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
170 t << "bool," << itBool.key() << "," << (*itBool ) << endl;
171 }
172
173 QMap<QString,QString>::ConstIterator itString;
174 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
175 t << "QString," << itString.key() << "," << (*itString ) << endl;
176 }
177
178 f.close();
179
180 mDirty = false;
181}
diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.h b/noncore/apps/tinykate/libkate/microkde/kconfig.h
deleted file mode 100644
index 8bd768a..0000000
--- a/noncore/apps/tinykate/libkate/microkde/kconfig.h
+++ b/dev/null
@@ -1,51 +0,0 @@
1#ifndef MINIKDE_KCONFIG_H
2#define MINIKDE_KCONFIG_H
3
4#include <qstring.h>
5#include <qstringlist.h>
6#include <qvaluelist.h>
7#include <qcolor.h>
8#include <qfont.h>
9#include <qmap.h>
10
11class KConfig
12{
13 public:
14 KConfig( const QString & );
15 ~KConfig();
16
17 void setGroup( const QString & );
18
19 bool hasGroup( const QString &) {return false;}
20
21 QValueList<int> readIntListEntry( const QString & );
22 int readNumEntry( const QString &, int def=0 );
23 QString readEntry( const QString &, const QString &def=QString::null );
24 QStringList readListEntry( const QString & );
25 bool readBoolEntry( const QString &, bool def=false );
26 QColor readColorEntry( const QString &, QColor * );
27 QFont readFontEntry( const QString &, QFont * );
28
29 void writeEntry( const QString &, QValueList<int> );
30 void writeEntry( const QString &, int );
31 void writeEntry( const QString &, const QString & );
32 void writeEntry( const QString &, const QStringList & );
33 void writeEntry( const QString &, bool );
34 void writeEntry( const QString &, const QColor & );
35 void writeEntry( const QString &, const QFont & );
36
37 void load();
38 void sync();
39
40 private:
41 static QString mGroup;
42
43 QString mFileName;
44
45 QMap<QString,bool> mBoolMap;
46 QMap<QString,QString> mStringMap;
47
48 bool mDirty;
49};
50
51#endif
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.cpp b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
index 572768d..9b5c4d3 100644
--- a/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
+++ b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
@@ -1,46 +1,46 @@
1#include "kglobal.h" 1#include "kglobal.h"
2 2
3KLocale *KGlobal::mLocale = 0; 3KLocale *KGlobal::mLocale = 0;
4KConfig *KGlobal::mConfig = 0; 4KateConfig *KGlobal::mConfig = 0;
5KIconLoader *KGlobal::mIconLoader = 0; 5KIconLoader *KGlobal::mIconLoader = 0;
6KStandardDirs *KGlobal::mDirs = 0; 6KStandardDirs *KGlobal::mDirs = 0;
7 7
8QString KGlobal::mAppName = "godot"; 8QString KGlobal::mAppName = "godot";
9 9
10KLocale *KGlobal::locale() 10KLocale *KGlobal::locale()
11{ 11{
12 if ( !mLocale ) { 12 if ( !mLocale ) {
13 mLocale = new KLocale(); 13 mLocale = new KLocale();
14 } 14 }
15 15
16 return mLocale; 16 return mLocale;
17} 17}
18 18
19KConfig *KGlobal::config() 19KateConfig *KGlobal::config()
20{ 20{
21 if ( !mConfig ) { 21 if ( !mConfig ) {
22 mConfig = new KConfig( KStandardDirs::appDir() + mAppName + "rc" ); 22 mConfig = new KateConfig( mAppName );
23 } 23 }
24 24
25 return mConfig; 25 return mConfig;
26} 26}
27 27
28KIconLoader *KGlobal::iconLoader() 28KIconLoader *KGlobal::iconLoader()
29{ 29{
30 if ( !mIconLoader ) { 30 if ( !mIconLoader ) {
31 mIconLoader = new KIconLoader(); 31 mIconLoader = new KIconLoader();
32 } 32 }
33 33
34 return mIconLoader; 34 return mIconLoader;
35} 35}
36 36
37KStandardDirs *KGlobal::dirs() 37KStandardDirs *KGlobal::dirs()
38{ 38{
39 if ( !mDirs ) { 39 if ( !mDirs ) {
40 mDirs = new KStandardDirs(); 40 mDirs = new KStandardDirs();
41 } 41 }
42 42
43 return mDirs; 43 return mDirs;
44} 44}
45 45
46void KGlobal::setAppName( const QString &appName ) 46void KGlobal::setAppName( const QString &appName )
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.h b/noncore/apps/tinykate/libkate/microkde/kglobal.h
index 8985bd4..e4e2c79 100644
--- a/noncore/apps/tinykate/libkate/microkde/kglobal.h
+++ b/noncore/apps/tinykate/libkate/microkde/kglobal.h
@@ -1,27 +1,27 @@
1#ifndef MINIKDE_KGLOBAL_H 1#ifndef MINIKDE_KGLOBAL_H
2#define MINIKDE_KGLOBAL_H 2#define MINIKDE_KGLOBAL_H
3 3
4#include "klocale.h" 4#include "klocale.h"
5#include "kiconloader.h" 5#include "kiconloader.h"
6#include "kstandarddirs.h" 6#include "kstandarddirs.h"
7#include "kconfig.h" 7#include <kateconfig.h>
8 8
9class KGlobal { 9class KGlobal {
10 public: 10 public:
11 static KLocale *locale(); 11 static KLocale *locale();
12 static KConfig *config(); 12 static KateConfig *config();
13 static KIconLoader *iconLoader(); 13 static KIconLoader *iconLoader();
14 static KStandardDirs *dirs(); 14 static KStandardDirs *dirs();
15 15
16 static void setAppName( const QString & ); 16 static void setAppName( const QString & );
17 17
18 private: 18 private:
19 static KLocale *mLocale; 19 static KLocale *mLocale;
20 static KConfig *mConfig; 20 static KateConfig *mConfig;
21 static KIconLoader *mIconLoader; 21 static KIconLoader *mIconLoader;
22 static KStandardDirs *mDirs; 22 static KStandardDirs *mDirs;
23 23
24 static QString mAppName; 24 static QString mAppName;
25}; 25};
26 26
27#endif 27#endif
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp
index 63e941f..af3b30d 100644
--- a/noncore/apps/tinykate/libkate/view/kateview.cpp
+++ b/noncore/apps/tinykate/libkate/view/kateview.cpp
@@ -25,59 +25,59 @@
25 modify it under the terms of the GNU Library General Public 25 modify it under the terms of the GNU Library General Public
26 License as published by the Free Software Foundation; either 26 License as published by the Free Software Foundation; either
27 version 2 of the License, or (at your option) any later version. 27 version 2 of the License, or (at your option) any later version.
28 28
29 This library is distributed in the hope that it will be useful, 29 This library is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of 30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 Library General Public License for more details. 32 Library General Public License for more details.
33 33
34 You should have received a copy of the GNU Library General Public License 34 You should have received a copy of the GNU Library General Public License
35 along with this library; see the file COPYING.LIB. If not, write to 35 along with this library; see the file COPYING.LIB. If not, write to
36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
37 Boston, MA 02111-1307, USA. 37 Boston, MA 02111-1307, USA.
38*/ 38*/
39 39
40 40
41 41
42#include "kateview.h" 42#include "kateview.h"
43 43
44#include "../document/katedocument.h" 44#include "../document/katedocument.h"
45#include "../document/katecmd.h" 45#include "../document/katecmd.h"
46#include "../document/katehighlight.h" 46#include "../document/katehighlight.h"
47#include "kateviewdialog.h" 47#include "kateviewdialog.h"
48#include "../document/katedialogs.h" 48#include "../document/katedialogs.h"
49#include <kateconfig.h>
49 50
50#include <qfocusdata.h> 51#include <qfocusdata.h>
51#include <kdebug.h> 52#include <kdebug.h>
52#include <kapplication.h> 53#include <kapplication.h>
53#include <qscrollbar.h> 54#include <qscrollbar.h>
54#include <qiodevice.h> 55#include <qiodevice.h>
55#include <qpopupmenu.h> 56#include <qpopupmenu.h>
56#include <kpopupmenu.h> 57#include <kpopupmenu.h>
57#include <qkeycode.h> 58#include <qkeycode.h>
58#include <qintdict.h> 59#include <qintdict.h>
59#include <kconfig.h>
60#include <qfont.h> 60#include <qfont.h>
61#include <qpainter.h> 61#include <qpainter.h>
62#include <qpixmap.h> 62#include <qpixmap.h>
63#include <qfileinfo.h> 63#include <qfileinfo.h>
64#include <qfile.h> 64#include <qfile.h>
65#include <qevent.h> 65#include <qevent.h>
66#include <qdir.h> 66#include <qdir.h>
67#include <qvbox.h> 67#include <qvbox.h>
68#include <qprintdialog.h> 68#include <qprintdialog.h>
69#include <qpaintdevicemetrics.h> 69#include <qpaintdevicemetrics.h>
70#include <qiodevice.h> 70#include <qiodevice.h>
71#include <qbuffer.h> 71#include <qbuffer.h>
72#include <qfocusdata.h> 72#include <qfocusdata.h>
73#include <klocale.h> 73#include <klocale.h>
74#include <kglobal.h> 74#include <kglobal.h>
75#include <kdebug.h> 75#include <kdebug.h>
76#include <kmessagebox.h> 76#include <kmessagebox.h>
77#include <qregexp.h> 77#include <qregexp.h>
78#include <kdialogbase.h> 78#include <kdialogbase.h>
79#include <klineeditdlg.h> 79#include <klineeditdlg.h>
80#include <qapplication.h> 80#include <qapplication.h>
81#include <kfiledialog.h> 81#include <kfiledialog.h>
82#include <kiconloader.h> 82#include <kiconloader.h>
83#include "../document/katetextline.h" 83#include "../document/katetextline.h"
@@ -1220,54 +1220,54 @@ KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate
1220 rmbMenu = 0L; 1220 rmbMenu = 0L;
1221 1221
1222 1222
1223 setFocusProxy( myViewInternal ); 1223 setFocusProxy( myViewInternal );
1224 myViewInternal->setFocus(); 1224 myViewInternal->setFocus();
1225 resize(parent->width() -4, parent->height() -4); 1225 resize(parent->width() -4, parent->height() -4);
1226 1226
1227 1227
1228 myViewInternal->installEventFilter( this ); 1228 myViewInternal->installEventFilter( this );
1229 1229
1230 //setupActions(); 1230 //setupActions();
1231 1231
1232 connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) ); 1232 connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) );
1233 connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) ); 1233 connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) );
1234 connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) ); 1234 connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) );
1235 connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) ); 1235 connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) );
1236 1236
1237 readConfig(); 1237 readConfig();
1238// setHighlight->setCurrentItem(getHl()); 1238// setHighlight->setCurrentItem(getHl());
1239 slotUpdate(); 1239 slotUpdate();
1240} 1240}
1241 1241
1242KateView::~KateView() 1242KateView::~KateView()
1243{ 1243{
1244 writeConfig();
1244 1245
1245 if (myDoc && !myDoc->m_bSingleViewMode) 1246 if (myDoc && !myDoc->m_bSingleViewMode)
1246 myDoc->removeView( this ); 1247 myDoc->removeView( this );
1247 1248
1248 delete myViewInternal; 1249 delete myViewInternal;
1249
1250} 1250}
1251 1251
1252#if 0 1252#if 0
1253void KateView::setupActions() 1253void KateView::setupActions()
1254{ 1254{
1255#if 0 1255#if 0
1256 KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" ); 1256 KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" );
1257 1257
1258 KStdAction::save(this, SLOT(save()), actionCollection()); 1258 KStdAction::save(this, SLOT(save()), actionCollection());
1259 1259
1260 // setup edit menu 1260 // setup edit menu
1261 editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection()); 1261 editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection());
1262 editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection()); 1262 editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection());
1263 editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()), 1263 editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()),
1264 actionCollection(), "edit_undoHistory"); 1264 actionCollection(), "edit_undoHistory");
1265 KStdAction::cut(this, SLOT(cut()), actionCollection()); 1265 KStdAction::cut(this, SLOT(cut()), actionCollection());
1266 KStdAction::copy(this, SLOT(copy()), actionCollection()); 1266 KStdAction::copy(this, SLOT(copy()), actionCollection());
1267 KStdAction::paste(this, SLOT(paste()), actionCollection()); 1267 KStdAction::paste(this, SLOT(paste()), actionCollection());
1268 1268
1269 if ( myDoc->hasBrowserExtension() ) 1269 if ( myDoc->hasBrowserExtension() )
1270 { 1270 {
1271 KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection()); 1271 KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection());
1272 KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find"); 1272 KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find");
1273 KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again"); 1273 KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again");
@@ -2201,82 +2201,82 @@ bool KateView::askReplaceEnd() {
2201 } else { 2201 } else {
2202 // backward search 2202 // backward search
2203 str = i18n("%1 replacement(s) made.\n" 2203 str = i18n("%1 replacement(s) made.\n"
2204 "Beginning of document reached.\n" 2204 "Beginning of document reached.\n"
2205 "Continue from the end?").arg(replaces); 2205 "Continue from the end?").arg(replaces);
2206 query = KMessageBox::questionYesNo(this, str, i18n("Replace"), 2206 query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
2207 i18n("Continue"), i18n("Stop")); 2207 i18n("Continue"), i18n("Stop"));
2208 } 2208 }
2209 replaces = 0; 2209 replaces = 0;
2210 continueSearch(s); 2210 continueSearch(s);
2211 return (query == KMessageBox::No); 2211 return (query == KMessageBox::No);
2212} 2212}
2213 2213
2214void KateView::replaceSlot() { 2214void KateView::replaceSlot() {
2215 doReplaceAction(replacePrompt->result(),true); 2215 doReplaceAction(replacePrompt->result(),true);
2216} 2216}
2217 2217
2218void KateView::installPopup(QPopupMenu *rmb_Menu) 2218void KateView::installPopup(QPopupMenu *rmb_Menu)
2219{ 2219{
2220 rmbMenu = rmb_Menu; 2220 rmbMenu = rmb_Menu;
2221} 2221}
2222 2222
2223void KateView::readConfig() 2223void KateView::readConfig()
2224{ 2224{
2225 KConfig *config = KGlobal::config(); 2225 KateConfig *config = KGlobal::config();
2226 config->setGroup("Kate View"); 2226 config->setGroup("Kate View");
2227 2227
2228 searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); 2228 searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt);
2229 configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; 2229 configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark;
2230 2230
2231 config->sync(); 2231// config->sync();
2232} 2232}
2233 2233
2234void KateView::writeConfig() 2234void KateView::writeConfig()
2235{ 2235{
2236 KConfig *config = KGlobal::config(); 2236 KateConfig *config = KGlobal::config();
2237 config->setGroup("Kate View"); 2237 config->setGroup("Kate View");
2238 2238
2239 config->writeEntry("SearchFlags",searchFlags); 2239 config->writeEntry("SearchFlags",searchFlags);
2240 config->writeEntry("ConfigFlags",configFlags); 2240 config->writeEntry("ConfigFlags",configFlags);
2241 2241
2242 config->sync(); 2242// config->sync();
2243} 2243}
2244 2244
2245void KateView::readSessionConfig(KConfig *config) 2245void KateView::readSessionConfig(KateConfig *config)
2246{ 2246{
2247 PointStruc cursor; 2247 PointStruc cursor;
2248 2248
2249 myViewInternal->xPos = config->readNumEntry("XPos"); 2249 myViewInternal->xPos = config->readNumEntry("XPos");
2250 myViewInternal->yPos = config->readNumEntry("YPos"); 2250 myViewInternal->yPos = config->readNumEntry("YPos");
2251 cursor.x = config->readNumEntry("CursorX"); 2251 cursor.x = config->readNumEntry("CursorX");
2252 cursor.y = config->readNumEntry("CursorY"); 2252 cursor.y = config->readNumEntry("CursorY");
2253 myViewInternal->updateCursor(cursor); 2253 myViewInternal->updateCursor(cursor);
2254 myIconBorder = config->readBoolEntry("IconBorder on"); 2254 myIconBorder = config->readBoolEntry("IconBorder on");
2255 setIconBorder(myIconBorder); 2255 setIconBorder(myIconBorder);
2256} 2256}
2257 2257
2258void KateView::writeSessionConfig(KConfig *config) 2258void KateView::writeSessionConfig(KateConfig *config)
2259{ 2259{
2260 config->writeEntry("XPos",myViewInternal->xPos); 2260 config->writeEntry("XPos",myViewInternal->xPos);
2261 config->writeEntry("YPos",myViewInternal->yPos); 2261 config->writeEntry("YPos",myViewInternal->yPos);
2262 config->writeEntry("CursorX",myViewInternal->cursor.x); 2262 config->writeEntry("CursorX",myViewInternal->cursor.x);
2263 config->writeEntry("CursorY",myViewInternal->cursor.y); 2263 config->writeEntry("CursorY",myViewInternal->cursor.y);
2264 config->writeEntry("IconBorder on", myIconBorder); 2264 config->writeEntry("IconBorder on", myIconBorder);
2265} 2265}
2266 2266
2267void KateView::configDialog() 2267void KateView::configDialog()
2268{ 2268{
2269 2269
2270#warning fixme 2270#warning fixme
2271 2271
2272#if 1 2272#if 1
2273 KDialogBase *kd = new KDialogBase(KDialogBase::IconList, 2273 KDialogBase *kd = new KDialogBase(KDialogBase::IconList,
2274 i18n("Configure Editor"), 2274 i18n("Configure Editor"),
2275 KDialogBase::Ok | KDialogBase::Cancel | 2275 KDialogBase::Ok | KDialogBase::Cancel |
2276 KDialogBase::Help , 2276 KDialogBase::Help ,
2277 KDialogBase::Ok, this, "tabdialog"); 2277 KDialogBase::Ok, this, "tabdialog");
2278 2278
2279 // color options 2279 // color options
2280 QFrame *page=kd->addPage(i18n("Colors")); 2280 QFrame *page=kd->addPage(i18n("Colors"));
2281 (new QVBoxLayout(page))->setAutoAdd(true); 2281 (new QVBoxLayout(page))->setAutoAdd(true);
2282 ColorConfig *colorConfig = new ColorConfig(page); 2282 ColorConfig *colorConfig = new ColorConfig(page);
@@ -2299,49 +2299,49 @@ void KateView::configDialog()
2299 page=kd->addPage(i18n("Select")); 2299 page=kd->addPage(i18n("Select"));
2300 (new QVBoxLayout(page))->setAutoAdd(true); 2300 (new QVBoxLayout(page))->setAutoAdd(true);
2301 2301
2302 SelectConfigTab *selectConfig = new SelectConfigTab(page, this); 2302 SelectConfigTab *selectConfig = new SelectConfigTab(page, this);
2303 2303
2304 // edit options 2304 // edit options
2305 page=kd->addPage(i18n("Edit")); 2305 page=kd->addPage(i18n("Edit"));
2306 (new QVBoxLayout(page))->setAutoAdd(true); 2306 (new QVBoxLayout(page))->setAutoAdd(true);
2307 2307
2308 EditConfigTab *editConfig = new EditConfigTab(page, this); 2308 EditConfigTab *editConfig = new EditConfigTab(page, this);
2309 2309
2310 2310
2311 2311
2312 HighlightDialogPage *hlPage; 2312 HighlightDialogPage *hlPage;
2313 HlManager *hlManager; 2313 HlManager *hlManager;
2314 HlDataList hlDataList; 2314 HlDataList hlDataList;
2315 ItemStyleList defaultStyleList; 2315 ItemStyleList defaultStyleList;
2316 2316
2317 hlManager = HlManager::self(); 2317 hlManager = HlManager::self();
2318 2318
2319 defaultStyleList.setAutoDelete(true); 2319 defaultStyleList.setAutoDelete(true);
2320 hlManager->getDefaults(defaultStyleList); 2320 hlManager->getDefaults(defaultStyleList);
2321 2321
2322 hlDataList.setAutoDelete(true); 2322 hlDataList.setAutoDelete(true);
2323 //this gets the data from the KConfig object 2323 //this gets the data from the KateConfig object
2324 hlManager->getHlDataList(hlDataList); 2324 hlManager->getHlDataList(hlDataList);
2325 2325
2326 page=kd->addPage(i18n("Highlighting")); 2326 page=kd->addPage(i18n("Highlighting"));
2327 (new QVBoxLayout(page))->setAutoAdd(true); 2327 (new QVBoxLayout(page))->setAutoAdd(true);
2328 2328
2329 hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); 2329 hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page);
2330 kd->showMaximized(); 2330 kd->showMaximized();
2331 if (kd->exec()) { 2331 if (kd->exec()) {
2332 // color options 2332 // color options
2333 colorConfig->getColors(colors); 2333 colorConfig->getColors(colors);
2334 myDoc->setFont (fontConfig->getFont()); 2334 myDoc->setFont (fontConfig->getFont());
2335 2335
2336 applyColors(); 2336 applyColors();
2337 // indent options 2337 // indent options
2338 indentConfig->getData(this); 2338 indentConfig->getData(this);
2339 // select options 2339 // select options
2340 selectConfig->getData(this); 2340 selectConfig->getData(this);
2341 // edit options 2341 // edit options
2342 editConfig->getData(this); 2342 editConfig->getData(this);
2343 // spell checker 2343 // spell checker
2344 hlManager->setHlDataList(hlDataList); 2344 hlManager->setHlDataList(hlDataList);
2345 hlManager->setDefaults(defaultStyleList); 2345 hlManager->setDefaults(defaultStyleList);
2346 hlPage->saveData(); 2346 hlPage->saveData();
2347 } 2347 }
diff --git a/noncore/apps/tinykate/libkate/view/kateview.h b/noncore/apps/tinykate/libkate/view/kateview.h
index 2e78a3a..858e8a1 100644
--- a/noncore/apps/tinykate/libkate/view/kateview.h
+++ b/noncore/apps/tinykate/libkate/view/kateview.h
@@ -28,48 +28,49 @@
28 28
29 This library is distributed in the hope that it will be useful, 29 This library is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of 30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 Library General Public License for more details. 32 Library General Public License for more details.
33 33
34 You should have received a copy of the GNU Library General Public License 34 You should have received a copy of the GNU Library General Public License
35 along with this library; see the file COPYING.LIB. If not, write to 35 along with this library; see the file COPYING.LIB. If not, write to
36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 36 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
37 Boston, MA 02111-1307, USA. 37 Boston, MA 02111-1307, USA.
38*/ 38*/
39 39
40#ifndef kate_view_h 40#ifndef kate_view_h
41#define kate_view_h 41#define kate_view_h
42 42
43#include "../interfaces/view.h" 43#include "../interfaces/view.h"
44#include "../interfaces/document.h" 44#include "../interfaces/document.h"
45 45
46#include <qlist.h> 46#include <qlist.h>
47#include <qstring.h> 47#include <qstring.h>
48#include <qdialog.h> 48#include <qdialog.h>
49 49
50 50
51class KateDocument; 51class KateDocument;
52class KateConfig;
52class Highlight; 53class Highlight;
53 54
54/* 55/*
55//dialog results 56//dialog results
56const int srYes = QDialog::Accepted; 57const int srYes = QDialog::Accepted;
57const int srNo = 10; 58const int srNo = 10;
58const int srAll = 11; 59const int srAll = 11;
59const int srCancel = QDialog::Rejected; 60const int srCancel = QDialog::Rejected;
60*/ 61*/
61// --- config flags --- 62// --- config flags ---
62// indent 63// indent
63 64
64enum Select_flags { 65enum Select_flags {
65 selectFlag = 0x100000, 66 selectFlag = 0x100000,
66 multiSelectFlag = 0x200000 67 multiSelectFlag = 0x200000
67}; 68};
68//state commands 69//state commands
69enum State_commands { 70enum State_commands {
70 cmToggleInsert = 1, 71 cmToggleInsert = 1,
71 cmToggleVertical = 2 72 cmToggleVertical = 2
72}; 73};
73 74
74class KateViewInternal; 75class KateViewInternal;
75class KateView; 76class KateView;
@@ -640,56 +641,56 @@ class KateView : public Kate::View
640 /** 641 /**
641 Install a Popup Menu. The Popup Menu will be activated on 642 Install a Popup Menu. The Popup Menu will be activated on
642 a right mouse button press event. 643 a right mouse button press event.
643 */ 644 */
644 void installPopup(QPopupMenu *rmb_Menu); 645 void installPopup(QPopupMenu *rmb_Menu);
645 646
646 protected: 647 protected:
647 QPopupMenu *rmbMenu; 648 QPopupMenu *rmbMenu;
648 649
649 signals: 650 signals:
650 void bookAddChanged(bool enabled); 651 void bookAddChanged(bool enabled);
651 void bookClearChanged(bool enabled); 652 void bookClearChanged(bool enabled);
652 653
653//config file / session management functions 654//config file / session management functions
654 public: 655 public:
655 /** 656 /**
656 Reads config entries 657 Reads config entries
657 */ 658 */
658 void readConfig(); 659 void readConfig();
659 /** 660 /**
660 Writes config entries i 661 Writes config entries i
661 */ 662 */
662 void writeConfig(); 663 void writeConfig();
663 /** 664 /**
664 Reads session config out of the KConfig object. This also includes 665 Reads session config out of the KateConfig object. This also includes
665 the actual cursor position and the bookmarks. 666 the actual cursor position and the bookmarks.
666 */ 667 */
667 void readSessionConfig(KConfig *); 668 void readSessionConfig(KateConfig *);
668 /** 669 /**
669 Writes session config into the KConfig object 670 Writes session config into the KateConfig object
670 */ 671 */
671 void writeSessionConfig(KConfig *); 672 void writeSessionConfig(KateConfig *);
672 673
673 674
674 public: 675 public:
675 void setDontChangeHlOnSave(); 676 void setDontChangeHlOnSave();
676 677
677 678
678 // syntax highlight 679 // syntax highlight
679 public slots: 680 public slots:
680 /** 681 /**
681 Presents the setup dialog to the user 682 Presents the setup dialog to the user
682 */ 683 */
683 void configDialog (); 684 void configDialog ();
684 /** 685 /**
685 Gets the highlight number 686 Gets the highlight number
686 */ 687 */
687 int getHl(); 688 int getHl();
688 /** 689 /**
689 Sets the highlight number n 690 Sets the highlight number n
690 */ 691 */
691 void setHl(int n); 692 void setHl(int n);
692 /** 693 /**
693 Get the end of line mode (Unix, Macintosh or Dos) 694 Get the end of line mode (Unix, Macintosh or Dos)
694 */ 695 */
695 int getEol(); 696 int getEol();
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
index 6164fa5..aecc1bd 100644
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/noncore/apps/tinykate/tinykate.cpp
@@ -14,56 +14,58 @@
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include <qwidget.h> 17#include <qwidget.h>
18#include <qaction.h> 18#include <qaction.h>
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qpe/qpetoolbar.h> 20#include <qpe/qpetoolbar.h>
21#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
26#include <opie/ofiledialog.h> 26#include <opie/ofiledialog.h>
27 27
28#include "tinykate.h" 28#include "tinykate.h"
29#include "pics/file-new.xpm" 29#include "pics/file-new.xpm"
30#include "pics/file-open.xpm" 30#include "pics/file-open.xpm"
31#include "pics/file-save.xpm" 31#include "pics/file-save.xpm"
32#include "pics/edit-undo.xpm" 32#include "pics/edit-undo.xpm"
33#include "pics/edit-redo.xpm" 33#include "pics/edit-redo.xpm"
34 34
35#include <katedocument.h> 35#include <katedocument.h>
36#include <katehighlight.h> 36#include <katehighlight.h>
37#include <kateview.h> 37#include <kateview.h>
38#include <kglobal.h>
38 39
39TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : 40TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
40 QMainWindow( parent, name, f ) 41 QMainWindow( parent, name, f )
41{ 42{
42 nextUnnamed=0; 43 nextUnnamed=0;
43 currentView=0; 44 currentView=0;
44 viewCount=0; 45 viewCount=0;
45 setCaption(tr("TinyKATE")); 46 setCaption(tr("TinyKATE"));
47 KGlobal::setAppName("TinyKATE");
46 48
47 setToolBarsMovable(FALSE); 49 setToolBarsMovable(FALSE);
48 50
49 QPEToolBar *bar = new QPEToolBar( this ); 51 QPEToolBar *bar = new QPEToolBar( this );
50 bar->setHorizontalStretchable( TRUE ); 52 bar->setHorizontalStretchable( TRUE );
51 QPEMenuBar *mb = new QPEMenuBar( bar ); 53 QPEMenuBar *mb = new QPEMenuBar( bar );
52 mb->setMargin( 0 ); 54 mb->setMargin( 0 );
53 55
54 tabwidget=new OTabWidget(this); 56 tabwidget=new OTabWidget(this);
55 setCentralWidget(tabwidget); 57 setCentralWidget(tabwidget);
56 connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *))); 58 connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *)));
57 59
58//FILE ACTIONS 60//FILE ACTIONS
59 QPopupMenu *popup = new QPopupMenu( this ); 61 QPopupMenu *popup = new QPopupMenu( this );
60 62
61 // Action for creating a new document 63 // Action for creating a new document
62 QAction *a = new QAction( tr( "New" ), QPixmap((const char**)file_new_xpm ), QString::null, 0, this, 0 ); 64 QAction *a = new QAction( tr( "New" ), QPixmap((const char**)file_new_xpm ), QString::null, 0, this, 0 );
63 a->addTo( popup ); 65 a->addTo( popup );
64 connect(a, SIGNAL(activated()), this, SLOT(slotNew())); 66 connect(a, SIGNAL(activated()), this, SLOT(slotNew()));
65 67
66 // Action for opening an exisiting document 68 // Action for opening an exisiting document
67 a = new QAction( tr( "Open" ), QPixmap((const char**)file_open_xpm), QString::null, 0, this, 0 ); 69 a = new QAction( tr( "Open" ), QPixmap((const char**)file_open_xpm), QString::null, 0, this, 0 );
68 a->addTo(popup); 70 a->addTo(popup);
69 connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); 71 connect(a, SIGNAL(activated()), this, SLOT(slotOpen()));
@@ -127,48 +129,56 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
127 129
128 130
129 131
130 popup = new QPopupMenu( this ); 132 popup = new QPopupMenu( this );
131 mb->insertItem(tr("Utils"),popup); 133 mb->insertItem(tr("Utils"),popup);
132 134
133//Highlight management 135//Highlight management
134 hlmenu=new QPopupMenu(this); 136 hlmenu=new QPopupMenu(this);
135 HlManager *hlm=HlManager::self(); 137 HlManager *hlm=HlManager::self();
136 for (int i=0;i<hlm->highlights();i++) 138 for (int i=0;i<hlm->highlights();i++)
137 { 139 {
138 hlmenu->insertItem(hlm->hlName(i),i); 140 hlmenu->insertItem(hlm->hlName(i),i);
139 } 141 }
140 popup->insertItem(tr("Highlighting"),hlmenu); 142 popup->insertItem(tr("Highlighting"),hlmenu);
141 143
142 144
143 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); 145 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
144 utilSettings->addTo( popup); 146 utilSettings->addTo( popup);
145 147
146 if( qApp->argc() > 1) open(qApp->argv()[1]); 148 if( qApp->argc() > 1) open(qApp->argv()[1]);
147 else slotNew(); 149 else slotNew();
148 150
149} 151}
150 152
153TinyKate::~TinyKate( )
154{
155 qWarning("TinyKate destructor\n");
156 if( KGlobal::config() != 0 ) {
157 qWarning("deleting KateConfig object..\n");
158 delete KGlobal::config();
159 }
160}
151 161
152void TinyKate::slotOpen( ) 162void TinyKate::slotOpen( )
153{ 163{
154 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 164 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
155 QPEApplication::documentDir()); 165 QPEApplication::documentDir());
156 if (!filename.isEmpty()) { 166 if (!filename.isEmpty()) {
157 open(filename); 167 open(filename);
158 } 168 }
159} 169}
160 170
161void TinyKate::open(const QString & filename) 171void TinyKate::open(const QString & filename)
162{ 172{
163 KateDocument *kd= new KateDocument(false, false, this,0,this); 173 KateDocument *kd= new KateDocument(false, false, this,0,this);
164 KTextEditor::View *kv; 174 KTextEditor::View *kv;
165 QFileInfo fi(filename); 175 QFileInfo fi(filename);
166 QString filenamed = fi.fileName(); 176 QString filenamed = fi.fileName();
167 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); 177 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
168 qDebug(filename); 178 qDebug(filename);
169 179
170 kd->setDocName( filenamed); 180 kd->setDocName( filenamed);
171 kd->open( filename ); 181 kd->open( filename );
172 viewCount++; 182 viewCount++;
173} 183}
174 184
diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h
index 7b61bae..bb32f98 100644
--- a/noncore/apps/tinykate/tinykate.h
+++ b/noncore/apps/tinykate/tinykate.h
@@ -10,58 +10,59 @@
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. * 13 * the Free Software Foundation. *
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef __TINYKATE_H__ 18#ifndef __TINYKATE_H__
19#define __TINYKATE_H__ 19#define __TINYKATE_H__
20 20
21 21
22#include <qmainwindow.h> 22#include <qmainwindow.h>
23#include <opie/otabwidget.h> 23#include <opie/otabwidget.h>
24#include <ktexteditor.h> 24#include <ktexteditor.h>
25 25
26class QAction; 26class QAction;
27class QPopupMenu; 27class QPopupMenu;
28 28
29class TinyKate : public QMainWindow 29class TinyKate : public QMainWindow
30{ 30{
31Q_OBJECT 31Q_OBJECT
32public: 32public:
33 TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); 33 TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0);
34 ~TinyKate( );
34 35
35public slots: 36public slots:
36 QString currentFileName;
37 void slotNew(); 37 void slotNew();
38 38
39protected slots: 39protected slots:
40 void slotOpen(); 40 void slotOpen();
41 void slotClose(); 41 void slotClose();
42 void slotCurrentChanged(QWidget *); 42 void slotCurrentChanged(QWidget *);
43 void slotSave(); 43 void slotSave();
44 void slotSaveAs(); 44 void slotSaveAs();
45protected: 45protected:
46 void open(const QString&); 46 void open(const QString&);
47private: 47private:
48 QString currentFileName;
48 OTabWidget *tabwidget; 49 OTabWidget *tabwidget;
49 KTextEditor::View *currentView; 50 KTextEditor::View *currentView;
50 51
51 QAction *editCopy; 52 QAction *editCopy;
52 QAction *editCut; 53 QAction *editCut;
53 QAction *editPaste; 54 QAction *editPaste;
54 QAction *editUndo; 55 QAction *editUndo;
55 QAction *editRedo; 56 QAction *editRedo;
56 QAction *editFindReplace; 57 QAction *editFindReplace;
57 QAction *viewIncFontSizes; 58 QAction *viewIncFontSizes;
58 QAction *viewDecFontSizes; 59 QAction *viewDecFontSizes;
59 QAction *utilSettings; 60 QAction *utilSettings;
60 61
61 QPopupMenu *hlmenu; 62 QPopupMenu *hlmenu;
62 uint nextUnnamed; 63 uint nextUnnamed;
63 uint viewCount; 64 uint viewCount;
64}; 65};
65 66
66 67
67#endif // __TINYKATE_H__ 68#endif // __TINYKATE_H__
diff --git a/noncore/apps/tinykate/tinykate.pro b/noncore/apps/tinykate/tinykate.pro
index 61b60a6..632bd49 100644
--- a/noncore/apps/tinykate/tinykate.pro
+++ b/noncore/apps/tinykate/tinykate.pro
@@ -1,20 +1,22 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = tinykate.h 4 HEADERS = tinykate.h
5 SOURCES = tinykate.cpp main.cpp 5 SOURCES = tinykate.cpp main.cpp
6 INTERFACES= 6 INTERFACES=
7 INCLUDEPATH+= $(OPIEDIR)/include $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ 7 INCLUDEPATH+= $(OPIEDIR)/include \
8 $(OPIEDIR)/noncore/apps/tinykate/libkate \
9 $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \
8 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ 10 $(OPIEDIR)/noncore/apps/tinykate/libkate/document \
9 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ 11 $(OPIEDIR)/noncore/apps/tinykate/libkate/view \
10 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ 12 $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \
11 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ 13 $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \
12 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back 14 $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back
13 15
14 DEPENDPATH+= $(OPIEDIR)/include 16 DEPENDPATH+= $(OPIEDIR)/include
15LIBS += -lqpe -ltinykate -lopie 17LIBS += -lqpe -ltinykate -lopie
16 TARGET = tinykate 18 TARGET = tinykate
17 19
18 20
19 21
20include ( $(OPIEDIR)/include.pro ) 22include ( $(OPIEDIR)/include.pro )