IDE Script Editor question...

Richard Gaskin ambassador at fourthworld.com
Fri Sep 23 17:42:40 EDT 2016


If memory serves, I believe indenting is handled in the IDE similarly to 
colorization, with a call to _internal.

Perhaps if used in conjunction with the info provided in 
revAvailableHandlers, we may be able to format large scripts even 
faster, maybe even in the blink of an eye.

-- 
  Richard Gaskin


Mark Talluto wrote:
>> 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





More information about the use-livecode mailing list