IDE Script Editor question...

Mark Talluto mark at canelasoftware.com
Fri Sep 23 13:05:38 EDT 2016


> On Sep 22, 2016, at 2:08 PM, Paul Dupuis <paul at researchware.com> wrote:
> 
> Ah ha. The insertion point must be INSIDE a handler and only re-indents
> that handler when you press TAB
> 
> If the insertion point is between handlers or outside of any handler,
> nothing happens. Ok, tab is useful, but something that reformatted ALL
> handlers in a script would be even better.
> 
> Not perfect, but a step better than nothing. Thanks for the tip!

Here is the code we use here to indent a whole script.

command cdt_FastIndent
     local tHandlerList, tOffset, tProgressSoFar
     
     if not(exists(fld "script" of grp "editor" of cd "main" of stack "revNewScriptEditor 1")) then exit cdt_FastIndent
     
     lock screen
     put the text of fld "script" of grp "editor" of cd "main" of stack "revNewScriptEditor 1" into tHandlerList
     filter tHandlerList with "end *"
     filter tHandlerList without "* switch" //IGNORE NON-HANDLER KEYWORDS
     filter tHandlerList without "* repeat" //IGNORE NON-HANDLER KEYWORDS
     filter tHandlerList without "* try" //IGNORE NON-HANDLER KEYWORDS
     filter tHandlerList without "* if" //IGNORE NON-HANDLER KEYWORDS
     
     put 0 into tProgressSoFar
     
     set the wholeMatches to true
     repeat for each line thisLine in tHandlerList
          put lineOffset(thisLine, fld "script" of grp "editor" of cd "main" of stack "revNewScriptEditor 1", tProgressSoFar) into tOffset
          select before line tOffset+tProgressSoFar of \
                fld "script" of grp "editor" of cd "main" of stack "revNewScriptEditor 1"
          dispatch "tabKey" to fld "script" of grp "editor" of cd "main" of stack "revNewScriptEditor 1"
          add tOffset to tProgressSoFar
     end repeat
     unlock screen
end cdt_FastIndent


Best regards,

Mark Talluto
livecloud.io
canelasoftware.com







More information about the use-livecode mailing list