> On Sep 23, 2016, at 1:05 PM, Mark Talluto <m...@canelasoftware.com> wrote: > > >> On Sep 22, 2016, at 2:08 PM, Paul Dupuis <p...@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
An alternative way of accomplishing the above is put the revAvailableHandlers of <objRef> into tHandlerList and then adjust the line below: > 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 put lineOffset(word 2 of 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 — Peter Peter M. Brigham pmb...@gmail.com _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode