• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

kateconfig.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2003 Christoph Cullmann <cullmann@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef __KATE_CONFIG_H__
00020 #define __KATE_CONFIG_H__
00021 
00022 #include <ktexteditor/markinterface.h>
00023 #include <kencodingdetector.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     KEncodingDetector::AutoDetectScript encodingAutoDetectionScript() const;
00187     void setEncodingAutoDetectionScript(KEncodingDetector::AutoDetectScript);
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     KEncodingDetector::AutoDetectScript m_scriptForEncodingAutoDetection;
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       // PowerSelectionOnly = 1 << 6, Better not save to file // Sebastian
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     // Do we still need the enum and related functions below?
00363     enum TextToSearch
00364     {
00365       Nowhere = 0,
00366       SelectionOnly = 1,
00367       SelectionWord = 2,
00368       WordOnly = 3,
00369       WordSelection = 4
00370     };
00371 
00372     bool automaticCompletionInvocation () const;
00373     void setAutomaticCompletionInvocation (bool on);
00374 
00375   private:
00376     bool m_dynWordWrap;
00377     int m_dynWordWrapIndicators;
00378     int m_dynWordWrapAlignIndent;
00379     bool m_lineNumbers;
00380     bool m_scrollBarMarks;
00381     bool m_iconBar;
00382     bool m_foldingBar;
00383     int m_bookmarkSort;
00384     int m_autoCenterLines;
00385     long m_searchFlags;
00386     uint m_defaultMarkType;
00387     bool m_persistentSelection;
00388     bool m_automaticCompletionInvocation;
00389 
00390     bool m_dynWordWrapSet : 1;
00391     bool m_dynWordWrapIndicatorsSet : 1;
00392     bool m_dynWordWrapAlignIndentSet : 1;
00393     bool m_lineNumbersSet : 1;
00394     bool m_scrollBarMarksSet : 1;
00395     bool m_iconBarSet : 1;
00396     bool m_foldingBarSet : 1;
00397     bool m_bookmarkSortSet : 1;
00398     bool m_autoCenterLinesSet : 1;
00399     bool m_searchFlagsSet : 1;
00400     bool m_defaultMarkTypeSet : 1;
00401     bool m_persistentSelectionSet : 1;
00402     bool m_automaticCompletionInvocationSet : 1;
00403 
00404   private:
00405     static KateViewConfig *s_global;
00406     KateView *m_view;
00407 };
00408 
00409 class KateRendererConfig : public KateConfig
00410 {
00411   private:
00412     friend class KateGlobal;
00413 
00417     KateRendererConfig ();
00418 
00419 
00420   public:
00424     KateRendererConfig (KateRenderer *renderer);
00425 
00429     ~KateRendererConfig ();
00430 
00431     inline static KateRendererConfig *global () { return s_global; }
00432 
00433     inline bool isGlobal () const { return (this == global()); }
00434 
00435   public:
00439     void readConfig (const KConfigGroup &config);
00440 
00444     void writeConfig (KConfigGroup &config);
00445 
00446   protected:
00447     void updateConfig ();
00448 
00449   public:
00450     const QString &schema () const;
00451     void setSchema (const QString &schema);
00457     void reloadSchema();
00458 
00459     const QFont& font() const;
00460     const QFontMetrics& fontMetrics() const;
00461     void setFont(const QFont &font);
00462 
00463     bool wordWrapMarker () const;
00464     void setWordWrapMarker (bool on);
00465 
00466     const QColor& backgroundColor() const;
00467     void setBackgroundColor (const QColor &col);
00468 
00469     const QColor& selectionColor() const;
00470     void setSelectionColor (const QColor &col);
00471 
00472     const QColor& highlightedLineColor() const;
00473     void setHighlightedLineColor (const QColor &col);
00474 
00475     const QColor& lineMarkerColor(KTextEditor::MarkInterface::MarkTypes type = KTextEditor::MarkInterface::markType01) const; // markType01 == Bookmark
00476     void setLineMarkerColor (const QColor &col, KTextEditor::MarkInterface::MarkTypes type = KTextEditor::MarkInterface::markType01);
00477 
00478     const QColor& highlightedBracketColor() const;
00479     void setHighlightedBracketColor (const QColor &col);
00480 
00481     const QColor& wordWrapMarkerColor() const;
00482     void setWordWrapMarkerColor (const QColor &col);
00483 
00484     const QColor& tabMarkerColor() const;
00485     void setTabMarkerColor (const QColor &col);
00486 
00487     const QColor& iconBarColor() const;
00488     void setIconBarColor (const QColor &col);
00489 
00490     // the line number color is used for the line numbers on the left bar and
00491     // for vertical separator lines and for code folding lines.
00492     const QColor& lineNumberColor() const;
00493     void setLineNumberColor (const QColor &col);
00494 
00495     bool showIndentationLines () const;
00496     void setShowIndentationLines (bool on);
00497 
00498     bool showWholeBracketExpression () const;
00499     void setShowWholeBracketExpression (bool on);
00500 
00501     const QColor &templateBackgroundColor() const;
00502     const QColor &templateEditablePlaceholderColor() const;
00503     const QColor &templateFocusedEditablePlaceholderColor() const;
00504     const QColor &templateNotEditablePlaceholderColor() const;
00505 
00506 
00507   private:
00511     void setSchemaInternal(const QString &schema);
00512 
00513     QString m_schema;
00514     QFont m_font;
00515     QFontMetrics m_fontMetrics;
00516     bool m_wordWrapMarker;
00517     bool m_showIndentationLines;
00518     bool m_showWholeBracketExpression;
00519     QColor m_backgroundColor;
00520     QColor m_selectionColor;
00521     QColor m_highlightedLineColor;
00522     QColor m_highlightedBracketColor;
00523     QColor m_wordWrapMarkerColor;
00524     QColor m_tabMarkerColor;
00525     QColor m_iconBarColor;
00526     QColor m_lineNumberColor;
00527     QVector<QColor> m_lineMarkerColor;
00528 
00529     QColor m_templateBackgroundColor;
00530     QColor m_templateEditablePlaceholderColor;
00531     QColor m_templateFocusedEditablePlaceholderColor;
00532     QColor m_templateNotEditablePlaceholderColor;
00533 
00534 
00535     bool m_schemaSet : 1;
00536     bool m_fontSet : 1;
00537     bool m_wordWrapMarkerSet : 1;
00538     bool m_showIndentationLinesSet : 1;
00539     bool m_showWholeBracketExpressionSet : 1;
00540     bool m_backgroundColorSet : 1;
00541     bool m_selectionColorSet : 1;
00542     bool m_highlightedLineColorSet : 1;
00543     bool m_highlightedBracketColorSet : 1;
00544     bool m_wordWrapMarkerColorSet : 1;
00545     bool m_tabMarkerColorSet : 1;
00546     bool m_iconBarColorSet : 1;
00547     bool m_lineNumberColorSet : 1;
00548     bool m_templateColorsSet : 1;
00549     QBitArray m_lineMarkerColorSet;
00550 
00551   private:
00552     static KateRendererConfig *s_global;
00553     KateRenderer *m_renderer;
00554 };
00555 
00556 #endif
00557 
00558 // kate: space-indent on; indent-width 2; replace-tabs on;

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal