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

Kate

  • sources
  • kde-4.12
  • applications
  • kate
  • part
  • syntax
katehighlighthelpers.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2003, 2004 Anders Lund <anders@alweb.dk>
3  Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
4  Copyright (C) 2001,2002 Joseph Wenninger <jowenn@kde.org>
5  Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
6  Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License version 2 as published by the Free Software Foundation.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 //BEGIN INCLUDES
24 #include "katehighlighthelpers.h"
25 
26 #include "katetextline.h"
27 #include "katedocument.h"
28 #include "katesyntaxdocument.h"
29 #include "katerenderer.h"
30 #include "kateglobal.h"
31 #include "kateschema.h"
32 #include "kateconfig.h"
33 #include "kateextendedattribute.h"
34 
35 #include <QtCore/QSet>
36 //END
37 
38 //BEGIN KateHlItem
39 KateHlItem::KateHlItem(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
40  : attr(attribute),
41  ctx(context),
42  region(regionId),
43  region2(regionId2),
44  lookAhead(false),
45  dynamic(false),
46  dynamicChild(false),
47  firstNonSpace(false),
48  onlyConsume(false),
49  column (-1),
50  alwaysStartEnable (true),
51  customStartEnable (false),
52  haveCache(false),
53  cachingHandled(false)
54 {
55 }
56 
57 KateHlItem::~KateHlItem()
58 {
59 }
60 
61 void KateHlItem::dynamicSubstitute(QString &str, const QStringList *args)
62 {
63  for (int i = 0; i < str.length() - 1; ++i)
64  {
65  if (str[i] == '%')
66  {
67  char c = str[i + 1].toLatin1();
68  if (c == '%')
69  str.remove(i, 1);
70  else if (c >= '0' && c <= '9')
71  {
72  if ((int)(c - '0') < args->size())
73  {
74  str.replace(i, 2, (*args)[c - '0']);
75  i += ((*args)[c - '0']).length() - 1;
76  }
77  else
78  {
79  str.remove(i, 2);
80  --i;
81  }
82  }
83  }
84  }
85 }
86 //END
87 
88 //BEGIN KateHlCharDetect
89 KateHlCharDetect::KateHlCharDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, QChar c)
90  : KateHlItem(attribute,context,regionId,regionId2)
91  , sChar(c)
92 {
93 }
94 
95 int KateHlCharDetect::checkHgl(const QString& text, int offset, int /*len*/)
96 {
97  if (text[offset] == sChar)
98  return offset + 1;
99 
100  return 0;
101 }
102 
103 KateHlItem *KateHlCharDetect::clone(const QStringList *args)
104 {
105  char c = sChar.toLatin1();
106 
107  if (c < '0' || c > '9' || (c - '0') >= args->size())
108  return this;
109 
110  KateHlCharDetect *ret = new KateHlCharDetect(attr, ctx, region, region2, (*args)[c - '0'][0]);
111  ret->dynamicChild = true;
112  return ret;
113 }
114 //END
115 
116 //BEGIN KateHl2CharDetect
117 KateHl2CharDetect::KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, QChar ch1, QChar ch2)
118  : KateHlItem(attribute,context,regionId,regionId2)
119  , sChar1 (ch1)
120  , sChar2 (ch2)
121 {
122 }
123 
124 int KateHl2CharDetect::checkHgl(const QString& text, int offset, int len)
125 {
126  if ((len >= 2) && text[offset++] == sChar1 && text[offset++] == sChar2)
127  return offset;
128 
129  return 0;
130 }
131 
132 KateHlItem *KateHl2CharDetect::clone(const QStringList *args)
133 {
134  char c1 = sChar1.toLatin1();
135  char c2 = sChar2.toLatin1();
136 
137  if (c1 < '0' || c1 > '9' || (c1 - '0') >= args->size())
138  return this;
139 
140  if (c2 < '0' || c2 > '9' || (c2 - '0') >= args->size())
141  return this;
142 
143  KateHl2CharDetect *ret = new KateHl2CharDetect(attr, ctx, region, region2, (*args)[c1 - '0'][0], (*args)[c2 - '0'][0]);
144  ret->dynamicChild = true;
145  return ret;
146 }
147 //END
148 
149 //BEGIN KateHlStringDetect
150 KateHlStringDetect::KateHlStringDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2,const QString &s, bool inSensitive)
151  : KateHlItem(attribute, context,regionId,regionId2)
152  , str(inSensitive ? s.toUpper() : s)
153  , strLen (str.length())
154  , _inSensitive(inSensitive)
155 {
156 }
157 
158 int KateHlStringDetect::checkHgl(const QString& text, int offset, int len)
159 {
160  if (len < strLen)
161  return 0;
162 
163  if (_inSensitive)
164  {
165  for (int i=0; i < strLen; i++)
166  if (text[offset++].toUpper() != str[i])
167  return 0;
168 
169  return offset;
170  }
171  else
172  {
173  for (int i=0; i < strLen; i++)
174  if (text[offset++] != str[i])
175  return 0;
176 
177  return offset;
178  }
179 
180  return 0;
181 }
182 
183 KateHlItem *KateHlStringDetect::clone(const QStringList *args)
184 {
185  QString newstr = str;
186 
187  dynamicSubstitute(newstr, args);
188 
189  if (newstr == str)
190  return this;
191 
192  KateHlStringDetect *ret = new KateHlStringDetect(attr, ctx, region, region2, newstr, _inSensitive);
193  ret->dynamicChild = true;
194  return ret;
195 }
196 //END
197 
198 //BEGIN KateHlWordDetect
199 
200 KateHlWordDetect::KateHlWordDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString& s, bool inSensitive)
201  : KateHlStringDetect(attribute, context, regionId, regionId2, s, inSensitive)
202 {
203 }
204 
205 inline bool isWordCharacter(const QChar& c)
206 {
207  // The Qt docs say for word characters:
208  // \w - Matches a word character (QChar::isLetterOrNumber(), QChar::isMark(), or '_').
209  // see also: http://doc.trolltech.com/qregexp.html
210  return c.isLetterOrNumber() || c.isMark() || c.unicode() == '_';
211 }
212 
213 int KateHlWordDetect::checkHgl(const QString& text, int offset, int len)
214 {
215  //NOTE: word boundary means: any non-word character.
216 
217  // make sure there is no letter or number before the word starts
218  if (offset > 0 && isWordCharacter(text.at(offset - 1))) {
219  return 0;
220  }
221  offset = KateHlStringDetect::checkHgl(text, offset, len);
222  // make sure there is no letter or number after the word ends
223  if (offset && offset < text.length() && isWordCharacter(text.at(offset))) {
224  return 0;
225  }
226  return offset;
227 }
228 
229 KateHlItem* KateHlWordDetect::clone(const QStringList* args)
230 {
231  QString newstr = str;
232 
233  dynamicSubstitute(newstr, args);
234 
235  if (newstr == str)
236  return this;
237 
238  KateHlWordDetect *ret = new KateHlWordDetect(attr, ctx, region, region2, newstr, _inSensitive);
239  ret->dynamicChild = true;
240  return ret;
241 }
242 
243 
244 //END KateHlWordDetect
245 
246 //BEGIN KateHlRangeDetect
247 KateHlRangeDetect::KateHlRangeDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, QChar ch1, QChar ch2)
248  : KateHlItem(attribute,context,regionId,regionId2)
249  , sChar1 (ch1)
250  , sChar2 (ch2)
251 {
252 }
253 
254 int KateHlRangeDetect::checkHgl(const QString& text, int offset, int len)
255 {
256  if (text[offset] == sChar1)
257  {
258  do
259  {
260  offset++;
261  len--;
262  if (len < 1) return 0;
263  }
264  while (text[offset] != sChar2);
265 
266  return offset + 1;
267  }
268  return 0;
269 }
270 //END
271 
272 //BEGIN KateHlKeyword
273 KateHlKeyword::KateHlKeyword (int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, bool insensitive, const QString& delims)
274  : KateHlItem(attribute,context,regionId,regionId2)
275  , _insensitive(insensitive)
276  , minLen (0xFFFFFF)
277  , maxLen (0)
278 {
279  alwaysStartEnable = false;
280  customStartEnable = true;
281  foreach (const QChar &c, delims)
282  deliminators << c;
283 }
284 
285 KateHlKeyword::~KateHlKeyword ()
286 {
287  qDeleteAll(dict);
288 }
289 
290 void KateHlKeyword::addList(const QStringList& list)
291 {
292  for(int i=0; i < list.count(); ++i)
293  {
294  int len = list[i].length();
295 
296  if (minLen > len)
297  minLen = len;
298 
299  if (maxLen < len)
300  maxLen = len;
301 
302  if (len >= dict.size())
303  {
304  uint oldSize = dict.size();
305  dict.resize (len+1);
306 
307  for (int m=oldSize; m < dict.size(); ++m)
308  dict[m] = 0;
309  }
310 
311  if (!dict[len])
312  dict[len] = new QSet<QString> ();
313 
314  if (!_insensitive)
315  dict[len]->insert(list[i]);
316  else
317  dict[len]->insert(list[i].toLower());
318  }
319 }
320 
321 int KateHlKeyword::checkHgl(const QString& text, int offset, int len)
322 {
323  int offset2 = offset;
324  int wordLen = 0;
325 
326  while ((len > wordLen) && !deliminators.contains(text[offset2]))
327  {
328  offset2++;
329  wordLen++;
330 
331  if (wordLen > maxLen) return 0;
332  }
333 
334  if (wordLen < minLen || !dict[wordLen]) return 0;
335 
336  if (!_insensitive)
337  {
338  if (dict[wordLen]->contains(QString::fromRawData(text.unicode() + offset, wordLen)) )
339  return offset2;
340  }
341  else
342  {
343  if (dict[wordLen]->contains(QString::fromRawData(text.unicode() + offset, wordLen).toLower()) )
344  return offset2;
345  }
346 
347  return 0;
348 }
349 //END
350 
351 //BEGIN KateHlInt
352 KateHlInt::KateHlInt(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
353  : KateHlItem(attribute,context,regionId,regionId2)
354 {
355  alwaysStartEnable = false;
356 }
357 
358 int KateHlInt::checkHgl(const QString& text, int offset, int len)
359 {
360  int offset2 = offset;
361 
362  while ((len > 0) && text[offset2].isDigit())
363  {
364  offset2++;
365  len--;
366  }
367 
368  if (offset2 > offset)
369  {
370  if (len > 0)
371  {
372  for (int i=0; i < subItems.size(); i++)
373  {
374  if ( (offset = subItems[i]->checkHgl(text, offset2, len)) )
375  return offset;
376  }
377  }
378 
379  return offset2;
380  }
381 
382  return 0;
383 }
384 //END
385 
386 //BEGIN KateHlFloat
387 KateHlFloat::KateHlFloat(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
388  : KateHlItem(attribute,context, regionId,regionId2)
389 {
390  alwaysStartEnable = false;
391 }
392 
393 int KateHlFloat::checkHgl(const QString& text, int offset, int len)
394 {
395  bool b = false;
396  bool p = false;
397 
398  while ((len > 0) && text[offset].isDigit())
399  {
400  offset++;
401  len--;
402  b = true;
403  }
404 
405  if ((len > 0) && (p = (text[offset] == '.')))
406  {
407  offset++;
408  len--;
409 
410  while ((len > 0) && text[offset].isDigit())
411  {
412  offset++;
413  len--;
414  b = true;
415  }
416  }
417 
418  if (!b)
419  return 0;
420 
421  if ((len > 0) && ((text[offset].toAscii() & 0xdf) == 'E'))
422  {
423  offset++;
424  len--;
425  }
426  else
427  {
428  if (!p)
429  return 0;
430  else
431  {
432  if (len > 0)
433  {
434  for (int i=0; i < subItems.size(); ++i)
435  {
436  int offset2 = subItems[i]->checkHgl(text, offset, len);
437 
438  if (offset2)
439  return offset2;
440  }
441  }
442 
443  return offset;
444  }
445  }
446 
447  if ((len > 0) && (text[offset] == '-' || text[offset] =='+'))
448  {
449  offset++;
450  len--;
451  }
452 
453  b = false;
454 
455  while ((len > 0) && text[offset].isDigit())
456  {
457  offset++;
458  len--;
459  b = true;
460  }
461 
462  if (b)
463  {
464  if (len > 0)
465  {
466  for (int i=0; i < subItems.size(); ++i)
467  {
468  int offset2 = subItems[i]->checkHgl(text, offset, len);
469 
470  if (offset2)
471  return offset2;
472  }
473  }
474 
475  return offset;
476  }
477 
478  return 0;
479 }
480 //END
481 
482 //BEGIN KateHlCOct
483 KateHlCOct::KateHlCOct(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
484  : KateHlItem(attribute,context,regionId,regionId2)
485 {
486  alwaysStartEnable = false;
487 }
488 
489 int KateHlCOct::checkHgl(const QString& text, int offset, int len)
490 {
491  if (text[offset].toAscii() == '0')
492  {
493  offset++;
494  len--;
495 
496  int offset2 = offset;
497 
498  while ((len > 0) && (text[offset2].toAscii() >= '0' && text[offset2].toAscii() <= '7'))
499  {
500  offset2++;
501  len--;
502  }
503 
504  if (offset2 > offset)
505  {
506  if ((len > 0) && ((text[offset2].toAscii() & 0xdf) == 'L' || (text[offset].toAscii() & 0xdf) == 'U' ))
507  offset2++;
508 
509  return offset2;
510  }
511  }
512 
513  return 0;
514 }
515 //END
516 
517 //BEGIN KateHlCHex
518 KateHlCHex::KateHlCHex(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
519  : KateHlItem(attribute,context,regionId,regionId2)
520 {
521  alwaysStartEnable = false;
522 }
523 
524 int KateHlCHex::checkHgl(const QString& text, int offset, int len)
525 {
526  if ((len > 1) && (text[offset++].toAscii() == '0') && ((text[offset++].toAscii() & 0xdf) == 'X' ))
527  {
528  len -= 2;
529 
530  int offset2 = offset;
531 
532  while ((len > 0) && (text[offset2].isDigit() || ((text[offset2].toAscii() & 0xdf) >= 'A' && (text[offset2].toAscii() & 0xdf) <= 'F')))
533  {
534  offset2++;
535  len--;
536  }
537 
538  if (offset2 > offset)
539  {
540  if ((len > 0) && ((text[offset2].toAscii() & 0xdf) == 'L' || (text[offset2].toAscii() & 0xdf) == 'U' ))
541  offset2++;
542 
543  return offset2;
544  }
545  }
546 
547  return 0;
548 }
549 //END
550 
551 //BEGIN KateHlCFloat
552 KateHlCFloat::KateHlCFloat(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
553  : KateHlFloat(attribute,context,regionId,regionId2)
554 {
555  alwaysStartEnable = false;
556 }
557 
558 int KateHlCFloat::checkIntHgl(const QString& text, int offset, int len)
559 {
560  int offset2 = offset;
561 
562  while ((len > 0) && text[offset].isDigit()) {
563  offset2++;
564  len--;
565  }
566 
567  if (offset2 > offset)
568  return offset2;
569 
570  return 0;
571 }
572 
573 int KateHlCFloat::checkHgl(const QString& text, int offset, int len)
574 {
575  int offset2 = KateHlFloat::checkHgl(text, offset, len);
576 
577  if (offset2)
578  {
579  if ((text[offset2].toAscii() & 0xdf) == 'F' )
580  offset2++;
581 
582  return offset2;
583  }
584  else
585  {
586  offset2 = checkIntHgl(text, offset, len);
587 
588  if (offset2 && ((text[offset2].toAscii() & 0xdf) == 'F' ))
589  return ++offset2;
590  else
591  return 0;
592  }
593 }
594 //END
595 
596 //BEGIN KateHlAnyChar
597 KateHlAnyChar::KateHlAnyChar(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QString& charList)
598  : KateHlItem(attribute, context,regionId,regionId2)
599  , _charList(charList)
600 {
601 }
602 
603 int KateHlAnyChar::checkHgl(const QString& text, int offset, int)
604 {
605  if (_charList.contains(text[offset]))
606  return ++offset;
607 
608  return 0;
609 }
610 //END
611 
612 //BEGIN KateHlRegExpr
613 KateHlRegExpr::KateHlRegExpr( int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QString &regexp, bool insensitive, bool minimal)
614  : KateHlItem(attribute, context, regionId,regionId2)
615  , handlesLinestart (regexp.startsWith('^'))
616  , _regexp(regexp)
617  , _insensitive(insensitive)
618  , _minimal(minimal)
619  , _lastOffset(-2) // -2 is start value, -1 is "not found at all"
620  , Expr (regexp, _insensitive ? Qt::CaseInsensitive : Qt::CaseSensitive)
621 {
622  // minimal or not ;)
623  Expr.setMinimal(_minimal);
624 }
625 
626 int KateHlRegExpr::checkHgl(const QString& text, int offset, int /*len*/)
627 {
628  if (offset && handlesLinestart)
629  return 0;
630 
631  // optimization: if we check something on the same text as the last time,
632  // try to reuse what we got that time
633  if ( haveCache ) {
634  if ( offset < _lastOffset || _lastOffset == -1 ) {
635  // reuse last match: not found or offset before match
636  return 0;
637  } else if ( offset == _lastOffset ) {
638  // reuse last match: found at this position
639  return (_lastOffset + _lastOffsetLength);
640  }
641  }
642 
643  haveCache = true;
644  _lastOffset = Expr.indexIn( text, offset, QRegExp::CaretAtOffset );
645 
646  if (_lastOffset == -1) return 0;
647 
648  _lastOffsetLength = Expr.matchedLength();
649 
650  if ( _lastOffset == offset ) {
651  // only valid when we match at the exact offset
652  return (_lastOffset + _lastOffsetLength);
653  } else {
654  return 0;
655  }
656 }
657 
658 void KateHlRegExpr::capturedTexts (QStringList &list)
659 {
660  list = Expr.capturedTexts();
661 }
662 
663 KateHlItem *KateHlRegExpr::clone(const QStringList *args)
664 {
665  QString regexp = _regexp;
666  QStringList escArgs = *args;
667 
668  for (QStringList::Iterator it = escArgs.begin(); it != escArgs.end(); ++it)
669  {
670  (*it).replace(QRegExp("(\\W)"), "\\\\1");
671  }
672 
673  dynamicSubstitute(regexp, &escArgs);
674 
675  if (regexp == _regexp)
676  return this;
677 
678  // kDebug (13010) << "clone regexp: " << regexp;
679 
680  KateHlRegExpr *ret = new KateHlRegExpr(attr, ctx, region, region2, regexp, _insensitive, _minimal);
681  ret->dynamicChild = true;
682  return ret;
683 }
684 // //END
685 
686 //BEGIN KateHlLineContinue
687 KateHlLineContinue::KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
688  : KateHlItem(attribute,context,regionId,regionId2) {
689 }
690 
691 int KateHlLineContinue::checkHgl(const QString& text, int offset, int len)
692 {
693  if ((len == 1) && (text[offset] == '\\'))
694  return ++offset;
695 
696  return 0;
697 }
698 //END
699 
700 //BEGIN KateHlCStringChar
701 KateHlCStringChar::KateHlCStringChar(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
702  : KateHlItem(attribute,context,regionId,regionId2) {
703 }
704 
705 // checks for C escaped chars \n and escaped hex/octal chars
706 static int checkEscapedChar(const QString& text, int offset, int& len)
707 {
708  int i;
709  if (text[offset] == '\\' && len > 1)
710  {
711  offset++;
712  len--;
713 
714  switch(text[offset].toAscii())
715  {
716  case 'a': // checks for control chars
717  case 'b': // we want to fall through
718  case 'e':
719  case 'f':
720 
721  case 'n':
722  case 'r':
723  case 't':
724  case 'v':
725  case '\'':
726  case '\"':
727  case '?' : // added ? ANSI C classifies this as an escaped char
728  case '\\':
729  offset++;
730  len--;
731  break;
732 
733  case 'x': // if it's like \xff
734  offset++; // eat the x
735  len--;
736  // these for loops can probably be
737  // replaced with something else but
738  // for right now they work
739  // check for hexdigits
740  for (i = 0; (len > 0) && (i < 2); i++)
741  {
742  const char ch = text[offset].toAscii();
743  if (((ch >= '0') && (ch <= '9')) || (((ch & 0xdf) >= 'A') && ((ch & 0xdf) <= 'F'))) {
744  offset++;
745  len--;
746  } else {
747  break;
748  }
749  }
750 
751  if (i == 0)
752  return 0; // takes care of case '\x'
753 
754  break;
755 
756  case '0': case '1': case '2': case '3' :
757  case '4': case '5': case '6': case '7' :
758  for (i = 0; (len > 0) && (i < 3) && (text[offset] >='0'&& text[offset] <='7'); i++)
759  {
760  offset++;
761  len--;
762  }
763  break;
764 
765  default:
766  return 0;
767  }
768 
769  return offset;
770  }
771 
772  return 0;
773 }
774 
775 int KateHlCStringChar::checkHgl(const QString& text, int offset, int len)
776 {
777  return checkEscapedChar(text, offset, len);
778 }
779 //END
780 
781 //BEGIN KateHlCChar
782 KateHlCChar::KateHlCChar(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
783  : KateHlItem(attribute,context,regionId,regionId2) {
784 }
785 
786 int KateHlCChar::checkHgl(const QString& text, int offset, int len)
787 {
788  if ((len > 1) && (text[offset] == '\'') && (text[offset+1] != '\''))
789  {
790  int oldl;
791  oldl = len;
792 
793  len--;
794 
795  int offset2 = checkEscapedChar(text, offset + 1, len);
796 
797  if (!offset2)
798  {
799  if (oldl > 2)
800  {
801  offset2 = offset + 2;
802  len = oldl - 2;
803  }
804  else
805  {
806  return 0;
807  }
808  }
809 
810  if ((len > 0) && (text[offset2] == '\''))
811  return ++offset2;
812  }
813 
814  return 0;
815 }
816 //END
817 
818 //BEGIN KateHl2CharDetect
819 KateHl2CharDetect::KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QChar *s)
820  : KateHlItem(attribute,context,regionId,regionId2) {
821  sChar1 = s[0];
822  sChar2 = s[1];
823  }
824 //END KateHl2CharDetect
825 
826 //BEGIN KateHlContext
827 KateHlContext::KateHlContext (const QString &_hlId, int attribute, KateHlContextModification _lineEndContext, bool _fallthrough,
828  KateHlContextModification _fallthroughContext, bool _dynamic, bool _noIndentationBasedFolding,
829  bool _emptyLineContext, KateHlContextModification _emptyLineContextModification)
830 {
831  hlId = _hlId;
832  attr = attribute;
833  lineEndContext = _lineEndContext;
834  fallthrough = _fallthrough;
835  ftctx = _fallthroughContext;
836  dynamic = _dynamic;
837  dynamicChild = false;
838  noIndentationBasedFolding=_noIndentationBasedFolding;
839  emptyLineContext = _emptyLineContext;
840  emptyLineContextModification = _emptyLineContextModification;
841  if (_noIndentationBasedFolding) kDebug(13010)<<QString("**********************_noIndentationBasedFolding is TRUE*****************");
842 
843 }
844 
845 KateHlContext *KateHlContext::clone(const QStringList *args)
846 {
847  KateHlContext *ret = new KateHlContext(hlId, attr, lineEndContext, fallthrough, ftctx, false,noIndentationBasedFolding
848  , emptyLineContext, emptyLineContextModification
849  );
850 
851  for (int n=0; n < items.size(); ++n)
852  {
853  KateHlItem *item = items[n];
854  KateHlItem *i = (item->dynamic ? item->clone(args) : item);
855  ret->items.append(i);
856  }
857 
858  ret->dynamicChild = true;
859 
860  return ret;
861 }
862 
863 KateHlContext::~KateHlContext()
864 {
865  if (dynamicChild)
866  {
867  for (int n=0; n < items.size(); ++n)
868  {
869  if (items[n]->dynamicChild)
870  delete items[n];
871  }
872  }
873 }
874 //END
875 
876 // kate: space-indent on; indent-width 2; replace-tabs on;
katetextline.h
KateHlStringDetect::str
const QString str
Definition: katehighlighthelpers.h:158
KateHlCChar::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:786
KateHlStringDetect::_inSensitive
const bool _inSensitive
Definition: katehighlighthelpers.h:160
KateHlCharDetect::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:95
katerenderer.h
KateHlInt::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:358
KateHl2CharDetect::clone
virtual KateHlItem * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:132
KateHlItem::KateHlItem
KateHlItem(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:39
KateHlContext::fallthrough
bool fallthrough
Definition: katehighlighthelpers.h:91
KateHlItem
Definition: katehighlighthelpers.h:28
KateHlWordDetect
Definition: katehighlighthelpers.h:163
KateHlWordDetect::KateHlWordDetect
KateHlWordDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString &, bool inSensitive=false)
Definition: katehighlighthelpers.cpp:200
katedocument.h
KateHlContext::dynamic
bool dynamic
Definition: katehighlighthelpers.h:94
KateHlItem::subItems
QVector< KateHlItem * > subItems
Definition: katehighlighthelpers.h:47
KateHlItem::ctx
KateHlContextModification ctx
Definition: katehighlighthelpers.h:49
kateextendedattribute.h
KateHlItem::haveCache
bool haveCache
Definition: katehighlighthelpers.h:67
QString
KateHlContext::KateHlContext
KateHlContext(const QString &_hlId, int attribute, KateHlContextModification _lineEndContext, bool _fallthrough, KateHlContextModification _fallthroughContext, bool _dynamic, bool _noIndentationBasedFolding, bool _emptyLineContex, KateHlContextModification _emptyLineContextModification)
Definition: katehighlighthelpers.cpp:827
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KateHlInt::KateHlInt
KateHlInt(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:352
KateHlItem::region
signed char region
Definition: katehighlighthelpers.h:50
KateHlRegExpr::capturedTexts
virtual void capturedTexts(QStringList &)
Definition: katehighlighthelpers.cpp:658
KateHlContext::items
QVector< KateHlItem * > items
Definition: katehighlighthelpers.h:82
KateHlContextModification
describe a modification of the context stack
Definition: katehighlight.h:61
KateHlContext
Definition: katehighlighthelpers.h:72
KateHlFloat::KateHlFloat
KateHlFloat(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:387
KateHlCOct::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:489
KateHlContext::lineEndContext
KateHlContextModification lineEndContext
Definition: katehighlighthelpers.h:85
KateHlCFloat::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:573
KateHlItem::clone
virtual KateHlItem * clone(const QStringList *)
Definition: katehighlighthelpers.h:43
KateHl2CharDetect::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:124
KateHlContext::emptyLineContextModification
KateHlContextModification emptyLineContextModification
Definition: katehighlighthelpers.h:99
kateschema.h
KateHlCFloat::checkIntHgl
int checkIntHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:558
KateHlContext::noIndentationBasedFolding
bool noIndentationBasedFolding
Definition: katehighlighthelpers.h:96
KateHlContext::clone
KateHlContext * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:845
KateHlRegExpr
Definition: katehighlighthelpers.h:280
KateHlKeyword::KateHlKeyword
KateHlKeyword(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, bool insensitive, const QString &delims)
Definition: katehighlighthelpers.cpp:273
kateglobal.h
KateHlKeyword::addList
void addList(const QStringList &)
Definition: katehighlighthelpers.cpp:290
QStringList
katesyntaxdocument.h
isWordCharacter
bool isWordCharacter(const QChar &c)
Definition: katehighlighthelpers.cpp:205
KateHlStringDetect::strLen
const int strLen
Definition: katehighlighthelpers.h:159
KateHlRegExpr::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:626
KateHlRangeDetect::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:254
KateHlItem::customStartEnable
bool customStartEnable
Definition: katehighlighthelpers.h:64
KateHlStringDetect::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:158
KateHlStringDetect::clone
virtual KateHlItem * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:183
KateHlContext::~KateHlContext
virtual ~KateHlContext()
Definition: katehighlighthelpers.cpp:863
KateHlContext::dynamicChild
bool dynamicChild
Definition: katehighlighthelpers.h:95
KateHlKeyword::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:321
KateHlCharDetect::KateHlCharDetect
KateHlCharDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar)
Definition: katehighlighthelpers.cpp:89
KateHlItem::region2
signed char region2
Definition: katehighlighthelpers.h:51
KateHl2CharDetect
Definition: katehighlighthelpers.h:135
KateHlCStringChar::KateHlCStringChar
KateHlCStringChar(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:701
checkEscapedChar
static int checkEscapedChar(const QString &text, int offset, int &len)
Definition: katehighlighthelpers.cpp:706
KateHlStringDetect::KateHlStringDetect
KateHlStringDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString &, bool inSensitive=false)
Definition: katehighlighthelpers.cpp:150
KateHlRegExpr::clone
virtual KateHlItem * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:663
QSet< QString >
KateHlItem::dynamicSubstitute
static void dynamicSubstitute(QString &str, const QStringList *args)
Definition: katehighlighthelpers.cpp:61
KateHlKeyword::~KateHlKeyword
virtual ~KateHlKeyword()
Definition: katehighlighthelpers.cpp:285
KateHlCharDetect
Definition: katehighlighthelpers.h:123
KateHlItem::dynamicChild
bool dynamicChild
Definition: katehighlighthelpers.h:56
KateHlStringDetect
Definition: katehighlighthelpers.h:149
KateHl2CharDetect::KateHl2CharDetect
KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar ch1, QChar ch2)
Definition: katehighlighthelpers.cpp:117
KateHlCHex::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:524
KateHlAnyChar::KateHlAnyChar
KateHlAnyChar(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString &charList)
Definition: katehighlighthelpers.cpp:597
KateHlRangeDetect::KateHlRangeDetect
KateHlRangeDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar ch1, QChar ch2)
Definition: katehighlighthelpers.cpp:247
KateHlCHex::KateHlCHex
KateHlCHex(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:518
KateHlCStringChar::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:775
KateHlCFloat::KateHlCFloat
KateHlCFloat(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:552
KateHlContext::emptyLineContext
bool emptyLineContext
Definition: katehighlighthelpers.h:98
KateHlCharDetect::clone
virtual KateHlItem * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:103
KateHlContext::hlId
QString hlId
A unique highlight identifier. Used to look up correct properties.
Definition: katehighlighthelpers.h:83
KateHlLineContinue::KateHlLineContinue
KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:687
KateHlCChar::KateHlCChar
KateHlCChar(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:782
KateHlItem::alwaysStartEnable
bool alwaysStartEnable
Definition: katehighlighthelpers.h:63
KateHlCOct::KateHlCOct
KateHlCOct(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:483
KateHlFloat
Definition: katehighlighthelpers.h:209
KateHlWordDetect::clone
virtual KateHlItem * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:229
CaseInsensitive
KateHlLineContinue::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:691
KateHlWordDetect::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:213
katehighlighthelpers.h
kateconfig.h
KateHlAnyChar::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:603
KateHlItem::attr
int attr
Definition: katehighlighthelpers.h:48
KateHlRegExpr::KateHlRegExpr
KateHlRegExpr(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString &expr, bool insensitive, bool minimal)
Definition: katehighlighthelpers.cpp:613
KateHlContext::attr
int attr
Definition: katehighlighthelpers.h:84
KateHlFloat::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:393
KateHlContext::ftctx
KateHlContextModification ftctx
Definition: katehighlighthelpers.h:92
KateHlItem::dynamic
bool dynamic
Definition: katehighlighthelpers.h:55
KateHlItem::~KateHlItem
virtual ~KateHlItem()
Definition: katehighlighthelpers.cpp:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

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

applications API Reference

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

Search



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

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