Text color emphasis

Tim Olson tim at jumpnet.com
Tue Dec 30 16:08:32 UTC 1997


Ernest Micklei wrote:

>In addition to bold emphasis for the selector in
>the source code of a method, I prefer to have
>the comment portions show up in blue.
>A simple scan for comment delimiters in the source
>and adding the appropriate attribute to the Text
>object, is all what it takes to achieve this effect in Squeak.

Well, almost.  The "simple scan" code works well in most cases, but it 
blows up badly when double-quote characters appear inside of a string, as 
is the case in a few of the methods in the image (try to view 
ParagraphEditor>>explain when this feature is turned on) ***.

>However, I noticed that whenever a code window
>gets focus again (after selecting outside the code window), 
>the color emphasis are ignored when refreshing the contents of the window.
>Could someone point me to the object with this responsibility ?.

This is due to 2 things:

     - cacheing window bits for faster update
     - StandardSystemView caches window bits as two-tone instead of color

You can turn off cacheing by selecting the Window... menu and choosing 
"don't save bits (compact)".  This will slow down display when windows 
are updated, though.

You can also tell the StandardSystemView to cache color info by changing 
StandardSystemView>>cacheBitsAsTwoTone to return false instead of true.  
However, this will greatly increase the size of the cached window bitmaps.


*** To correctly display the comments, you need to parse the method text 
just as the compiler would.  In fact, the Compiler contains a method to 
do just that:
Compiler>>format:in:notifying: will "pretty-print" a method, and decorate 
it (comments in green, etc.) when the shift key is held down (You can try 
it out by selecting "format" from the shifted Yellow-button menu of a 
CodeView).  I have experimented with making this the default way of 
displaying text in a CodeView (selector bold, comments italics are my 
preferences), with good results.




     -- tim





More information about the Squeak-dev mailing list