21 #ifndef __KATE_HIGHLIGHT_H__
22 #define __KATE_HIGHLIGHT_H__
24 #include "katetextline.h"
25 #include "kateattribute.h"
27 #include "../interfaces/document.h"
29 #include <tdeconfig.h>
31 #include <tqptrlist.h>
32 #include <tqvaluelist.h>
33 #include <tqvaluevector.h>
36 #include <tqintdict.h>
39 #include <tqstringlist.h>
40 #include <tqguardedptr.h>
41 #include <tqdatetime.h>
42 #include <tqpopupmenu.h>
48 class KateEmbeddedHlInfo;
49 class KateHlIncludeRule;
56 typedef TQPtrList<KateAttribute> KateAttributeList;
57 typedef TQValueList<KateHlIncludeRule*> KateHlIncludeRules;
58 typedef TQPtrList<KateHlItemData> KateHlItemDataList;
59 typedef TQPtrList<KateHlData> KateHlDataList;
60 typedef TQMap<TQString,KateEmbeddedHlInfo> KateEmbeddedHlInfos;
61 typedef TQMap<int*,TQString> KateHlUnresolvedCtxRefs;
62 typedef TQValueList<int> IntList;
68 KateHlItemData(
const TQString name,
int defStyleNum);
94 KateHlData(
const TQString &wildcards,
const TQString &mimetypes,
const TQString &identifier,
int priority);
103 class KateHighlighting
112 TQMemArray<uint> *foldingList,
115 void loadWildcards();
116 TQValueList<TQRegExp>& getRegexpExtensions();
117 TQStringList& getPlainExtensions();
119 TQString getMimetypes();
122 KateHlData *getData();
123 void setData(KateHlData *);
125 void setKateHlItemDataList(uint schema, KateHlItemDataList &);
130 void getKateHlItemDataListCopy (uint schema, KateHlItemDataList &);
132 const TQString &
name()
const {
return iName;}
133 const TQString &nameTranslated()
const {
return iNameTranslated;}
134 const TQString §ion()
const {
return iSection;}
135 bool hidden()
const {
return iHidden;}
136 const TQString &
version()
const {
return iVersion;}
137 const TQString &author ()
const {
return iAuthor; }
138 const TQString &license ()
const {
return iLicense; }
140 const TQString &getIdentifier()
const {
return identifier;}
148 bool isInWord( TQChar c,
int attrib=0 )
const;
154 bool canBreakAt( TQChar c,
int attrib=0 )
const;
160 bool canComment(
int startAttr,
int endAttr )
const;
166 signed char commentRegion(
int attr)
const;
172 TQString getCommentStart(
int attrib=0 )
const;
178 TQString getCommentEnd(
int attrib=0 )
const;
184 TQString getCommentSingleLineStart(
int attrib=0 )
const;
190 enum CSLPos { CSLPosColumn0=0,CSLPosAfterWhitespace=1};
196 CSLPos getCommentSingleLinePosition(
int attrib=0 )
const;
201 int attribute(
int context )
const;
207 TQString hlKeyForAttrib(
int attrib )
const;
210 void clearAttributeArrays ();
212 TQMemArray<KateAttribute> *attributes (uint schema);
214 inline bool noHighlighting ()
const {
return noHl; };
217 void dropDynamicContexts();
219 TQString indentation () {
return m_indentation; }
223 void getKateHlItemDataList(uint schema, KateHlItemDataList &);
227 void makeContextList ();
228 int makeDynamicContext(KateHlContext *model,
const TQStringList *args);
229 void handleKateHlIncludeRules ();
230 void handleKateHlIncludeRulesRecursive(KateHlIncludeRules::iterator it, KateHlIncludeRules *list);
231 int addToContextList(
const TQString &ident,
int ctx0);
232 void addToKateHlItemDataList();
233 void createKateHlItemData (KateHlItemDataList &list);
234 void readGlobalKeywordConfig();
235 void readWordWrapConfig();
236 void readCommentConfig();
237 void readIndentationConfig ();
238 void readFoldingConfig ();
241 void generateContextStack(
int *ctxNum,
int ctx, TQMemArray<short> *ctxs,
int *posPrevLine);
243 KateHlItem *createKateHlItem(
KateSyntaxContextData *data, KateHlItemDataList &iDl, TQStringList *RegionList, TQStringList *ContextList);
244 int lookupAttrName(
const TQString& name, KateHlItemDataList &iDl);
246 void createContextNameList(TQStringList *ContextNameList,
int ctx0);
247 int getIdFromString(TQStringList *ContextNameList, TQString tmpLineEndContext, TQString &unres);
249 KateHlItemDataList internalIDList;
251 TQValueVector<KateHlContext*> m_contexts;
252 inline KateHlContext *contextNum (uint n) {
if (n < m_contexts.size())
return m_contexts[n];
return 0; }
254 TQMap< TQPair<KateHlContext *, TQString>,
short> dynamicCtxs;
257 KateEmbeddedHlInfos embeddedHls;
258 KateHlUnresolvedCtxRefs unresolvedContextReferences;
259 TQStringList RegionList;
260 TQStringList ContextNameList;
265 TQString weakDeliminator;
266 TQString deliminator;
269 TQString iNameTranslated;
278 TQString m_indentation;
281 int startctx, base_startctx;
283 TQString errorsAndWarnings;
284 TQString buildIdentifier;
285 TQString buildPrefix;
288 uint buildContext0Offset;
289 KateHlIncludeRules includeRules;
290 bool m_foldingIndentationSensitive;
292 TQIntDict< TQMemArray<KateAttribute> > m_attributeArrays;
307 class HighlightPropertyBag {
309 TQString singleLineCommentMarker;
310 TQString multiLineCommentStart;
311 TQString multiLineCommentEnd;
312 TQString multiLineRegion;
313 CSLPos singleLineCommentPosition;
314 TQString deliminator;
315 TQString wordWrapDeliminator;
322 TQDict<HighlightPropertyBag> m_additionalData;
329 TQMap<int, TQString> m_hlIndex;
332 TQString extensionSource;
333 TQValueList<TQRegExp> regexpExtensions;
334 TQStringList plainExtensions;
337 inline bool foldingIndentationSensitive () {
return m_foldingIndentationSensitive; }
338 inline bool allowsFolding(){
return folding;}
341 class KateHlManager :
public TQObject
351 static KateHlManager *
self();
353 inline TDEConfig *getTDEConfig() {
return &m_config; };
355 KateHighlighting *getHl(
int n);
356 int nameFind(
const TQString &name);
358 int detectHighlighting (
class KateDocument *doc);
360 int findHl(KateHighlighting *h) {
return hlList.find(h);}
361 TQString identifierForName(
const TQString&);
364 static uint defaultStyles();
365 static TQString defaultStyleName(
int n,
bool translateNames =
false);
367 void getDefaults(uint schema, KateAttributeList &);
368 void setDefaults(uint schema, KateAttributeList &);
371 TQString hlName(
int n);
372 TQString hlNameTranslated (
int n);
373 TQString hlSection(
int n);
374 bool hlHidden(
int n);
376 void incDynamicCtxs() { ++dynamicCtxsCount; };
377 uint countDynamicCtxs() {
return dynamicCtxsCount; };
378 void setForceNoDCReset(
bool b) { forceNoDCReset = b; };
381 bool resetDynamicCtxs();
387 int wildcardFind(
const TQString &fileName);
388 int mimeFind(KateDocument *);
389 int realWildcardFind(
const TQString &fileName);
392 friend class KateHighlighting;
394 TQPtrList<KateHighlighting> hlList;
395 TQDict<KateHighlighting> hlDict;
397 static KateHlManager *s_self;
400 TQStringList commonSuffixes;
404 uint dynamicCtxsCount;
405 TQTime lastCtxsReset;
409 class KateViewHighlightAction:
public Kate::ActionMenu
414 KateViewHighlightAction(
const TQString& text, TQObject* parent = 0,
const char* name = 0)
415 :
Kate::ActionMenu(text, parent,
name) { init(); };
417 ~KateViewHighlightAction(){;};
424 TQGuardedPtr<Kate::Document> m_doc;
425 TQStringList subMenusName;
427 TQPtrList<TQPopupMenu> subMenus;
430 void slotAboutToShow();
433 void setHl (
int mode);
The Attribute class incorporates all text decorations supported by Kate.
Class holding the data around the current QDomElement.
Store and manage the information about Syntax Highlighting.
Information about each syntax hl Mode.
The KateTextLine represents a line of text.
This interface provides access to the Kate Document class.
Kate namespace All classes in this namespace must stay BC during one major release series (e....
TQString name(StdAccel id)