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 allowEolDetection () const;
00202 void setAllowEolDetection (bool on);
00203
00204 bool allowSimpleMode () const;
00205 void setAllowSimpleMode (bool on);
00206
00207 enum BackupFlags
00208 {
00209 LocalFiles=1,
00210 RemoteFiles=2
00211 };
00212
00213 uint backupFlags () const;
00214 void setBackupFlags (uint flags);
00215
00216 const QString &backupPrefix () const;
00217 void setBackupPrefix (const QString &prefix);
00218
00219 const QString &backupSuffix () const;
00220 void setBackupSuffix (const QString &suffix);
00221
00227 int searchDirConfigDepth () const;
00228
00229 void setSearchDirConfigDepth (int depth);
00230
00231 private:
00232 QString m_indentationMode;
00233 int m_indentationWidth;
00234 int m_tabWidth;
00235 uint m_tabHandling;
00236 uint m_configFlags;
00237 int m_wordWrapAt;
00238 bool m_wordWrap;
00239 bool m_pageUpDownMovesCursor;
00240 bool m_allowEolDetection;
00241 bool m_allowSimpleMode;
00242 int m_eol;
00243 uint m_backupFlags;
00244 int m_searchDirConfigDepth;
00245 KEncodingProber::ProberType m_proberTypeForEncodingAutoDetection;
00246 QString m_encoding;
00247 QString m_backupPrefix;
00248 QString m_backupSuffix;
00249
00250 bool m_tabWidthSet : 1;
00251 bool m_indentationWidthSet : 1;
00252 bool m_indentationModeSet : 1;
00253 bool m_wordWrapSet : 1;
00254 bool m_wordWrapAtSet : 1;
00255 bool m_pageUpDownMovesCursorSet : 1;
00256 uint m_configFlagsSet;
00257 bool m_encodingSet : 1;
00258 bool m_eolSet : 1;
00259 bool m_allowEolDetectionSet : 1;
00260 bool m_allowSimpleModeSet : 1;
00261 bool m_backupFlagsSet : 1;
00262 bool m_searchDirConfigDepthSet : 1;
00263 bool m_backupPrefixSet : 1;
00264 bool m_backupSuffixSet : 1;
00265
00266 private:
00267 static KateDocumentConfig *s_global;
00268 KateDocument *m_doc;
00269 };
00270
00271 class KateViewConfig : public KateConfig
00272 {
00273 private:
00274 friend class KateGlobal;
00275
00279 KateViewConfig ();
00280
00281 public:
00285 explicit KateViewConfig (KateView *view);
00286
00290 ~KateViewConfig ();
00291
00292 inline static KateViewConfig *global () { return s_global; }
00293
00294 inline bool isGlobal () const { return (this == global()); }
00295
00296 public:
00300 void readConfig (const KConfigGroup &config);
00301
00305 void writeConfig (KConfigGroup &config);
00306
00307 protected:
00308 void updateConfig ();
00309
00310 public:
00311 bool dynWordWrap () const;
00312 void setDynWordWrap (bool wrap);
00313
00314 int dynWordWrapIndicators () const;
00315 void setDynWordWrapIndicators (int mode);
00316
00317 int dynWordWrapAlignIndent () const;
00318 void setDynWordWrapAlignIndent (int indent);
00319
00320 bool lineNumbers () const;
00321 void setLineNumbers (bool on);
00322
00323 bool scrollBarMarks () const;
00324 void setScrollBarMarks (bool on);
00325
00326 bool iconBar () const;
00327 void setIconBar (bool on);
00328
00329 bool foldingBar () const;
00330 void setFoldingBar (bool on);
00331
00332 int bookmarkSort () const;
00333 void setBookmarkSort (int mode);
00334
00335 int autoCenterLines() const;
00336 void setAutoCenterLines (int lines);
00337
00338 enum SearchFlags {
00339 IncMatchCase = 1 << 0,
00340 IncHighlightAll = 1 << 1,
00341 IncFromCursor = 1 << 2,
00342 PowerMatchCase = 1 << 3,
00343 PowerHighlightAll = 1 << 4,
00344 PowerFromCursor = 1 << 5,
00345
00346 PowerModePlainText = 1 << 7,
00347 PowerModeWholeWords = 1 << 8,
00348 PowerModeEscapeSequences = 1 << 9,
00349 PowerModeRegularExpression = 1 << 10,
00350 PowerUsePlaceholders = 1 << 11
00351 };
00352
00353 long searchFlags () const;
00354 void setSearchFlags (long flags);
00355
00356 uint defaultMarkType () const;
00357 void setDefaultMarkType (uint type);
00358
00359 bool persistentSelection () const;
00360 void setPersistentSelection (bool on);
00361
00362 bool viInputMode () const;
00363 void setViInputMode (bool on);
00364
00365 bool viInputModeStealKeys () const;
00366 void setViInputModeStealKeys (bool on);
00367
00368 bool viInputModeHideStatusBar () const;
00369 void setViInputModeHideStatusBar (bool on);
00370
00371
00372 enum TextToSearch
00373 {
00374 Nowhere = 0,
00375 SelectionOnly = 1,
00376 SelectionWord = 2,
00377 WordOnly = 3,
00378 WordSelection = 4
00379 };
00380
00381 bool automaticCompletionInvocation () const;
00382 void setAutomaticCompletionInvocation (bool on);
00383
00384 bool wordCompletion () const;
00385 void setWordCompletion (bool on);
00386
00387 int wordCompletionMinimalWordLength () const;
00388 void setWordCompletionMinimalWordLength (int lenght);
00389
00390 private:
00391 bool m_dynWordWrap;
00392 int m_dynWordWrapIndicators;
00393 int m_dynWordWrapAlignIndent;
00394 bool m_lineNumbers;
00395 bool m_scrollBarMarks;
00396 bool m_iconBar;
00397 bool m_foldingBar;
00398 int m_bookmarkSort;
00399 int m_autoCenterLines;
00400 long m_searchFlags;
00401 uint m_defaultMarkType;
00402 bool m_persistentSelection;
00403 bool m_viInputMode;
00404 bool m_viInputModeStealKeys;
00405 bool m_viInputModeHideStatusBar;
00406 bool m_automaticCompletionInvocation;
00407 bool m_wordCompletion;
00408 int m_wordCompletionMinimalWordLength;
00409
00410 bool m_dynWordWrapSet : 1;
00411 bool m_dynWordWrapIndicatorsSet : 1;
00412 bool m_dynWordWrapAlignIndentSet : 1;
00413 bool m_lineNumbersSet : 1;
00414 bool m_scrollBarMarksSet : 1;
00415 bool m_iconBarSet : 1;
00416 bool m_foldingBarSet : 1;
00417 bool m_bookmarkSortSet : 1;
00418 bool m_autoCenterLinesSet : 1;
00419 bool m_searchFlagsSet : 1;
00420 bool m_defaultMarkTypeSet : 1;
00421 bool m_persistentSelectionSet : 1;
00422 bool m_viInputModeSet : 1;
00423 bool m_viInputModeStealKeysSet : 1;
00424 bool m_viInputModeHideStatusBarSet : 1;
00425 bool m_automaticCompletionInvocationSet : 1;
00426 bool m_wordCompletionSet : 1;
00427 bool m_wordCompletionMinimalWordLengthSet : 1;
00428
00429 private:
00430 static KateViewConfig *s_global;
00431 KateView *m_view;
00432 };
00433
00434 class KateRendererConfig : public KateConfig
00435 {
00436 private:
00437 friend class KateGlobal;
00438
00442 KateRendererConfig ();
00443
00444
00445 public:
00449 KateRendererConfig (KateRenderer *renderer);
00450
00454 ~KateRendererConfig ();
00455
00456 inline static KateRendererConfig *global () { return s_global; }
00457
00458 inline bool isGlobal () const { return (this == global()); }
00459
00460 public:
00464 void readConfig (const KConfigGroup &config);
00465
00469 void writeConfig (KConfigGroup &config);
00470
00471 protected:
00472 void updateConfig ();
00473
00474 public:
00475 const QString &schema () const;
00476 void setSchema (const QString &schema);
00482 void reloadSchema();
00483
00484 const QFont& font() const;
00485 const QFontMetrics& fontMetrics() const;
00486 void setFont(const QFont &font);
00487
00488 bool wordWrapMarker () const;
00489 void setWordWrapMarker (bool on);
00490
00491 const QColor& backgroundColor() const;
00492 void setBackgroundColor (const QColor &col);
00493
00494 const QColor& selectionColor() const;
00495 void setSelectionColor (const QColor &col);
00496
00497 const QColor& highlightedLineColor() const;
00498 void setHighlightedLineColor (const QColor &col);
00499
00500 const QColor& lineMarkerColor(KTextEditor::MarkInterface::MarkTypes type = KTextEditor::MarkInterface::markType01) const;
00501 void setLineMarkerColor (const QColor &col, KTextEditor::MarkInterface::MarkTypes type = KTextEditor::MarkInterface::markType01);
00502
00503 const QColor& highlightedBracketColor() const;
00504 void setHighlightedBracketColor (const QColor &col);
00505
00506 const QColor& wordWrapMarkerColor() const;
00507 void setWordWrapMarkerColor (const QColor &col);
00508
00509 const QColor& tabMarkerColor() const;
00510 void setTabMarkerColor (const QColor &col);
00511
00512 const QColor& iconBarColor() const;
00513 void setIconBarColor (const QColor &col);
00514
00515
00516
00517 const QColor& lineNumberColor() const;
00518 void setLineNumberColor (const QColor &col);
00519
00520 bool showIndentationLines () const;
00521 void setShowIndentationLines (bool on);
00522
00523 bool showWholeBracketExpression () const;
00524 void setShowWholeBracketExpression (bool on);
00525
00526 const QColor &templateBackgroundColor() const;
00527 const QColor &templateEditablePlaceholderColor() const;
00528 const QColor &templateFocusedEditablePlaceholderColor() const;
00529 const QColor &templateNotEditablePlaceholderColor() const;
00530
00531
00532 private:
00536 void setSchemaInternal(const QString &schema);
00537
00538 QString m_schema;
00539 QFont m_font;
00540 QFontMetrics m_fontMetrics;
00541 bool m_wordWrapMarker;
00542 bool m_showIndentationLines;
00543 bool m_showWholeBracketExpression;
00544 QColor m_backgroundColor;
00545 QColor m_selectionColor;
00546 QColor m_highlightedLineColor;
00547 QColor m_highlightedBracketColor;
00548 QColor m_wordWrapMarkerColor;
00549 QColor m_tabMarkerColor;
00550 QColor m_iconBarColor;
00551 QColor m_lineNumberColor;
00552 QVector<QColor> m_lineMarkerColor;
00553
00554 QColor m_templateBackgroundColor;
00555 QColor m_templateEditablePlaceholderColor;
00556 QColor m_templateFocusedEditablePlaceholderColor;
00557 QColor m_templateNotEditablePlaceholderColor;
00558
00559
00560 bool m_schemaSet : 1;
00561 bool m_fontSet : 1;
00562 bool m_wordWrapMarkerSet : 1;
00563 bool m_showIndentationLinesSet : 1;
00564 bool m_showWholeBracketExpressionSet : 1;
00565 bool m_backgroundColorSet : 1;
00566 bool m_selectionColorSet : 1;
00567 bool m_highlightedLineColorSet : 1;
00568 bool m_highlightedBracketColorSet : 1;
00569 bool m_wordWrapMarkerColorSet : 1;
00570 bool m_tabMarkerColorSet : 1;
00571 bool m_iconBarColorSet : 1;
00572 bool m_lineNumberColorSet : 1;
00573 bool m_templateColorsSet : 1;
00574 QBitArray m_lineMarkerColorSet;
00575
00576 private:
00577 static KateRendererConfig *s_global;
00578 KateRenderer *m_renderer;
00579 };
00580
00581 #endif
00582
00583