Kate
kateconfig.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __KATE_CONFIG_H__
00020 #define __KATE_CONFIG_H__
00021
00022 #include <ktexteditor/markinterface.h>
00023 #include <kencodingprober.h>
00024
00025 #include <QtCore/QBitRef>
00026 #include <QtGui/QColor>
00027 #include <QtCore/QObject>
00028 #include <QtCore/QVector>
00029 #include <QtGui/QFontMetrics>
00030
00031 class KConfigGroup;
00032 class KateView;
00033 class KateDocument;
00034 class KateRenderer;
00035
00036 class KConfig;
00037
00038 class QTextCodec;
00039
00040
00044 class KateConfig
00045 {
00046 public:
00050 KateConfig ();
00051
00055 virtual ~KateConfig ();
00056
00057 public:
00064 void configStart ();
00065
00070 void configEnd ();
00071
00072 protected:
00076 virtual void updateConfig () = 0;
00077
00078 private:
00082 uint configSessionNumber;
00083
00087 bool configIsRunning;
00088 };
00089
00090 class KateDocumentConfig : public KateConfig
00091 {
00092 private:
00093 friend class KateGlobal;
00094
00098 KateDocumentConfig ();
00099
00100 public:
00104 KateDocumentConfig (KateDocument *doc);
00105
00109 ~KateDocumentConfig ();
00110
00111 inline static KateDocumentConfig *global () { return s_global; }
00112
00113 inline bool isGlobal () const { return (this == global()); }
00114
00115 public:
00119 void readConfig (const KConfigGroup &config);
00120
00124 void writeConfig (KConfigGroup &config);
00125
00126 protected:
00127 void updateConfig ();
00128
00129 public:
00130 int tabWidth () const;
00131 void setTabWidth (int tabWidth);
00132
00133 int indentationWidth () const;
00134 void setIndentationWidth (int indentationWidth);
00135
00136 const QString &indentationMode () const;
00137 void setIndentationMode (const QString &identationMode);
00138
00139 enum TabHandling
00140 {
00141 tabInsertsTab = 0,
00142 tabIndents = 1,
00143 tabSmart = 2
00144 };
00145
00146 uint tabHandling () const;
00147 void setTabHandling (uint tabHandling);
00148
00149 bool wordWrap () const;
00150 void setWordWrap (bool on);
00151
00152 unsigned int wordWrapAt () const;
00153 void setWordWrapAt (unsigned int col);
00154
00155 bool pageUpDownMovesCursor () const;
00156 void setPageUpDownMovesCursor (bool on);
00157
00158 enum ConfigFlags
00159 {
00160 cfBackspaceIndents= 0x2,
00161 cfWordWrap= 0x4,
00162 cfRemoveSpaces = 0x10,
00163 cfWrapCursor= 0x20,
00164 cfAutoBrackets= 0x40,
00165 cfTabIndentsMode = 0x200,
00166 cfOvr= 0x1000,
00167 cfKeepExtraSpaces= 0x10000,
00168 cfTabIndents= 0x80000,
00169 cfShowTabs= 0x200000,
00170 cfShowSpaces= 0x400000,
00171 cfSmartHome = 0x800000,
00172 cfTabInsertsTab = 0x1000000,
00173 cfReplaceTabsDyn= 0x2000000,
00174 cfRemoveTrailingDyn=0x4000000,
00175 cfIndentPastedText = 0x10000000
00176 };
00177
00178 uint configFlags () const;
00179 void setConfigFlags (KateDocumentConfig::ConfigFlags flag, bool enable);
00180 void setConfigFlags (uint fullFlags);
00181
00182 QTextCodec *codec () const;
00183 const QString &encoding () const;
00184 bool setEncoding (const QString &encoding,bool resetDetection=true);
00185 bool isSetEncoding () const;
00186 KEncodingProber::ProberType encodingProberType() const;
00187 void setEncodingProberType(KEncodingProber::ProberType);
00188
00189 enum Eol
00190 {
00191 eolUnix = 0,
00192 eolDos = 1,
00193 eolMac = 2
00194 };
00195
00196 int eol () const;
00197 QString eolString ();
00198
00199 void setEol (int mode);
00200
00201 bool bom () const;
00202 void setBom(bool bom);
00203
00204 bool allowEolDetection () const;
00205 void setAllowEolDetection (bool on);
00206
00207 bool allowSimpleMode () const;
00208 void setAllowSimpleMode (bool on);
00209
00210 enum BackupFlags
00211 {
00212 LocalFiles=1,
00213 RemoteFiles=2
00214 };
00215
00216 uint backupFlags () const;
00217 void setBackupFlags (uint flags);
00218
00219 const QString &backupPrefix () const;
00220 void setBackupPrefix (const QString &prefix);
00221
00222 const QString &backupSuffix () const;
00223 void setBackupSuffix (const QString &suffix);
00224
00230 int searchDirConfigDepth () const;
00231
00232 void setSearchDirConfigDepth (int depth);
00233
00234 bool onTheFlySpellCheck() const;
00235 void setOnTheFlySpellCheck(bool on);
00236
00237
00238 private:
00239 QString m_indentationMode;
00240 int m_indentationWidth;
00241 int m_tabWidth;
00242 uint m_tabHandling;
00243 uint m_configFlags;
00244 int m_wordWrapAt;
00245 bool m_wordWrap;
00246 bool m_pageUpDownMovesCursor;
00247 bool m_allowEolDetection;
00248 bool m_allowSimpleMode;
00249 int m_eol;
00250 bool m_bom;
00251 uint m_backupFlags;
00252 int m_searchDirConfigDepth;
00253 KEncodingProber::ProberType m_proberTypeForEncodingAutoDetection;
00254 QString m_encoding;
00255 QString m_backupPrefix;
00256 QString m_backupSuffix;
00257 bool m_onTheFlySpellCheck;
00258
00259 bool m_tabWidthSet : 1;
00260 bool m_indentationWidthSet : 1;
00261 bool m_indentationModeSet : 1;
00262 bool m_wordWrapSet : 1;
00263 bool m_wordWrapAtSet : 1;
00264 bool m_pageUpDownMovesCursorSet : 1;
00265 uint m_configFlagsSet;
00266 bool m_encodingSet : 1;
00267 bool m_eolSet : 1;
00268 bool m_bomSet :1;
00269 bool m_allowEolDetectionSet : 1;
00270 bool m_allowSimpleModeSet : 1;
00271 bool m_backupFlagsSet : 1;
00272 bool m_searchDirConfigDepthSet : 1;
00273 bool m_backupPrefixSet : 1;
00274 bool m_backupSuffixSet : 1;
00275 bool m_onTheFlySpellCheckSet : 1;
00276
00277 private:
00278 static KateDocumentConfig *s_global;
00279 KateDocument *m_doc;
00280 };
00281
00282 class KateViewConfig : public KateConfig
00283 {
00284 private:
00285 friend class KateGlobal;
00286
00290 KateViewConfig ();
00291
00292 public:
00296 explicit KateViewConfig (KateView *view);
00297
00301 ~KateViewConfig ();
00302
00303 inline static KateViewConfig *global () { return s_global; }
00304
00305 inline bool isGlobal () const { return (this == global()); }
00306
00307 public:
00311 void readConfig (const KConfigGroup &config);
00312
00316 void writeConfig (KConfigGroup &config);
00317
00318 protected:
00319 void updateConfig ();
00320
00321 public:
00322 bool dynWordWrap () const;
00323 void setDynWordWrap (bool wrap);
00324
00325 int dynWordWrapIndicators () const;
00326 void setDynWordWrapIndicators (int mode);
00327
00328 int dynWordWrapAlignIndent () const;
00329 void setDynWordWrapAlignIndent (int indent);
00330
00331 bool lineNumbers () const;
00332 void setLineNumbers (bool on);
00333
00334 bool scrollBarMarks () const;
00335 void setScrollBarMarks (bool on);
00336
00337 bool iconBar () const;
00338 void setIconBar (bool on);
00339
00340 bool foldingBar () const;
00341 void setFoldingBar (bool on);
00342
00343 int bookmarkSort () const;
00344 void setBookmarkSort (int mode);
00345
00346 int autoCenterLines() const;
00347 void setAutoCenterLines (int lines);
00348
00349 enum SearchFlags {
00350 IncMatchCase = 1 << 0,
00351 IncHighlightAll = 1 << 1,
00352 IncFromCursor = 1 << 2,
00353 PowerMatchCase = 1 << 3,
00354 PowerHighlightAll = 1 << 4,
00355 PowerFromCursor = 1 << 5,
00356
00357 PowerModePlainText = 1 << 7,
00358 PowerModeWholeWords = 1 << 8,
00359 PowerModeEscapeSequences = 1 << 9,
00360 PowerModeRegularExpression = 1 << 10,
00361 PowerUsePlaceholders = 1 << 11
00362 };
00363
00364 long searchFlags () const;
00365 void setSearchFlags (long flags);
00366
00367 uint defaultMarkType () const;
00368 void setDefaultMarkType (uint type);
00369
00370 bool persistentSelection () const;
00371 void setPersistentSelection (bool on);
00372
00373 bool viInputMode () const;
00374 void setViInputMode (bool on);
00375
00376 bool viInputModeStealKeys () const;
00377 void setViInputModeStealKeys (bool on);
00378
00379 bool viInputModeHideStatusBar () const;
00380 void setViInputModeHideStatusBar (bool on);
00381
00382
00383 enum TextToSearch
00384 {
00385 Nowhere = 0,
00386 SelectionOnly = 1,
00387 SelectionWord = 2,
00388 WordOnly = 3,
00389 WordSelection = 4
00390 };
00391
00392 bool automaticCompletionInvocation () const;
00393 void setAutomaticCompletionInvocation (bool on);
00394
00395 bool wordCompletion () const;
00396 void setWordCompletion (bool on);
00397
00398 int wordCompletionMinimalWordLength () const;
00399 void setWordCompletionMinimalWordLength (int length);
00400
00401 bool smartCopyCut() const;
00402 void setSmartCopyCut(bool on);
00403
00404 bool scrollPastEnd() const;
00405 void setScrollPastEnd(bool on);
00406
00407 private:
00408 bool m_dynWordWrap;
00409 int m_dynWordWrapIndicators;
00410 int m_dynWordWrapAlignIndent;
00411 bool m_lineNumbers;
00412 bool m_scrollBarMarks;
00413 bool m_iconBar;
00414 bool m_foldingBar;
00415 int m_bookmarkSort;
00416 int m_autoCenterLines;
00417 long m_searchFlags;
00418 uint m_defaultMarkType;
00419 bool m_persistentSelection;
00420 bool m_viInputMode;
00421 bool m_viInputModeStealKeys;
00422 bool m_viInputModeHideStatusBar;
00423 bool m_automaticCompletionInvocation;
00424 bool m_wordCompletion;
00425 int m_wordCompletionMinimalWordLength;
00426 bool m_smartCopyCut;
00427 bool m_scrollPastEnd;
00428
00429 bool m_dynWordWrapSet : 1;
00430 bool m_dynWordWrapIndicatorsSet : 1;
00431 bool m_dynWordWrapAlignIndentSet : 1;
00432 bool m_lineNumbersSet : 1;
00433 bool m_scrollBarMarksSet : 1;
00434 bool m_iconBarSet : 1;
00435 bool m_foldingBarSet : 1;
00436 bool m_bookmarkSortSet : 1;
00437 bool m_autoCenterLinesSet : 1;
00438 bool m_searchFlagsSet : 1;
00439 bool m_defaultMarkTypeSet : 1;
00440 bool m_persistentSelectionSet : 1;
00441 bool m_viInputModeSet : 1;
00442 bool m_viInputModeStealKeysSet : 1;
00443 bool m_viInputModeHideStatusBarSet : 1;
00444 bool m_automaticCompletionInvocationSet : 1;
00445 bool m_wordCompletionSet : 1;
00446 bool m_wordCompletionMinimalWordLengthSet : 1;
00447 bool m_smartCopyCutSet : 1;
00448 bool m_scrollPastEndSet : 1;
00449
00450 private:
00451 static KateViewConfig *s_global;
00452 KateView *m_view;
00453 };
00454
00455 class KateRendererConfig : public KateConfig
00456 {
00457 private:
00458 friend class KateGlobal;
00459
00463 KateRendererConfig ();
00464
00465
00466 public:
00470 KateRendererConfig (KateRenderer *renderer);
00471
00475 ~KateRendererConfig ();
00476
00477 inline static KateRendererConfig *global () { return s_global; }
00478
00479 inline bool isGlobal () const { return (this == global()); }
00480
00481 public:
00485 void readConfig (const KConfigGroup &config);
00486
00490 void writeConfig (KConfigGroup &config);
00491
00492 protected:
00493 void updateConfig ();
00494
00495 public:
00496 const QString &schema () const;
00497 void setSchema (const QString &schema);
00503 void reloadSchema();
00504
00505 const QFont& font() const;
00506 const QFontMetrics& fontMetrics() const;
00507 void setFont(const QFont &font);
00508
00509 bool wordWrapMarker () const;
00510 void setWordWrapMarker (bool on);
00511
00512 const QColor& backgroundColor() const;
00513 void setBackgroundColor (const QColor &col);
00514
00515 const QColor& selectionColor() const;
00516 void setSelectionColor (const QColor &col);
00517
00518 const QColor& highlightedLineColor() const;
00519 void setHighlightedLineColor (const QColor &col);
00520
00521 const QColor& lineMarkerColor(KTextEditor::MarkInterface::MarkTypes type = KTextEditor::MarkInterface::markType01) const;
00522 void setLineMarkerColor (const QColor &col, KTextEditor::MarkInterface::MarkTypes type = KTextEditor::MarkInterface::markType01);
00523
00524 const QColor& highlightedBracketColor() const;
00525 void setHighlightedBracketColor (const QColor &col);
00526
00527 const QColor& wordWrapMarkerColor() const;
00528 void setWordWrapMarkerColor (const QColor &col);
00529
00530 const QColor& tabMarkerColor() const;
00531 void setTabMarkerColor (const QColor &col);
00532
00533 const QColor& iconBarColor() const;
00534 void setIconBarColor (const QColor &col);
00535
00536
00537
00538 const QColor& lineNumberColor() const;
00539 void setLineNumberColor (const QColor &col);
00540
00541 const QColor& spellingMistakeLineColor() const;
00542 void setSpellingMistakeKineColor (const QColor &col);
00543
00544 bool showIndentationLines () const;
00545 void setShowIndentationLines (bool on);
00546
00547 bool showWholeBracketExpression () const;
00548 void setShowWholeBracketExpression (bool on);
00549
00550 const QColor &templateBackgroundColor() const;
00551 const QColor &templateEditablePlaceholderColor() const;
00552 const QColor &templateFocusedEditablePlaceholderColor() const;
00553 const QColor &templateNotEditablePlaceholderColor() const;
00554
00555
00556 private:
00560 void setSchemaInternal(const QString &schema);
00561
00562 QString m_schema;
00563 QFont m_font;
00564 QFontMetrics m_fontMetrics;
00565 bool m_wordWrapMarker;
00566 bool m_showIndentationLines;
00567 bool m_showWholeBracketExpression;
00568 QColor m_backgroundColor;
00569 QColor m_selectionColor;
00570 QColor m_highlightedLineColor;
00571 QColor m_highlightedBracketColor;
00572 QColor m_wordWrapMarkerColor;
00573 QColor m_tabMarkerColor;
00574 QColor m_iconBarColor;
00575 QColor m_lineNumberColor;
00576 QColor m_spellingMistakeLineColor;
00577 QVector<QColor> m_lineMarkerColor;
00578
00579 QColor m_templateBackgroundColor;
00580 QColor m_templateEditablePlaceholderColor;
00581 QColor m_templateFocusedEditablePlaceholderColor;
00582 QColor m_templateNotEditablePlaceholderColor;
00583
00584
00585 bool m_schemaSet : 1;
00586 bool m_fontSet : 1;
00587 bool m_wordWrapMarkerSet : 1;
00588 bool m_showIndentationLinesSet : 1;
00589 bool m_showWholeBracketExpressionSet : 1;
00590 bool m_backgroundColorSet : 1;
00591 bool m_selectionColorSet : 1;
00592 bool m_highlightedLineColorSet : 1;
00593 bool m_highlightedBracketColorSet : 1;
00594 bool m_wordWrapMarkerColorSet : 1;
00595 bool m_tabMarkerColorSet : 1;
00596 bool m_iconBarColorSet : 1;
00597 bool m_lineNumberColorSet : 1;
00598 bool m_spellingMistakeLineColorSet : 1;
00599 bool m_templateColorsSet : 1;
00600 QBitArray m_lineMarkerColorSet;
00601
00602 private:
00603 static KateRendererConfig *s_global;
00604 KateRenderer *m_renderer;
00605 };
00606
00607 #endif
00608
00609