On Jul 6, 2007, at 1:31 PM, Kay C Lan wrote:

This puts a smile on my face because the best assistant for me is a program
called CopyPaste.

...
Unfortunately, Rev and CopyPaste don't get on :-(


I favor CopyPaste, too...everywhere but Rev. Rev's stranglehold on the clipboard trips up CopyPaste, and another favorite of mine, TypeIt4me.

To console myself, I made a snippet-paster that lets me insert boilerplate into scripts, optionally merging the contents of the clipboard, and position the insertion cursor within the boilerplate.


First, I have a frontscript for various utility functions, among them a keydown handler that reads, in part:
    ...
      switch pKey
            case "`"  -- same key as tilde
                get the selectedchunk
                put the long id of the target into  word -2 to -1 of it
                set the dialogdata to it
                popup "CFX_Snippets"
                exit keydown
                break
      ...

It pops up a menu whenever I type ` in a script. The dialogData is first set to the position in the script field for the boilerplate text. The CFX_Snippets stack has a custompropertyset (i.e. array property) in which each property name (key) is a description of its content, the boilerplate text. For example, one of the snippets is called:

      log "x="

the text that is stored for that key is:

     log param(0) && "[[it]]=" & [[it]] ` --///

which, if the variable name "tVar" is on the clipboard, will result in:

    log param(0) && "tVar=" & tVar --///

in my script. My "log" handler (which lives in the frontscript) will post :

   myHandlerName  tVar = 5

when it gets to that statement, which can sometimes be more useful than the debugger and variable watcher in nailing down certain bugs.


Other snippets result in more elaborate log statements, switch statements, etc.


in the CFX_Snippets stack:


on preopenstack
    put the dialogdata into sSel  -- save the insertion point
    set the custompropertyset of me to uSnippetsA
    get  the customkeys of me
    sort lines of it ascending
    put it into fld 1 of me
set the height of fld 1 of me to (the formattedheight of fld 1 of me) + 8
    set the topleft of fld 1 of me to 0,0
    set the height of me to the height of fld 1 of me
end preopenstack


on closeStack
put the uSnippetsA[the selectedtext of fld 1 of me] of me into tSnip
    if tSnip contains "[[" then       -- use merge statement
if length(the clipboarddata["text"] ) < 30 -- only for short clipboard text
        then get line 1 of the clipboarddata["text"] else get empty
        put merge( tSnip ) into tSnip
    end if
put offset( "`", tSnip) into tInsertion -- set the insertion point if tInsertion is 0 then put (the length of tSnip) - 6 into tInsertion -- before "--///"
    else put space into char tInsertion of tSnip
    do "put tSnip into" && sSel
    add tInsertion to word 2 of sSel
    put (word 2 of sSel) - 1 into word 4 of sSel
    do "select" && sSel
end closeStack


t


Tereza Snyder
Califex Software, Inc.


_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to