Colorize Script

Brian Yennie briany at qldlearning.com
Thu Apr 15 04:06:02 EDT 2004


This reminds me of something that I think would be awfully useful.
What if the below was modified to make keywords clickable and take you 
directly to the documentation...? You could type the command name, 
scratching your head trying to remember the syntax, and then aww shoot, 
just click on it...

> See 'on colorizescript' in the card script of MC's script editor 
> window...
>
> on colorizescript
>   if tokencolors["if"] is empty then setupcolors
>   local s
>   put field "Editor Field" into s
>   put s into field "Editor Field"
>   go to card 2
>   local curword
>   put 1 into curword
>   repeat for each word w in s
>     if tokencolors[w] is not empty
>     then set the textColor of word curword of field "Editor Field" of 
> card 1
> to tokencolors[w]
>     add 1 to curword
>   end repeat
>   local oldline, cline, curline, nwords
>   put min(lineoffset("#", s), lineoffset("--", s)) into oldline
>   put 0 into cline
>   repeat while oldline is not 0
>     add oldline to cline
>     put line cline of s into curline
>     put the number of words in curline into nwords
>     repeat with curword = 1 to nwords
>       if char 1 of word curword of curline is "#" or char 1 to 2 of 
> word
> curword of curline is "--" then
>         set the textColor of word curword to nwords of line cline of 
> field
> "Editor Field" of card 1 to "DarkOrchid4"
>         exit repeat
>       end if
>     end repeat
>     put min(lineoffset("#", s, cline), lineoffset("--", s, cline)) into
> oldline
>   end repeat
>   go to card 1
>   unlock screen
> end colorizescript
>
> on setupcolors
>   repeat for each word w in the commandNames
>     put "blue" into tokencolors[w]
>   end repeat
>   repeat for each word w in "if then else repeat for with while on end 
> switch
> case getprop setprop"
>     put "Brown" into tokencolors[w]
>   end repeat
>   repeat for each word w in the functionNames
>     put "DarkOrange" into tokencolors[w]
>   end repeat
>   repeat for each word w in the propertyNames
>     put "red" into tokencolors[w]
>   end repeat
> end setupcolors



More information about the use-livecode mailing list