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

Kate

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