[ENH] Add "show text as code" and "don't show text as code" options to text morphs.

sps2000 at mail.com sps2000 at mail.com
Wed Sep 26 08:59:53 UTC 2001


from preamble:

"Change Set:		spsCodePane
Date:			26 September 2001
Author:			Steven Swerling

This changeset gives you options to 'show text as code' and 'don't show
text as code' in the yellow button menu. When text is shown as code, a
temporary font is derived from the original font, but the underscore and
caret characters are replaced with assign-arrow and up-arrow images. A
cache of CodeStrikeFonts is maintained so that no more than one is
generated for each real font. This cache is flushed on image saves, so
code fonts should not add to the image size unless there are some stray
pointer to any CodeStrikeFont created, such as in an open window
containing text widgets currently using the code font.

Note that you will not notice a diffence between 'show text as code' and
'don't show text as code' for fonts where the original font has already
been altered to replace the underscore and caret. 

This is a nice changeset to use if you wish to import external fonts
into squeak, but don't want to go through the hassle of manually editing
the fonts to display Smalltalk code. Also, it might be handy for those
who wish to deploy applications that use PluggableTextMorphs but don't
want their users to see anything but normal ascii characters -- call
#viewAsCode: with false to the PluggableCodeTextMorphs in your end user
application, and then the original, unaltered StrikeFont is used.

Should Squeak Central decide them worthy, I think the changes made in
this changeset would best be added to the base PluggableTextMorph class,
rather than doing them in a subclass as I have done
(PluggableCodeTextMorph). But unless that happens (or something like
it), it will be kept separately to make it easier for me to keep it up
to date. This means you have to replace references to PluggableTextMorph
with PluggableCodeTextMorph to get the desired functionality.
PluggableTextMorph is replaced in this changeset with with
PluggableCodeTextMorph in the following few spots, which will probably
take you close to where you want to go:

	#CodeHolder>>buildMorphicCodePaneWith:
	#FileList>>openAsMorph
	#Workspace>>openAsMorphLabel:inWorld:

As noted earlier, this changeset only works for fonts that have *not*
already been altered to use graphical arrows instead of underscores and
carets. So for a demo, try opening up a workspace after filing this in;
typing in some underscores and carets; then setting the font style to
ComicPlain, and the font size to 14. This is done through the yellow
button menu options 'set style...' and 'set font...' (hold down the
shift key when you invoke the yellow button menu). (Make sure to select
all the text before calling 'set font...'). Then access the options to
view as code (or not) from the yellow button menu. 

"!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spsCodePane.cs.gz
Type: application/octet-stream
Size: 5502 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20010926/a9db85b6/spsCodePane.cs.obj


More information about the Squeak-dev mailing list