Styled text from file-in?

Dan Ingalls Dan.Ingalls at disney.com
Thu Sep 2 16:17:12 UTC 1999


>Can can someone tell me how to file-in text and apply its style chunk?
> ...
>I suppose I have to convert the style chunk into an appropriate
>text-attribute run array and apply it to the text before it is compiled.  I
>don't see any examples of how this is done.  Any pointers would be
>appreciated.

If you are willing to dig a bit, here is how to learn about fileIn/out of stylized text...

A.  if you are an experienced Squeaker, just open a selectorFinder, enter 'nextChunk'  in the top pane, and the rest will be obvious.

B.  If not then...

1.  Make up a short method with a bunch of style changes in it.

2.  Accept the method, and confirm 'save method with style'.  This will cause it to be written on the end of the changes file in fileOut format.  The method that does the work is WriteStream nextChunkPutWithStyle:.

3.  Execute...
        (StringHolder new contents:
                ((SourceFiles at: 2) readOnlyCopy setToEnd; skip: -1000; next: 1000))
            openLabel: 'Last 1000 chars'.
    ...this will show you what the source file contains as a result.

4.  Now look at the code for PositionableStream nextChunkText.  This is what fileIn uses to read code back from the changes file.

Hope this helps

	- Dan

PS:  For an example using ReferenceStream storage, look at
	Utilities storeTextWindowContentsToFileNamed:
	Utilities reconstructTextWindowsFromFileNamed:
These save the text from all Workspaces on the screen to a file, and then (presumably in another image or project) reconstruct a set of workspaces with the same text in them.





More information about the Squeak-dev mailing list