[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kate/utils
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2010-04-14 17:39:16
Message-ID: 20100414173916.696A9AC899 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1114838 by cullmann:

jowenn: support for initial values

 M  +54 -5     katetemplatehandler.cpp  


--- trunk/KDE/kdelibs/kate/utils/katetemplatehandler.cpp #1114837:1114838
@@ -400,6 +400,34 @@
       // skip '{'
       ++i;
       column += 2;
+    } else if ( (startPos!=-1) && (templateString[i] == ':') ) { // skip init value, handled by KTE
+      i++;
+      column++;
+      int backslash_count=0;
+      for (;i<templateString.size();i++,column++) {
+        if ( templateString[i] == '\n' ) {
+          ++line;
+          column = 0;
+          if ( startPos != -1 ) {
+            // don't allow variables to span multiple lines
+            startPos = -1;
+          }
+          break;
+        }
+        if (templateString[i]=='}') {
+          if ((backslash_count % 2) ==0) {
+            i--;
+            //column--;
+            break;
+          } else {
+            backslash_count=0;
+          }
+        } else if (templateString[i]=='\\') {
+          backslash_count++;
+        } else { // any character teminates a backslash sequence
+          backslash_count=0; 
+        }
+      }      
     } else if ( (startPos!=-1) && (templateString[i] == '/') ) { // skip regexp
       i++;
       column++;
@@ -436,16 +464,37 @@
       int keyLength=key.length();
       QString searchReplace;
       ifDebug(kDebug() << "key found:" << key;)
-      if (key.contains("/")) {
-        searchReplace=key.mid(key.indexOf("/")+1);
-        key=key.left(key.indexOf("/"));
+      bool check_slash=false;
+      bool check_colon=false;
+      int pos_slash=key.indexOf("/");
+      int pos_colon=key.indexOf(":");
+      if ( (pos_slash==-1) && (pos_colon==-1) ) {
+          // do nothing
+      } else if ( (pos_slash!=-1) && (pos_colon==-1) ) {
+          check_slash=true;
+      } else if ( (pos_slash==-1) && (pos_colon!=-1) ) {
+          check_colon=true;
+      } else {
+        if (pos_colon<pos_slash) {
+            check_colon=true;
+        } else {
+            check_slash=true;
+        }
+      }
+      if (check_slash) {
+        searchReplace=key.mid(pos_slash+1);
+        key=key.left(pos_slash);
+        ifDebug(kDebug() << "search_replace" << searchReplace;)
+      } else if (check_colon) {
+        key=key.left(pos_colon);
         ifDebug(kDebug() << "real key found:" << key;)
-        ifDebug(kDebug() << "search_replace" << searchReplace;)
-      }
+      }      
+      
       if (key.contains("@")) {
         key=key.left(key.indexOf("@"));
         force_first=true;
       }
+      ifDebug(kDebug() << "real key found:" << key;)
       if ( !initialValues.contains(key) ) {
         kWarning() << "unknown variable key:" << key;
       } else if ( key == "cursor" ) {
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic