• 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
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 QSet<QString> KateHlKeyword::allKeywords() const
291 {
292  QSet<QString> result;
293  foreach ( const QSet<QString>* v, dict ) {
294  if ( ! v ) {
295  continue;
296  }
297  result.unite(*v);
298  }
299  return result;
300 }
301 
302 void KateHlKeyword::addList(const QStringList& list)
303 {
304  for(int i=0; i < list.count(); ++i)
305  {
306  int len = list[i].length();
307 
308  if (minLen > len)
309  minLen = len;
310 
311  if (maxLen < len)
312  maxLen = len;
313 
314  if (len >= dict.size())
315  {
316  uint oldSize = dict.size();
317  dict.resize (len+1);
318 
319  for (int m=oldSize; m < dict.size(); ++m)
320  dict[m] = 0;
321  }
322 
323  if (!dict[len])
324  dict[len] = new QSet<QString> ();
325 
326  if (!_insensitive)
327  dict[len]->insert(list[i]);
328  else
329  dict[len]->insert(list[i].toLower());
330  }
331 }
332 
333 int KateHlKeyword::checkHgl(const QString& text, int offset, int len)
334 {
335  int offset2 = offset;
336  int wordLen = 0;
337 
338  while ((len > wordLen) && !deliminators.contains(text[offset2]))
339  {
340  offset2++;
341  wordLen++;
342 
343  if (wordLen > maxLen) return 0;
344  }
345 
346  if (wordLen < minLen || !dict[wordLen]) return 0;
347 
348  if (!_insensitive)
349  {
350  if (dict[wordLen]->contains(QString::fromRawData(text.unicode() + offset, wordLen)) )
351  return offset2;
352  }
353  else
354  {
355  if (dict[wordLen]->contains(QString::fromRawData(text.unicode() + offset, wordLen).toLower()) )
356  return offset2;
357  }
358 
359  return 0;
360 }
361 //END
362 
363 //BEGIN KateHlInt
364 KateHlInt::KateHlInt(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
365  : KateHlItem(attribute,context,regionId,regionId2)
366 {
367  alwaysStartEnable = false;
368 }
369 
370 int KateHlInt::checkHgl(const QString& text, int offset, int len)
371 {
372  int offset2 = offset;
373 
374  while ((len > 0) && text[offset2].isDigit())
375  {
376  offset2++;
377  len--;
378  }
379 
380  if (offset2 > offset)
381  {
382  if (len > 0)
383  {
384  for (int i=0; i < subItems.size(); i++)
385  {
386  if ( (offset = subItems[i]->checkHgl(text, offset2, len)) )
387  return offset;
388  }
389  }
390 
391  return offset2;
392  }
393 
394  return 0;
395 }
396 //END
397 
398 //BEGIN KateHlFloat
399 KateHlFloat::KateHlFloat(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
400  : KateHlItem(attribute,context, regionId,regionId2)
401 {
402  alwaysStartEnable = false;
403 }
404 
405 int KateHlFloat::checkHgl(const QString& text, int offset, int len)
406 {
407  bool b = false;
408  bool p = false;
409 
410  while ((len > 0) && text[offset].isDigit())
411  {
412  offset++;
413  len--;
414  b = true;
415  }
416 
417  if ((len > 0) && (p = (text[offset] == '.')))
418  {
419  offset++;
420  len--;
421 
422  while ((len > 0) && text[offset].isDigit())
423  {
424  offset++;
425  len--;
426  b = true;
427  }
428  }
429 
430  if (!b)
431  return 0;
432 
433  if ((len > 0) && ((text[offset].toAscii() & 0xdf) == 'E'))
434  {
435  offset++;
436  len--;
437  }
438  else
439  {
440  if (!p)
441  return 0;
442  else
443  {
444  if (len > 0)
445  {
446  for (int i=0; i < subItems.size(); ++i)
447  {
448  int offset2 = subItems[i]->checkHgl(text, offset, len);
449 
450  if (offset2)
451  return offset2;
452  }
453  }
454 
455  return offset;
456  }
457  }
458 
459  if ((len > 0) && (text[offset] == '-' || text[offset] =='+'))
460  {
461  offset++;
462  len--;
463  }
464 
465  b = false;
466 
467  while ((len > 0) && text[offset].isDigit())
468  {
469  offset++;
470  len--;
471  b = true;
472  }
473 
474  if (b)
475  {
476  if (len > 0)
477  {
478  for (int i=0; i < subItems.size(); ++i)
479  {
480  int offset2 = subItems[i]->checkHgl(text, offset, len);
481 
482  if (offset2)
483  return offset2;
484  }
485  }
486 
487  return offset;
488  }
489 
490  return 0;
491 }
492 //END
493 
494 //BEGIN KateHlCOct
495 KateHlCOct::KateHlCOct(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
496  : KateHlItem(attribute,context,regionId,regionId2)
497 {
498  alwaysStartEnable = false;
499 }
500 
501 int KateHlCOct::checkHgl(const QString& text, int offset, int len)
502 {
503  if (text[offset].toAscii() == '0')
504  {
505  offset++;
506  len--;
507 
508  int offset2 = offset;
509 
510  while ((len > 0) && (text[offset2].toAscii() >= '0' && text[offset2].toAscii() <= '7'))
511  {
512  offset2++;
513  len--;
514  }
515 
516  if (offset2 > offset)
517  {
518  if ((len > 0) && ((text[offset2].toAscii() & 0xdf) == 'L' || (text[offset].toAscii() & 0xdf) == 'U' ))
519  offset2++;
520 
521  return offset2;
522  }
523  }
524 
525  return 0;
526 }
527 //END
528 
529 //BEGIN KateHlCHex
530 KateHlCHex::KateHlCHex(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
531  : KateHlItem(attribute,context,regionId,regionId2)
532 {
533  alwaysStartEnable = false;
534 }
535 
536 int KateHlCHex::checkHgl(const QString& text, int offset, int len)
537 {
538  if ((len > 1) && (text[offset++].toAscii() == '0') && ((text[offset++].toAscii() & 0xdf) == 'X' ))
539  {
540  len -= 2;
541 
542  int offset2 = offset;
543 
544  while ((len > 0) && (text[offset2].isDigit() || ((text[offset2].toAscii() & 0xdf) >= 'A' && (text[offset2].toAscii() & 0xdf) <= 'F')))
545  {
546  offset2++;
547  len--;
548  }
549 
550  if (offset2 > offset)
551  {
552  if ((len > 0) && ((text[offset2].toAscii() & 0xdf) == 'L' || (text[offset2].toAscii() & 0xdf) == 'U' ))
553  offset2++;
554 
555  return offset2;
556  }
557  }
558 
559  return 0;
560 }
561 //END
562 
563 //BEGIN KateHlCFloat
564 KateHlCFloat::KateHlCFloat(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
565  : KateHlFloat(attribute,context,regionId,regionId2)
566 {
567  alwaysStartEnable = false;
568 }
569 
570 int KateHlCFloat::checkIntHgl(const QString& text, int offset, int len)
571 {
572  int offset2 = offset;
573 
574  while ((len > 0) && text[offset].isDigit()) {
575  offset2++;
576  len--;
577  }
578 
579  if (offset2 > offset)
580  return offset2;
581 
582  return 0;
583 }
584 
585 int KateHlCFloat::checkHgl(const QString& text, int offset, int len)
586 {
587  int offset2 = KateHlFloat::checkHgl(text, offset, len);
588 
589  if (offset2)
590  {
591  if ((text[offset2].toAscii() & 0xdf) == 'F' )
592  offset2++;
593 
594  return offset2;
595  }
596  else
597  {
598  offset2 = checkIntHgl(text, offset, len);
599 
600  if (offset2 && ((text[offset2].toAscii() & 0xdf) == 'F' ))
601  return ++offset2;
602  else
603  return 0;
604  }
605 }
606 //END
607 
608 //BEGIN KateHlAnyChar
609 KateHlAnyChar::KateHlAnyChar(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QString& charList)
610  : KateHlItem(attribute, context,regionId,regionId2)
611  , _charList(charList)
612 {
613 }
614 
615 int KateHlAnyChar::checkHgl(const QString& text, int offset, int)
616 {
617  if (_charList.contains(text[offset]))
618  return ++offset;
619 
620  return 0;
621 }
622 //END
623 
624 //BEGIN KateHlRegExpr
625 KateHlRegExpr::KateHlRegExpr( int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QString &regexp, bool insensitive, bool minimal)
626  : KateHlItem(attribute, context, regionId,regionId2)
627  , handlesLinestart (regexp.startsWith('^'))
628  , _regexp(regexp)
629  , _insensitive(insensitive)
630  , _minimal(minimal)
631  , _lastOffset(-2) // -2 is start value, -1 is "not found at all"
632  , Expr (regexp, _insensitive ? Qt::CaseInsensitive : Qt::CaseSensitive)
633 {
634  // minimal or not ;)
635  Expr.setMinimal(_minimal);
636 }
637 
638 int KateHlRegExpr::checkHgl(const QString& text, int offset, int /*len*/)
639 {
640  if (offset && handlesLinestart)
641  return 0;
642 
643  // optimization: if we check something on the same text as the last time,
644  // try to reuse what we got that time
645  if ( haveCache ) {
646  if ( offset < _lastOffset || _lastOffset == -1 ) {
647  // reuse last match: not found or offset before match
648  return 0;
649  } else if ( offset == _lastOffset ) {
650  // reuse last match: found at this position
651  return (_lastOffset + _lastOffsetLength);
652  }
653  }
654 
655  haveCache = true;
656  _lastOffset = Expr.indexIn( text, offset, QRegExp::CaretAtOffset );
657 
658  if (_lastOffset == -1) return 0;
659 
660  _lastOffsetLength = Expr.matchedLength();
661 
662  if ( _lastOffset == offset ) {
663  // only valid when we match at the exact offset
664  return (_lastOffset + _lastOffsetLength);
665  } else {
666  return 0;
667  }
668 }
669 
670 void KateHlRegExpr::capturedTexts (QStringList &list)
671 {
672  list = Expr.capturedTexts();
673 }
674 
675 KateHlItem *KateHlRegExpr::clone(const QStringList *args)
676 {
677  QString regexp = _regexp;
678  QStringList escArgs = *args;
679 
680  for (QStringList::Iterator it = escArgs.begin(); it != escArgs.end(); ++it)
681  {
682  (*it).replace(QRegExp("(\\W)"), "\\\\1");
683  }
684 
685  dynamicSubstitute(regexp, &escArgs);
686 
687  if (regexp == _regexp)
688  return this;
689 
690  // kDebug (13010) << "clone regexp: " << regexp;
691 
692  KateHlRegExpr *ret = new KateHlRegExpr(attr, ctx, region, region2, regexp, _insensitive, _minimal);
693  ret->dynamicChild = true;
694  return ret;
695 }
696 // //END
697 
698 //BEGIN KateHlLineContinue
699 KateHlLineContinue::KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar c)
700  : KateHlItem(attribute, context, regionId, regionId2)
701  , m_trailer(c.isNull() ? QLatin1Char('\\') : c)
702 {
703 }
704 
705 int KateHlLineContinue::checkHgl(const QString& text, int offset, int len)
706 {
707  if ((len == 1) && (text[offset] == m_trailer))
708  return ++offset;
709 
710  return 0;
711 }
712 //END
713 
714 //BEGIN KateHlCStringChar
715 KateHlCStringChar::KateHlCStringChar(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
716  : KateHlItem(attribute,context,regionId,regionId2) {
717 }
718 
719 // checks for C escaped chars \n and escaped hex/octal chars
720 static int checkEscapedChar(const QString& text, int offset, int& len)
721 {
722  int i;
723  if (text[offset] == '\\' && len > 1)
724  {
725  offset++;
726  len--;
727 
728  switch(text[offset].toAscii())
729  {
730  case 'a': // checks for control chars
731  case 'b': // we want to fall through
732  case 'e':
733  case 'f':
734 
735  case 'n':
736  case 'r':
737  case 't':
738  case 'v':
739  case '\'':
740  case '\"':
741  case '?' : // added ? ANSI C classifies this as an escaped char
742  case '\\':
743  offset++;
744  len--;
745  break;
746 
747  case 'x': // if it's like \xff
748  offset++; // eat the x
749  len--;
750  // these for loops can probably be
751  // replaced with something else but
752  // for right now they work
753  // check for hexdigits
754  for (i = 0; (len > 0) && (i < 2); i++)
755  {
756  const char ch = text[offset].toAscii();
757  if (((ch >= '0') && (ch <= '9')) || (((ch & 0xdf) >= 'A') && ((ch & 0xdf) <= 'F'))) {
758  offset++;
759  len--;
760  } else {
761  break;
762  }
763  }
764 
765  if (i == 0)
766  return 0; // takes care of case '\x'
767 
768  break;
769 
770  case '0': case '1': case '2': case '3' :
771  case '4': case '5': case '6': case '7' :
772  for (i = 0; (len > 0) && (i < 3) && (text[offset] >='0'&& text[offset] <='7'); i++)
773  {
774  offset++;
775  len--;
776  }
777  break;
778 
779  default:
780  return 0;
781  }
782 
783  return offset;
784  }
785 
786  return 0;
787 }
788 
789 int KateHlCStringChar::checkHgl(const QString& text, int offset, int len)
790 {
791  return checkEscapedChar(text, offset, len);
792 }
793 //END
794 
795 //BEGIN KateHlCChar
796 KateHlCChar::KateHlCChar(int attribute, KateHlContextModification context,signed char regionId,signed char regionId2)
797  : KateHlItem(attribute,context,regionId,regionId2) {
798 }
799 
800 int KateHlCChar::checkHgl(const QString& text, int offset, int len)
801 {
802  if ((len > 1) && (text[offset] == '\'') && (text[offset+1] != '\''))
803  {
804  int oldl;
805  oldl = len;
806 
807  len--;
808 
809  int offset2 = checkEscapedChar(text, offset + 1, len);
810 
811  if (!offset2)
812  {
813  if (oldl > 2)
814  {
815  offset2 = offset + 2;
816  len = oldl - 2;
817  }
818  else
819  {
820  return 0;
821  }
822  }
823 
824  if ((len > 0) && (text[offset2] == '\''))
825  return ++offset2;
826  }
827 
828  return 0;
829 }
830 //END
831 
832 //BEGIN KateHl2CharDetect
833 KateHl2CharDetect::KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, const QChar *s)
834  : KateHlItem(attribute,context,regionId,regionId2) {
835  sChar1 = s[0];
836  sChar2 = s[1];
837  }
838 //END KateHl2CharDetect
839 
840 //BEGIN KateHlContext
841 KateHlContext::KateHlContext (const QString &_hlId, int attribute, KateHlContextModification _lineEndContext, bool _fallthrough,
842  KateHlContextModification _fallthroughContext, bool _dynamic, bool _noIndentationBasedFolding,
843  bool _emptyLineContext, KateHlContextModification _emptyLineContextModification)
844 {
845  hlId = _hlId;
846  attr = attribute;
847  lineEndContext = _lineEndContext;
848  fallthrough = _fallthrough;
849  ftctx = _fallthroughContext;
850  dynamic = _dynamic;
851  dynamicChild = false;
852  noIndentationBasedFolding=_noIndentationBasedFolding;
853  emptyLineContext = _emptyLineContext;
854  emptyLineContextModification = _emptyLineContextModification;
855  if (_noIndentationBasedFolding) kDebug(13010)<<QString("**********************_noIndentationBasedFolding is TRUE*****************");
856 
857 }
858 
859 KateHlContext *KateHlContext::clone(const QStringList *args)
860 {
861  KateHlContext *ret = new KateHlContext(hlId, attr, lineEndContext, fallthrough, ftctx, false,noIndentationBasedFolding
862  , emptyLineContext, emptyLineContextModification
863  );
864 
865  for (int n=0; n < items.size(); ++n)
866  {
867  KateHlItem *item = items[n];
868  KateHlItem *i = (item->dynamic ? item->clone(args) : item);
869  ret->items.append(i);
870  }
871 
872  ret->dynamicChild = true;
873 
874  return ret;
875 }
876 
877 KateHlContext::~KateHlContext()
878 {
879  if (dynamicChild)
880  {
881  for (int n=0; n < items.size(); ++n)
882  {
883  if (items[n]->dynamicChild)
884  delete items[n];
885  }
886  }
887 }
888 //END
889 
890 // kate: space-indent on; indent-width 2; replace-tabs on;
katetextline.h
QChar::isMark
bool isMark() const
KateHlStringDetect::str
const QString str
Definition: katehighlighthelpers.h:158
KateHlCChar::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:800
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:370
KateHl2CharDetect::clone
virtual KateHlItem * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:132
QVector::append
void append(const T &value)
KateHlItem::KateHlItem
KateHlItem(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:39
QList::length
int length() const
QRegExp::setMinimal
void setMinimal(bool minimal)
KateHlContext::fallthrough
bool fallthrough
Definition: katehighlighthelpers.h:91
QChar
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
QVector::insert
void insert(int i, const T &value)
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::remove
QString & remove(int position, int n)
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:841
KateHlInt::KateHlInt
KateHlInt(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:364
KateHlItem::region
signed char region
Definition: katehighlighthelpers.h:50
QList::size
int size() const
KateHlRegExpr::capturedTexts
virtual void capturedTexts(QStringList &)
Definition: katehighlighthelpers.cpp:670
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
QRegExp::matchedLength
int matchedLength() const
QRegExp::indexIn
int indexIn(const QString &str, int offset, CaretMode caretMode) const
QRegExp
KateHlFloat::KateHlFloat
KateHlFloat(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:399
KateHlCOct::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:501
KateHlContext::lineEndContext
KateHlContextModification lineEndContext
Definition: katehighlighthelpers.h:85
QString::fromRawData
QString fromRawData(const QChar *unicode, int size)
KateHlCFloat::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:585
QList::count
int count(const T &value) const
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
QVector::resize
void resize(int size)
KateHlContext::emptyLineContextModification
KateHlContextModification emptyLineContextModification
Definition: katehighlighthelpers.h:99
kateschema.h
KateHlCFloat::checkIntHgl
int checkIntHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:570
KateHlContext::noIndentationBasedFolding
bool noIndentationBasedFolding
Definition: katehighlighthelpers.h:96
QRegExp::capturedTexts
QStringList capturedTexts() const
KateHlContext::clone
KateHlContext * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:859
KateHlRegExpr
Definition: katehighlighthelpers.h:284
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:302
katesyntaxdocument.h
isWordCharacter
bool isWordCharacter(const QChar &c)
Definition: katehighlighthelpers.cpp:205
KateHlStringDetect::strLen
const int strLen
Definition: katehighlighthelpers.h:159
QList::Iterator
typedef Iterator
KateHlRegExpr::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:638
KateHlRangeDetect::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:254
QSet< QString >
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:877
KateHlLineContinue::KateHlLineContinue
KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar)
Definition: katehighlighthelpers.cpp:699
KateHlContext::dynamicChild
bool dynamicChild
Definition: katehighlighthelpers.h:95
QString
QChar::unicode
ushort unicode() const
KateHlKeyword::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:333
KateHlCharDetect::KateHlCharDetect
KateHlCharDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar)
Definition: katehighlighthelpers.cpp:89
QStringList
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:715
checkEscapedChar
static int checkEscapedChar(const QString &text, int offset, int &len)
Definition: katehighlighthelpers.cpp:720
QList::end
iterator end()
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
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:675
KateHlItem::dynamicSubstitute
static void dynamicSubstitute(QString &str, const QStringList *args)
Definition: katehighlighthelpers.cpp:61
QLatin1Char
KateHlKeyword::~KateHlKeyword
virtual ~KateHlKeyword()
Definition: katehighlighthelpers.cpp:285
KateHlCharDetect
Definition: katehighlighthelpers.h:123
KateHlItem::dynamicChild
bool dynamicChild
Definition: katehighlighthelpers.h:56
QChar::toLatin1
char toLatin1() const
QSet::contains
bool contains(const T &value) const
KateHlKeyword::allKeywords
QSet< QString > allKeywords() const
Definition: katehighlighthelpers.cpp:290
KateHlStringDetect
Definition: katehighlighthelpers.h:149
QString::replace
QString & replace(int position, int n, QChar after)
QString::unicode
const QChar * unicode() const
KateHl2CharDetect::KateHl2CharDetect
KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar ch1, QChar ch2)
Definition: katehighlighthelpers.cpp:117
QString::toLatin1
QByteArray toLatin1() const
KateHlCHex::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:536
KateHlAnyChar::KateHlAnyChar
KateHlAnyChar(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString &charList)
Definition: katehighlighthelpers.cpp:609
QSet::unite
QSet< T > & unite(const QSet< T > &other)
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:530
KateHlCStringChar::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:789
KateHlCFloat::KateHlCFloat
KateHlCFloat(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:564
KateHlContext::emptyLineContext
bool emptyLineContext
Definition: katehighlighthelpers.h:98
QString::at
const QChar at(int position) const
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
QString::length
int length() const
KateHlCChar::KateHlCChar
KateHlCChar(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:796
KateHlItem::alwaysStartEnable
bool alwaysStartEnable
Definition: katehighlighthelpers.h:63
KateHlCOct::KateHlCOct
KateHlCOct(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2)
Definition: katehighlighthelpers.cpp:495
KateHlFloat
Definition: katehighlighthelpers.h:210
KateHlWordDetect::clone
virtual KateHlItem * clone(const QStringList *args)
Definition: katehighlighthelpers.cpp:229
KateHlLineContinue::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:705
KateHlWordDetect::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:213
QVector::size
int size() const
katehighlighthelpers.h
kateconfig.h
QList::begin
iterator begin()
QString::toAscii
QByteArray toAscii() const
KateHlAnyChar::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:615
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:625
KateHlContext::attr
int attr
Definition: katehighlighthelpers.h:84
KateHlFloat::checkHgl
virtual int checkHgl(const QString &text, int offset, int len)
Definition: katehighlighthelpers.cpp:405
QChar::isLetterOrNumber
bool isLetterOrNumber() const
QList::replace
void replace(int i, const T &value)
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-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