• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
katehighlight.h
1/* This file is part of the KDE libraries
2 Copyright (C) 2001,2002 Joseph Wenninger <jowenn@kde.org>
3 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
4 Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef __KATE_HIGHLIGHT_H__
22#define __KATE_HIGHLIGHT_H__
23
24#include "katetextline.h"
25#include "kateattribute.h"
26
27#include "../interfaces/document.h"
28
29#include <tdeconfig.h>
30
31#include <tqptrlist.h>
32#include <tqvaluelist.h>
33#include <tqvaluevector.h>
34#include <tqregexp.h>
35#include <tqdict.h>
36#include <tqintdict.h>
37#include <tqmap.h>
38#include <tqobject.h>
39#include <tqstringlist.h>
40#include <tqguardedptr.h>
41#include <tqdatetime.h>
42#include <tqpopupmenu.h>
43
44class KateHlContext;
45class KateHlItem;
46class KateHlItemData;
47class KateHlData;
48class KateEmbeddedHlInfo;
49class KateHlIncludeRule;
50class KateSyntaxDocument;
51class KateTextLine;
52class KateSyntaxModeListItem;
53class KateSyntaxContextData;
54
55// some typedefs
56typedef TQPtrList<KateAttribute> KateAttributeList;
57typedef TQValueList<KateHlIncludeRule*> KateHlIncludeRules;
58typedef TQPtrList<KateHlItemData> KateHlItemDataList;
59typedef TQPtrList<KateHlData> KateHlDataList;
60typedef TQMap<TQString,KateEmbeddedHlInfo> KateEmbeddedHlInfos;
61typedef TQMap<int*,TQString> KateHlUnresolvedCtxRefs;
62typedef TQValueList<int> IntList;
63
64//Item Properties: name, Item Style, Item Font
65class KateHlItemData : public KateAttribute
66{
67 public:
68 KateHlItemData(const TQString name, int defStyleNum);
69
70 enum ItemStyles {
71 dsNormal,
72 dsKeyword,
73 dsDataType,
74 dsDecVal,
75 dsBaseN,
76 dsFloat,
77 dsChar,
78 dsString,
79 dsComment,
80 dsOthers,
81 dsAlert,
82 dsFunction,
83 dsRegionMarker,
84 dsError };
85
86 public:
87 const TQString name;
88 int defStyleNum;
89};
90
91class KateHlData
92{
93 public:
94 KateHlData(const TQString &wildcards, const TQString &mimetypes,const TQString &identifier, int priority);
95
96 public:
97 TQString wildcards;
98 TQString mimetypes;
99 TQString identifier;
100 int priority;
101};
102
103class KateHighlighting
104{
105 public:
106 KateHighlighting(const KateSyntaxModeListItem *def);
107 ~KateHighlighting();
108
109 public:
110 void doHighlight ( KateTextLine *prevLine,
111 KateTextLine *textLine,
112 TQMemArray<uint> *foldingList,
113 bool *ctxChanged );
114
115 void loadWildcards();
116 TQValueList<TQRegExp>& getRegexpExtensions();
117 TQStringList& getPlainExtensions();
118
119 TQString getMimetypes();
120
121 // this pointer needs to be deleted !!!!!!!!!!
122 KateHlData *getData();
123 void setData(KateHlData *);
124
125 void setKateHlItemDataList(uint schema, KateHlItemDataList &);
126
127 // both methodes return hard copies of the internal lists
128 // the lists are cleared first + autodelete is set !
129 // keep track that you delete them, or mem will be lost
130 void getKateHlItemDataListCopy (uint schema, KateHlItemDataList &);
131
132 const TQString &name() const {return iName;}
133 const TQString &nameTranslated() const {return iNameTranslated;}
134 const TQString &section() 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; }
139 int priority();
140 const TQString &getIdentifier() const {return identifier;}
141 void use();
142 void release();
143
148 bool isInWord( TQChar c, int attrib=0 ) const;
149
154 bool canBreakAt( TQChar c, int attrib=0 ) const;
155
160 bool canComment( int startAttr, int endAttr ) const;
161
166 signed char commentRegion(int attr) const;
167
172 TQString getCommentStart( int attrib=0 ) const;
173
178 TQString getCommentEnd( int attrib=0 ) const;
179
184 TQString getCommentSingleLineStart( int attrib=0 ) const;
185
186
190 enum CSLPos { CSLPosColumn0=0,CSLPosAfterWhitespace=1};
191
196 CSLPos getCommentSingleLinePosition( int attrib=0 ) const;
197
201 int attribute( int context ) const;
202
207 TQString hlKeyForAttrib( int attrib ) const;
208
209
210 void clearAttributeArrays ();
211
212 TQMemArray<KateAttribute> *attributes (uint schema);
213
214 inline bool noHighlighting () const { return noHl; };
215
216 // be carefull: all documents hl should be invalidated after calling this method!
217 void dropDynamicContexts();
218
219 TQString indentation () { return m_indentation; }
220
221 private:
222 // make this private, nobody should play with the internal data pointers
223 void getKateHlItemDataList(uint schema, KateHlItemDataList &);
224
225 void init();
226 void done();
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 ();
239
240 // manipulates the ctxs array directly ;)
241 void generateContextStack(int *ctxNum, int ctx, TQMemArray<short> *ctxs, int *posPrevLine);
242
243 KateHlItem *createKateHlItem(KateSyntaxContextData *data, KateHlItemDataList &iDl, TQStringList *RegionList, TQStringList *ContextList);
244 int lookupAttrName(const TQString& name, KateHlItemDataList &iDl);
245
246 void createContextNameList(TQStringList *ContextNameList, int ctx0);
247 int getIdFromString(TQStringList *ContextNameList, TQString tmpLineEndContext,/*NO CONST*/ TQString &unres);
248
249 KateHlItemDataList internalIDList;
250
251 TQValueVector<KateHlContext*> m_contexts;
252 inline KateHlContext *contextNum (uint n) { if (n < m_contexts.size()) return m_contexts[n]; return 0; }
253
254 TQMap< TQPair<KateHlContext *, TQString>, short> dynamicCtxs;
255
256 // make them pointers perhaps
257 KateEmbeddedHlInfos embeddedHls;
258 KateHlUnresolvedCtxRefs unresolvedContextReferences;
259 TQStringList RegionList;
260 TQStringList ContextNameList;
261
262 bool noHl;
263 bool folding;
264 bool casesensitive;
265 TQString weakDeliminator;
266 TQString deliminator;
267
268 TQString iName;
269 TQString iNameTranslated;
270 TQString iSection;
271 bool iHidden;
272 TQString iWildcards;
273 TQString iMimetypes;
274 TQString identifier;
275 TQString iVersion;
276 TQString iAuthor;
277 TQString iLicense;
278 TQString m_indentation;
279 int m_priority;
280 int refCount;
281 int startctx, base_startctx;
282
283 TQString errorsAndWarnings;
284 TQString buildIdentifier;
285 TQString buildPrefix;
286 bool building;
287 uint itemData0;
288 uint buildContext0Offset;
289 KateHlIncludeRules includeRules;
290 bool m_foldingIndentationSensitive;
291
292 TQIntDict< TQMemArray<KateAttribute> > m_attributeArrays;
293
294
307 class HighlightPropertyBag {
308 public:
309 TQString singleLineCommentMarker;
310 TQString multiLineCommentStart;
311 TQString multiLineCommentEnd;
312 TQString multiLineRegion;
313 CSLPos singleLineCommentPosition;
314 TQString deliminator;
315 TQString wordWrapDeliminator;
316 };
317
322 TQDict<HighlightPropertyBag> m_additionalData;
323
329 TQMap<int, TQString> m_hlIndex;
330
331
332 TQString extensionSource;
333 TQValueList<TQRegExp> regexpExtensions;
334 TQStringList plainExtensions;
335
336 public:
337 inline bool foldingIndentationSensitive () { return m_foldingIndentationSensitive; }
338 inline bool allowsFolding(){return folding;}
339};
340
341class KateHlManager : public TQObject
342{
343 TQ_OBJECT
344
345 private:
346 KateHlManager();
347
348 public:
349 ~KateHlManager();
350
351 static KateHlManager *self();
352
353 inline TDEConfig *getTDEConfig() { return &m_config; };
354
355 KateHighlighting *getHl(int n);
356 int nameFind(const TQString &name);
357
358 int detectHighlighting (class KateDocument *doc);
359
360 int findHl(KateHighlighting *h) {return hlList.find(h);}
361 TQString identifierForName(const TQString&);
362
363 // methodes to get the default style count + names
364 static uint defaultStyles();
365 static TQString defaultStyleName(int n, bool translateNames = false);
366
367 void getDefaults(uint schema, KateAttributeList &);
368 void setDefaults(uint schema, KateAttributeList &);
369
370 int highlights();
371 TQString hlName(int n);
372 TQString hlNameTranslated (int n);
373 TQString hlSection(int n);
374 bool hlHidden(int n);
375
376 void incDynamicCtxs() { ++dynamicCtxsCount; };
377 uint countDynamicCtxs() { return dynamicCtxsCount; };
378 void setForceNoDCReset(bool b) { forceNoDCReset = b; };
379
380 // be carefull: all documents hl should be invalidated after having successfully called this method!
381 bool resetDynamicCtxs();
382
383 signals:
384 void changed();
385
386 private:
387 int wildcardFind(const TQString &fileName);
388 int mimeFind(KateDocument *);
389 int realWildcardFind(const TQString &fileName);
390
391 private:
392 friend class KateHighlighting;
393
394 TQPtrList<KateHighlighting> hlList;
395 TQDict<KateHighlighting> hlDict;
396
397 static KateHlManager *s_self;
398
399 TDEConfig m_config;
400 TQStringList commonSuffixes;
401
402 KateSyntaxDocument *syntax;
403
404 uint dynamicCtxsCount;
405 TQTime lastCtxsReset;
406 bool forceNoDCReset;
407};
408
409class KateViewHighlightAction: public Kate::ActionMenu
410{
411 TQ_OBJECT
412
413 public:
414 KateViewHighlightAction(const TQString& text, TQObject* parent = 0, const char* name = 0)
415 : Kate::ActionMenu(text, parent, name) { init(); };
416
417 ~KateViewHighlightAction(){;};
418
419 void updateMenu (Kate::Document *doc);
420
421 private:
422 void init();
423
424 TQGuardedPtr<Kate::Document> m_doc;
425 TQStringList subMenusName;
426 TQStringList names;
427 TQPtrList<TQPopupMenu> subMenus;
428
429 public slots:
430 void slotAboutToShow();
431
432 private slots:
433 void setHl (int mode);
434};
435
436#endif
KateAttribute
The Attribute class incorporates all text decorations supported by Kate.
Definition: kateattribute.h:33
KateSyntaxContextData
Class holding the data around the current QDomElement.
Definition: katesyntaxdocument.h:54
KateSyntaxDocument
Store and manage the information about Syntax Highlighting.
Definition: katesyntaxdocument.h:65
KateSyntaxModeListItem
Information about each syntax hl Mode.
Definition: katesyntaxdocument.h:30
KateTextLine
The KateTextLine represents a line of text.
Definition: katetextline.h:42
Kate::Document
This interface provides access to the Kate Document class.
Definition: document.h:190
TDEConfig
KDE::version
unsigned int version()
Kate
Kate namespace All classes in this namespace must stay BC during one major release series (e....
Definition: document.h:51
TDEStdAccel::name
TQString name(StdAccel id)

kate

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

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.4
This website is maintained by Timothy Pearson.