kate Library API Documentation

katehighlight.h

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001,2002 Joseph Wenninger <jowenn@kde.org> 00003 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> 00004 Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef _KATE_HIGHLIGHT_H_ 00022 #define _KATE_HIGHLIGHT_H_ 00023 00024 #include "katetextline.h" 00025 #include "kateattribute.h" 00026 00027 #include "../interfaces/document.h" 00028 00029 #include <kconfig.h> 00030 00031 #include <qptrlist.h> 00032 #include <qvaluelist.h> 00033 #include <qregexp.h> 00034 #include <qdict.h> 00035 #include <qintdict.h> 00036 #include <qmap.h> 00037 #include <qobject.h> 00038 #include <qstringlist.h> 00039 #include <qguardedptr.h> 00040 00041 class HlContext; 00042 class HlItem; 00043 class ItemData; 00044 class HlData; 00045 class EmbeddedHlInfo; 00046 class IncludeRule; 00047 class SyntaxDocument; 00048 class TextLine; 00049 struct syntaxModeListItem; 00050 struct syntaxContextData; 00051 00052 class QPopupMenu; 00053 00054 // some typedefs 00055 typedef QPtrList<KateAttribute> KateAttributeList; 00056 typedef QValueList<IncludeRule*> IncludeRules; 00057 typedef QPtrList<ItemData> ItemDataList; 00058 typedef QPtrList<HlData> HlDataList; 00059 typedef QMap<QString,EmbeddedHlInfo> EmbeddedHlInfos; 00060 typedef QMap<int*,QString> UnresolvedContextReferences; 00061 00062 //Item Properties: name, Item Style, Item Font 00063 class ItemData : public KateAttribute 00064 { 00065 public: 00066 ItemData(const QString name, int defStyleNum); 00067 00068 public: 00069 const QString name; 00070 int defStyleNum; 00071 }; 00072 00073 class HlData 00074 { 00075 public: 00076 HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier, int priority); 00077 00078 public: 00079 QString wildcards; 00080 QString mimetypes; 00081 QString identifier; 00082 int priority; 00083 }; 00084 00085 class Highlight 00086 { 00087 public: 00088 Highlight(const syntaxModeListItem *def); 00089 ~Highlight(); 00090 00091 public: 00092 void doHighlight(QMemArray<short> oCtx, TextLine *,bool lineContinue,QMemArray<signed char> *foldingList); 00093 00094 void loadWildcards(); 00095 QValueList<QRegExp>& getRegexpExtensions(); 00096 QStringList& getPlainExtensions(); 00097 00098 QString getMimetypes(); 00099 00100 // this pointer needs to be deleted !!!!!!!!!! 00101 HlData *getData(); 00102 void setData(HlData *); 00103 00104 void setItemDataList(uint schema, ItemDataList &); 00105 00106 // both methodes return hard copies of the internal lists 00107 // the lists are cleared first + autodelete is set ! 00108 // keep track that you delete them, or mem will be lost 00109 void getItemDataListCopy (uint schema, ItemDataList &); 00110 00111 inline QString name() const {return iName;} 00112 inline QString section() const {return iSection;} 00113 inline QString version() const {return iVersion;} 00114 int priority(); 00115 inline QString getIdentifier() const {return identifier;} 00116 void use(); 00117 void release(); 00118 bool isInWord(QChar c); 00119 00120 inline QString getCommentStart() const {return cmlStart;}; 00121 inline QString getCommentEnd() const {return cmlEnd;}; 00122 inline QString getCommentSingleLineStart() const { return cslStart;}; 00123 00124 void clearAttributeArrays (); 00125 00126 QMemArray<KateAttribute> *attributes (uint schema); 00127 00128 private: 00129 // make this private, nobody should play with the internal data pointers 00130 void getItemDataList(uint schema, ItemDataList &); 00131 00132 void init(); 00133 void done(); 00134 void makeContextList (); 00135 void handleIncludeRules (); 00136 void handleIncludeRulesRecursive(IncludeRules::iterator it, IncludeRules *list); 00137 int addToContextList(const QString &ident, int ctx0); 00138 void addToItemDataList(); 00139 void createItemData (ItemDataList &list); 00140 void readGlobalKeywordConfig(); 00141 void readCommentConfig(); 00142 void readFoldingConfig (); 00143 00144 // manipulates the ctxs array directly ;) 00145 void generateContextStack(int *ctxNum, int ctx, QMemArray<short> *ctxs, int *posPrevLine,bool lineContinue=false); 00146 00147 HlItem *createHlItem(struct syntaxContextData *data, ItemDataList &iDl, QStringList *RegionList, QStringList *ContextList); 00148 int lookupAttrName(const QString& name, ItemDataList &iDl); 00149 00150 void createContextNameList(QStringList *ContextNameList, int ctx0); 00151 int getIdFromString(QStringList *ContextNameList, QString tmpLineEndContext,/*NO CONST*/ QString &unres); 00152 00153 ItemDataList internalIDList; 00154 00155 QIntDict<HlContext> contextList; 00156 HlContext *contextNum (uint n); 00157 00158 // make them pointers perhaps 00159 EmbeddedHlInfos embeddedHls; 00160 UnresolvedContextReferences unresolvedContextReferences; 00161 QStringList RegionList; 00162 QStringList ContextNameList; 00163 00164 bool noHl; 00165 bool folding; 00166 bool casesensitive; 00167 QString weakDeliminator; 00168 QString deliminator; 00169 00170 QString cmlStart; 00171 QString cmlEnd; 00172 QString cslStart; 00173 QString iName; 00174 QString iSection; 00175 QString iWildcards; 00176 QString iMimetypes; 00177 QString identifier; 00178 QString iVersion; 00179 int m_priority; 00180 int refCount; 00181 00182 QString errorsAndWarnings; 00183 QString buildIdentifier; 00184 QString buildPrefix; 00185 bool building; 00186 uint itemData0; 00187 uint buildContext0Offset; 00188 IncludeRules includeRules; 00189 QValueList<int> contextsIncludingSomething; 00190 bool m_foldingIndentationSensitive; 00191 00192 QIntDict< QMemArray<KateAttribute> > m_attributeArrays; 00193 00194 QString extensionSource; 00195 QValueList<QRegExp> regexpExtensions; 00196 QStringList plainExtensions; 00197 00198 public: 00199 inline bool foldingIndentationSensitive () { return m_foldingIndentationSensitive; } 00200 inline bool allowsFolding(){return folding;} 00201 }; 00202 00203 class HlManager : public QObject 00204 { 00205 Q_OBJECT 00206 00207 private: 00208 HlManager(); 00209 00210 public: 00211 ~HlManager(); 00212 00213 static HlManager *self(); 00214 00215 inline KConfig *getKConfig() { return &m_config; }; 00216 00217 Highlight *getHl(int n); 00218 int nameFind(const QString &name); 00219 00220 int detectHighlighting (class KateDocument *doc); 00221 00222 int findHl(Highlight *h) {return hlList.find(h);} 00223 QString identifierForName(const QString&); 00224 00225 // methodes to get the default style count + names 00226 static uint defaultStyles(); 00227 static QString defaultStyleName(int n); 00228 00229 void getDefaults(uint schema, KateAttributeList &); 00230 void setDefaults(uint schema, KateAttributeList &); 00231 00232 int highlights(); 00233 QString hlName(int n); 00234 QString hlSection(int n); 00235 00236 signals: 00237 void changed(); 00238 00239 private: 00240 int wildcardFind(const QString &fileName); 00241 int mimeFind(const QByteArray &contents); 00242 int realWildcardFind(const QString &fileName); 00243 00244 private: 00245 friend class Highlight; 00246 00247 QPtrList<Highlight> hlList; 00248 QDict<Highlight> hlDict; 00249 00250 static HlManager *s_self; 00251 00252 KConfig m_config; 00253 QStringList commonSuffixes; 00254 00255 SyntaxDocument *syntax; 00256 }; 00257 00258 class KateViewHighlightAction: public Kate::ActionMenu 00259 { 00260 Q_OBJECT 00261 00262 public: 00263 KateViewHighlightAction(const QString& text, QObject* parent = 0, const char* name = 0) 00264 : Kate::ActionMenu(text, parent, name) { init(); }; 00265 00266 ~KateViewHighlightAction(){;}; 00267 00268 void updateMenu (Kate::Document *doc); 00269 00270 private: 00271 void init(); 00272 00273 QGuardedPtr<Kate::Document> m_doc; 00274 QStringList subMenusName; 00275 QStringList names; 00276 QPtrList<QPopupMenu> subMenus; 00277 00278 public slots: 00279 void slotAboutToShow(); 00280 00281 private slots: 00282 void setHl (int mode); 00283 }; 00284 00285 #endif //_HIGHLIGHT_H_ 00286 00287 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE Logo
This file is part of the documentation for kate Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 8 11:16:26 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003