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

List:       kde-commits
Subject:    KDE/kdelibs/interfaces/ktexteditor
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2010-04-17 12:26:31
Message-ID: 20100417122631.22414AC89B () svn ! kde ! org
[Download RAW message or body]

SVN commit 1115773 by cullmann:

jowenn:

    Test snippets for scripted place holders, clarifications of the
    interface. Correct replacement propagtion to mirrors even during
    replacments of the initialvalue by replace or script actions on the
    master range. (Currently inefficient, since the mirroring is done twice
    for all ranges. I think this could be optimized by doing the mirror
    action only on possible masters first and on the mirrored ranges only in
    the end


 M  +7 -0      templateinterface.cpp  
 M  +13 -0     templateinterface.h  


--- trunk/KDE/kdelibs/interfaces/ktexteditor/templateinterface.cpp #1115772:1115773
@@ -144,8 +144,10 @@
       
       int pos_colon=placeholder.indexOf(":");
       int pos_slash=placeholder.indexOf("/");
+      int pos_backtick=placeholder.indexOf("`");
       bool check_slash=false;
       bool check_colon=false;
+      bool check_backtick=false;
       if ((pos_colon==-1) && ( pos_slash==-1)) {
         //do nothing
       } else if ( (pos_colon==-1) && (pos_slash!=-1)) {
@@ -159,6 +161,9 @@
           check_slash=true;
       }
       
+      if ( (!check_slash) && (!check_colon) && (pos_backtick>=0) )
+        check_backtick=true;
+      
       if (check_slash) {                
         //in most cases it should not matter, but better safe then sorry.
         const int end=placeholder.length();
@@ -213,6 +218,8 @@
           }
         }
         placeholder=placeholder.left(placeholder.indexOf(":"));
+      } else if (check_backtick) {
+        placeholder=placeholder.left(pos_backtick);
       }
       
       if (placeholder.contains("@")) \
                placeholder=placeholder.left(placeholder.indexOf("@"));
--- trunk/KDE/kdelibs/interfaces/ktexteditor/templateinterface.h #1115772:1115773
@@ -87,7 +87,20 @@
      * If you have mirrored ranges and want another occurence than the first one as \
                the master
      * you can add @ directly after the placeholder name.
      * 
+     * The interface2 version invokes the function specified by functionName within \
the script specified +     * by the scriptToken, if a placeholder is specified with \
backticks like +     * ${placeholder`functionName`}
+     * The function has a global environment containing "view", "document" and \
"debug", at  +     * least in the katepart implementation. The function invokation is \
                not allowed to be mixed with other replacements
      * 
+     * If a / or ` replacement is done on a master the initial value is modified and \
therefor +     * also all mirrored placeholders are affected too, later on the \
replacement is not done anymore on master ranges +     * 
+     *
+     * The parameters for invoked javascript functions will be the following:
+     * value of the master (or initial value), //to be done: placeholder name, small \
wrapper around the template handler (to do more sophisticated things, like adding \
additional placehlder points, aattaching custom properties for state keeping, ....) \
you tell +     *
+     * 
      * Specification of initial values
      * You can specify initial values which are different from the placeholder name
      * this is done via, this makes only sense for $ placeholders, not for %


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

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