00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "kateconfig.h"
00020
00021 #include "katefactory.h"
00022 #include "katerenderer.h"
00023 #include "kateview.h"
00024 #include "katedocument.h"
00025 #include "katefont.h"
00026 #include "kateschema.h"
00027
00028 #include <math.h>
00029
00030 #include <kapplication.h>
00031 #include <kconfig.h>
00032 #include <kglobalsettings.h>
00033 #include <kcharsets.h>
00034 #include <klocale.h>
00035 #include <kfinddialog.h>
00036 #include <kreplacedialog.h>
00037 #include <kinstance.h>
00038 #include <kstaticdeleter.h>
00039
00040 #include <qpopupmenu.h>
00041 #include <qtextcodec.h>
00042
00043 #include <kdebug.h>
00044
00045
00046 KateConfig::KateConfig ()
00047 : configSessionNumber (0), configIsRunning (false)
00048 {
00049 }
00050
00051 KateConfig::~KateConfig ()
00052 {
00053 }
00054
00055 void KateConfig::configStart ()
00056 {
00057 configSessionNumber++;
00058
00059 if (configSessionNumber > 1)
00060 return;
00061
00062 configIsRunning = true;
00063 }
00064
00065 void KateConfig::configEnd ()
00066 {
00067 if (configSessionNumber == 0)
00068 return;
00069
00070 configSessionNumber--;
00071
00072 if (configSessionNumber > 0)
00073 return;
00074
00075 configIsRunning = false;
00076
00077 updateConfig ();
00078 }
00079
00080
00081
00082 KateDocumentConfig *KateDocumentConfig::s_global = 0;
00083 KateViewConfig *KateViewConfig::s_global = 0;
00084 KateRendererConfig *KateRendererConfig::s_global = 0;
00085
00086 KateDocumentConfig::KateDocumentConfig ()
00087 : m_tabWidth (8),
00088 m_indentationWidth (2),
00089 m_wordWrapAt (80),
00090 m_configFlags (0),
00091 m_plugins (KateFactory::self()->plugins().count()),
00092 m_tabWidthSet (true),
00093 m_indentationWidthSet (true),
00094 m_indentationModeSet (true),
00095 m_wordWrapSet (true),
00096 m_wordWrapAtSet (true),
00097 m_pageUpDownMovesCursorSet (true),
00098 m_undoStepsSet (true),
00099 m_configFlagsSet (0xFFFF),
00100 m_encodingSet (true),
00101 m_eolSet (true),
00102 m_allowEolDetectionSet (true),
00103 m_backupFlagsSet (true),
00104 m_searchDirConfigDepthSet (true),
00105 m_backupPrefixSet (true),
00106 m_backupSuffixSet (true),
00107 m_pluginsSet (m_plugins.size()),
00108 m_doc (0)
00109 {
00110 s_global = this;
00111
00112
00113 m_plugins.fill (false);
00114 m_pluginsSet.fill (true);
00115
00116
00117 KConfig *config = kapp->config();
00118 config->setGroup("Kate Document Defaults");
00119 readConfig (config);
00120 }
00121
00122 KateDocumentConfig::KateDocumentConfig (KateDocument *doc)
00123 : m_configFlags (0),
00124 m_plugins (KateFactory::self()->plugins().count()),
00125 m_tabWidthSet (false),
00126 m_indentationWidthSet (false),
00127 m_indentationModeSet (false),
00128 m_wordWrapSet (false),
00129 m_wordWrapAtSet (false),
00130 m_pageUpDownMovesCursorSet (false),
00131 m_undoStepsSet (false),
00132 m_configFlagsSet (0),
00133 m_encodingSet (false),
00134 m_eolSet (false),
00135 m_allowEolDetectionSet (false),
00136 m_backupFlagsSet (false),
00137 m_searchDirConfigDepthSet (false),
00138 m_backupPrefixSet (false),
00139 m_backupSuffixSet (false),
00140 m_pluginsSet (m_plugins.size()),
00141 m_doc (doc)
00142 {
00143
00144 m_plugins.fill (false);
00145 m_pluginsSet.fill (false);
00146 }
00147
00148 KateDocumentConfig::~KateDocumentConfig ()
00149 {
00150 }
00151
00152 void KateDocumentConfig::readConfig (KConfig *config)
00153 {
00154 configStart ();
00155
00156 setTabWidth (config->readNumEntry("Tab Width", 8));
00157
00158 setIndentationWidth (config->readNumEntry("Indentation Width", 2));
00159
00160 setIndentationMode (config->readNumEntry("Indentation Mode", KateDocumentConfig::imNone));
00161
00162 setWordWrap (config->readBoolEntry("Word Wrap", false));
00163 setWordWrapAt (config->readNumEntry("Word Wrap Column", 80));
00164 setPageUpDownMovesCursor (config->readBoolEntry("PageUp/PageDown Moves Cursor", false));
00165 setUndoSteps(config->readNumEntry("Undo Steps", 0));
00166
00167 setConfigFlags (config->readNumEntry("Basic Config Flags", KateDocumentConfig::cfTabIndents
00168 | KateDocumentConfig::cfKeepIndentProfile
00169 | KateDocumentConfig::cfWrapCursor
00170 | KateDocumentConfig::cfShowTabs
00171 | KateDocumentConfig::cfSmartHome
00172 | KateDocumentConfig::cfIndentPastedText));
00173
00174 setEncoding (config->readEntry("Encoding", ""));
00175
00176 setEol (config->readNumEntry("End of Line", 0));
00177 setAllowEolDetection (config->readBoolEntry("Allow End of Line Detection", true));
00178
00179 setBackupFlags (config->readNumEntry("Backup Config Flags", 1));
00180
00181 setSearchDirConfigDepth (config->readNumEntry("Search Dir Config Depth", 3));
00182
00183 setBackupPrefix (config->readEntry("Backup Prefix", QString ("")));
00184
00185 setBackupSuffix (config->readEntry("Backup Suffix", QString ("~")));
00186
00187
00188 for (uint i=0; i<KateFactory::self()->plugins().count(); i++)
00189 setPlugin (i, config->readBoolEntry("KTextEditor Plugin " + (KateFactory::self()->plugins())[i]->library(), false));
00190
00191 configEnd ();
00192 }
00193
00194 void KateDocumentConfig::writeConfig (KConfig *config)
00195 {
00196 config->writeEntry("Tab Width", tabWidth());
00197
00198 config->writeEntry("Indentation Width", indentationWidth());
00199 config->writeEntry("Indentation Mode", indentationMode());
00200
00201 config->writeEntry("Word Wrap", wordWrap());
00202 config->writeEntry("Word Wrap Column", wordWrapAt());
00203
00204 config->writeEntry("PageUp/PageDown Moves Cursor", pageUpDownMovesCursor());
00205
00206 config->writeEntry("Undo Steps", undoSteps());
00207
00208 config->writeEntry("Basic Config Flags", configFlags());
00209
00210 config->writeEntry("Encoding", encoding());
00211
00212 config->writeEntry("End of Line", eol());
00213 config->writeEntry("Allow End of Line Detection", allowEolDetection());
00214
00215 config->writeEntry("Backup Config Flags", backupFlags());
00216
00217 config->writeEntry("Search Dir Config Depth", searchDirConfigDepth());
00218
00219 config->writeEntry("Backup Prefix", backupPrefix());
00220
00221 config->writeEntry("Backup Suffix", backupSuffix());
00222
00223
00224 for (uint i=0; i<KateFactory::self()->plugins().count(); i++)
00225 config->writeEntry("KTextEditor Plugin " + (KateFactory::self()->plugins())[i]->library(), plugin(i));
00226 }
00227
00228 void KateDocumentConfig::updateConfig ()
00229 {
00230 if (m_doc)
00231 {
00232 m_doc->updateConfig ();
00233 return;
00234 }
00235
00236 if (isGlobal())
00237 {
00238 for (uint z=0; z < KateFactory::self()->documents()->count(); z++)
00239 {
00240 KateFactory::self()->documents()->at(z)->updateConfig ();
00241 }
00242 }
00243 }
00244
00245 int KateDocumentConfig::tabWidth () const
00246 {
00247 if (m_tabWidthSet || isGlobal())
00248 return m_tabWidth;
00249
00250 return s_global->tabWidth();
00251 }
00252
00253 void KateDocumentConfig::setTabWidth (int tabWidth)
00254 {
00255 if (tabWidth < 1)
00256 return;
00257
00258 configStart ();
00259
00260 m_tabWidthSet = true;
00261 m_tabWidth = tabWidth;
00262
00263 configEnd ();
00264 }
00265
00266 int KateDocumentConfig::indentationWidth () const
00267 {
00268 if (m_indentationWidthSet || isGlobal())
00269 return m_indentationWidth;
00270
00271 return s_global->indentationWidth();
00272 }
00273
00274 void KateDocumentConfig::setIndentationWidth (int indentationWidth)
00275 {
00276 if (indentationWidth < 1)
00277 return;
00278
00279 configStart ();
00280
00281 m_indentationWidthSet = true;
00282 m_indentationWidth = indentationWidth;
00283
00284 configEnd ();
00285 }
00286
00287 uint KateDocumentConfig::indentationMode () const
00288 {
00289 if (m_indentationModeSet || isGlobal())
00290 return m_indentationMode;
00291
00292 return s_global->indentationMode();
00293 }
00294
00295 void KateDocumentConfig::setIndentationMode (uint indentationMode)
00296 {
00297 configStart ();
00298
00299 m_indentationModeSet = true;
00300 m_indentationMode = indentationMode;
00301
00302 configEnd ();
00303 }
00304
00305 bool KateDocumentConfig::wordWrap () const
00306 {
00307 if (m_wordWrapSet || isGlobal())
00308 return m_wordWrap;
00309
00310 return s_global->wordWrap();
00311 }
00312
00313 void KateDocumentConfig::setWordWrap (bool on)
00314 {
00315 configStart ();
00316
00317 m_wordWrapSet = true;
00318 m_wordWrap = on;
00319
00320 configEnd ();
00321 }
00322
00323 unsigned int KateDocumentConfig::wordWrapAt () const
00324 {
00325 if (m_wordWrapAtSet || isGlobal())
00326 return m_wordWrapAt;
00327
00328 return s_global->wordWrapAt();
00329 }
00330
00331 void KateDocumentConfig::setWordWrapAt (unsigned int col)
00332 {
00333 if (col < 1)
00334 return;
00335
00336 configStart ();
00337
00338 m_wordWrapAtSet = true;
00339 m_wordWrapAt = col;
00340
00341 configEnd ();
00342 }
00343
00344 uint KateDocumentConfig::undoSteps () const
00345 {
00346 if (m_undoStepsSet || isGlobal())
00347 return m_undoSteps;
00348
00349 return s_global->undoSteps();
00350 }
00351
00352 void KateDocumentConfig::setUndoSteps (uint undoSteps)
00353 {
00354 configStart ();
00355
00356 m_undoStepsSet = true;
00357 m_undoSteps = undoSteps;
00358
00359 configEnd ();
00360 }
00361
00362 bool KateDocumentConfig::pageUpDownMovesCursor () const
00363 {
00364 if (m_pageUpDownMovesCursorSet || isGlobal())
00365 return m_pageUpDownMovesCursor;
00366
00367 return s_global->pageUpDownMovesCursor();
00368 }
00369
00370 void KateDocumentConfig::setPageUpDownMovesCursor (bool on)
00371 {
00372 configStart ();
00373
00374 m_pageUpDownMovesCursorSet = true;
00375 m_pageUpDownMovesCursor = on;
00376
00377 configEnd ();
00378 }
00379
00380 uint KateDocumentConfig::configFlags () const
00381 {
00382 if (isGlobal())
00383 return m_configFlags;
00384
00385 return ((s_global->configFlags() & ~ m_configFlagsSet) | m_configFlags);
00386 }
00387
00388 void KateDocumentConfig::setConfigFlags (KateDocumentConfig::ConfigFlags flag, bool enable)
00389 {
00390 configStart ();
00391
00392 m_configFlagsSet |= flag;
00393
00394 if (enable)
00395 m_configFlags = m_configFlags | flag;
00396 else
00397 m_configFlags = m_configFlags & ~ flag;
00398
00399 configEnd ();
00400 }
00401
00402 void KateDocumentConfig::setConfigFlags (uint fullFlags)
00403 {
00404 configStart ();
00405
00406 m_configFlagsSet = 0xFFFF;
00407 m_configFlags = fullFlags;
00408
00409 configEnd ();
00410 }
00411
00412 const QString &KateDocumentConfig::encoding () const
00413 {
00414 if (m_encodingSet || isGlobal())
00415 return m_encoding;
00416
00417 return s_global->encoding();
00418 }
00419
00420 QTextCodec *KateDocumentConfig::codec ()
00421 {
00422 if (m_encodingSet || isGlobal())
00423 {
00424 if (m_encoding.isEmpty() && isGlobal())
00425 return KGlobal::charsets()->codecForName (QString::fromLatin1(KGlobal::locale()->encoding()));
00426 else if (m_encoding.isEmpty())
00427 return s_global->codec ();
00428 else
00429 return KGlobal::charsets()->codecForName (m_encoding);
00430 }
00431
00432 return s_global->codec ();
00433 }
00434
00435 void KateDocumentConfig::setEncoding (const QString &encoding)
00436 {
00437 QString enc = encoding;
00438
00439 if (!enc.isEmpty())
00440 {
00441 bool found = false;
00442 QTextCodec *codec = KGlobal::charsets()->codecForName (encoding, found);
00443
00444 if (!found || !codec)
00445 return;
00446
00447 enc = codec->name();
00448 }
00449
00450 configStart ();
00451
00452 if (isGlobal())
00453 KateDocument::setDefaultEncoding (enc);
00454
00455 m_encodingSet = true;
00456 m_encoding = enc;
00457
00458 configEnd ();
00459 }
00460
00461 bool KateDocumentConfig::isSetEncoding () const
00462 {
00463 return m_encodingSet;
00464 }
00465
00466 int KateDocumentConfig::eol () const
00467 {
00468 if (m_eolSet || isGlobal())
00469 return m_eol;
00470
00471 return s_global->eol();
00472 }
00473
00474 QString KateDocumentConfig::eolString ()
00475 {
00476 if (eol() == KateDocumentConfig::eolUnix)
00477 return QString ("\n");
00478 else if (eol() == KateDocumentConfig::eolDos)
00479 return QString ("\r\n");
00480 else if (eol() == KateDocumentConfig::eolMac)
00481 return QString ("\r");
00482
00483 return QString ("\n");
00484 }
00485
00486 void KateDocumentConfig::setEol (int mode)
00487 {
00488 configStart ();
00489
00490 m_eolSet = true;
00491 m_eol = mode;
00492
00493 configEnd ();
00494 }
00495
00496 bool KateDocumentConfig::allowEolDetection () const
00497 {
00498 if (m_allowEolDetectionSet || isGlobal())
00499 return m_allowEolDetection;
00500
00501 return s_global->allowEolDetection();
00502 }
00503
00504 void KateDocumentConfig::setAllowEolDetection (bool on)
00505 {
00506 configStart ();
00507
00508 m_allowEolDetectionSet = true;
00509 m_allowEolDetection = on;
00510
00511 configEnd ();
00512 }
00513
00514 uint KateDocumentConfig::backupFlags () const
00515 {
00516 if (m_backupFlagsSet || isGlobal())
00517 return m_backupFlags;
00518
00519 return s_global->backupFlags();
00520 }
00521
00522 void KateDocumentConfig::setBackupFlags (uint flags)
00523 {
00524 configStart ();
00525
00526 m_backupFlagsSet = true;
00527 m_backupFlags = flags;
00528
00529 configEnd ();
00530 }
00531
00532 const QString &KateDocumentConfig::backupPrefix () const
00533 {
00534 if (m_backupPrefixSet || isGlobal())
00535 return m_backupPrefix;
00536
00537 return s_global->backupPrefix();
00538 }
00539
00540 const QString &KateDocumentConfig::backupSuffix () const
00541 {
00542 if (m_backupSuffixSet || isGlobal())
00543 return m_backupSuffix;
00544
00545 return s_global->backupSuffix();
00546 }
00547
00548 void KateDocumentConfig::setBackupPrefix (const QString &prefix)
00549 {
00550 configStart ();
00551
00552 m_backupPrefixSet = true;
00553 m_backupPrefix = prefix;
00554
00555 configEnd ();
00556 }
00557
00558 void KateDocumentConfig::setBackupSuffix (const QString &suffix)
00559 {
00560 configStart ();
00561
00562 m_backupSuffixSet = true;
00563 m_backupSuffix = suffix;
00564
00565 configEnd ();
00566 }
00567
00568 bool KateDocumentConfig::plugin (uint index) const
00569 {
00570 if (index >= m_plugins.size())
00571 return false;
00572
00573 if (m_pluginsSet.at(index) || isGlobal())
00574 return m_plugins.at(index);
00575
00576 return s_global->plugin (index);
00577 }
00578
00579 void KateDocumentConfig::setPlugin (uint index, bool load)
00580 {
00581 if (index >= m_plugins.size())
00582 return;
00583
00584 configStart ();
00585
00586 m_pluginsSet.setBit(index);
00587 m_plugins.setBit(index, load);
00588
00589 configEnd ();
00590 }
00591
00592 int KateDocumentConfig::searchDirConfigDepth () const
00593 {
00594 if (m_searchDirConfigDepthSet || isGlobal())
00595 return m_searchDirConfigDepth;
00596
00597 return s_global->searchDirConfigDepth ();
00598 }
00599
00600 void KateDocumentConfig::setSearchDirConfigDepth (int depth)
00601 {
00602 configStart ();
00603
00604 m_searchDirConfigDepthSet = true;
00605 m_searchDirConfigDepth = depth;
00606
00607 configEnd ();
00608 }
00609
00610
00611
00612
00613 KateViewConfig::KateViewConfig ()
00614 :
00615 m_dynWordWrapSet (true),
00616 m_dynWordWrapIndicatorsSet (true),
00617 m_dynWordWrapAlignIndentSet (true),
00618 m_lineNumbersSet (true),
00619 m_scrollBarMarksSet (true),
00620 m_iconBarSet (true),
00621 m_foldingBarSet (true),
00622 m_bookmarkSortSet (true),
00623 m_autoCenterLinesSet (true),
00624 m_searchFlagsSet (true),
00625 m_cmdLineSet (true),
00626 m_defaultMarkTypeSet (true),
00627 m_persistentSelectionSet (true),
00628 m_textToSearchModeSet (true),
00629 m_view (0)
00630 {
00631 s_global = this;
00632
00633
00634 KConfig *config = kapp->config();
00635 config->setGroup("Kate View Defaults");
00636 readConfig (config);
00637 }
00638
00639 KateViewConfig::KateViewConfig (KateView *view)
00640 :
00641 m_dynWordWrapSet (false),
00642 m_dynWordWrapIndicatorsSet (false),
00643 m_dynWordWrapAlignIndentSet (false),
00644 m_lineNumbersSet (false),
00645 m_scrollBarMarksSet (false),
00646 m_iconBarSet (false),
00647 m_foldingBarSet (false),
00648 m_bookmarkSortSet (false),
00649 m_autoCenterLinesSet (false),
00650 m_searchFlagsSet (false),
00651 m_cmdLineSet (false),
00652 m_defaultMarkTypeSet (false),
00653 m_persistentSelectionSet (false),
00654 m_textToSearchModeSet (false),
00655 m_view (view)
00656 {
00657 }
00658
00659 KateViewConfig::~KateViewConfig ()
00660 {
00661 }
00662
00663 void KateViewConfig::readConfig (KConfig *config)
00664 {
00665 configStart ();
00666
00667 setDynWordWrap (config->readBoolEntry( "Dynamic Word Wrap", true ));
00668 setDynWordWrapIndicators (config->readNumEntry( "Dynamic Word Wrap Indicators", 1 ));
00669 setDynWordWrapAlignIndent (config->readNumEntry( "Dynamic Word Wrap Align Indent", 80 ));
00670
00671 setLineNumbers (config->readBoolEntry( "Line Numbers", false));
00672
00673 setScrollBarMarks (config->readBoolEntry( "Scroll Bar Marks", false));
00674
00675 setIconBar (config->readBoolEntry( "Icon Bar", false ));
00676
00677 setFoldingBar (config->readBoolEntry( "Folding Bar", true));
00678
00679 setBookmarkSort (config->readNumEntry( "Bookmark Menu Sorting", 0 ));
00680
00681 setAutoCenterLines (config->readNumEntry( "Auto Center Lines", 0 ));
00682
00683 setSearchFlags (config->readNumEntry("Search Config Flags", KFindDialog::FromCursor | KFindDialog::CaseSensitive | KReplaceDialog::PromptOnReplace));
00684
00685 setCmdLine (config->readBoolEntry( "Command Line", false));
00686
00687 setDefaultMarkType (config->readNumEntry( "Default Mark Type", KTextEditor::MarkInterface::markType01 ));
00688
00689 setPersistentSelection (config->readNumEntry( "Persistent Selection", false ));
00690
00691 setTextToSearchMode (config->readNumEntry( "Text To Search Mode", KateViewConfig::SelectionWord));
00692
00693 configEnd ();
00694 }
00695
00696 void KateViewConfig::writeConfig (KConfig *config)
00697 {
00698 config->writeEntry( "Dynamic Word Wrap", dynWordWrap() );
00699 config->writeEntry( "Dynamic Word Wrap Indicators", dynWordWrapIndicators() );
00700 config->writeEntry( "Dynamic Word Wrap Align Indent", dynWordWrapAlignIndent() );
00701
00702 config->writeEntry( "Line Numbers", lineNumbers() );
00703
00704 config->writeEntry( "Scroll Bar Marks", scrollBarMarks() );
00705
00706 config->writeEntry( "Icon Bar", iconBar() );
00707
00708 config->writeEntry( "Folding Bar", foldingBar() );
00709
00710 config->writeEntry( "Bookmark Menu Sorting", bookmarkSort() );
00711
00712 config->writeEntry( "Auto Center Lines", autoCenterLines() );
00713
00714 config->writeEntry("Search Config Flags", searchFlags());
00715
00716 config->writeEntry("Command Line", cmdLine());
00717
00718 config->writeEntry("Default Mark Type", defaultMarkType());
00719
00720 config->writeEntry("Persistent Selection", persistentSelection());
00721
00722 config->writeEntry("Text To Search Mode", textToSearchMode());
00723 }
00724
00725 void KateViewConfig::updateConfig ()
00726 {
00727 if (m_view)
00728 {
00729 m_view->updateConfig ();
00730 return;
00731 }
00732
00733 if (isGlobal())
00734 {
00735 for (uint z=0; z < KateFactory::self()->views()->count(); z++)
00736 {
00737 KateFactory::self()->views()->at(z)->updateConfig ();
00738 }
00739 }
00740 }
00741
00742 bool KateViewConfig::dynWordWrap () const
00743 {
00744 if (m_dynWordWrapSet || isGlobal())
00745 return m_dynWordWrap;
00746
00747 return s_global->dynWordWrap();
00748 }
00749
00750 void KateViewConfig::setDynWordWrap (bool wrap)
00751 {
00752 configStart ();
00753
00754 m_dynWordWrapSet = true;
00755 m_dynWordWrap = wrap;
00756
00757 configEnd ();
00758 }
00759
00760 int KateViewConfig::dynWordWrapIndicators () const
00761 {
00762 if (m_dynWordWrapIndicatorsSet || isGlobal())
00763 return m_dynWordWrapIndicators;
00764
00765 return s_global->dynWordWrapIndicators();
00766 }
00767
00768 void KateViewConfig::setDynWordWrapIndicators (int mode)
00769 {
00770 configStart ();
00771
00772 m_dynWordWrapIndicatorsSet = true;
00773 m_dynWordWrapIndicators = kMin(80, kMax(0, mode));
00774
00775 configEnd ();
00776 }
00777
00778 int KateViewConfig::dynWordWrapAlignIndent () const
00779 {
00780 if (m_dynWordWrapAlignIndentSet || isGlobal())
00781 return m_dynWordWrapAlignIndent;
00782
00783 return s_global->dynWordWrapAlignIndent();
00784 }
00785
00786 void KateViewConfig::setDynWordWrapAlignIndent (int indent)
00787 {
00788 configStart ();
00789
00790 m_dynWordWrapAlignIndentSet = true;
00791 m_dynWordWrapAlignIndent = indent;
00792
00793 configEnd ();
00794 }
00795
00796 bool KateViewConfig::lineNumbers () const
00797 {
00798 if (m_lineNumbersSet || isGlobal())
00799 return m_lineNumbers;
00800
00801 return s_global->lineNumbers();
00802 }
00803
00804 void KateViewConfig::setLineNumbers (bool on)
00805 {
00806 configStart ();
00807
00808 m_lineNumbersSet = true;
00809 m_lineNumbers = on;
00810
00811 configEnd ();
00812 }
00813
00814 bool KateViewConfig::scrollBarMarks () const
00815 {
00816 if (m_scrollBarMarksSet || isGlobal())
00817 return m_scrollBarMarks;
00818
00819 return s_global->scrollBarMarks();
00820 }
00821
00822 void KateViewConfig::setScrollBarMarks (bool on)
00823 {
00824 configStart ();
00825
00826 m_scrollBarMarksSet = true;
00827 m_scrollBarMarks = on;
00828
00829 configEnd ();
00830 }
00831
00832 bool KateViewConfig::iconBar () const
00833 {
00834 if (m_iconBarSet || isGlobal())
00835 return m_iconBar;
00836
00837 return s_global->iconBar();
00838 }
00839
00840 void KateViewConfig::setIconBar (bool on)
00841 {
00842 configStart ();
00843
00844 m_iconBarSet = true;
00845 m_iconBar = on;
00846
00847 configEnd ();
00848 }
00849
00850 bool KateViewConfig::foldingBar () const
00851 {
00852 if (m_foldingBarSet || isGlobal())
00853 return m_foldingBar;
00854
00855 return s_global->foldingBar();
00856 }
00857
00858 void KateViewConfig::setFoldingBar (bool on)
00859 {
00860 configStart ();
00861
00862 m_foldingBarSet = true;
00863 m_foldingBar = on;
00864
00865 configEnd ();
00866 }
00867
00868 int KateViewConfig::bookmarkSort () const
00869 {
00870 if (m_bookmarkSortSet || isGlobal())
00871 return m_bookmarkSort;
00872
00873 return s_global->bookmarkSort();
00874 }
00875
00876 void KateViewConfig::setBookmarkSort (int mode)
00877 {
00878 configStart ();
00879
00880 m_bookmarkSortSet = true;
00881 m_bookmarkSort = mode;
00882
00883 configEnd ();
00884 }
00885
00886 int KateViewConfig::autoCenterLines () const
00887 {
00888 if (m_autoCenterLinesSet || isGlobal())
00889 return m_autoCenterLines;
00890
00891 return s_global->autoCenterLines();
00892 }
00893
00894 void KateViewConfig::setAutoCenterLines (int lines)
00895 {
00896 if (lines < 0)
00897 return;
00898
00899 configStart ();
00900
00901 m_autoCenterLinesSet = true;
00902 m_autoCenterLines = lines;
00903
00904 configEnd ();
00905 }
00906
00907 long KateViewConfig::searchFlags () const
00908 {
00909 if (m_searchFlagsSet || isGlobal())
00910 return m_searchFlags;
00911
00912 return s_global->searchFlags();
00913 }
00914
00915 void KateViewConfig::setSearchFlags (long flags)
00916 {
00917 configStart ();
00918
00919 m_searchFlagsSet = true;
00920 m_searchFlags = flags;
00921
00922 configEnd ();
00923 }
00924
00925 bool KateViewConfig::cmdLine () const
00926 {
00927 if (m_cmdLineSet || isGlobal())
00928 return m_cmdLine;
00929
00930 return s_global->cmdLine();
00931 }
00932
00933 void KateViewConfig::setCmdLine (bool on)
00934 {
00935 configStart ();
00936
00937 m_cmdLineSet = true;
00938 m_cmdLine = on;
00939
00940 configEnd ();
00941 }
00942
00943 uint KateViewConfig::defaultMarkType () const
00944 {
00945 if (m_defaultMarkTypeSet || isGlobal())
00946 return m_defaultMarkType;
00947
00948 return s_global->defaultMarkType();
00949 }
00950
00951 void KateViewConfig::setDefaultMarkType (uint type)
00952 {
00953 configStart ();
00954
00955 m_defaultMarkTypeSet = true;
00956 m_defaultMarkType = type;
00957
00958 configEnd ();
00959 }
00960
00961 bool KateViewConfig::persistentSelection () const
00962 {
00963 if (m_persistentSelectionSet || isGlobal())
00964 return m_persistentSelection;
00965
00966 return s_global->persistentSelection();
00967 }
00968
00969 void KateViewConfig::setPersistentSelection (bool on)
00970 {
00971 configStart ();
00972
00973 m_persistentSelectionSet = true;
00974 m_persistentSelection = on;
00975
00976 configEnd ();
00977 }
00978
00979 int KateViewConfig::textToSearchMode () const
00980 {
00981 if (m_textToSearchModeSet || isGlobal())
00982 return m_textToSearchMode;
00983
00984 return s_global->textToSearchMode();
00985 }
00986
00987 void KateViewConfig::setTextToSearchMode (int mode)
00988 {
00989 configStart ();
00990
00991 m_textToSearchModeSet = true;
00992 m_textToSearchMode = mode;
00993
00994 configEnd ();
00995 }
00996
00997
00998
00999
01000 KateRendererConfig::KateRendererConfig ()
01001 :
01002 m_font (new KateFontStruct ()),
01003 m_lineMarkerColor (KTextEditor::MarkInterface::reservedMarkersCount()),
01004 m_schemaSet (true),
01005 m_fontSet (true),
01006 m_wordWrapMarkerSet (true),
01007 m_showIndentationLinesSet (true),
01008 m_backgroundColorSet (true),
01009 m_selectionColorSet (true),
01010 m_highlightedLineColorSet (true),
01011 m_highlightedBracketColorSet (true),
01012 m_wordWrapMarkerColorSet (true),
01013 m_tabMarkerColorSet(true),
01014 m_iconBarColorSet (true),
01015 m_lineNumberColorSet (true),
01016 m_lineMarkerColorSet (m_lineMarkerColor.size()),
01017 m_renderer (0)
01018 {
01019
01020 m_lineMarkerColorSet.fill (true);
01021
01022 s_global = this;
01023
01024
01025 KConfig *config = kapp->config();
01026 config->setGroup("Kate Renderer Defaults");
01027 readConfig (config);
01028 }
01029
01030 KateRendererConfig::KateRendererConfig (KateRenderer *renderer)
01031 : m_font (0),
01032 m_lineMarkerColor (KTextEditor::MarkInterface::reservedMarkersCount()),
01033 m_schemaSet (false),
01034 m_fontSet (false),
01035 m_wordWrapMarkerSet (false),
01036 m_showIndentationLinesSet (false),
01037 m_backgroundColorSet (false),
01038 m_selectionColorSet (false),
01039 m_highlightedLineColorSet (false),
01040 m_highlightedBracketColorSet (false),
01041 m_wordWrapMarkerColorSet (false),
01042 m_tabMarkerColorSet(false),
01043 m_iconBarColorSet (false),
01044 m_lineNumberColorSet (false),
01045 m_lineMarkerColorSet (m_lineMarkerColor.size()),
01046 m_renderer (renderer)
01047 {
01048
01049 m_lineMarkerColorSet.fill (false);
01050 }
01051
01052 KateRendererConfig::~KateRendererConfig ()
01053 {
01054 delete m_font;
01055 }
01056
01057 void KateRendererConfig::readConfig (KConfig *config)
01058 {
01059 configStart ();
01060
01061 setSchema (KateFactory::self()->schemaManager()->number (config->readEntry("Schema", KateSchemaManager::normalSchema())));
01062
01063 setWordWrapMarker (config->readBoolEntry("Word Wrap Marker", false ));
01064
01065 setShowIndentationLines (config->readBoolEntry( "Show Indentation Lines", false));
01066
01067 configEnd ();
01068 }
01069
01070 void KateRendererConfig::writeConfig (KConfig *config)
01071 {
01072 config->writeEntry ("Schema", KateFactory::self()->schemaManager()->name(schema()));
01073
01074 config->writeEntry("Word Wrap Marker", wordWrapMarker() );
01075
01076 config->writeEntry("Show Indentation Lines", showIndentationLines());
01077 }
01078
01079 void KateRendererConfig::updateConfig ()
01080 {
01081 if (m_renderer)
01082 {
01083 m_renderer->updateConfig ();
01084 return;
01085 }
01086
01087 if (isGlobal())
01088 {
01089 for (uint z=0; z < KateFactory::self()->renderers()->count(); z++)
01090 {
01091 KateFactory::self()->renderers()->at(z)->updateConfig ();
01092 }
01093 }
01094 }
01095
01096 uint KateRendererConfig::schema () const
01097 {
01098 if (m_schemaSet || isGlobal())
01099 return m_schema;
01100
01101 return s_global->schema();
01102 }
01103
01104 void KateRendererConfig::setSchema (uint schema)
01105 {
01106 configStart ();
01107 m_schemaSet = true;
01108 m_schema = schema;
01109 setSchemaInternal( schema );
01110 configEnd ();
01111 }
01112
01113 void KateRendererConfig::reloadSchema()
01114 {
01115 if ( isGlobal() )
01116 for ( uint z=0; z < KateFactory::self()->renderers()->count(); z++ )
01117 KateFactory::self()->renderers()->at(z)->config()->reloadSchema();
01118
01119 else if ( m_renderer && m_schemaSet )
01120 setSchemaInternal( m_schema );
01121 }
01122
01123 void KateRendererConfig::setSchemaInternal( int schema )
01124 {
01125 m_schemaSet = true;
01126 m_schema = schema;
01127
01128 KConfig *config (KateFactory::self()->schemaManager()->schema(schema));
01129
01130 QColor tmp0 (KGlobalSettings::baseColor());
01131 QColor tmp1 (KGlobalSettings::highlightColor());
01132 QColor tmp2 (KGlobalSettings::alternateBackgroundColor());
01133 QColor tmp3 ( "#FFFF99" );
01134 QColor tmp4 (tmp2.dark());
01135 QColor tmp5 ( KGlobalSettings::textColor() );
01136 QColor tmp6 ( "#EAE9E8" );
01137 QColor tmp7 ( "#000000" );
01138
01139 m_backgroundColor = config->readColorEntry("Color Background", &tmp0);
01140 m_backgroundColorSet = true;
01141 m_selectionColor = config->readColorEntry("Color Selection", &tmp1);
01142 m_selectionColorSet = true;
01143 m_highlightedLineColor = config->