[kde-doc-english] [kate] /: syntax: add ability to specify LineContinue char

Michal Humpula michal.humpula at seznam.cz
Tue Feb 18 16:49:18 UTC 2014


Git commit b11076ad0aa53a9ed9627e76a6de5626f64c0452 by Michal Humpula.
Committed on 17/02/2014 at 20:35.
Pushed by michalhumpula into branch 'master'.

syntax: add ability to specify LineContinue char

REVIEW: 115845

M  +4    -5    doc/kate/highlighting.docbook
M  +2    -0    part/syntax/data/language.dtd
M  +1    -1    part/syntax/katehighlight.cpp
M  +5    -3    part/syntax/katehighlighthelpers.cpp
M  +4    -1    part/syntax/katehighlighthelpers.h

http://commits.kde.org/kate/b11076ad0aa53a9ed9627e76a6de5626f64c0452

diff --git a/doc/kate/highlighting.docbook b/doc/kate/highlighting.docbook
index 7706887..d855578 100644
--- a/doc/kate/highlighting.docbook
+++ b/doc/kate/highlighting.docbook
@@ -827,11 +827,10 @@ will not find strings spanning over a line break.</para>
 <varlistentry>
 <term>LineContinue</term>
 <listitem>
-<para>Matches a backslash (<userinput>'\'</userinput>) at the end of a line.</para>
-<programlisting><LineContinue (common attributes) /></programlisting>
-<para>This rule has no specific attributes.</para>
-<para>This rule is useful for switching context at end of line, if the last
-character is a backslash (<userinput>'\'</userinput>). This is needed for
+<para>Matches a specified char at the end of a line.</para>
+<programlisting><LineContinue (common attributes) [char="\"] /></programlisting>
+<para><userinput>char</userinput> optional character to match, default is backslash (<userinput>'\'</userinput>). New since KDE 4.13.</para>
+<para>This rule is useful for switching context at end of line. This is needed for
 example in C/C++ to continue macros or strings.</para>
 </listitem>
 </varlistentry>
diff --git a/part/syntax/data/language.dtd b/part/syntax/data/language.dtd
index a86d51f..8a0b98d 100644
--- a/part/syntax/data/language.dtd
+++ b/part/syntax/data/language.dtd
@@ -432,10 +432,12 @@ TODO
 
 <!-- Detect a line continuation
   commonAttributes: Common attributes
+  char:             The char marking the end of line [char,  optional,  default='\\']
 -->
 <!ELEMENT LineContinue EMPTY>
 <!ATTLIST LineContinue
   %commonAttributes;
+  char          CDATA  #IMPLIED
 >
 
 <!-- Detect a C-style escaped character
diff --git a/part/syntax/katehighlight.cpp b/part/syntax/katehighlight.cpp
index 1a3abfa..1ae649d 100644
--- a/part/syntax/katehighlight.cpp
+++ b/part/syntax/katehighlight.cpp
@@ -1018,7 +1018,7 @@ KateHlItem *KateHighlighting::createKateHlItem(KateSyntaxContextData *data,
   else if (dataname=="DetectChar") tmpItem=(new KateHlCharDetect(attr,context,regionId,regionId2,chr));
   else if (dataname=="Detect2Chars") tmpItem=(new KateHl2CharDetect(attr,context,regionId,regionId2,chr,chr1));
   else if (dataname=="RangeDetect") tmpItem=(new KateHlRangeDetect(attr,context,regionId,regionId2, chr, chr1));
-  else if (dataname=="LineContinue") tmpItem=(new KateHlLineContinue(attr,context,regionId,regionId2));
+  else if (dataname=="LineContinue") tmpItem=(new KateHlLineContinue(attr, context, regionId, regionId2, chr));
   else if (dataname=="StringDetect") tmpItem=(new KateHlStringDetect(attr,context,regionId,regionId2,stringdata,insensitive));
   else if (dataname=="WordDetect") tmpItem=(new KateHlWordDetect(attr,context,regionId,regionId2,stringdata,insensitive));
   else if (dataname=="AnyChar") tmpItem=(new KateHlAnyChar(attr,context,regionId,regionId2,stringdata));
diff --git a/part/syntax/katehighlighthelpers.cpp b/part/syntax/katehighlighthelpers.cpp
index 9528fb1..6da4aeb 100644
--- a/part/syntax/katehighlighthelpers.cpp
+++ b/part/syntax/katehighlighthelpers.cpp
@@ -696,13 +696,15 @@ KateHlItem *KateHlRegExpr::clone(const QStringList *args)
 // //END
 
 //BEGIN KateHlLineContinue
-KateHlLineContinue::KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2)
-  : KateHlItem(attribute,context,regionId,regionId2) {
+KateHlLineContinue::KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar c)
+  : KateHlItem(attribute, context, regionId, regionId2)
+  , m_trailer(c.isNull() ? QLatin1Char('\\') : c)
+{
 }
 
 int KateHlLineContinue::checkHgl(const QString& text, int offset, int len)
 {
-  if ((len == 1) && (text[offset] == '\\'))
+  if ((len == 1) && (text[offset] == m_trailer))
     return ++offset;
 
   return 0;
diff --git a/part/syntax/katehighlighthelpers.h b/part/syntax/katehighlighthelpers.h
index 24daf7c..02ac40e 100644
--- a/part/syntax/katehighlighthelpers.h
+++ b/part/syntax/katehighlighthelpers.h
@@ -244,11 +244,14 @@ class KateHlCHex : public KateHlItem
 class KateHlLineContinue : public KateHlItem
 {
   public:
-    KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2);
+    KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId,signed char regionId2, QChar);
 
     virtual bool endEnable(QChar c) {return c == '\0';}
     virtual int checkHgl(const QString& text, int offset, int len);
     virtual bool lineContinue(){return true;}
+
+  private:
+    QChar m_trailer;
 };
 
 class KateHlCStringChar : public KateHlItem


More information about the kde-doc-english mailing list