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 private:
00385 bool m_dynWordWrap;
00386 int m_dynWordWrapIndicators;
00387 int m_dynWordWrapAlignIndent;
00388 bool m_lineNumbers;
00389 bool m_scrollBarMarks;
00390 bool m_iconBar;
00391 bool m_foldingBar;
00392 int m_bookmarkSort;
00393 int m_autoCenterLines;
00394 long m_searchFlags;
00395 uint m_defaultMarkType;
00396 bool m_persistentSelection;
00397 bool m_viInputMode;
00398 bool m_viInputModeStealKeys;
00399 bool m_viInputModeHideStatusBar;
00400 bool m_automaticCompletionInvocation;
00401
00402 bool m_dynWordWrapSet : 1;
00403 bool m_dynWordWrapIndicatorsSet : 1;
00404 bool m_dynWordWrapAlignIndentSet : 1;
00405 bool m_lineNumbersSet : 1;
00406 bool m_scrollBarMarksSet : 1;
00407 bool m_iconBarSet : 1;
00408 bool m_foldingBarSet : 1;
00409 bool m_bookmarkSortSet : 1;
00410 bool m_autoCenterLinesSet : 1;
00411 bool m_searchFlagsSet : 1;
00412 bool m_defaultMarkTypeSet : 1;
00413 bool m_persistentSelectionSet : 1;
00414 bool m_viInputModeSet : 1;
00415 bool m_viInputModeStealKeysSet : 1;
00416 bool m_viInputModeHideStatusBarSet : 1;
00417 bool m_automaticCompletionInvocationSet : 1;
00418
00419 private:
00420 static KateViewConfig *s_global;
00421 KateView *m_view;
00422 };
00423
00424 class KateRendererConfig : public KateConfig
00425 {
00426 private:
00427 friend class KateGlobal;
00428
00432 KateRendererConfig ();
00433
00434
00435 public:
00439 KateRendererConfig (KateRenderer *renderer);
00440
00444 ~KateRendererConfig ();
00445
00446 inline static KateRendererConfig *global () { return s_global; }
00447
00448 inline bool isGlobal () const { return (this == global()); }
00449
00450 public:
00454 void readConfig (const KConfigGroup &config);
00455
00459 void writeConfig (KConfigGroup &config);
00460
00461 protected:
00462 void updateConfig ();
00463
00464 public:
00465 const QString &schema () const;
00466 void setSchema (const QString &schema);
00472 void reloadSchema();
00473
00474 const QFont& font() const;
00475 const QFontMetrics& fontMetrics() const;
00476 void setFont(const QFont &font);
00477
00478 bool wordWrapMarker () const;
00479 void setWordWrapMarker (bool on);
00480
00481 const QColor& backgroundColor() const;
00482 void setBackgroundColor (const QColor &col);
00483
00484 const QColor& selectionColor() const;
00485 void setSelectionColor (const QColor &col);
00486
00487 const QColor& highlightedLineColor() const;
00488 void setHighlightedLineColor (const QColor &col);
00489
00490 const QColor& lineMarkerColor(KTextEditor::MarkInterface::MarkTypes type = KTextEditor::MarkInterface::markType01) const;
00491 void setLineMarkerColor (const QColor &col, KTextEditor::MarkInterface::MarkTypes type = KTextEditor::MarkInterface::markType01);
00492
00493 const QColor& highlightedBracketColor() const;
00494 void setHighlightedBracketColor (const QColor &col);
00495
00496 const QColor& wordWrapMarkerColor() const;
00497 void setWordWrapMarkerColor (const QColor &col);
00498
00499 const QColor& tabMarkerColor() const;
00500 void setTabMarkerColor (const QColor &col);
00501
00502 const QColor& iconBarColor() const;
00503 void setIconBarColor (const QColor &col);
00504
00505
00506
00507 const QColor& lineNumberColor() const;
00508 void setLineNumberColor (const QColor &col);
00509
00510 bool showIndentationLines () const;
00511 void setShowIndentationLines (bool on);
00512
00513 bool showWholeBracketExpression () const;
00514 void setShowWholeBracketExpression (bool on);
00515
00516 const QColor &templateBackgroundColor() const;
00517 const QColor &templateEditablePlaceholderColor() const;
00518 const QColor &templateFocusedEditablePlaceholderColor() const;
00519 const QColor &templateNotEditablePlaceholderColor() const;
00520
00521
00522 private:
00526 void setSchemaInternal(const QString &schema);
00527
00528 QString m_schema;
00529 QFont m_font;
00530 QFontMetrics m_fontMetrics;
00531 bool m_wordWrapMarker;
00532 bool m_showIndentationLines;
00533 bool m_showWholeBracketExpression;
00534 QColor m_backgroundColor;
00535 QColor m_selectionColor;
00536 QColor m_highlightedLineColor;
00537 QColor m_highlightedBracketColor;
00538 QColor m_wordWrapMarkerColor;
00539 QColor m_tabMarkerColor;
00540 QColor m_iconBarColor;
00541 QColor m_lineNumberColor;
00542 QVector<QColor> m_lineMarkerColor;
00543
00544 QColor m_templateBackgroundColor;
00545 QColor m_templateEditablePlaceholderColor;
00546 QColor m_templateFocusedEditablePlaceholderColor;
00547 QColor m_templateNotEditablePlaceholderColor;
00548
00549
00550 bool m_schemaSet : 1;
00551 bool m_fontSet : 1;
00552 bool m_wordWrapMarkerSet : 1;
00553 bool m_showIndentationLinesSet : 1;
00554 bool m_showWholeBracketExpressionSet : 1;
00555 bool m_backgroundColorSet : 1;
00556 bool m_selectionColorSet : 1;
00557 bool m_highlightedLineColorSet : 1;
00558 bool m_highlightedBracketColorSet : 1;
00559 bool m_wordWrapMarkerColorSet : 1;
00560 bool m_tabMarkerColorSet : 1;
00561 bool m_iconBarColorSet : 1;
00562 bool m_lineNumberColorSet : 1;
00563 bool m_templateColorsSet : 1;
00564 QBitArray m_lineMarkerColorSet;
00565
00566 private:
00567 static KateRendererConfig *s_global;
00568 KateRenderer *m_renderer;
00569 };
00570
00571 #endif
00572
00573