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