• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • sources
  • kde-4.12
  • applications
  • kate
  • part
  • syntax
katehighlight.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2007 Mirko Stocker <me@misto.ch>
3  Copyright (C) 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
4  Copyright (C) 2003, 2004 Anders Lund <anders@alweb.dk>
5  Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
6  Copyright (C) 2001,2002 Joseph Wenninger <jowenn@kde.org>
7  Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
8  Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Library General Public
12  License version 2 as published by the Free Software Foundation.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Library General Public License for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with this library; see the file COPYING.LIB. If not, write to
21  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  Boston, MA 02110-1301, USA.
23 */
24 
25 //BEGIN INCLUDES
26 #include "katehighlight.h"
27 
28 #include "katehighlighthelpers.h"
29 #include "katetextline.h"
30 #include "katedocument.h"
31 #include "katesyntaxdocument.h"
32 #include "katerenderer.h"
33 #include "kateglobal.h"
34 #include "kateschema.h"
35 #include "kateconfig.h"
36 #include "kateextendedattribute.h"
37 
38 #include <kconfig.h>
39 #include <kconfiggroup.h>
40 #include <kglobal.h>
41 #include <kcomponentdata.h>
42 #include <kmimetype.h>
43 #include <klocale.h>
44 #include <kmenu.h>
45 #include <kglobalsettings.h>
46 #include <kdebug.h>
47 #include <kstandarddirs.h>
48 #include <kmessagebox.h>
49 #include <kapplication.h>
50 
51 #include <ktexteditor/highlightinterface.h>
52 
53 #include <QtCore/QSet>
54 #include <QtGui/QAction>
55 #include <QtGui/QApplication>
56 #include <QtCore/QStringList>
57 #include <QtCore/QTextStream>
58 #include <QVarLengthArray>
59 //END
60 
61 //BEGIN defines
62 // x is a QString. if x is "true" or "1" this expression returns "true"
63 #define IS_TRUE(x) x.toLower() == QLatin1String("true") || x.toInt() == 1
64 //END defines
65 
66 //BEGIN STATICS
67 static const QString stdDeliminator = QString (" \t.():!+,-<=>%&*/;?[]^{|}~\\");
68 //END
69 
70 //BEGIN KateHighlighting
71 KateHighlighting::KateHighlighting(const KateSyntaxModeListItem *def) : refCount(0)
72 {
73  errorsAndWarnings = "";
74  building=false;
75  noHl = false;
76  m_foldingIndentationSensitive = false;
77  folding=false;
78 
79  if (def == 0)
80  {
81  noHl = true;
82  iName = "None"; // not translated internal name (for config and more)
83  iNameTranslated = i18nc("Syntax highlighting", "None"); // user visible name
84  iSection = "";
85  iHidden = false;
86  m_additionalData.insert( "none", new HighlightPropertyBag );
87  m_additionalData["none"]->deliminator = stdDeliminator;
88  m_additionalData["none"]->wordWrapDeliminator = stdDeliminator;
89  m_hlIndex[0] = "none";
90  m_ctxIndex[0]= "none";
91  }
92  else
93  {
94  iName = def->name;
95  iNameTranslated = def->nameTranslated;
96  iSection = def->section;
97  iHidden = def->hidden;
98  identifier = def->identifier;
99  iVersion=def->version;
100  iStyle = def->style;
101  iAuthor=def->author;
102  iLicense=def->license;
103  }
104 
105  deliminator = stdDeliminator;
106 }
107 
108 KateHighlighting::~KateHighlighting()
109 {
110  // cleanup ;)
111  cleanup ();
112 
113  qDeleteAll(m_additionalData);
114 }
115 
116 void KateHighlighting::cleanup ()
117 {
118  qDeleteAll (m_contexts);
119  m_contexts.clear ();
120 
121  qDeleteAll (m_hlItemCleanupList);
122  m_hlItemCleanupList.clear ();
123 
124  m_attributeArrays.clear ();
125 
126  internalIDList.clear();
127 }
128 
129 KateHlContext *KateHighlighting::generateContextStack (Kate::TextLineData::ContextStack &contextStack,
130  KateHlContextModification modification,
131  int &indexLastContextPreviousLine)
132 {
133  while (true)
134  {
135  switch (modification.type)
136  {
141  case KateHlContextModification::doNothing:
142  return contextNum (contextStack.isEmpty() ? 0 : contextStack.last());
143 
148  case KateHlContextModification::doPush:
149  contextStack.append (modification.newContext);
150  return contextNum (modification.newContext);
151 
155  case KateHlContextModification::doPopsAndPush:
156  // resize stack
157  contextStack.resize ((modification.pops >= contextStack.size()) ? 0 : (contextStack.size() - modification.pops));
158 
159  // push imediate the new context....
160  // don't handle the previous line stuff at all....
161  // ### TODO ### think about this
162  contextStack.append (modification.newContext);
163  return contextNum (modification.newContext);
164 
168  default:
169  {
170  // resize stack
171  contextStack.resize ((modification.pops >= contextStack.size()) ? 0 : (contextStack.size() - modification.pops));
172 
173  // handling of context of previous line....
174  if (indexLastContextPreviousLine >= (contextStack.size()-1))
175  {
176  // set new index, if stack is empty, this is -1, done for eternity...
177  indexLastContextPreviousLine = contextStack.size() - 1;
178 
179  // stack already empty, nothing to do...
180  if ( contextStack.isEmpty() )
181  return contextNum (0);
182 
183  KateHlContext *c = contextNum(contextStack.last());
184 
185  // this must be a valid context, or our context stack is borked....
186  Q_ASSERT (c);
187 
188  // handle line end context as new modificationContext
189  modification = c->lineEndContext;
190  continue;
191  }
192 
193  return contextNum (contextStack.isEmpty() ? 0 : contextStack.last());
194  }
195  }
196  }
197 
198  // should never be reached
199  Q_ASSERT (false);
200 
201  return contextNum (0);
202 }
203 
207 int KateHighlighting::makeDynamicContext(KateHlContext *model, const QStringList *args)
208 {
209  QPair<KateHlContext *, QString> key(model, args->front());
210  short value;
211 
212  if (dynamicCtxs.contains(key))
213  value = dynamicCtxs[key];
214  else
215  {
216 #ifdef HIGHLIGHTING_DEBUG
217  kDebug(13010) << "new stuff: " << startctx;
218 #endif
219 
220  KateHlContext *newctx = model->clone(args);
221 
222  m_contexts.push_back (newctx);
223 
224  value = startctx++;
225  dynamicCtxs[key] = value;
226  KateHlManager::self()->incDynamicCtxs();
227  }
228 
229  // kDebug(13010) << "Dynamic context: using context #" << value << " (for model " << model << " with args " << *args << ")";
230 
231  return value;
232 }
233 
238 void KateHighlighting::dropDynamicContexts()
239 {
240  if (refCount == 0) // unused highlighting - nothing to drop
241  return;
242 
243  if (noHl) // "normal texts" highlighting - no context list
244  return;
245 
246  qDeleteAll(m_contexts.begin()+base_startctx, m_contexts.end()); // delete dynamic contexts (after base_startctx)
247  m_contexts.resize (base_startctx);
248 
249  dynamicCtxs.clear();
250  startctx = base_startctx;
251 }
252 
253 void KateHighlighting::doHighlight ( const Kate::TextLineData *_prevLine,
254  Kate::TextLineData *textLine,
255  const Kate::TextLineData *nextLine,
256  bool &ctxChanged,
257  int tabWidth )
258 {
259  if (!textLine)
260  return;
261 
262  // in all cases, remove old hl, or we will grow to infinite ;)
263  textLine->clearAttributes ();
264 
265  // reset folding start
266  textLine->clearMarkedAsFoldingStart ();
267 
268  // no hl set, nothing to do more than the above cleaning ;)
269  if (noHl)
270  return;
271 
272  const bool firstLine = (_prevLine == 0);
273  const Kate::TextLine dummy = Kate::TextLine (new Kate::TextLineData ());
274  const Kate::TextLineData * prevLine = firstLine ? dummy.data() : _prevLine;
275 
276  int previousLine = -1;
277  KateHlContext *context;
278 
279  // duplicate the ctx stack, only once !
280  Kate::TextLineData::ContextStack ctx (prevLine->contextStack());
281 
282  if (ctx.isEmpty())
283  {
284  // If the stack is empty, we assume to be in Context 0 (Normal)
285  if (firstLine) {
286  context = contextNum(0);
287  } else {
288  context = generateContextStack(ctx, contextNum(0)->lineEndContext, previousLine); //get stack ID to use
289  }
290  }
291  else
292  {
293  //kDebug(13010) << "\t\tctxNum = " << ctxNum << " contextList[ctxNum] = " << contextList[ctxNum]; // ellis
294 
295  //if (lineContinue) kDebug(13010)<<QString("The old context should be %1").arg((int)ctxNum);
296  context = contextNum(ctx.last());
297 
298  //kDebug(13010)<<"test1-2-1-text2";
299 
300  previousLine = ctx.size()-1; //position of the last context ID of th previous line within the stack
301 
302  // hl continue set or not ???
303  if (prevLine->hlLineContinue())
304  previousLine--;
305  else
306  context = generateContextStack(ctx, context->lineEndContext, previousLine); //get stack ID to use
307 
308  //kDebug(13010)<<"test1-2-1-text4";
309 
310  //if (lineContinue) kDebug(13010)<<QString("The new context is %1").arg((int)ctxNum);
311  }
312 
313  // text, for programming convenience :)
314  QChar lastChar = ' ';
315  const QString& text = textLine->string();
316  const int len = textLine->length();
317 
318  // calc at which char the first char occurs, set it to length of line if never
319  const int firstChar = textLine->firstChar();
320  const int startNonSpace = (firstChar == -1) ? len : firstChar;
321 
322  // last found item
323  KateHlItem *item = 0;
324 
325  // loop over the line, offset gives current offset
326  int offset = 0;
327 
328  KateHighlighting::HighlightPropertyBag* additionalData = m_additionalData[context->hlId];
329  KateHlContext* oldContext = context;
330 
331  // optimization: list of highlighting items that need their cache reset
332  static QVarLengthArray<KateHlItem*> cachingItems;
333 
334  // catch empty lines
335  if (len == 0) {
336  // regenerate context stack if needed
337  if (context->emptyLineContext)
338  context = generateContextStack (ctx, context->emptyLineContextModification, previousLine);
339  } else {
344  QHash<short, int> *foldingStartToCount = 0;
345 
349  QChar lastDelimChar = 0;
350  while (offset < len)
351  {
352  bool anItemMatched = false;
353  bool customStartEnableDetermined = false;
354 
355  foreach (item, context->items)
356  {
357  // does we only match if we are firstNonSpace?
358  if (item->firstNonSpace && (offset > startNonSpace))
359  continue;
360 
361  // have we a column specified? if yes, only match at this column
362  if ((item->column != -1) && (item->column != offset))
363  continue;
364 
365  if (!item->alwaysStartEnable)
366  {
367  if (item->customStartEnable)
368  {
369  if ( oldContext != context ) {
370  oldContext = context;
371  additionalData = m_additionalData[oldContext->hlId];
372  }
373  if (customStartEnableDetermined || additionalData->deliminator.contains(lastChar))
374  customStartEnableDetermined = true;
375  else
376  continue;
377  }
378  else
379  {
380  if (lastDelimChar == lastChar) {
381  } else if ( stdDeliminator.contains(lastChar) ) {
382  lastDelimChar = lastChar;
383  } else {
384  continue;
385  }
386  }
387  }
388 
389  int offset2 = item->checkHgl(text, offset, len-offset);
390  if ( item->haveCache && !item->cachingHandled ) {
391  cachingItems.append(item);
392  item->cachingHandled = true;
393  }
394 
395  if (offset2 <= offset)
396  continue;
397 
398  // dominik: on lookAhead, do not preocess any data by fixing offset2
399  if (item->lookAhead) {
400  offset2 = offset;
401  } else {
402  // make sure the rule does not violate the text line length
403  if (offset2 > len)
404  offset2 = len;
405  }
406 
407  // BUG 144599: Ignore a context change that would push the same context
408  // without eating anything... this would be an infinite loop!
409  if ( item->lookAhead && ( item->ctx.pops < 2 && item->ctx.newContext == ( ctx.isEmpty() ? 0 : ctx.last() ) ) )
410  continue;
411 
412  // regenerate context stack if needed
413  context = generateContextStack (ctx, item->ctx, previousLine);
414 
415  // dynamic context: substitute the model with an 'instance'
416  if (context->dynamic)
417  {
418  // try to retrieve captures from regexp
419  QStringList captures;
420  item->capturedTexts (captures);
421  if (!captures.empty())
422  {
423  // Replace the top of the stack and the current context
424  int newctx = makeDynamicContext(context, &captures);
425  if (ctx.size() > 0)
426  ctx[ctx.size() - 1] = newctx;
427 
428  context = contextNum(newctx);
429  }
430  }
431 
432  // handle folding end or begin
433  if (item->region || item->region2) {
437  if (item->region2 && foldingStartToCount) {
438  QHash<short, int>::iterator end = foldingStartToCount->find (-item->region2);
439  if (end != foldingStartToCount->end()) {
440  if (end.value() > 1)
441  --(end.value());
442  else
443  foldingStartToCount->erase (end);
444  }
445  }
446 
450  if (item->region) {
451  // construct on demand!
452  if (!foldingStartToCount)
453  foldingStartToCount = new QHash<short, int> ();
454 
455  ++(*foldingStartToCount)[item->region];
456  }
457  }
458 
459  // even set attributes or end of region! ;)
460  int attribute = item->onlyConsume ? context->attr : item->attr;
461  if ((attribute > 0 && !item->lookAhead) || item->region2)
462  textLine->addAttribute (Kate::TextLineData::Attribute (offset, offset2-offset, attribute, item->region2));
463 
464  // create 0 length attribute for begin of region, if any!
465  if (item->region)
466  textLine->addAttribute (Kate::TextLineData::Attribute (offset2, 0, attribute, item->region));
467 
468  // only process, if lookAhead is false
469  if (!item->lookAhead) {
470  offset = offset2;
471  lastChar = text[offset-1];
472  }
473 
474  anItemMatched = true;
475  break;
476  }
477 
478  // something matched, continue loop
479  if (anItemMatched)
480  continue;
481 
482  item = 0;
483 
484  // nothing found: set attribute of one char
485  // anders: unless this context does not want that!
486  if ( context->fallthrough )
487  {
488  // set context to context->ftctx.
489  context=generateContextStack(ctx, context->ftctx, previousLine); //regenerate context stack
490 
491  //kDebug(13010)<<"context num after fallthrough at col "<<z<<": "<<ctxNum;
492  // the next is necessary, as otherwise keyword (or anything using the std delimitor check)
493  // immediately after fallthrough fails. Is it bad?
494  // jowenn, can you come up with a nicer way to do this?
495  /* if (offset)
496  lastChar = text[offset - 1];
497  else
498  lastChar = '\\';*/
499  continue;
500  }
501  else
502  {
503  // set attribute if any
504  if (context->attr > 0)
505  textLine->addAttribute (Kate::TextLineData::Attribute (offset, 1, context->attr, 0));
506 
507  lastChar = text[offset];
508  offset++;
509  }
510  }
511 
516  if (foldingStartToCount) {
520  if (!foldingStartToCount->isEmpty())
521  textLine->markAsFoldingStartAttribute ();
522 
526  delete foldingStartToCount;
527  foldingStartToCount = 0;
528  }
529  }
530 
534  if ((ctxChanged = (ctx != textLine->contextStack()))) {
538  static const Kate::TextLineData::ContextStack onlyDefaulContext (1, 0);
539  if (ctx == onlyDefaulContext)
540  textLine->setContextStack(onlyDefaulContext);
541 
545  else if (ctx == prevLine->contextStack())
546  textLine->setContextStack(prevLine->contextStack());
547 
551  else
552  textLine->setContextStack(ctx);
553  }
554 
555  // write hl continue flag
556  textLine->setHlLineContinue (item && item->lineContinue());
557 
558  // check for indentation based folding
559  if (m_foldingIndentationSensitive && (tabWidth > 0) && !textLine->markedAsFoldingStartAttribute ()) {
560  bool skipIndentationBasedFolding = false;
561  for(int i = ctx.size() - 1; i >= 0; --i) {
562  if (contextNum(ctx[i])->noIndentationBasedFolding) {
563  skipIndentationBasedFolding = true;
564  break;
565  }
566  }
567 
571  if (!skipIndentationBasedFolding && !isEmptyLine (textLine) && !isEmptyLine (nextLine)
572  && (textLine->indentDepth (tabWidth) < nextLine->indentDepth (tabWidth)))
573  textLine->markAsFoldingStartIndentation ();
574  }
575 
576  // invalidate caches
577  for ( int i = 0; i < cachingItems.size(); ++i) {
578  cachingItems[i]->cachingHandled = false;
579  cachingItems[i]->haveCache = false;
580  }
581  cachingItems.clear();
582 }
583 
584 void KateHighlighting::getKateExtendedAttributeList (const QString &schema, QList<KateExtendedAttribute::Ptr> &list, KConfig* cfg)
585 {
586  KConfigGroup config(cfg?cfg:KateHlManager::self()->getKConfig(),
587  "Highlighting " + iName + " - Schema " + schema);
588 
589  list.clear();
590  createKateExtendedAttribute(list);
591 
592  foreach (KateExtendedAttribute::Ptr p, list)
593  {
594  Q_ASSERT(p);
595 
596  QStringList s = config.readEntry(p->name(), QStringList());
597 
598 // kDebug(13010)<<p->name<<s.count();
599  if (s.count()>0)
600  {
601 
602  while(s.count()<10) s<<"";
603  QString name = p->name();
604  bool spellCheck = p->performSpellchecking();
605  p->clear();
606  p->setName(name);
607  p->setPerformSpellchecking(spellCheck);
608 
609  QString tmp=s[0]; if (!tmp.isEmpty()) p->setDefaultStyleIndex(tmp.toInt());
610 
611  QRgb col;
612 
613  tmp=s[1]; if (!tmp.isEmpty()) {
614  col=tmp.toUInt(0,16); p->setForeground(QColor(col)); }
615 
616  tmp=s[2]; if (!tmp.isEmpty()) {
617  col=tmp.toUInt(0,16); p->setSelectedForeground(QColor(col)); }
618 
619  tmp=s[3]; if (!tmp.isEmpty()) p->setFontBold(tmp!="0");
620 
621  tmp=s[4]; if (!tmp.isEmpty()) p->setFontItalic(tmp!="0");
622 
623  tmp=s[5]; if (!tmp.isEmpty()) p->setFontStrikeOut(tmp!="0");
624 
625  tmp=s[6]; if (!tmp.isEmpty()) p->setFontUnderline(tmp!="0");
626 
627  tmp=s[7]; if (!tmp.isEmpty()) {
628  col=tmp.toUInt(0,16); p->setBackground(QColor(col)); }
629 
630  tmp=s[8]; if (!tmp.isEmpty()) {
631  col=tmp.toUInt(0,16); p->setSelectedBackground(QColor(col)); }
632 
633  tmp=s[9]; if (!tmp.isEmpty() && tmp!=QLatin1String("---")) p->setFontFamily(tmp);
634 
635  }
636  }
637 }
638 
639 void KateHighlighting::getKateExtendedAttributeListCopy( const QString &schema, QList< KateExtendedAttribute::Ptr >& list, KConfig* cfg )
640 {
641  QList<KateExtendedAttribute::Ptr> attributes;
642  getKateExtendedAttributeList(schema, attributes,cfg);
643 
644  list.clear();
645 
646  foreach (const KateExtendedAttribute::Ptr &attribute, attributes)
647  list.append(KateExtendedAttribute::Ptr(new KateExtendedAttribute(*attribute.data())));
648 }
649 
650 
657 void KateHighlighting::setKateExtendedAttributeList(const QString &schema, QList<KateExtendedAttribute::Ptr> &list, KConfig *cfg, bool writeDefaultsToo)
658 {
659  KConfigGroup config(cfg?cfg:KateHlManager::self()->getKConfig(),
660  "Highlighting " + iName + " - Schema "+ schema);
661 
662  QStringList settings;
663 
664  KateAttributeList defList;
665  KateHlManager::self()->getDefaults(schema, defList);
666 
667  foreach (const KateExtendedAttribute::Ptr& p, list)
668  {
669  Q_ASSERT(p);
670 
671  settings.clear();
672  uint defStyle=p->defaultStyleIndex();
673  KTextEditor::Attribute::Ptr a(defList[defStyle]);
674  settings<<QString::number(p->defaultStyleIndex(),10);
675  settings<<(p->hasProperty(QTextFormat::ForegroundBrush)?QString::number(p->foreground().color().rgb(),16):(writeDefaultsToo?QString::number(a->foreground().color().rgb(),16):""));
676  settings<<(p->hasProperty(KTextEditor::Attribute::SelectedForeground)?QString::number(p->selectedForeground().color().rgb(),16):(writeDefaultsToo?QString::number(a->selectedForeground().color().rgb(),16):""));
677  settings<<(p->hasProperty(QTextFormat::FontWeight)?(p->fontBold()?"1":"0"):(writeDefaultsToo?(a->fontBold()?"1":"0"):""));
678  settings<<(p->hasProperty(QTextFormat::FontItalic)?(p->fontItalic()?"1":"0"):(writeDefaultsToo?(a->fontItalic()?"1":"0"):""));
679  settings<<(p->hasProperty(QTextFormat::FontStrikeOut)?(p->fontStrikeOut()?"1":"0"):(writeDefaultsToo?(a->fontStrikeOut()?"1":"0"):""));
680  settings<<(p->hasProperty(QTextFormat::FontUnderline)?(p->fontUnderline()?"1":"0"):(writeDefaultsToo?(a->fontUnderline()?"1":"0"):""));
681  settings<<(p->hasProperty(QTextFormat::BackgroundBrush)?QString::number(p->background().color().rgb(),16):((writeDefaultsToo && a->hasProperty(QTextFormat::BackgroundBrush))?QString::number(a->background().color().rgb(),16):""));
682  settings<<(p->hasProperty(KTextEditor::Attribute::SelectedBackground)?QString::number(p->selectedBackground().color().rgb(),16):((writeDefaultsToo&& a->hasProperty(KTextEditor::Attribute::SelectedBackground))?QString::number(a->selectedBackground().color().rgb(),16):""));
683  settings<<(p->hasProperty(QTextFormat::FontFamily)?(p->fontFamily()):(writeDefaultsToo?a->fontFamily():QString()));
684  settings<<"---";
685  config.writeEntry(p->name(),settings);
686  }
687 }
688 
689 const QHash<QString, QChar>& KateHighlighting::getCharacterEncodings( int attrib ) const
690 {
691  return m_additionalData[ hlKeyForAttrib( attrib ) ]->characterEncodings;
692 }
693 
694 const KatePrefixStore& KateHighlighting::getCharacterEncodingsPrefixStore( int attrib ) const
695 {
696  return m_additionalData[ hlKeyForAttrib( attrib ) ]->characterEncodingsPrefixStore;
697 }
698 
699 const QHash<QChar, QString>& KateHighlighting::getReverseCharacterEncodings( int attrib ) const
700 {
701  return m_additionalData[ hlKeyForAttrib( attrib ) ]->reverseCharacterEncodings;
702 }
703 
704 int KateHighlighting::getEncodedCharactersInsertionPolicy( int attrib ) const
705 {
706  return m_additionalData[ hlKeyForAttrib( attrib ) ]->encodedCharactersInsertionPolicy;
707 }
708 
709 void KateHighlighting::addCharacterEncoding( const QString& key, const QString& encoding, const QChar& c )
710 {
711  m_additionalData[ key ]->characterEncodingsPrefixStore.addPrefix(encoding);
712  m_additionalData[ key ]->characterEncodings[ encoding ] = c;
713  m_additionalData[ key ]->reverseCharacterEncodings[ c ] = encoding;
714 }
715 
719 void KateHighlighting::use()
720 {
721  if (refCount == 0)
722  init();
723 
724  refCount++;
725 }
726 
730 void KateHighlighting::release()
731 {
732  refCount--;
733 
734  if (refCount == 0)
735  done();
736 }
737 
742 void KateHighlighting::init()
743 {
744  if (noHl)
745  return;
746 
747  qDeleteAll(m_contexts);
748  m_contexts.clear ();
749 
750  makeContextList();
751 }
752 
753 
758 void KateHighlighting::done()
759 {
760  if (noHl)
761  return;
762 
763  cleanup ();
764 }
765 
773 void KateHighlighting::createKateExtendedAttribute(QList<KateExtendedAttribute::Ptr> &list)
774 {
775  // If the internal list isn't already available read the config file
776  if (!noHl) {
777  if (internalIDList.isEmpty())
778  makeContextList();
779 
780  list=internalIDList;
781  }
782 
783  // If no highlighting is selected or we have no attributes we need only one default.
784  if (noHl || list.isEmpty())
785  list.append(KateExtendedAttribute::Ptr(new KateExtendedAttribute(i18n("Normal Text"), KTextEditor::HighlightInterface::dsNormal)));
786 }
787 
791 void KateHighlighting::addToKateExtendedAttributeList()
792 {
793  //Tell the syntax document class which file we want to parse and which data group
794  KateHlManager::self()->syntax->setIdentifier(buildIdentifier);
795  KateSyntaxContextData *data = KateHlManager::self()->syntax->getGroupInfo("highlighting","itemData");
796 
797  //begin with the real parsing
798  while (KateHlManager::self()->syntax->nextGroup(data))
799  {
800  // read all attributes
801  QString color = KateHlManager::self()->syntax->groupData(data,QString("color"));
802  QString selColor = KateHlManager::self()->syntax->groupData(data,QString("selColor"));
803  QString bold = KateHlManager::self()->syntax->groupData(data,QString("bold"));
804  QString italic = KateHlManager::self()->syntax->groupData(data,QString("italic"));
805  QString underline = KateHlManager::self()->syntax->groupData(data,QString("underline"));
806  QString strikeOut = KateHlManager::self()->syntax->groupData(data,QString("strikeOut"));
807  QString bgColor = KateHlManager::self()->syntax->groupData(data,QString("backgroundColor"));
808  QString selBgColor = KateHlManager::self()->syntax->groupData(data,QString("selBackgroundColor"));
809  QString spellChecking = KateHlManager::self()->syntax->groupData(data,QString("spellChecking"));
810  QString fontFamily = KateHlManager::self()->syntax->groupData(data,QString("fontFamily"));
811 
812  KateExtendedAttribute::Ptr newData(new KateExtendedAttribute(
813  buildPrefix+KateHlManager::self()->syntax->groupData(data,QString("name")).simplified(),
814  KateExtendedAttribute::indexForStyleName(KateHlManager::self()->syntax->groupData(data,QString("defStyleNum")))));
815 
816  /* here the custom style overrides are specified, if needed */
817  if (!color.isEmpty()) newData->setForeground(QColor(color));
818  if (!selColor.isEmpty()) newData->setSelectedForeground(QColor(selColor));
819  if (!bold.isEmpty()) newData->setFontBold( IS_TRUE(bold) );
820  if (!italic.isEmpty()) newData->setFontItalic( IS_TRUE(italic) );
821  // new attributes for the new rendering view
822  if (!underline.isEmpty()) newData->setFontUnderline( IS_TRUE(underline) );
823  if (!strikeOut.isEmpty()) newData->setFontStrikeOut( IS_TRUE(strikeOut) );
824  if (!bgColor.isEmpty()) newData->setBackground(QColor(bgColor));
825  if (!selBgColor.isEmpty()) newData->setSelectedBackground(QColor(selBgColor));
826  // is spellchecking desired?
827  if (!spellChecking.isEmpty()) newData->setPerformSpellchecking( IS_TRUE(spellChecking) );
828  if (!fontFamily.isEmpty()) newData->setFontFamily(fontFamily);
829 
830  internalIDList.append(newData);
831  }
832 
833  //clean up
834  if (data)
835  KateHlManager::self()->syntax->freeGroupInfo(data);
836 }
837 
848 int KateHighlighting::lookupAttrName(const QString& name, QList<KateExtendedAttribute::Ptr> &iDl)
849 {
850  for (int i = 0; i < iDl.count(); i++)
851  if (iDl.at(i)->name() == buildPrefix+name)
852  return i;
853 
854 #ifdef HIGHLIGHTING_DEBUG
855  kDebug(13010)<<"Couldn't resolve itemDataName:"<<name;
856 #endif
857 
858  return 0;
859 }
860 
874 KateHlItem *KateHighlighting::createKateHlItem(KateSyntaxContextData *data,
875  QList<KateExtendedAttribute::Ptr> &iDl,
876  QStringList *RegionList,
877  QStringList *ContextNameList)
878 {
879  // No highlighting -> exit
880  if (noHl)
881  return 0;
882 
883  // get the (tagname) itemd type
884  QString dataname=KateHlManager::self()->syntax->groupItemData(data,QString(""));
885 
886  // code folding region handling:
887  QString beginRegionStr=KateHlManager::self()->syntax->groupItemData(data,QString("beginRegion"));
888  QString endRegionStr=KateHlManager::self()->syntax->groupItemData(data,QString("endRegion"));
889 
890  signed char regionId=0;
891  signed char regionId2=0;
892 
893  if (!beginRegionStr.isEmpty())
894  {
895  regionId = RegionList->indexOf(beginRegionStr);
896 
897  if (regionId==-1) // if the region name doesn't already exist, add it to the list
898  {
899  (*RegionList)<<beginRegionStr;
900  regionId = RegionList->indexOf(beginRegionStr);
901  }
902 
903  regionId++;
904 
905 #ifdef HIGHLIGHTING_DEBUG
906  kDebug(13010) << "########### BEG REG: " << beginRegionStr << " NUM: " << regionId;
907 #endif
908  }
909 
910  if (!endRegionStr.isEmpty())
911  {
912  regionId2 = RegionList->indexOf(endRegionStr);
913 
914  if (regionId2==-1) // if the region name doesn't already exist, add it to the list
915  {
916  (*RegionList)<<endRegionStr;
917  regionId2 = RegionList->indexOf(endRegionStr);
918  }
919 
920  regionId2 = -regionId2 - 1;
921 
922 #ifdef HIGHLIGHTING_DEBUG
923  kDebug(13010) << "########### END REG: " << endRegionStr << " NUM: " << regionId2;
924 #endif
925  }
926 
927  int attr = 0;
928  QString tmpAttr=KateHlManager::self()->syntax->groupItemData(data,QString("attribute")).simplified();
929  bool onlyConsume = tmpAttr.isEmpty();
930 
931  // only relevant for non consumer
932  if (!onlyConsume)
933  {
934  if (QString("%1").arg(tmpAttr.toInt())==tmpAttr)
935  {
936  errorsAndWarnings+=i18n(
937  "<b>%1</b>: Deprecated syntax. Attribute (%2) not addressed by symbolic name<br />",
938  buildIdentifier, tmpAttr);
939  attr=tmpAttr.toInt();
940  }
941  else
942  attr=lookupAttrName(tmpAttr,iDl);
943  }
944 
945  // Info about context switch
946  KateHlContextModification context = -1;
947  QString unresolvedContext;
948  QString tmpcontext=KateHlManager::self()->syntax->groupItemData(data,QString("context"));
949  if (!tmpcontext.isEmpty())
950  context=getContextModificationFromString(ContextNameList, tmpcontext,unresolvedContext);
951 
952  // Get the char parameter (eg DetectChar)
953  QChar chr;
954  if (! KateHlManager::self()->syntax->groupItemData(data,QString("char")).isEmpty()) {
955  chr= (KateHlManager::self()->syntax->groupItemData(data,QString("char")))[0];
956  }
957 
958  // Get the String parameter (eg. StringDetect)
959  QString stringdata=KateHlManager::self()->syntax->groupItemData(data,QString("String"));
960 
961  // Get a second char parameter (char1) (eg Detect2Chars)
962  QChar chr1;
963  if (! KateHlManager::self()->syntax->groupItemData(data,QString("char1")).isEmpty()) {
964  chr1= (KateHlManager::self()->syntax->groupItemData(data,QString("char1")))[0];
965  }
966 
967  // Will be removed eventually. Atm used for StringDetect, WordDetect, keyword and RegExp
968  const QString & insensitive_str = KateHlManager::self()->syntax->groupItemData(data,QString("insensitive"));
969  bool insensitive = IS_TRUE( insensitive_str );
970 
971  // for regexp only
972  bool minimal = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data,QString("minimal")) );
973 
974  // dominik: look ahead and do not change offset. so we can change contexts w/o changing offset1.
975  bool lookAhead = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data,QString("lookAhead")) );
976 
977  bool dynamic= IS_TRUE(KateHlManager::self()->syntax->groupItemData(data,QString("dynamic")) );
978 
979  bool firstNonSpace = IS_TRUE(KateHlManager::self()->syntax->groupItemData(data,QString("firstNonSpace")) );
980 
981  int column = -1;
982  QString colStr = KateHlManager::self()->syntax->groupItemData(data,QString("column"));
983  if (!colStr.isEmpty())
984  column = colStr.toInt();
985 
986  // Create the item corresponding to its type and set its parameters
987  KateHlItem *tmpItem;
988 
989  if (dataname=="keyword")
990  {
991  bool keywordInsensitive = insensitive_str.isEmpty() ? !casesensitive : insensitive;
992  KateHlKeyword *keyword=new KateHlKeyword(attr,context,regionId,regionId2,keywordInsensitive,
993  m_additionalData[ buildIdentifier ]->deliminator);
994 
995  //Get the entries for the keyword lookup list
996  keyword->addList(KateHlManager::self()->syntax->finddata("highlighting",stringdata));
997  tmpItem=keyword;
998  }
999  else if (dataname=="Float") tmpItem= (new KateHlFloat(attr,context,regionId,regionId2));
1000  else if (dataname=="Int") tmpItem=(new KateHlInt(attr,context,regionId,regionId2));
1001  else if (dataname=="DetectChar") tmpItem=(new KateHlCharDetect(attr,context,regionId,regionId2,chr));
1002  else if (dataname=="Detect2Chars") tmpItem=(new KateHl2CharDetect(attr,context,regionId,regionId2,chr,chr1));
1003  else if (dataname=="RangeDetect") tmpItem=(new KateHlRangeDetect(attr,context,regionId,regionId2, chr, chr1));
1004  else if (dataname=="LineContinue") tmpItem=(new KateHlLineContinue(attr,context,regionId,regionId2));
1005  else if (dataname=="StringDetect") tmpItem=(new KateHlStringDetect(attr,context,regionId,regionId2,stringdata,insensitive));
1006  else if (dataname=="WordDetect") tmpItem=(new KateHlWordDetect(attr,context,regionId,regionId2,stringdata,insensitive));
1007  else if (dataname=="AnyChar") tmpItem=(new KateHlAnyChar(attr,context,regionId,regionId2,stringdata));
1008  else if (dataname=="RegExpr") tmpItem=(new KateHlRegExpr(attr,context,regionId,regionId2,stringdata, insensitive, minimal));
1009  else if (dataname=="HlCChar") tmpItem= ( new KateHlCChar(attr,context,regionId,regionId2));
1010  else if (dataname=="HlCHex") tmpItem= (new KateHlCHex(attr,context,regionId,regionId2));
1011  else if (dataname=="HlCOct") tmpItem= (new KateHlCOct(attr,context,regionId,regionId2));
1012  else if (dataname=="HlCFloat") tmpItem= (new KateHlCFloat(attr,context,regionId,regionId2));
1013  else if (dataname=="HlCStringChar") tmpItem= (new KateHlCStringChar(attr,context,regionId,regionId2));
1014  else if (dataname=="DetectSpaces") tmpItem= (new KateHlDetectSpaces(attr,context,regionId,regionId2));
1015  else if (dataname=="DetectIdentifier") tmpItem= (new KateHlDetectIdentifier(attr,context,regionId,regionId2));
1016  else
1017  {
1018  // oops, unknown type. Perhaps a spelling error in the xml file
1019  return 0;
1020  }
1021 
1022  // set lookAhead & dynamic properties
1023  tmpItem->lookAhead = lookAhead;
1024  tmpItem->dynamic = dynamic;
1025  tmpItem->firstNonSpace = firstNonSpace;
1026  tmpItem->column = column;
1027  tmpItem->onlyConsume = onlyConsume;
1028 
1029  if (!unresolvedContext.isEmpty())
1030  {
1031  unresolvedContextReferences.insert(&(tmpItem->ctx),unresolvedContext);
1032  }
1033 
1034  // remember all to delete them
1035  m_hlItemCleanupList.append (tmpItem);
1036 
1037  return tmpItem;
1038 }
1039 
1040 int KateHighlighting::attribute(int ctx) const
1041 {
1042  return m_contexts[ctx]->attr;
1043 }
1044 
1045 bool KateHighlighting::attributeRequiresSpellchecking( int attr )
1046 {
1047  QList<KTextEditor::Attribute::Ptr> attributeList = attributes("");
1048  if(attr < attributeList.length() && attributeList[attr]->hasProperty(KateExtendedAttribute::Spellchecking)) {
1049  return attributeList[attr]->boolProperty(KateExtendedAttribute::Spellchecking);
1050  }
1051  return true;
1052 }
1053 
1054 QString KateHighlighting::hlKeyForContext(int i) const
1055 {
1056  int k = 0;
1057  QMap<int,QString>::const_iterator it = m_ctxIndex.constEnd();
1058  while ( it != m_ctxIndex.constBegin() )
1059  {
1060  --it;
1061  k = it.key();
1062  if ( i >= k )
1063  break;
1064  }
1065  return it.value();
1066 }
1067 
1068 QString KateHighlighting::hlKeyForAttrib( int i ) const
1069 {
1070  // find entry. This is faster than QMap::find. m_hlIndex always has an entry
1071  // for key '0' (it is "none"), so the result is always valid.
1072  int k = 0;
1073  QMap<int,QString>::const_iterator it = m_hlIndex.constEnd();
1074  while ( it != m_hlIndex.constBegin() )
1075  {
1076  --it;
1077  k = it.key();
1078  if ( i >= k )
1079  break;
1080  }
1081  return it.value();
1082 }
1083 
1084 bool KateHighlighting::isInWord( QChar c, int attrib ) const
1085 {
1086  return m_additionalData[ hlKeyForAttrib( attrib ) ]->deliminator.indexOf(c) < 0
1087  && !c.isSpace()
1088  && c != QChar::fromAscii('"') && c != QChar::fromAscii('\'') && c != QChar::fromAscii('`');
1089 }
1090 
1091 bool KateHighlighting::canBreakAt( QChar c, int attrib ) const
1092 {
1093  static const QString& sq = KGlobal::staticQString("\"'");
1094  return (m_additionalData[ hlKeyForAttrib( attrib ) ]->wordWrapDeliminator.indexOf(c) != -1) && (sq.indexOf(c) == -1);
1095 }
1096 
1097 QLinkedList<QRegExp> KateHighlighting::emptyLines(int attrib) const
1098 {
1099 #ifdef HIGHLIGHTING_DEBUG
1100  kDebug(13010)<<"hlKeyForAttrib: "<<hlKeyForAttrib(attrib);
1101 #endif
1102 
1103  return m_additionalData[hlKeyForAttrib(attrib)]->emptyLines;
1104 }
1105 
1106 signed char KateHighlighting::commentRegion(int attr) const {
1107  QString commentRegion=m_additionalData[ hlKeyForAttrib( attr ) ]->multiLineRegion;
1108  return (commentRegion.isEmpty()?0:(commentRegion.toShort()));
1109 }
1110 
1111 bool KateHighlighting::canComment( int startAttrib, int endAttrib ) const
1112 {
1113  QString k = hlKeyForAttrib( startAttrib );
1114  return ( k == hlKeyForAttrib( endAttrib ) &&
1115  ( ( !m_additionalData[k]->multiLineCommentStart.isEmpty() && !m_additionalData[k]->multiLineCommentEnd.isEmpty() ) ||
1116  ! m_additionalData[k]->singleLineCommentMarker.isEmpty() ) );
1117 }
1118 
1119 QString KateHighlighting::getCommentStart( int attrib ) const
1120 {
1121  return m_additionalData[ hlKeyForAttrib( attrib) ]->multiLineCommentStart;
1122 }
1123 
1124 QString KateHighlighting::getCommentEnd( int attrib ) const
1125 {
1126  return m_additionalData[ hlKeyForAttrib( attrib ) ]->multiLineCommentEnd;
1127 }
1128 
1129 QString KateHighlighting::getCommentSingleLineStart( int attrib ) const
1130 {
1131  return m_additionalData[ hlKeyForAttrib( attrib) ]->singleLineCommentMarker;
1132 }
1133 
1134 KateHighlighting::CSLPos KateHighlighting::getCommentSingleLinePosition( int attrib ) const
1135 {
1136  return m_additionalData[ hlKeyForAttrib( attrib) ]->singleLineCommentPosition;
1137 }
1138 
1139 const QHash<QString, QChar>& KateHighlighting::characterEncodings( int attrib ) const
1140 {
1141  return m_additionalData[ hlKeyForAttrib( attrib) ]->characterEncodings;
1142 }
1143 
1148 void KateHighlighting::readCommentConfig()
1149 {
1150  KateHlManager::self()->syntax->setIdentifier(buildIdentifier);
1151  KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("general","comment");
1152 
1153  QString cmlStart="", cmlEnd="", cmlRegion="", cslStart="";
1154  CSLPos cslPosition=CSLPosColumn0;
1155 
1156  if (data)
1157  {
1158  while (KateHlManager::self()->syntax->nextGroup(data))
1159  {
1160  if (KateHlManager::self()->syntax->groupData(data,"name")=="singleLine")
1161  {
1162  cslStart=KateHlManager::self()->syntax->groupData(data,"start");
1163  QString cslpos=KateHlManager::self()->syntax->groupData(data,"position");
1164  if (cslpos=="afterwhitespace")
1165  cslPosition=CSLPosAfterWhitespace;
1166  else
1167  cslPosition=CSLPosColumn0;
1168  }
1169  else if (KateHlManager::self()->syntax->groupData(data,"name")=="multiLine")
1170  {
1171  cmlStart=KateHlManager::self()->syntax->groupData(data,"start");
1172  cmlEnd=KateHlManager::self()->syntax->groupData(data,"end");
1173  cmlRegion=KateHlManager::self()->syntax->groupData(data,"region");
1174  }
1175  }
1176 
1177  KateHlManager::self()->syntax->freeGroupInfo(data);
1178  }
1179 
1180  m_additionalData[buildIdentifier]->singleLineCommentMarker = cslStart;
1181  m_additionalData[buildIdentifier]->singleLineCommentPosition = cslPosition;
1182  m_additionalData[buildIdentifier]->multiLineCommentStart = cmlStart;
1183  m_additionalData[buildIdentifier]->multiLineCommentEnd = cmlEnd;
1184  m_additionalData[buildIdentifier]->multiLineRegion = cmlRegion;
1185 }
1186 
1187 
1188 
1189 
1190 void KateHighlighting::readEmptyLineConfig()
1191 {
1192  KateHlManager::self()->syntax->setIdentifier(buildIdentifier);
1193  KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("general","emptyLine");
1194 
1195  QLinkedList<QRegExp> exprList;
1196 
1197  if (data)
1198  {
1199  while (KateHlManager::self()->syntax->nextGroup(data))
1200  {
1201 #ifdef HIGHLIGHTING_DEBUG
1202  kDebug(13010)<<"creating an empty line regular expression";
1203 #endif
1204 
1205  QString regexprline=KateHlManager::self()->syntax->groupData(data,"regexpr");
1206  bool regexprcase=(KateHlManager::self()->syntax->groupData(data,"casesensitive").toUpper().compare("TRUE")==0);
1207  exprList.append(QRegExp(regexprline,regexprcase?Qt::CaseSensitive:Qt::CaseInsensitive));
1208  }
1209  KateHlManager::self()->syntax->freeGroupInfo(data);
1210  }
1211 
1212  m_additionalData[buildIdentifier]->emptyLines = exprList;
1213 }
1214 
1215 
1216 
1217 
1218 
1219 
1225 void KateHighlighting::readGlobalKeywordConfig()
1226 {
1227  deliminator = stdDeliminator;
1228 
1229 #ifdef HIGHLIGHTING_DEBUG
1230  kDebug(13010)<<"readGlobalKeywordConfig:BEGIN";
1231 #endif
1232 
1233  // Tell the syntax document class which file we want to parse
1234  KateHlManager::self()->syntax->setIdentifier(buildIdentifier);
1235  KateSyntaxContextData *data = KateHlManager::self()->syntax->getConfig("general","keywords");
1236 
1237  if (data)
1238  {
1239 #ifdef HIGHLIGHTING_DEBUG
1240  kDebug(13010)<<"Found global keyword config";
1241 #endif
1242 
1243  casesensitive = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data,QString("casesensitive")) );
1244 
1245  //get the weak deliminators
1246  weakDeliminator=(KateHlManager::self()->syntax->groupItemData(data,QString("weakDeliminator")));
1247 
1248 #ifdef HIGHLIGHTING_DEBUG
1249  kDebug(13010)<<"weak delimiters are: "<<weakDeliminator;
1250 #endif
1251 
1252  // remove any weakDelimitars (if any) from the default list and store this list.
1253  for (int s=0; s < weakDeliminator.length(); s++)
1254  {
1255  int f = deliminator.indexOf (weakDeliminator[s]);
1256 
1257  if (f > -1)
1258  deliminator.remove (f, 1);
1259  }
1260 
1261  QString addDelim = (KateHlManager::self()->syntax->groupItemData(data,QString("additionalDeliminator")));
1262 
1263  if (!addDelim.isEmpty())
1264  deliminator=deliminator+addDelim;
1265 
1266  KateHlManager::self()->syntax->freeGroupInfo(data);
1267  }
1268  else
1269  {
1270  //Default values
1271  casesensitive=true;
1272  weakDeliminator=QString("");
1273  }
1274 
1275 #ifdef HIGHLIGHTING_DEBUG
1276  kDebug(13010)<<"readGlobalKeywordConfig:END";
1277  kDebug(13010)<<"delimiterCharacters are: "<<deliminator;
1278 #endif
1279 
1280  m_additionalData[buildIdentifier]->deliminator = deliminator;
1281 }
1282 
1293 void KateHighlighting::readWordWrapConfig()
1294 {
1295 #ifdef HIGHLIGHTING_DEBUG
1296  kDebug(13010)<<"readWordWrapConfig:BEGIN";
1297 #endif
1298 
1299  // Tell the syntax document class which file we want to parse
1300  KateHlManager::self()->syntax->setIdentifier(buildIdentifier);
1301  KateSyntaxContextData *data = KateHlManager::self()->syntax->getConfig("general","keywords");
1302 
1303  QString wordWrapDeliminator = stdDeliminator;
1304  if (data)
1305  {
1306 #ifdef HIGHLIGHTING_DEBUG
1307  kDebug(13010)<<"Found global keyword config";
1308 #endif
1309 
1310  wordWrapDeliminator = (KateHlManager::self()->syntax->groupItemData(data,QString("wordWrapDeliminator")));
1311  //when no wordWrapDeliminator is defined use the deliminator list
1312  if ( wordWrapDeliminator.length() == 0 ) wordWrapDeliminator = deliminator;
1313 
1314 #ifdef HIGHLIGHTING_DEBUG
1315  kDebug(13010) << "word wrap deliminators are " << wordWrapDeliminator;
1316 #endif
1317 
1318  KateHlManager::self()->syntax->freeGroupInfo(data);
1319  }
1320 
1321 #ifdef HIGHLIGHTING_DEBUG
1322  kDebug(13010)<<"readWordWrapConfig:END";
1323 #endif
1324 
1325  m_additionalData[buildIdentifier]->wordWrapDeliminator = wordWrapDeliminator;
1326 }
1327 
1328 void KateHighlighting::readIndentationConfig()
1329 {
1330  m_indentation = "";
1331 
1332  KateHlManager::self()->syntax->setIdentifier(buildIdentifier);
1333  KateSyntaxContextData *data = KateHlManager::self()->syntax->getConfig("general","indentation");
1334 
1335  if (data)
1336  {
1337  m_indentation = (KateHlManager::self()->syntax->groupItemData(data,QString("mode")));
1338 
1339  KateHlManager::self()->syntax->freeGroupInfo(data);
1340  }
1341 }
1342 
1343 void KateHighlighting::readFoldingConfig()
1344 {
1345 #ifdef HIGHLIGHTING_DEBUG
1346  kDebug(13010)<<"readfoldignConfig:BEGIN";
1347 #endif
1348 
1349  // Tell the syntax document class which file we want to parse
1350  KateHlManager::self()->syntax->setIdentifier(buildIdentifier);
1351  KateSyntaxContextData *data = KateHlManager::self()->syntax->getConfig("general","folding");
1352 
1353  if (data)
1354  {
1355 #ifdef HIGHLIGHTING_DEBUG
1356  kDebug(13010)<<"Found global keyword config";
1357 #endif
1358 
1359  m_foldingIndentationSensitive = IS_TRUE( KateHlManager::self()->syntax->groupItemData(data, QString("indentationsensitive")) );
1360 
1361  KateHlManager::self()->syntax->freeGroupInfo(data);
1362  }
1363  else
1364  {
1365  //Default values
1366  m_foldingIndentationSensitive = false;
1367  }
1368 
1369 #ifdef HIGHLIGHTING_DEBUG
1370  kDebug(13010)<<"readfoldingConfig:END";
1371  kDebug(13010)<<"############################ use indent for fold are: "<<m_foldingIndentationSensitive;
1372 #endif
1373 }
1374 
1375 void KateHighlighting::readSpellCheckingConfig()
1376 {
1377  KateHlManager::self()->syntax->setIdentifier(buildIdentifier);
1378  KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("spellchecking","encoding");
1379 
1380  if (data)
1381  {
1382  while (KateHlManager::self()->syntax->nextGroup(data))
1383  {
1384  QString encoding = KateHlManager::self()->syntax->groupData(data,"string");
1385  QString character = KateHlManager::self()->syntax->groupData(data,"char");
1386  QString ignored = KateHlManager::self()->syntax->groupData(data,"ignored");
1387 
1388  const bool ignoredIsTrue = IS_TRUE(ignored);
1389  if(encoding.isEmpty() || (character.isEmpty() && !ignoredIsTrue))
1390  {
1391  continue;
1392  }
1393  QRegExp newLineRegExp("\\r|\\n");
1394  if(encoding.indexOf(newLineRegExp) >= 0)
1395  {
1396  encoding.replace(newLineRegExp, "<\\n|\\r>");
1397 
1398 #ifdef HIGHLIGHTING_DEBUG
1399  kDebug() << "Encoding" << encoding
1400  << "contains new-line characters. Ignored.";
1401 #endif
1402  }
1403  QChar c = (character.isEmpty() || ignoredIsTrue) ? QChar() : character[0];
1404  addCharacterEncoding(buildIdentifier, encoding, c);
1405  }
1406 
1407  KateHlManager::self()->syntax->freeGroupInfo(data);
1408  }
1409 
1410  data=KateHlManager::self()->syntax->getConfig("spellchecking","configuration");
1411  if (data)
1412  {
1413  QString policy = KateHlManager::self()->syntax->groupItemData(data,"encodingReplacementPolicy");
1414  QString policyLowerCase = policy.toLower();
1415  int p;
1416 
1417  if(policyLowerCase == "encodewhenpresent") {
1418  p = KateDocument::EncodeWhenPresent;
1419  }
1420  else if(policyLowerCase == "encodealways") {
1421  p = KateDocument::EncodeAlways;
1422  }
1423  else {
1424  p = KateDocument::EncodeNever;
1425  }
1426 
1427  m_additionalData[buildIdentifier]->encodedCharactersInsertionPolicy = p;
1428 
1429  KateHlManager::self()->syntax->freeGroupInfo(data);
1430  }
1431 }
1432 
1433 void KateHighlighting::createContextNameList(QStringList *ContextNameList,int ctx0)
1434 {
1435 #ifdef HIGHLIGHTING_DEBUG
1436  kDebug(13010)<<"creatingContextNameList:BEGIN";
1437 #endif
1438 
1439  if (ctx0 == 0)
1440  ContextNameList->clear();
1441 
1442  KateHlManager::self()->syntax->setIdentifier(buildIdentifier);
1443 
1444  KateSyntaxContextData *data=KateHlManager::self()->syntax->getGroupInfo("highlighting","context");
1445 
1446  int id=ctx0;
1447 
1448  if (data)
1449  {
1450  while (KateHlManager::self()->syntax->nextGroup(data))
1451  {
1452  QString tmpAttr=KateHlManager::self()->syntax->groupData(data,QString("name")).simplified();
1453  if (tmpAttr.isEmpty())
1454  {
1455  tmpAttr = QString("!KATE_INTERNAL_DUMMY! %1").arg(id);
1456  errorsAndWarnings += i18n("<b>%1</b>: Deprecated syntax. Context %2 has no symbolic name<br />", buildIdentifier, id-ctx0);
1457  }
1458  else tmpAttr = buildPrefix + tmpAttr;
1459  (*ContextNameList) << tmpAttr;
1460  id++;
1461  }
1462  KateHlManager::self()->syntax->freeGroupInfo(data);
1463  }
1464 
1465 #ifdef HIGHLIGHTING_DEBUG
1466  kDebug(13010)<<"creatingContextNameList:END";
1467 #endif
1468 }
1469 
1470 KateHlContextModification KateHighlighting::getContextModificationFromString(QStringList *ContextNameList, QString tmpLineEndContext, /*NO CONST*/ QString &unres)
1471 {
1472  // nothing unresolved
1473  unres = "";
1474 
1475  // context to push on stack
1476  int context = -1;
1477 
1478  // number of contexts to pop
1479  int pops = 0;
1480 
1481  // we allow arbitrary #stay and #pop at the start
1482  bool anyFound = false;
1483  while (tmpLineEndContext.startsWith(QLatin1String("#stay")) ||
1484  tmpLineEndContext.startsWith(QLatin1String("#pop")))
1485  {
1486  // ignore stay
1487  if (tmpLineEndContext.startsWith(QLatin1String("#stay")))
1488  {
1489  tmpLineEndContext.remove (0, 5);
1490  }
1491  else // count the pops
1492  {
1493  ++pops;
1494  tmpLineEndContext.remove (0, 4);
1495  }
1496 
1497  anyFound = true;
1498  }
1499 
1503  if (anyFound && !tmpLineEndContext.isEmpty())
1504  {
1505  if (tmpLineEndContext.startsWith('!'))
1506  tmpLineEndContext.remove (0, 1);
1507  }
1508 
1512  if (tmpLineEndContext.isEmpty())
1513  return KateHlContextModification (context, pops);
1514 
1519  if ( tmpLineEndContext.contains("##"))
1520  {
1521  int o = tmpLineEndContext.indexOf("##");
1522  // FIXME at least with 'foo##bar'-style contexts the rules are picked up
1523  // but the default attribute is not
1524  QString tmp=tmpLineEndContext.mid(o+2);
1525  if (!embeddedHls.contains(tmp)) embeddedHls.insert(tmp,KateEmbeddedHlInfo());
1526  unres=tmp+':'+tmpLineEndContext.left(o);
1527 
1528 #ifdef HIGHLIGHTING_DEBUG
1529  kDebug(13010) << "unres = " << unres;
1530 #endif
1531 
1532  context=0;
1533  }
1534 
1535  else
1536  {
1537  context=ContextNameList->indexOf(buildPrefix+tmpLineEndContext);
1538  if (context==-1)
1539  {
1540  context=tmpLineEndContext.toInt();
1541  errorsAndWarnings+=i18n(
1542  "<B>%1</B>:Deprecated syntax. Context %2 not addressed by a symbolic name"
1543  , buildIdentifier, tmpLineEndContext);
1544  }
1545 //#warning restructure this the name list storage.
1546 // context=context+buildContext0Offset;
1547  }
1548 
1549  return KateHlContextModification (context, pops);
1550 }
1551 
1557 void KateHighlighting::makeContextList()
1558 {
1559  if (noHl) // if this a highlighting for "normal texts" only, tere is no need for a context list creation
1560  return;
1561 
1562  embeddedHls.clear();
1563  embeddedHighlightingModes.clear();
1564  unresolvedContextReferences.clear();
1565  RegionList.clear();
1566  ContextNameList.clear();
1567 
1568  // prepare list creation. To reuse as much code as possible handle this
1569  // highlighting the same way as embedded onces
1570  embeddedHls.insert(iName,KateEmbeddedHlInfo());
1571 
1572  bool something_changed;
1573  // the context "0" id is 0 for this hl, all embedded context "0"s have offsets
1574  startctx=base_startctx=0;
1575  // inform everybody that we are building the highlighting contexts and itemlists
1576  building=true;
1577 
1578  do
1579  {
1580 #ifdef HIGHLIGHTING_DEBUG
1581  kDebug(13010)<<"**************** Outer loop in make ContextList";
1582  kDebug(13010)<<"**************** Hl List count:"<<embeddedHls.count();
1583 #endif
1584 
1585  something_changed=false; //assume all "embedded" hls have already been loaded
1586  for (KateEmbeddedHlInfos::iterator it=embeddedHls.begin(); it!=embeddedHls.end();++it)
1587  {
1588  if (!it.value().loaded) // we found one, we still have to load
1589  {
1590 #ifdef HIGHLIGHTING_DEBUG
1591  kDebug(13010)<<"**************** Inner loop in make ContextList";
1592 #endif
1593 
1594  QString identifierToUse;
1595 
1596 #ifdef HIGHLIGHTING_DEBUG
1597  kDebug(13010)<<"Trying to open highlighting definition file: "<< it.key();
1598 #endif
1599 
1600  if (iName==it.key()) // the own identifier is known
1601  identifierToUse=identifier;
1602  else // all others have to be looked up
1603  identifierToUse=KateHlManager::self()->identifierForName(it.key());
1604 
1605 #ifdef HIGHLIGHTING_DEBUG
1606  kDebug(13010)<<"Location is:"<< identifierToUse;
1607 #endif
1608 
1609  if (identifierToUse.isEmpty() )
1610  kWarning(13010)<<"Unknown highlighting description referenced:" << it.key() << "in" << identifier;
1611 
1612  buildPrefix=it.key()+':'; // attribute names get prefixed by the names
1613  // of the highlighting definitions they belong to
1614 
1615 
1616 #ifdef HIGHLIGHTING_DEBUG
1617  kDebug(13010)<<"setting ("<<it.key()<<") to loaded";
1618 #endif
1619 
1620  //mark hl as loaded
1621  it=embeddedHls.insert(it.key(),KateEmbeddedHlInfo(true,startctx));
1622  //set class member for context 0 offset, so we don't need to pass it around
1623  buildContext0Offset=startctx;
1624  //parse one hl definition file
1625  startctx=addToContextList(identifierToUse,startctx);
1626 
1627  if (noHl) return; // an error occurred
1628 
1629  base_startctx = startctx;
1630  something_changed=true; // something has been loaded
1631  }
1632  }
1633  } while (something_changed); // as long as there has been another file parsed
1634  // repeat everything, there could be newly added embedded hls.
1635 
1636 
1637 #ifdef HIGHLIGHTING_DEBUG
1638  // at this point all needed highlighing (sub)definitions are loaded. It's time
1639  // to resolve cross file references (if there are any)#
1640  kDebug(13010)<<"Unresolved contexts, which need attention: "<<unresolvedContextReferences.count();
1641 #endif
1642 
1643  //optimize this a littlebit
1644  for (KateHlUnresolvedCtxRefs::iterator unresIt=unresolvedContextReferences.begin();
1645  unresIt != unresolvedContextReferences.end();
1646  ++unresIt)
1647  {
1648  QString incCtx = unresIt.value();
1649 
1650 #ifdef HIGHLIGHTING_DEBUG
1651  kDebug(13010) << "Context " <<incCtx << " is unresolved";
1652 #endif
1653 
1654  // only resolve '##Name' contexts here; handleKateHlIncludeRules() can figure
1655  // out 'Name##Name'-style inclusions, but we screw it up
1656  if (incCtx.endsWith(':')) {
1657 #ifdef HIGHLIGHTING_DEBUG
1658  kDebug(13010)<<"Looking up context0 for ruleset "<<incCtx;
1659 #endif
1660 
1661  incCtx = incCtx.left(incCtx.length()-1);
1662  //try to find the context0 id for a given unresolvedReference
1663  KateEmbeddedHlInfos::const_iterator hlIt=embeddedHls.constFind(incCtx);
1664  if (hlIt!=embeddedHls.constEnd())
1665  *(unresIt.key())=hlIt.value().context0;
1666  }
1667  }
1668 
1669  // eventually handle KateHlIncludeRules items, if they exist.
1670  // This has to be done after the cross file references, because it is allowed
1671  // to include the context0 from a different definition, than the one the rule
1672  // belongs to
1673  handleKateHlIncludeRules();
1674 
1675  embeddedHighlightingModes = embeddedHls.keys();
1676  embeddedHighlightingModes.removeOne(iName);
1677 
1678  embeddedHls.clear(); //save some memory.
1679  unresolvedContextReferences.clear(); //save some memory
1680  RegionList.clear(); // I think you get the idea ;)
1681  ContextNameList.clear();
1682 
1683 
1684  // if there have been errors show them
1685  if (!errorsAndWarnings.isEmpty())
1686  KMessageBox::detailedSorry(QApplication::activeWindow(),i18n(
1687  "There were warning(s) and/or error(s) while parsing the syntax "
1688  "highlighting configuration."),
1689  errorsAndWarnings, i18n("Kate Syntax Highlighting Parser"));
1690 
1691  // we have finished
1692  building=false;
1693 
1694  Q_ASSERT(m_contexts.size() > 0);
1695 }
1696 
1697 void KateHighlighting::handleKateHlIncludeRules()
1698 {
1699  // if there are noe include rules to take care of, just return
1700 #ifdef HIGHLIGHTING_DEBUG
1701  kDebug(13010)<<"KateHlIncludeRules, which need attention: " <<includeRules.size();
1702 #endif
1703 
1704  if (includeRules.isEmpty()) return;
1705 
1706  buildPrefix="";
1707  QString dummy;
1708 
1709  // By now the context0 references are resolved, now more or less only inner
1710  // file references are resolved. If we decide that arbitrary inclusion is
1711  // needed, this doesn't need to be changed, only the addToContextList
1712  // method.
1713 
1714  //resolove context names
1715  for (KateHlIncludeRules::iterator it=includeRules.begin(); it!=includeRules.end(); )
1716  {
1717  if ((*it)->incCtx.newContext==-1) // context unresolved ?
1718  {
1719 
1720  if ((*it)->incCtxN.isEmpty())
1721  {
1722  // no context name given, and no valid context id set, so this item is
1723  // going to be removed
1724  KateHlIncludeRules::iterator it1=it;
1725  ++it1;
1726  delete (*it);
1727  includeRules.erase(it);
1728  it=it1;
1729  }
1730  else
1731  {
1732  // resolve name to id
1733  (*it)->incCtx=getContextModificationFromString(&ContextNameList,(*it)->incCtxN,dummy).newContext;
1734 
1735 #ifdef HIGHLIGHTING_DEBUG
1736  kDebug(13010)<<"Resolved "<<(*it)->incCtxN<< " to "<<(*it)->incCtx.newContext<<" for include rule";
1737 #endif
1738 
1739  // It would be good to look here somehow, if the result is valid
1740  }
1741  }
1742  else ++it; //nothing to do, already resolved (by the cross definition reference resolver)
1743  }
1744 
1745  // now that all KateHlIncludeRule items should be valid and completely resolved,
1746  // do the real inclusion of the rules.
1747  // recursiveness is needed, because context 0 could include context 1, which
1748  // itself includes context 2 and so on.
1749  // In that case we have to handle context 2 first, then 1, 0
1750  //TODO: catch circular references: eg 0->1->2->3->1
1751  for (int i=0; i<includeRules.count(); i++)
1752  handleKateHlIncludeRulesRecursive(i, &includeRules);
1753  qDeleteAll(includeRules);
1754  includeRules.clear();
1755 }
1756 
1757 void KateHighlighting::handleKateHlIncludeRulesRecursive(int index, KateHlIncludeRules *list)
1758 {
1759  if (index < 0 || index >= list->count()) return; //invalid iterator, shouldn't happen, but better have a rule prepared ;)
1760 
1761  int index1 = index;
1762  int ctx = list->at(index1)->ctx;
1763 
1764  if (ctx == -1) return; // skip already processed entries
1765 
1766  // find the last entry for the given context in the KateHlIncludeRules list
1767  // this is need if one context includes more than one. This saves us from
1768  // updating all insert positions:
1769  // eg: context 0:
1770  // pos 3 - include context 2
1771  // pos 5 - include context 3
1772  // During the building of the includeRules list the items are inserted in
1773  // ascending order, now we need it descending to make our life easier.
1774  while (index < list->count() && list->at(index)->ctx == ctx)
1775  {
1776  index1 = index;
1777  ++index;
1778  }
1779 
1780  // iterate over each include rule for the context the function has been called for.
1781  while (index1 >= 0 && index1 < list->count() && list->at(index1)->ctx == ctx)
1782  {
1783  KateHlContextModification ctx1 = list->at(index1)->incCtx;
1784 
1785  //let's see, if the included context includes other contexts
1786  for (int index2 = 0; index2 < list->count(); ++index2)
1787  {
1788  if (list->at(index2)->ctx == ctx1.newContext)
1789  {
1790  if (index2 == index1) {
1791  // prevent accidental infinite recursion
1792  kWarning() << "infinite recursion in IncludeRules in language file for " << iName << "in context" << list->at(index1)->incCtxN;
1793  continue;
1794  }
1795  //yes it does, so first handle that include rules, since we want to
1796  // include those subincludes too
1797  handleKateHlIncludeRulesRecursive(index2, list);
1798  break;
1799  }
1800  }
1801 
1802  // if the context we want to include had sub includes, they are already inserted there.
1803  KateHlContext *dest=m_contexts[ctx];
1804  KateHlContext *src=m_contexts[ctx1.newContext];
1805 // kDebug(3010)<<"linking included rules from "<<ctx<<" to "<<ctx1;
1806 
1807  // If so desired, change the dest attribute to the one of the src.
1808  // Required to make commenting work, if text matched by the included context
1809  // is a different highlight than the host context.
1810  if ( list->at(index1)->includeAttrib )
1811  dest->attr = src->attr;
1812 
1813  // insert the included context's rules starting at position p
1814  int p = list->at(index1)->pos;
1815 
1816  // remember some stuff
1817  int oldLen = dest->items.size();
1818  uint itemsToInsert = src->items.size();
1819 
1820  // resize target
1821  dest->items.resize (oldLen + itemsToInsert);
1822 
1823  // move old elements
1824  for (int i=oldLen-1; i >= p; --i)
1825  dest->items[i+itemsToInsert] = dest->items[i];
1826 
1827  // insert new stuff
1828  for (uint i=0; i < itemsToInsert; ++i )
1829  dest->items[p+i] = src->items[i];
1830 
1831  index = index1; //backup the iterator
1832  --index1; //move to the next entry, which has to be take care of
1833  list->at(index)->ctx = -1; // set ctx to -1 to mark already processed entries
1834  }
1835 }
1836 
1842 int KateHighlighting::addToContextList(const QString &ident, int ctx0)
1843 {
1844  //kDebug(13010)<<"=== Adding hl with ident '"<<ident<<"' ctx0="<<ctx0;
1845 
1846  buildIdentifier=ident;
1847  QString dummy;
1848 
1849  // Let the syntax document class know, which file we'd like to parse
1850  if (!KateHlManager::self()->syntax->setIdentifier(ident))
1851  {
1852  noHl=true;
1853  KMessageBox::information(QApplication::activeWindow(),i18n(
1854  "Since there has been an error parsing the highlighting description, "
1855  "this highlighting will be disabled"));
1856  return 0;
1857  }
1858 
1859  // only read for the own stuff
1860  if (identifier == ident)
1861  {
1862  readIndentationConfig ();
1863  }
1864 
1865  RegionList<<"!KateInternal_TopLevel!";
1866 
1867  m_hlIndex[internalIDList.count()] = ident;
1868  m_ctxIndex[ctx0]=ident;
1869 
1870  // clear and reuse or create new
1871  if (m_additionalData[ident])
1872  *m_additionalData[ident] = HighlightPropertyBag ();
1873  else
1874  m_additionalData.insert( ident, new HighlightPropertyBag );
1875 
1876  // fill out the propertybag
1877  readCommentConfig();
1878  readEmptyLineConfig();
1879  readGlobalKeywordConfig();
1880  readWordWrapConfig();
1881 
1882  // only read for ourself
1883  if (identifier == ident)
1884  readFoldingConfig ();
1885 
1886  readSpellCheckingConfig();
1887 
1888  // This list is needed for the translation of the attribute parameter,
1889  // if the itemData name is given instead of the index
1890  addToKateExtendedAttributeList();
1891  QList<KateExtendedAttribute::Ptr> iDl = internalIDList;
1892 
1893  createContextNameList(&ContextNameList,ctx0);
1894 
1895 #ifdef HIGHLIGHTING_DEBUG
1896  kDebug(13010)<<"Parsing Context structure";
1897 #endif
1898 
1899  //start the real work
1900  uint i=buildContext0Offset;
1901  KateSyntaxContextData * data = KateHlManager::self()->syntax->getGroupInfo("highlighting", "context");
1902  if (data)
1903  {
1904  while (KateHlManager::self()->syntax->nextGroup(data))
1905  {
1906 #ifdef HIGHLIGHTING_DEBUG
1907  kDebug(13010)<<"Found a context in file, building structure now";
1908 #endif
1909 
1910  //BEGIN - Translation of the attribute parameter
1911  QString tmpAttr=KateHlManager::self()->syntax->groupData(data,QString("attribute")).simplified();
1912  int attr;
1913  if (QString("%1").arg(tmpAttr.toInt())==tmpAttr)
1914  attr=tmpAttr.toInt();
1915  else
1916  attr=lookupAttrName(tmpAttr,iDl);
1917  //END - Translation of the attribute parameter
1918 
1919  QString tmpLineEndContext=KateHlManager::self()->syntax->groupData(data,QString("lineEndContext")).simplified();
1920  KateHlContextModification context;
1921 
1922  context=getContextModificationFromString(&ContextNameList, tmpLineEndContext,dummy);
1923 
1924  QString tmpNIBF = KateHlManager::self()->syntax->groupData(data, QString("noIndentationBasedFolding") );
1925  bool noIndentationBasedFolding=IS_TRUE(tmpNIBF);
1926 
1927  //BEGIN get fallthrough props
1928  KateHlContextModification ftc = 0; // fallthrough context
1929  QString tmpFt = KateHlManager::self()->syntax->groupData(data, QString("fallthrough") );
1930  const bool ft = IS_TRUE(tmpFt);
1931  if ( ft )
1932  {
1933  QString tmpFtc = KateHlManager::self()->syntax->groupData( data, QString("fallthroughContext") );
1934 
1935  ftc=getContextModificationFromString(&ContextNameList, tmpFtc,dummy);
1936 
1937  // stay is not allowed, we need to #pop or push some context...
1938  if (ftc.type == KateHlContextModification::doNothing) ftc = 0;
1939 
1940 #ifdef HIGHLIGHTING_DEBUG
1941  kDebug(13010)<<"Setting fall through context (context "<<i<<"): "<<ftc.newContext;
1942 #endif
1943  }
1944  //END falltrhough props
1945 
1946  // empty line context
1947  QString emptyLineContext = KateHlManager::self()->syntax->groupData( data, QString("lineEmptyContext") );
1948  KateHlContextModification emptyLineContextModification;
1949  if (!emptyLineContext.isEmpty())
1950  emptyLineContextModification = getContextModificationFromString(&ContextNameList, emptyLineContext, dummy);
1951 
1952  bool dynamic = false;
1953  QString tmpDynamic = KateHlManager::self()->syntax->groupData(data, QString("dynamic") );
1954  if ( tmpDynamic.toLower() == "true" || tmpDynamic.toInt() == 1 )
1955  dynamic = true;
1956 
1957  KateHlContext *ctxNew = new KateHlContext (
1958  ident,
1959  attr,
1960  context,
1961  ft, ftc, dynamic, noIndentationBasedFolding,
1962  !emptyLineContext.isEmpty(), emptyLineContextModification);
1963 
1964  m_contexts.push_back (ctxNew);
1965 
1966 #ifdef HIGHLIGHTING_DEBUG
1967  kDebug(13010) << "INDEX: " << i << " LENGTH " << m_contexts.size()-1;
1968 #endif
1969 
1970  //Let's create all items for the context
1971  while (KateHlManager::self()->syntax->nextItem(data))
1972  {
1973 // kDebug(13010)<< "In make Contextlist: Item:";
1974 
1975  // KateHlIncludeRules : add a pointer to each item in that context
1976  // TODO add a attrib includeAttrib
1977  QString tag = KateHlManager::self()->syntax->groupItemData(data,QString(""));
1978  if ( tag == "IncludeRules" ) //if the new item is an Include rule, we have to take special care
1979  {
1980  QString incCtx = KateHlManager::self()->syntax->groupItemData( data, QString("context"));
1981  QString incAttrib = KateHlManager::self()->syntax->groupItemData( data, QString("includeAttrib"));
1982  bool includeAttrib = IS_TRUE( incAttrib );
1983 
1984  // only context refernces of type Name, ##Name, and Subname##Name are allowed
1985  if (incCtx.startsWith("##") || (!incCtx.startsWith('#')))
1986  {
1987  int incCtxi = incCtx.indexOf ("##");
1988  //#stay, #pop is not interesting here
1989  if (incCtxi >= 0)
1990  {
1991  QString incSet = incCtx.mid(incCtxi + 2);
1992  QString incCtxN = incSet + ':' + incCtx.left(incCtxi);
1993 
1994  //a cross highlighting reference
1995 #ifdef HIGHLIGHTING_DEBUG
1996  kDebug(13010)<<"Cross highlight reference <IncludeRules>, context "<<incCtxN;
1997 #endif
1998 
1999  KateHlIncludeRule *ir=new KateHlIncludeRule(i,m_contexts[i]->items.count(),incCtxN,includeAttrib);
2000 
2001  //use the same way to determine cross hl file references as other items do
2002  if (!embeddedHls.contains(incSet))
2003  embeddedHls.insert(incSet,KateEmbeddedHlInfo());
2004 #ifdef HIGHLIGHTING_DEBUG
2005  else
2006  kDebug(13010)<<"Skipping embeddedHls.insert for "<<incCtxN;
2007 #endif
2008 
2009  unresolvedContextReferences.insert(&(ir->incCtx), incCtxN);
2010 
2011  includeRules.append(ir);
2012  }
2013  else
2014  {
2015  // a local reference -> just initialize the include rule structure
2016  incCtx=buildPrefix+incCtx.simplified ();
2017  includeRules.append(new KateHlIncludeRule(i,m_contexts[i]->items.count(),incCtx, includeAttrib));
2018  }
2019  }
2020 
2021  continue;
2022  }
2023 // TODO -- can we remove the block below??
2024 #if 0
2025  QString tag = KateHlManager::self()->syntax->groupKateExtendedAttribute(data,QString(""));
2026  if ( tag == "IncludeRules" ) {
2027  // attrib context: the index (jowenn, i think using names here
2028  // would be a cool feat, goes for mentioning the context in
2029  // any item. a map or dict?)
2030  int ctxId = getIdFromString(&ContextNameList,
2031  KateHlManager::self()->syntax->groupKateExtendedAttribute( data, QString("context")),dummy); // the index is *required*
2032  if ( ctxId > -1) { // we can even reuse rules of 0 if we want to:)
2033  kDebug(13010)<<"makeContextList["<<i<<"]: including all items of context "<<ctxId;
2034  if ( ctxId < (int) i ) { // must be defined
2035  for ( c = m_contexts[ctxId]->items.first(); c; c = m_contexts[ctxId]->items.next() )
2036  m_contexts[i]->items.append(c);
2037  }
2038  else
2039  kDebug(13010)<<"Context "<<ctxId<<"not defined. You can not include the rules of an undefined context";
2040  }
2041  continue; // while nextItem
2042  }
2043 #endif
2044  KateHlItem * c = createKateHlItem(data, iDl, &RegionList, &ContextNameList);
2045  if (c)
2046  {
2047  m_contexts[i]->items.append(c);
2048 
2049  // Not supported completely atm and only one level. Subitems.(all have
2050  // to be matched to at once)
2051  KateSyntaxContextData * datasub = KateHlManager::self()->syntax->getSubItems(data);
2052  for (bool tmpbool=KateHlManager::self()->syntax->nextItem(datasub);
2053  tmpbool;
2054  tmpbool=KateHlManager::self()->syntax->nextItem(datasub))
2055  {
2056  c->subItems.resize (c->subItems.size()+1);
2057  c->subItems[c->subItems.size()-1] = createKateHlItem(datasub,iDl,&RegionList,&ContextNameList);
2058  }
2059  KateHlManager::self()->syntax->freeGroupInfo(datasub);
2060  }
2061  }
2062  i++;
2063  }
2064 
2065  KateHlManager::self()->syntax->freeGroupInfo(data);
2066  } else {
2067  // error handling: no "context" element at all in the xml file
2068  noHl = true;
2069  kWarning() << "There is no \"context\" in the highlighting file:" << buildIdentifier;
2070  }
2071 
2072 
2073  if (RegionList.count()!=1)
2074  folding=true;
2075 
2076  folding = folding || m_foldingIndentationSensitive;
2077 
2078  //BEGIN Resolve multiline region if possible
2079  if (!m_additionalData[ ident ]->multiLineRegion.isEmpty()) {
2080  long commentregionid=RegionList.indexOf( m_additionalData[ ident ]->multiLineRegion );
2081  if (-1==commentregionid) {
2082  errorsAndWarnings+=i18n(
2083  "<b>%1</b>: Specified multiline comment region (%2) could not be resolved<br />"
2084  , buildIdentifier, m_additionalData[ ident ]->multiLineRegion );
2085  m_additionalData[ ident ]->multiLineRegion.clear();
2086 
2087 #ifdef HIGHLIGHTING_DEBUG
2088  kDebug(13010)<<"ERROR comment region attribute could not be resolved";
2089 #endif
2090  } else {
2091  m_additionalData[ ident ]->multiLineRegion=QString::number(commentregionid+1);
2092 
2093 #ifdef HIGHLIGHTING_DEBUG
2094  kDebug(13010)<<"comment region resolved to:"<<m_additionalData[ ident ]->multiLineRegion;
2095 #endif
2096  }
2097  }
2098  //END Resolve multiline region if possible
2099  return i;
2100 }
2101 
2102 void KateHighlighting::clearAttributeArrays ()
2103 {
2104  QMutableHashIterator< QString, QList<KTextEditor::Attribute::Ptr> > it = m_attributeArrays;
2105  while (it.hasNext())
2106  {
2107  it.next();
2108 
2109  // k, schema correct, let create the data
2110  KateAttributeList defaultStyleList;
2111 
2112  KateHlManager::self()->getDefaults(it.key(), defaultStyleList);
2113 
2114  QList<KateExtendedAttribute::Ptr> itemDataList;
2115  getKateExtendedAttributeList(it.key(), itemDataList);
2116 
2117  uint nAttribs = itemDataList.count();
2118  QList<KTextEditor::Attribute::Ptr>& array = it.value();
2119  array.clear();
2120 
2121  for (uint z = 0; z < nAttribs; z++)
2122  {
2123  KateExtendedAttribute::Ptr itemData = itemDataList.at(z);
2124  KTextEditor::Attribute::Ptr newAttribute( new KTextEditor::Attribute(*defaultStyleList.at(itemData->defaultStyleIndex())) );
2125 
2126  if (itemData && itemData->hasAnyProperty())
2127  *newAttribute += *itemData;
2128 
2129  array.append(newAttribute);
2130  }
2131  }
2132 }
2133 
2134 QList<KTextEditor::Attribute::Ptr> KateHighlighting::attributes (const QString &schema)
2135 {
2136  // found it, already floating around
2137  if (m_attributeArrays.contains(schema))
2138  return m_attributeArrays[schema];
2139 
2140  // k, schema correct, let create the data
2141  QList<KTextEditor::Attribute::Ptr> array;
2142  KateAttributeList defaultStyleList;
2143 
2144  KateHlManager::self()->getDefaults(schema, defaultStyleList);
2145 
2146  QList<KateExtendedAttribute::Ptr> itemDataList;
2147  getKateExtendedAttributeList(schema, itemDataList);
2148 
2149  uint nAttribs = itemDataList.count();
2150  for (uint z = 0; z < nAttribs; z++)
2151  {
2152  KateExtendedAttribute::Ptr itemData = itemDataList.at(z);
2153  KTextEditor::Attribute::Ptr newAttribute( new KTextEditor::Attribute(*defaultStyleList.at(itemData->defaultStyleIndex())) );
2154 
2155  if (itemData && itemData->hasAnyProperty())
2156  *newAttribute += *itemData;
2157 
2158  array.append(newAttribute);
2159  }
2160 
2161  m_attributeArrays.insert(schema, array);
2162 
2163  return array;
2164 }
2165 
2166 QStringList KateHighlighting::getEmbeddedHighlightingModes() const
2167 {
2168  return embeddedHighlightingModes;
2169 }
2170 
2171 bool KateHighlighting::isEmptyLine(const Kate::TextLineData *textline) const
2172 {
2173  const QString &txt=textline->string();
2174  if (txt.isEmpty())
2175  return true;
2176 
2177  QLinkedList<QRegExp> l;
2178  l=emptyLines(textline->attribute(0));
2179  if (l.isEmpty()) return false;
2180  foreach(const QRegExp &re,l) {
2181  if (re.exactMatch(txt)) return true;
2182  }
2183  return false;
2184 }
2185 
2186 //END
2187 
2188 // kate: space-indent on; indent-width 2; replace-tabs on;
KateEmbeddedHlInfo
Definition: katehighlight.h:103
QColor
KatePrefixStore
This class can be used to efficiently search for occurrences of strings in a given string...
Definition: prefixstore.h:41
KateHlItem::lineContinue
virtual bool lineContinue()
Definition: katehighlighthelpers.h:40
KateSyntaxDocument::freeGroupInfo
void freeGroupInfo(KateSyntaxContextData *data)
Definition: katesyntaxdocument.cpp:196
Kate::TextLineData::attribute
short attribute(int pos) const
Gets the attribute at the given position use KRenderer::attributes to get the KTextAttribute for this...
Definition: katetextline.h:376
KSharedPtr< KateExtendedAttribute >
katehighlight.h
katetextline.h
Kate::Script::i18n
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
KateHighlighting::canComment
bool canComment(int startAttr, int endAttr) const
Definition: katehighlight.cpp:1111
dummy
static int dummy
Definition: katedocument.cpp:101
kdebug.h
KSharedPtr::data
T * data()
katerenderer.h
kmimetype.h
KTextEditor::Attribute
KateHlContextModification::doNothing
Definition: katehighlight.h:65
kapplication.h
Kate::TextLineData::indentDepth
int indentDepth(int tabWidth) const
Returns the indentation depth with each tab expanded into tabWidth characters.
Definition: katetextline.cpp:81
KateSyntaxDocument::getSubItems
KateSyntaxContextData * getSubItems(KateSyntaxContextData *data)
Definition: katesyntaxdocument.cpp:201
Kate::TextLineData::Attribute
Attribute storage.
Definition: katetextline.h:52
KateSyntaxModeListItem::style
QString style
Default styles provided by the highlighter.
Definition: katesyntaxdocument.h:47
KateSyntaxModeListItem::section
QString section
Submenu section (eg. Assembly)
Definition: katesyntaxdocument.h:39
kglobalsettings.h
Kate::Script::i18nc
QScriptValue i18nc(QScriptContext *context, QScriptEngine *engine)
i18nc("context", "text", arguments [optional])
Definition: katescripthelpers.cpp:210
KateHlContextModification::pops
int pops
number of contexts to pop from the stack before pushing a new context on it
Definition: katehighlight.h:100
Kate::TextLineData::ContextStack
QVector< short > ContextStack
Context stack.
Definition: katetextline.h:47
KateHlContext::fallthrough
bool fallthrough
Definition: katehighlighthelpers.h:91
KateExtendedAttribute::defaultStyleIndex
int defaultStyleIndex() const
Definition: kateextendedattribute.cpp:69
KateSyntaxModeListItem::hidden
bool hidden
Hides the mode from Kate's menus.
Definition: katesyntaxdocument.h:51
KateHlItem
Definition: katehighlighthelpers.h:28
KateHighlighting::clearAttributeArrays
void clearAttributeArrays()
Definition: katehighlight.cpp:2102
KateHighlighting::KateHighlighting
KateHighlighting(const KateSyntaxModeListItem *def)
Definition: katehighlight.cpp:71
KMessageBox::information
static void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
KateHlWordDetect
Definition: katehighlighthelpers.h:163
KateHighlighting::getCommentStart
QString getCommentStart(int attrib=0) const
Definition: katehighlight.cpp:1119
kconfig.h
KateHighlighting::use
void use()
Increase the usage count, and trigger initialization if needed.
Definition: katehighlight.cpp:719
katedocument.h
KateHlContext::dynamic
bool dynamic
Definition: katehighlighthelpers.h:94
KateHlLineContinue
Definition: katehighlighthelpers.h:243
KateHlItem::onlyConsume
bool onlyConsume
Definition: katehighlighthelpers.h:58
KateHlItem::subItems
QVector< KateHlItem * > subItems
Definition: katehighlighthelpers.h:47
KTextEditor::Attribute::selectedForeground
QBrush selectedForeground() const
KConfigGroup::writeEntry
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
KateHlItem::ctx
KateHlContextModification ctx
Definition: katehighlighthelpers.h:49
kateextendedattribute.h
KateHlItem::haveCache
bool haveCache
Definition: katehighlighthelpers.h:67
Kate::TextLineData::length
int length() const
Returns the line's length.
Definition: katetextline.h:266
Kate::TextLineData::addAttribute
void addAttribute(const Attribute &attribute)
Add attribute to this line.
Definition: katetextline.cpp:185
KateHighlighting::isEmptyLine
bool isEmptyLine(const Kate::TextLineData *textline) const
Definition: katehighlight.cpp:2171
QString
KateHlContextModification::doPopsAndPush
Definition: katehighlight.h:68
KateHighlighting::canBreakAt
bool canBreakAt(QChar c, int attrib=0) const
Definition: katehighlight.cpp:1091
KateHighlighting::CSLPosAfterWhitespace
Definition: katehighlight.h:219
QHash
KTextEditor::HighlightInterface::dsNormal
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
IS_TRUE
#define IS_TRUE(x)
Definition: katehighlight.cpp:63
klocale.h
Kate::TextLineData
Class representing a single text line.
Definition: katetextline.h:37
KTextEditor::Attribute::setSelectedForeground
void setSelectedForeground(const QBrush &foreground)
KateHighlighting::hlKeyForAttrib
QString hlKeyForAttrib(int attrib) const
map attribute to its highlighting file.
Definition: katehighlight.cpp:1068
KateHlItem::region
signed char region
Definition: katehighlighthelpers.h:50
KateHighlighting::emptyLines
QLinkedList< QRegExp > emptyLines(int attribute=0) const
Definition: katehighlight.cpp:1097
Kate::TextLineData::setHlLineContinue
void setHlLineContinue(bool cont)
set hl continue flag
Definition: katetextline.h:394
KateSyntaxModeListItem::version
QString version
Definition: katesyntaxdocument.h:43
KateHighlighting::getCommentEnd
QString getCommentEnd(int attrib=0) const
Definition: katehighlight.cpp:1124
config
KSharedConfigPtr config()
KateHlContext::items
QVector< KateHlItem * > items
Definition: katehighlighthelpers.h:82
KateSyntaxModeListItem::nameTranslated
QString nameTranslated
i18n of same, for display purposes
Definition: katesyntaxdocument.h:38
Kate::TextLineData::contextStack
const ContextStack & contextStack() const
context stack
Definition: katetextline.h:344
KateHlItem::capturedTexts
virtual void capturedTexts(QStringList &)
Definition: katehighlighthelpers.h:42
KateHlCOct
Definition: katehighlighthelpers.h:227
KTextEditor::Attribute::fontBold
bool fontBold() const
KateHighlighting::getCharacterEncodingsPrefixStore
const KatePrefixStore & getCharacterEncodingsPrefixStore(int attrib) const
Definition: katehighlight.cpp:694
KateHlContextModification
describe a modification of the context stack
Definition: katehighlight.h:61
KateHlContext
Definition: katehighlighthelpers.h:72
KateHighlighting::getCommentSingleLinePosition
CSLPos getCommentSingleLinePosition(int attrib=0) const
Definition: katehighlight.cpp:1134
KateExtendedAttribute::setDefaultStyleIndex
void setDefaultStyleIndex(int index)
Definition: kateextendedattribute.cpp:74
KateHighlighting::attributeRequiresSpellchecking
bool attributeRequiresSpellchecking(int attr)
Definition: katehighlight.cpp:1045
KTextEditor::Attribute::hasAnyProperty
bool hasAnyProperty() const
KateHlContextModification::newContext
int newContext
new context to push on the stack if this is < 0, push nothing on the stack
Definition: katehighlight.h:94
kglobal.h
KateHlContext::lineEndContext
KateHlContextModification lineEndContext
Definition: katehighlighthelpers.h:85
KateHlRangeDetect
Definition: katehighlighthelpers.h:172
KateHighlighting::commentRegion
signed char commentRegion(int attr) const
Definition: katehighlight.cpp:1106
KateHighlighting::getEncodedCharactersInsertionPolicy
int getEncodedCharactersInsertionPolicy(int attrib) const
Definition: katehighlight.cpp:704
KateHlContext::emptyLineContextModification
KateHlContextModification emptyLineContextModification
Definition: katehighlighthelpers.h:99
KateExtendedAttribute::name
QString name() const
Definition: kateextendedattribute.cpp:54
kateschema.h
KateHighlighting::characterEncodings
const QHash< QString, QChar > & characterEncodings(int attrib=0) const
Definition: katehighlight.cpp:1139
kmenu.h
KateHighlighting::attribute
int attribute(int context) const
Definition: katehighlight.cpp:1040
KateHlContext::noIndentationBasedFolding
bool noIndentationBasedFolding
Definition: katehighlighthelpers.h:96
KateExtendedAttribute::performSpellchecking
bool performSpellchecking() const
Definition: kateextendedattribute.cpp:79
Kate::TextLineData::markAsFoldingStartIndentation
void markAsFoldingStartIndentation()
Mark as folding start line of an indentation based folding.
Definition: katetextline.h:257
KateHlRegExpr
Definition: katehighlighthelpers.h:280
KateHlContext::clone
KateHlContext * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:845
KateSyntaxDocument::groupData
QString groupData(const KateSyntaxContextData *data, const QString &name)
Definition: katesyntaxdocument.cpp:181
KateSyntaxDocument::nextItem
bool nextItem(KateSyntaxContextData *data)
Jump to the next item, KateSyntaxContextData::item will point to the next item.
Definition: katesyntaxdocument.cpp:133
KateHighlighting::attributes
QList< KTextEditor::Attribute::Ptr > attributes(const QString &schema)
Definition: katehighlight.cpp:2134
kateglobal.h
KateSyntaxDocument::getConfig
KateSyntaxContextData * getConfig(const QString &mainGroupName, const QString &config)
Get the KateSyntaxContextData of the DomElement Config inside mainGroupName It just fills KateSyntaxC...
Definition: katesyntaxdocument.cpp:262
KateHlKeyword::addList
void addList(const QStringList &)
Definition: katehighlighthelpers.cpp:290
QStringList
KTextEditor::Attribute::setSelectedBackground
void setSelectedBackground(const QBrush &brush)
katesyntaxdocument.h
KTextEditor::Attribute::setFontBold
void setFontBold(bool bold=true)
KateHlDetectIdentifier
Definition: katehighlighthelpers.h:320
stdDeliminator
static const QString stdDeliminator
Definition: katehighlight.cpp:67
KateHighlighting::getReverseCharacterEncodings
const QHash< QChar, QString > & getReverseCharacterEncodings(int attrib) const
Definition: katehighlight.cpp:699
Kate::TextLineData::markAsFoldingStartAttribute
void markAsFoldingStartAttribute()
Mark as folding start line of an attribute based folding.
Definition: katetextline.h:248
KateHlCFloat
Definition: katehighlighthelpers.h:218
KateHlCStringChar
Definition: katehighlighthelpers.h:253
Kate::TextLineData::setContextStack
void setContextStack(const ContextStack &val)
Sets the syntax highlight context number.
Definition: katetextline.h:350
KateSyntaxModeListItem::author
QString author
Author's name.
Definition: katesyntaxdocument.h:48
KateHlItem::customStartEnable
bool customStartEnable
Definition: katehighlighthelpers.h:64
KateHlManager::incDynamicCtxs
void incDynamicCtxs()
Definition: katesyntaxmanager.h:85
KateHlItem::firstNonSpace
bool firstNonSpace
Definition: katehighlighthelpers.h:57
KateHlItem::cachingHandled
bool cachingHandled
Definition: katehighlighthelpers.h:69
KateHlCHex
Definition: katehighlighthelpers.h:235
KateExtendedAttribute::Spellchecking
Definition: kateextendedattribute.h:45
KTextEditor::Attribute::SelectedBackground
KateHlItem::region2
signed char region2
Definition: katehighlighthelpers.h:51
Kate::TextLineData::hlLineContinue
bool hlLineContinue() const
Returns true, if the line's hl-continue flag is set, otherwise returns false.
Definition: katetextline.h:273
KateHighlighting::getEmbeddedHighlightingModes
QStringList getEmbeddedHighlightingModes() const
Returns a list of names of embedded modes.
Definition: katehighlight.cpp:2166
KateHl2CharDetect
Definition: katehighlighthelpers.h:135
KTextEditor::Attribute::selectedBackground
QBrush selectedBackground() const
KateHlCChar
Definition: katehighlighthelpers.h:261
KateHlCharDetect
Definition: katehighlighthelpers.h:123
Kate::TextLineData::markedAsFoldingStartAttribute
bool markedAsFoldingStartAttribute() const
Is on this line a folding start per attribute?
Definition: katetextline.h:231
KateHighlighting::doHighlight
void doHighlight(const Kate::TextLineData *prevLine, Kate::TextLineData *textLine, const Kate::TextLineData *nextLine, bool &ctxChanged, int tabWidth=0)
Parse the text and fill in the context array and folding list array.
Definition: katehighlight.cpp:253
KateSyntaxModeListItem::identifier
QString identifier
Definition: katesyntaxdocument.h:42
KateHighlighting::getKateExtendedAttributeList
void getKateExtendedAttributeList(const QString &schema, QList< KateExtendedAttribute::Ptr > &, KConfig *cfg=0)
Definition: katehighlight.cpp:584
KateHlKeyword
Definition: katehighlighthelpers.h:184
KateSyntaxDocument::setIdentifier
bool setIdentifier(const QString &identifier)
If the open hl file is different from the one needed, it opens the new one and assign some other thin...
Definition: katesyntaxdocument.cpp:59
KateHlStringDetect
Definition: katehighlighthelpers.h:149
KConfigGroup
KateExtendedAttribute::indexForStyleName
static int indexForStyleName(const QString &name)
Definition: kateextendedattribute.cpp:34
KConfig
KateHighlighting::getCommentSingleLineStart
QString getCommentSingleLineStart(int attrib=0) const
Definition: katehighlight.cpp:1129
KateSyntaxModeListItem
Information about each syntax hl Mode.
Definition: katesyntaxdocument.h:34
Kate::TextLineData::clearMarkedAsFoldingStart
void clearMarkedAsFoldingStart()
Clear folding start status.
Definition: katetextline.h:222
KateHighlighting::getCharacterEncodings
const QHash< QString, QChar > & getCharacterEncodings(int attrib) const
Definition: katehighlight.cpp:689
kstandarddirs.h
KateHlContext::emptyLineContext
bool emptyLineContext
Definition: katehighlighthelpers.h:98
KateHlContext::hlId
QString hlId
A unique highlight identifier. Used to look up correct properties.
Definition: katehighlighthelpers.h:83
KateHlAnyChar
Definition: katehighlighthelpers.h:269
Kate::TextLine
QSharedPointer< TextLineData > TextLine
The normal world only accesses the text lines with shared pointers.
Definition: katetextline.h:443
KateExtendedAttribute::setName
void setName(const QString &name)
Definition: kateextendedattribute.cpp:59
KateHighlighting::CSLPosColumn0
Definition: katehighlight.h:219
Kate::TextLineData::firstChar
int firstChar() const
Returns the position of the first non-whitespace character.
Definition: katetextline.cpp:40
KateHlInt
Definition: katehighlighthelpers.h:201
KMessageBox::detailedSorry
static void detailedSorry(QWidget *parent, const QString &text, const QString &details, const QString &caption=QString(), Options options=Notify)
KateHighlighting::~KateHighlighting
~KateHighlighting()
Definition: katehighlight.cpp:108
KateHlContextModification::type
char type
indicates what this modification does, for speed
Definition: katehighlight.h:88
KateHlManager::getDefaults
void getDefaults(const QString &schema, KateAttributeList &, KConfig *cfg=0)
Definition: katesyntaxmanager.cpp:177
kWarning
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KateHlItem::alwaysStartEnable
bool alwaysStartEnable
Definition: katehighlighthelpers.h:63
Kate::TextLineData::string
const QString & string() const
Returns the complete text line (as a QString reference).
Definition: katetextline.h:286
KateHighlighting::setKateExtendedAttributeList
void setKateExtendedAttributeList(const QString &schema, QList< KateExtendedAttribute::Ptr > &, KConfig *cfg=0, bool writeDefaultsToo=false)
Saves the attribute definitions to the config file.
Definition: katehighlight.cpp:657
KateHlFloat
Definition: katehighlighthelpers.h:209
KateHighlighting::getKateExtendedAttributeListCopy
void getKateExtendedAttributeListCopy(const QString &schema, QList< KateExtendedAttribute::Ptr > &, KConfig *cfg=0)
Definition: katehighlight.cpp:639
QPair
KateHlItem::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)=0
KateHlIncludeRule
Definition: katehighlighthelpers.h:102
KateHighlighting::hlKeyForContext
QString hlKeyForContext(int attrib) const
Definition: katehighlight.cpp:1054
KateHighlighting::CSLPos
CSLPos
This enum is used for storing the information where a single line comment marker should be inserted...
Definition: katehighlight.h:219
KateHlItem::lookAhead
bool lookAhead
Definition: katehighlighthelpers.h:53
KateHlDetectSpaces
Definition: katehighlighthelpers.h:306
KGlobal::staticQString
const QString & staticQString(const char *str)
KateHighlighting::name
const QString & name() const
Definition: katehighlight.h:153
KateHighlighting::release
void release()
Decrease the usage count, and trigger cleanup if needed.
Definition: katehighlight.cpp:730
KateDocument::EncodeWhenPresent
Definition: katedocument.h:1144
highlightinterface.h
kcomponentdata.h
KateHlItem::column
int column
Definition: katehighlighthelpers.h:59
KateHighlighting::dropDynamicContexts
void dropDynamicContexts()
Drop all dynamic contexts.
Definition: katehighlight.cpp:238
kmessagebox.h
Kate::TextLineData::clearAttributes
void clearAttributes()
Clear attributes of this line.
Definition: katetextline.h:361
KateHighlighting::isInWord
bool isInWord(QChar c, int attrib=0) const
Definition: katehighlight.cpp:1084
KateDocument::EncodeAlways
Definition: katedocument.h:1144
KateHlManager::identifierForName
QString identifierForName(const QString &)
Definition: katesyntaxmanager.cpp:380
KateHlIncludeRule::incCtx
KateHlContextModification incCtx
Definition: katehighlighthelpers.h:118
katehighlighthelpers.h
end
const KShortcut & end()
kateconfig.h
KConfigGroup::readEntry
T readEntry(const QString &key, const T &aDefault) const
KateHlContextModification::doPush
Definition: katehighlight.h:66
KateSyntaxContextData
Class holding the data around the current QDomElement.
Definition: katesyntaxdocument.h:62
KateSyntaxModeListItem::name
QString name
Name of the mode (eg. Asm6502)
Definition: katesyntaxdocument.h:37
KateDocument::EncodeNever
Definition: katedocument.h:1144
KateHlManager::self
static KateHlManager * self()
Definition: katesyntaxmanager.cpp:103
KateExtendedAttribute::setPerformSpellchecking
void setPerformSpellchecking(bool spellchecking)
Definition: kateextendedattribute.cpp:84
KateSyntaxModeListItem::license
QString license
License; for example: "LGPL".
Definition: katesyntaxdocument.h:49
KTextEditor::Attribute::clear
void clear()
KateSyntaxDocument::getGroupInfo
KateSyntaxContextData * getGroupInfo(const QString &mainGroupName, const QString &group)
Get the KateSyntaxContextData of the QDomElement Config inside mainGroupName KateSyntaxContextData::p...
Definition: katesyntaxdocument.cpp:278
KTextEditor::Attribute::SelectedForeground
QMap
KateHighlighting::contextNum
KateHlContext * contextNum(int n)
Definition: katehighlight.h:267
KateHlItem::attr
int attr
Definition: katehighlighthelpers.h:48
kconfiggroup.h
KateExtendedAttribute
An extension of the KTextEditor::Attribute class, with convenience functions for access to extra kate...
Definition: kateextendedattribute.h:35
KateSyntaxDocument::groupItemData
QString groupItemData(const KateSyntaxContextData *data, const QString &name)
This function is used to fetch the atributes of the tags.
Definition: katesyntaxdocument.cpp:161
KateHlContext::attr
int attr
Definition: katehighlighthelpers.h:84
QList< KateExtendedAttribute::Ptr >
KateHlContext::ftctx
KateHlContextModification ftctx
Definition: katehighlighthelpers.h:92
KateHlItem::dynamic
bool dynamic
Definition: katehighlighthelpers.h:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

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

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Applications
  •   Libraries
  •     libkonq
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal