ColorizeScript challenge

Dave Cragg dcragg at lacscentre.co.uk
Thu Apr 27 11:40:57 CDT 2006


On 27 Apr 2006, at 16:31, Richard Gaskin wrote:
>
> Here's a tough one:  Your script works great in MC (I've had to  
> modify it to use it there, and changed some color assignments while  
> I was at it -- see below), but it doesn't set the color of function  
> names when the function is used in the traditional parenthetic form  
> rather than with "the", e.g.:
>
>   put the length of "Hello" -- colorizes "length"
>   put length("Hello") -- doesn't colorize "length"
>
> I began exploring ways to use token instead of work, but I couldn't  
> do it without changing the actual text.  Maybe with a little more  
> dilligence token might be the magic key we're looking for....

I took a peek at Rev's coloring method. They use words, but then do a  
sneaky check on the first token in each word.

Geoff wrote:
> I think if I really want the beer (maybe tonight) I'd rewrite my  
> code to simply loop through the characters of the script and keep  
> my own state variables: inBlockComment, inQuotedString. Assemble  
> words, put them into the HTML, etc. <sigh>
>

I was coming to the same conclusion, and had already started playing  
with something like inBlockComment. But then I screamed when I heard  
about the ("text in quotes in parentheses") word count issue. (BTW,  
that example is 5 words but stil only 3 tokens. Not sure if that  
offers any help.)

Richard wrote:

>> I don't colorize either. What a couple of saps.
>>
>
> That makes three of us. :)
>
> But folks seem to like it so it seems worth doing.
>

I'd be interested to know more about what people like about it. It  
seems the current method is just to do the obvious and colorize key  
word catagories (built-in commands, functions, etc.) and apply a  
different color for each category.

My problem with the multi-colored approach is that it makes  
continuous reading tiresome. And I'd hazard a guess that most people  
don't pay too much attention to the different colors. It's the fact  
that they're not black that is useful. I prefer the AppleScript  
editor which bolds (boldens?) key words, but doesn't change colors.  
My preferred scheme would be something like this:

-- handler start/end statements :  Bold and slightly bigger type (but  
with any arguments at normal size and plain)
-- key words :  bold
-- comments:  lighter color

However, it wouldn't make the job much easier, except that we  
wouldn't have to worry about key words that carry two purposes (e.g.  
return)

Do you think there's a market in script editor themes? (don't answer)

Cheers
Dave



More information about the metacard mailing list