19 #include "kateconfig.h"
21 #include "katefactory.h"
22 #include "katerenderer.h"
24 #include "katedocument.h"
26 #include "kateschema.h"
30 #include <tdeapplication.h>
31 #include <tdeconfig.h>
32 #include <tdeglobalsettings.h>
33 #include <kcharsets.h>
35 #include <kfinddialog.h>
36 #include <kreplacedialog.h>
37 #include <kinstance.h>
38 #include <kstaticdeleter.h>
40 #include <tqpopupmenu.h>
41 #include <tqtextcodec.h>
47 : configSessionNumber (0), configIsRunning (false)
57 configSessionNumber++;
59 if (configSessionNumber > 1)
62 configIsRunning =
true;
67 if (configSessionNumber == 0)
70 configSessionNumber--;
72 if (configSessionNumber > 0)
75 configIsRunning =
false;
82 KateDocumentConfig *KateDocumentConfig::s_global = 0;
83 KateViewConfig *KateViewConfig::s_global = 0;
84 KateRendererConfig *KateRendererConfig::s_global = 0;
86 KateDocumentConfig::KateDocumentConfig ()
88 m_indentationWidth (2),
91 m_plugins (KateFactory::self()->plugins().count()),
93 m_indentationWidthSet (true),
94 m_indentationModeSet (true),
96 m_wordWrapAtSet (true),
97 m_pageUpDownMovesCursorSet (true),
98 m_undoStepsSet (true),
99 m_configFlagsSet (0xFFFF),
100 m_encodingSet (true),
102 m_allowEolDetectionSet (true),
103 m_backupFlagsSet (true),
104 m_searchDirConfigDepthSet (true),
105 m_backupPrefixSet (true),
106 m_backupSuffixSet (true),
107 m_pluginsSet (m_plugins.size()),
113 m_plugins.fill (
false);
114 m_pluginsSet.fill (
true);
118 config->setGroup(
"Kate Document Defaults");
122 KateDocumentConfig::KateDocumentConfig (KateDocument *doc)
124 m_plugins (KateFactory::self()->plugins().count()),
125 m_tabWidthSet (false),
126 m_indentationWidthSet (false),
127 m_indentationModeSet (false),
128 m_wordWrapSet (false),
129 m_wordWrapAtSet (false),
130 m_pageUpDownMovesCursorSet (false),
131 m_undoStepsSet (false),
132 m_configFlagsSet (0),
133 m_encodingSet (false),
135 m_allowEolDetectionSet (false),
136 m_backupFlagsSet (false),
137 m_searchDirConfigDepthSet (false),
138 m_backupPrefixSet (false),
139 m_backupSuffixSet (false),
140 m_pluginsSet (m_plugins.size()),
144 m_plugins.fill (
false);
145 m_pluginsSet.fill (
false);
148 KateDocumentConfig::~KateDocumentConfig ()
152 void KateDocumentConfig::readConfig (
TDEConfig *config)
156 setTabWidth (config->readNumEntry(
"Tab Width", 8));
158 setIndentationWidth (config->readNumEntry(
"Indentation Width", 2));
160 setIndentationMode (config->readNumEntry(
"Indentation Mode", KateDocumentConfig::imNone));
162 setWordWrap (config->readBoolEntry(
"Word Wrap",
false));
163 setWordWrapAt (config->readNumEntry(
"Word Wrap Column", 80));
164 setPageUpDownMovesCursor (config->readBoolEntry(
"PageUp/PageDown Moves Cursor",
false));
165 setUndoSteps(config->readNumEntry(
"Undo Steps", 0));
167 setConfigFlags (config->readNumEntry(
"Basic Config Flags", KateDocumentConfig::cfTabIndents
168 | KateDocumentConfig::cfKeepIndentProfile
169 | KateDocumentConfig::cfWrapCursor
170 | KateDocumentConfig::cfShowTabs
171 | KateDocumentConfig::cfSmartHome
172 | KateDocumentConfig::cfIndentPastedText));
174 setEncoding (config->readEntry(
"Encoding",
""));
176 setEol (config->readNumEntry(
"End of Line", 0));
177 setAllowEolDetection (config->readBoolEntry(
"Allow End of Line Detection",
true));
179 setBackupFlags (config->readNumEntry(
"Backup Config Flags", 1));
181 setSearchDirConfigDepth (config->readNumEntry(
"Search Dir Config Depth", 3));
183 setBackupPrefix (config->readEntry(
"Backup Prefix", TQString (
"")));
185 setBackupSuffix (config->readEntry(
"Backup Suffix", TQString (
"~")));
188 for (uint i=0; i<KateFactory::self()->plugins().count(); i++)
189 setPlugin (i, config->readBoolEntry(
"KTextEditor Plugin " + (KateFactory::self()->plugins())[i]->library(),
false));
194 void KateDocumentConfig::writeConfig (
TDEConfig *config)
196 config->writeEntry(
"Tab Width", tabWidth());
198 config->writeEntry(
"Indentation Width", indentationWidth());
199 config->writeEntry(
"Indentation Mode", indentationMode());
201 config->writeEntry(
"Word Wrap", wordWrap());
202 config->writeEntry(
"Word Wrap Column", wordWrapAt());
204 config->writeEntry(
"PageUp/PageDown Moves Cursor", pageUpDownMovesCursor());
206 config->writeEntry(
"Undo Steps", undoSteps());
208 config->writeEntry(
"Basic Config Flags", configFlags());
210 config->writeEntry(
"Encoding", encoding());
212 config->writeEntry(
"End of Line", eol());
213 config->writeEntry(
"Allow End of Line Detection", allowEolDetection());
215 config->writeEntry(
"Backup Config Flags", backupFlags());
217 config->writeEntry(
"Search Dir Config Depth", searchDirConfigDepth());
219 config->writeEntry(
"Backup Prefix", backupPrefix());
221 config->writeEntry(
"Backup Suffix", backupSuffix());
224 for (uint i=0; i<KateFactory::self()->plugins().count(); i++)
225 config->writeEntry(
"KTextEditor Plugin " + (KateFactory::self()->plugins())[i]->library(), plugin(i));
228 void KateDocumentConfig::updateConfig ()
232 m_doc->updateConfig ();
238 for (uint z=0; z < KateFactory::self()->documents()->count(); z++)
240 KateFactory::self()->documents()->at(z)->updateConfig ();
245 int KateDocumentConfig::tabWidth ()
const
247 if (m_tabWidthSet || isGlobal())
250 return s_global->tabWidth();
253 void KateDocumentConfig::setTabWidth (
int tabWidth)
260 m_tabWidthSet =
true;
261 m_tabWidth = tabWidth;
266 int KateDocumentConfig::indentationWidth ()
const
268 if (m_indentationWidthSet || isGlobal())
269 return m_indentationWidth;
271 return s_global->indentationWidth();
274 void KateDocumentConfig::setIndentationWidth (
int indentationWidth)
276 if (indentationWidth < 1)
281 m_indentationWidthSet =
true;
282 m_indentationWidth = indentationWidth;
287 uint KateDocumentConfig::indentationMode ()
const
289 if (m_indentationModeSet || isGlobal())
290 return m_indentationMode;
292 return s_global->indentationMode();
295 void KateDocumentConfig::setIndentationMode (uint indentationMode)
299 m_indentationModeSet =
true;
300 m_indentationMode = indentationMode;
305 bool KateDocumentConfig::wordWrap ()
const
307 if (m_wordWrapSet || isGlobal())
310 return s_global->wordWrap();
313 void KateDocumentConfig::setWordWrap (
bool on)
317 m_wordWrapSet =
true;
323 unsigned int KateDocumentConfig::wordWrapAt ()
const
325 if (m_wordWrapAtSet || isGlobal())
328 return s_global->wordWrapAt();
331 void KateDocumentConfig::setWordWrapAt (
unsigned int col)
338 m_wordWrapAtSet =
true;
344 uint KateDocumentConfig::undoSteps ()
const
346 if (m_undoStepsSet || isGlobal())
349 return s_global->undoSteps();
352 void KateDocumentConfig::setUndoSteps (uint undoSteps)
356 m_undoStepsSet =
true;
357 m_undoSteps = undoSteps;
362 bool KateDocumentConfig::pageUpDownMovesCursor ()
const
364 if (m_pageUpDownMovesCursorSet || isGlobal())
365 return m_pageUpDownMovesCursor;
367 return s_global->pageUpDownMovesCursor();
370 void KateDocumentConfig::setPageUpDownMovesCursor (
bool on)
374 m_pageUpDownMovesCursorSet =
true;
375 m_pageUpDownMovesCursor = on;
380 uint KateDocumentConfig::configFlags ()
const
383 return m_configFlags;
385 return ((s_global->configFlags() & ~ m_configFlagsSet) | m_configFlags);
388 void KateDocumentConfig::setConfigFlags (KateDocumentConfig::ConfigFlags flag,
bool enable)
392 m_configFlagsSet |= flag;
395 m_configFlags = m_configFlags | flag;
397 m_configFlags = m_configFlags & ~ flag;
402 void KateDocumentConfig::setConfigFlags (uint fullFlags)
406 m_configFlagsSet = 0xFFFF;
407 m_configFlags = fullFlags;
412 const TQString &KateDocumentConfig::encoding ()
const
414 if (m_encodingSet || isGlobal())
417 return s_global->encoding();
420 TQTextCodec *KateDocumentConfig::codec ()
422 if (m_encodingSet || isGlobal())
424 if (m_encoding.isEmpty() && isGlobal())
426 else if (m_encoding.isEmpty())
427 return s_global->codec ();
432 return s_global->codec ();
435 void KateDocumentConfig::setEncoding (
const TQString &encoding)
437 TQString enc = encoding;
444 if (!found || !codec)
453 KateDocument::setDefaultEncoding (enc);
455 m_encodingSet =
true;
461 bool KateDocumentConfig::isSetEncoding ()
const
463 return m_encodingSet;
466 int KateDocumentConfig::eol ()
const
468 if (m_eolSet || isGlobal())
471 return s_global->eol();
474 TQString KateDocumentConfig::eolString ()
476 if (eol() == KateDocumentConfig::eolUnix)
477 return TQString (
"\n");
478 else if (eol() == KateDocumentConfig::eolDos)
479 return TQString (
"\r\n");
480 else if (eol() == KateDocumentConfig::eolMac)
481 return TQString (
"\r");
483 return TQString (
"\n");
486 void KateDocumentConfig::setEol (
int mode)
496 bool KateDocumentConfig::allowEolDetection ()
const
498 if (m_allowEolDetectionSet || isGlobal())
499 return m_allowEolDetection;
501 return s_global->allowEolDetection();
504 void KateDocumentConfig::setAllowEolDetection (
bool on)
508 m_allowEolDetectionSet =
true;
509 m_allowEolDetection = on;
514 uint KateDocumentConfig::backupFlags ()
const
516 if (m_backupFlagsSet || isGlobal())
517 return m_backupFlags;
519 return s_global->backupFlags();
522 void KateDocumentConfig::setBackupFlags (uint flags)
526 m_backupFlagsSet =
true;
527 m_backupFlags = flags;
532 const TQString &KateDocumentConfig::backupPrefix ()
const
534 if (m_backupPrefixSet || isGlobal())
535 return m_backupPrefix;
537 return s_global->backupPrefix();
540 const TQString &KateDocumentConfig::backupSuffix ()
const
542 if (m_backupSuffixSet || isGlobal())
543 return m_backupSuffix;
545 return s_global->backupSuffix();
548 void KateDocumentConfig::setBackupPrefix (
const TQString &prefix)
552 m_backupPrefixSet =
true;
553 m_backupPrefix = prefix;
558 void KateDocumentConfig::setBackupSuffix (
const TQString &suffix)
562 m_backupSuffixSet =
true;
563 m_backupSuffix = suffix;
568 bool KateDocumentConfig::plugin (uint index)
const
570 if (index >= m_plugins.size())
573 if (m_pluginsSet.at(index) || isGlobal())
574 return m_plugins.at(index);
576 return s_global->plugin (index);
579 void KateDocumentConfig::setPlugin (uint index,
bool load)
581 if (index >= m_plugins.size())
586 m_pluginsSet.setBit(index);
587 m_plugins.setBit(index, load);
592 int KateDocumentConfig::searchDirConfigDepth ()
const
594 if (m_searchDirConfigDepthSet || isGlobal())
595 return m_searchDirConfigDepth;
597 return s_global->searchDirConfigDepth ();
600 void KateDocumentConfig::setSearchDirConfigDepth (
int depth)
604 m_searchDirConfigDepthSet =
true;
605 m_searchDirConfigDepth = depth;
613 KateViewConfig::KateViewConfig ()
615 m_dynWordWrapSet (true),
616 m_dynWordWrapIndicatorsSet (true),
617 m_dynWordWrapAlignIndentSet (true),
618 m_lineNumbersSet (true),
619 m_scrollBarMarksSet (true),
621 m_foldingBarSet (true),
622 m_bookmarkSortSet (true),
623 m_autoCenterLinesSet (true),
624 m_searchFlagsSet (true),
626 m_defaultMarkTypeSet (true),
627 m_persistentSelectionSet (true),
628 m_textToSearchModeSet (true),
635 config->setGroup(
"Kate View Defaults");
639 KateViewConfig::KateViewConfig (KateView *view)
641 m_dynWordWrapSet (false),
642 m_dynWordWrapIndicatorsSet (false),
643 m_dynWordWrapAlignIndentSet (false),
644 m_lineNumbersSet (false),
645 m_scrollBarMarksSet (false),
646 m_iconBarSet (false),
647 m_foldingBarSet (false),
648 m_bookmarkSortSet (false),
649 m_autoCenterLinesSet (false),
650 m_searchFlagsSet (false),
651 m_cmdLineSet (false),
652 m_defaultMarkTypeSet (false),
653 m_persistentSelectionSet (false),
654 m_textToSearchModeSet (false),
659 KateViewConfig::~KateViewConfig ()
663 void KateViewConfig::readConfig (
TDEConfig *config)
667 setDynWordWrap (config->readBoolEntry(
"Dynamic Word Wrap",
true ));
668 setDynWordWrapIndicators (config->readNumEntry(
"Dynamic Word Wrap Indicators", 1 ));
669 setDynWordWrapAlignIndent (config->readNumEntry(
"Dynamic Word Wrap Align Indent", 80 ));
671 setLineNumbers (config->readBoolEntry(
"Line Numbers",
false));
673 setScrollBarMarks (config->readBoolEntry(
"Scroll Bar Marks",
false));
675 setIconBar (config->readBoolEntry(
"Icon Bar",
false ));
677 setFoldingBar (config->readBoolEntry(
"Folding Bar",
true));
679 setBookmarkSort (config->readNumEntry(
"Bookmark Menu Sorting", 0 ));
681 setAutoCenterLines (config->readNumEntry(
"Auto Center Lines", 0 ));
683 setSearchFlags (config->readNumEntry(
"Search Config Flags", KFindDialog::FromCursor | KFindDialog::CaseSensitive | KReplaceDialog::PromptOnReplace));
685 setCmdLine (config->readBoolEntry(
"Command Line",
false));
687 setDefaultMarkType (config->readNumEntry(
"Default Mark Type", KTextEditor::MarkInterface::markType01 ));
689 setPersistentSelection (config->readNumEntry(
"Persistent Selection",
false ));
691 setTextToSearchMode (config->readNumEntry(
"Text To Search Mode", KateViewConfig::SelectionWord));
696 void KateViewConfig::writeConfig (
TDEConfig *config)
698 config->writeEntry(
"Dynamic Word Wrap", dynWordWrap() );
699 config->writeEntry(
"Dynamic Word Wrap Indicators", dynWordWrapIndicators() );
700 config->writeEntry(
"Dynamic Word Wrap Align Indent", dynWordWrapAlignIndent() );
702 config->writeEntry(
"Line Numbers", lineNumbers() );
704 config->writeEntry(
"Scroll Bar Marks", scrollBarMarks() );
706 config->writeEntry(
"Icon Bar", iconBar() );
708 config->writeEntry(
"Folding Bar", foldingBar() );
710 config->writeEntry(
"Bookmark Menu Sorting", bookmarkSort() );
712 config->writeEntry(
"Auto Center Lines", autoCenterLines() );
714 config->writeEntry(
"Search Config Flags", searchFlags());
716 config->writeEntry(
"Command Line", cmdLine());
718 config->writeEntry(
"Default Mark Type", defaultMarkType());
720 config->writeEntry(
"Persistent Selection", persistentSelection());
722 config->writeEntry(
"Text To Search Mode", textToSearchMode());
725 void KateViewConfig::updateConfig ()
729 m_view->updateConfig ();
735 for (uint z=0; z < KateFactory::self()->views()->count(); z++)
737 KateFactory::self()->views()->at(z)->updateConfig ();
742 bool KateViewConfig::dynWordWrap ()
const
744 if (m_dynWordWrapSet || isGlobal())
745 return m_dynWordWrap;
747 return s_global->dynWordWrap();
750 void KateViewConfig::setDynWordWrap (
bool wrap)
754 m_dynWordWrapSet =
true;
755 m_dynWordWrap = wrap;
760 int KateViewConfig::dynWordWrapIndicators ()
const
762 if (m_dynWordWrapIndicatorsSet || isGlobal())
763 return m_dynWordWrapIndicators;
765 return s_global->dynWordWrapIndicators();
768 void KateViewConfig::setDynWordWrapIndicators (
int mode)
772 m_dynWordWrapIndicatorsSet =
true;
773 m_dynWordWrapIndicators = kMin(80, kMax(0, mode));
778 int KateViewConfig::dynWordWrapAlignIndent ()
const
780 if (m_dynWordWrapAlignIndentSet || isGlobal())
781 return m_dynWordWrapAlignIndent;
783 return s_global->dynWordWrapAlignIndent();
786 void KateViewConfig::setDynWordWrapAlignIndent (
int indent)
790 m_dynWordWrapAlignIndentSet =
true;
791 m_dynWordWrapAlignIndent = indent;
796 bool KateViewConfig::lineNumbers ()
const
798 if (m_lineNumbersSet || isGlobal())
799 return m_lineNumbers;
801 return s_global->lineNumbers();
804 void KateViewConfig::setLineNumbers (
bool on)
808 m_lineNumbersSet =
true;
814 bool KateViewConfig::scrollBarMarks ()
const
816 if (m_scrollBarMarksSet || isGlobal())
817 return m_scrollBarMarks;
819 return s_global->scrollBarMarks();
822 void KateViewConfig::setScrollBarMarks (
bool on)
826 m_scrollBarMarksSet =
true;
827 m_scrollBarMarks = on;
832 bool KateViewConfig::iconBar ()
const
834 if (m_iconBarSet || isGlobal())
837 return s_global->iconBar();
840 void KateViewConfig::setIconBar (
bool on)
850 bool KateViewConfig::foldingBar ()
const
852 if (m_foldingBarSet || isGlobal())
855 return s_global->foldingBar();
858 void KateViewConfig::setFoldingBar (
bool on)
862 m_foldingBarSet =
true;
868 int KateViewConfig::bookmarkSort ()
const
870 if (m_bookmarkSortSet || isGlobal())
871 return m_bookmarkSort;
873 return s_global->bookmarkSort();
876 void KateViewConfig::setBookmarkSort (
int mode)
880 m_bookmarkSortSet =
true;
881 m_bookmarkSort = mode;
886 int KateViewConfig::autoCenterLines ()
const
888 if (m_autoCenterLinesSet || isGlobal())
889 return m_autoCenterLines;
891 return s_global->autoCenterLines();
894 void KateViewConfig::setAutoCenterLines (
int lines)
901 m_autoCenterLinesSet =
true;
902 m_autoCenterLines = lines;
907 long KateViewConfig::searchFlags ()
const
909 if (m_searchFlagsSet || isGlobal())
910 return m_searchFlags;
912 return s_global->searchFlags();
915 void KateViewConfig::setSearchFlags (
long flags)
919 m_searchFlagsSet =
true;
920 m_searchFlags = flags;
925 bool KateViewConfig::cmdLine ()
const
927 if (m_cmdLineSet || isGlobal())
930 return s_global->cmdLine();
933 void KateViewConfig::setCmdLine (
bool on)
943 uint KateViewConfig::defaultMarkType ()
const
945 if (m_defaultMarkTypeSet || isGlobal())
946 return m_defaultMarkType;
948 return s_global->defaultMarkType();
951 void KateViewConfig::setDefaultMarkType (uint type)
955 m_defaultMarkTypeSet =
true;
956 m_defaultMarkType = type;
961 bool KateViewConfig::persistentSelection ()
const
963 if (m_persistentSelectionSet || isGlobal())
964 return m_persistentSelection;
966 return s_global->persistentSelection();
969 void KateViewConfig::setPersistentSelection (
bool on)
973 m_persistentSelectionSet =
true;
974 m_persistentSelection = on;
979 int KateViewConfig::textToSearchMode ()
const
981 if (m_textToSearchModeSet || isGlobal())
982 return m_textToSearchMode;
984 return s_global->textToSearchMode();
987 void KateViewConfig::setTextToSearchMode (
int mode)
991 m_textToSearchModeSet =
true;
992 m_textToSearchMode = mode;
1000 KateRendererConfig::KateRendererConfig ()
1002 m_font (new KateFontStruct ()),
1003 m_lineMarkerColor (
KTextEditor::MarkInterface::reservedMarkersCount()),
1006 m_wordWrapMarkerSet (true),
1007 m_showIndentationLinesSet (true),
1008 m_backgroundColorSet (true),
1009 m_selectionColorSet (true),
1010 m_highlightedLineColorSet (true),
1011 m_highlightedBracketColorSet (true),
1012 m_wordWrapMarkerColorSet (true),
1013 m_tabMarkerColorSet(true),
1014 m_iconBarColorSet (true),
1015 m_lineNumberColorSet (true),
1016 m_lineMarkerColorSet (m_lineMarkerColor.size()),
1020 m_lineMarkerColorSet.fill (
true);
1026 config->setGroup(
"Kate Renderer Defaults");
1027 readConfig (config);
1030 KateRendererConfig::KateRendererConfig (
KateRenderer *renderer)
1032 m_lineMarkerColor (
KTextEditor::MarkInterface::reservedMarkersCount()),
1033 m_schemaSet (false),
1035 m_wordWrapMarkerSet (false),
1036 m_showIndentationLinesSet (false),
1037 m_backgroundColorSet (false),
1038 m_selectionColorSet (false),
1039 m_highlightedLineColorSet (false),
1040 m_highlightedBracketColorSet (false),
1041 m_wordWrapMarkerColorSet (false),
1042 m_tabMarkerColorSet(false),
1043 m_iconBarColorSet (false),
1044 m_lineNumberColorSet (false),
1045 m_lineMarkerColorSet (m_lineMarkerColor.size()),
1046 m_renderer (renderer)
1049 m_lineMarkerColorSet.fill (
false);
1052 KateRendererConfig::~KateRendererConfig ()
1057 void KateRendererConfig::readConfig (
TDEConfig *config)
1061 setSchema (KateFactory::self()->schemaManager()->number (config->readEntry(
"Schema", KateSchemaManager::normalSchema())));
1063 setWordWrapMarker (config->readBoolEntry(
"Word Wrap Marker",
false ));
1065 setShowIndentationLines (config->readBoolEntry(
"Show Indentation Lines",
false));
1070 void KateRendererConfig::writeConfig (
TDEConfig *config)
1072 config->writeEntry (
"Schema", KateFactory::self()->schemaManager()->
name(schema()));
1074 config->writeEntry(
"Word Wrap Marker", wordWrapMarker() );
1076 config->writeEntry(
"Show Indentation Lines", showIndentationLines());
1079 void KateRendererConfig::updateConfig ()
1083 m_renderer->updateConfig ();
1089 for (uint z=0; z < KateFactory::self()->renderers()->count(); z++)
1091 KateFactory::self()->renderers()->at(z)->updateConfig ();
1096 uint KateRendererConfig::schema ()
const
1098 if (m_schemaSet || isGlobal())
1101 return s_global->schema();
1104 void KateRendererConfig::setSchema (uint schema)
1109 setSchemaInternal( schema );
1113 void KateRendererConfig::reloadSchema()
1116 for ( uint z=0; z < KateFactory::self()->renderers()->count(); z++ )
1117 KateFactory::self()->renderers()->at(z)->config()->reloadSchema();
1119 else if ( m_renderer && m_schemaSet )
1120 setSchemaInternal( m_schema );
1123 void KateRendererConfig::setSchemaInternal(
int schema )
1128 TDEConfig *config (KateFactory::self()->schemaManager()->schema(schema));
1133 TQColor tmp3 (
"#FFFF99" );
1134 TQColor tmp4 (tmp2.dark());
1136 TQColor tmp6 (
"#EAE9E8" );
1137 TQColor tmp7 (
"#000000" );
1139 m_backgroundColor = config->readColorEntry(
"Color Background", &tmp0);
1140 m_backgroundColorSet =
true;
1141 m_selectionColor = config->readColorEntry(
"Color Selection", &tmp1);
1142 m_selectionColorSet =
true;
1143 m_highlightedLineColor = config->readColorEntry(
"Color Highlighted Line", &tmp2);
1144 m_highlightedLineColorSet =
true;
1145 m_highlightedBracketColor = config->readColorEntry(
"Color Highlighted Bracket", &tmp3);
1146 m_highlightedBracketColorSet =
true;
1147 m_wordWrapMarkerColor = config->readColorEntry(
"Color Word Wrap Marker", &tmp4);
1148 m_wordWrapMarkerColorSet =
true;
1149 m_tabMarkerColor = config->readColorEntry(
"Color Tab Marker", &tmp5);
1150 m_tabMarkerColorSet =
true;
1151 m_iconBarColor = config->readColorEntry(
"Color Icon Bar", &tmp6);
1152 m_iconBarColorSet =
true;
1153 m_lineNumberColor = config->readColorEntry(
"Color Line Number", &tmp7);
1154 m_lineNumberColorSet =
true;
1160 mark[2] = Qt::yellow;
1161 mark[3] = Qt::magenta;
1163 mark[5] = Qt::green;
1166 for (
int i = 1; i <= KTextEditor::MarkInterface::reservedMarkersCount(); i++) {
1167 TQColor col = config->readColorEntry(TQString(
"Color MarkType%1").arg(i), &mark[i - 1]);
1169 m_lineMarkerColorSet[index] =
true;
1170 m_lineMarkerColor[index] = col;
1178 m_font =
new KateFontStruct ();
1181 m_font->setFont(config->readFontEntry(
"Font", &f));
1184 KateFontStruct *KateRendererConfig::fontStruct ()
1186 if (m_fontSet || isGlobal())
1189 return s_global->fontStruct ();
1192 TQFont *KateRendererConfig::font()
1194 return &(fontStruct ()->myFont);
1197 KateFontMetrics *KateRendererConfig::fontMetrics()
1199 return &(fontStruct ()->myFontMetrics);
1202 void KateRendererConfig::setFont(
const TQFont &font)
1209 m_font =
new KateFontStruct ();
1212 m_font->setFont(font);
1217 bool KateRendererConfig::wordWrapMarker ()
const
1219 if (m_wordWrapMarkerSet || isGlobal())
1220 return m_wordWrapMarker;
1222 return s_global->wordWrapMarker();
1225 void KateRendererConfig::setWordWrapMarker (
bool on)
1229 m_wordWrapMarkerSet =
true;
1230 m_wordWrapMarker = on;
1235 const TQColor& KateRendererConfig::backgroundColor()
const
1237 if (m_backgroundColorSet || isGlobal())
1238 return m_backgroundColor;
1240 return s_global->backgroundColor();
1243 void KateRendererConfig::setBackgroundColor (
const TQColor &col)
1247 m_backgroundColorSet =
true;
1248 m_backgroundColor = col;
1253 const TQColor& KateRendererConfig::selectionColor()
const
1255 if (m_selectionColorSet || isGlobal())
1256 return m_selectionColor;
1258 return s_global->selectionColor();
1261 void KateRendererConfig::setSelectionColor (
const TQColor &col)
1265 m_selectionColorSet =
true;
1266 m_selectionColor = col;
1271 const TQColor& KateRendererConfig::highlightedLineColor()
const
1273 if (m_highlightedLineColorSet || isGlobal())
1274 return m_highlightedLineColor;
1276 return s_global->highlightedLineColor();
1279 void KateRendererConfig::setHighlightedLineColor (
const TQColor &col)
1283 m_highlightedLineColorSet =
true;
1284 m_highlightedLineColor = col;
1289 const TQColor& KateRendererConfig::lineMarkerColor(KTextEditor::MarkInterface::MarkTypes type)
const
1292 if (type > 0) {
while((type >> index++) ^ 1) {} }
1295 if ( index < 0 || index >= KTextEditor::MarkInterface::reservedMarkersCount() )
1297 static TQColor dummy;
1301 if (m_lineMarkerColorSet[index] || isGlobal())
1302 return m_lineMarkerColor[index];
1304 return s_global->lineMarkerColor( type );
1307 void KateRendererConfig::setLineMarkerColor (
const TQColor &col, KTextEditor::MarkInterface::MarkTypes type)
1309 int index =
static_cast<int>( log(static_cast<double>(type)) / log(2.0) );
1310 Q_ASSERT( index >= 0 && index < KTextEditor::MarkInterface::reservedMarkersCount() );
1313 m_lineMarkerColorSet[index] =
true;
1314 m_lineMarkerColor[index] = col;
1319 const TQColor& KateRendererConfig::highlightedBracketColor()
const
1321 if (m_highlightedBracketColorSet || isGlobal())
1322 return m_highlightedBracketColor;
1324 return s_global->highlightedBracketColor();
1327 void KateRendererConfig::setHighlightedBracketColor (
const TQColor &col)
1331 m_highlightedBracketColorSet =
true;
1332 m_highlightedBracketColor = col;
1337 const TQColor& KateRendererConfig::wordWrapMarkerColor()
const
1339 if (m_wordWrapMarkerColorSet || isGlobal())
1340 return m_wordWrapMarkerColor;
1342 return s_global->wordWrapMarkerColor();
1345 void KateRendererConfig::setWordWrapMarkerColor (
const TQColor &col)
1349 m_wordWrapMarkerColorSet =
true;
1350 m_wordWrapMarkerColor = col;
1355 const TQColor& KateRendererConfig::tabMarkerColor()
const
1357 if (m_tabMarkerColorSet || isGlobal())
1358 return m_tabMarkerColor;
1360 return s_global->tabMarkerColor();
1363 void KateRendererConfig::setTabMarkerColor (
const TQColor &col)
1367 m_tabMarkerColorSet =
true;
1368 m_tabMarkerColor = col;
1373 const TQColor& KateRendererConfig::iconBarColor()
const
1375 if (m_iconBarColorSet || isGlobal())
1376 return m_iconBarColor;
1378 return s_global->iconBarColor();
1381 void KateRendererConfig::setIconBarColor (
const TQColor &col)
1385 m_iconBarColorSet =
true;
1386 m_iconBarColor = col;
1391 const TQColor& KateRendererConfig::lineNumberColor()
const
1393 if (m_lineNumberColorSet || isGlobal())
1394 return m_lineNumberColor;
1396 return s_global->lineNumberColor();
1399 void KateRendererConfig::setLineNumberColor (
const TQColor &col)
1403 m_lineNumberColorSet =
true;
1404 m_lineNumberColor = col;
1409 bool KateRendererConfig::showIndentationLines ()
const
1411 if (m_showIndentationLinesSet || isGlobal())
1412 return m_showIndentationLines;
1414 return s_global->showIndentationLines();
1417 void KateRendererConfig::setShowIndentationLines (
bool on)
1421 m_showIndentationLinesSet =
true;
1422 m_showIndentationLines = on;
virtual void updateConfig()=0
do the real update
static TQColor baseColor()
void configEnd()
end a config change transaction, update the concerned documents/views/renderers
static TQColor highlightColor()
void configStart()
start some config changes this method is needed to init some kind of transaction for config changes...
Handles all of the work of rendering the text (used for the views and printing)
KateConfig()
Default Constructor.
static KCharsets * charsets()
static TQColor textColor()
static TDELocale * locale()
TQTextCodec * codecForName(const TQString &name) const
static TQFont fixedFont()
virtual ~KateConfig()
Virtual Destructor.
TQString name(StdAccel id)
static TQColor alternateBackgroundColor()