Hi.
Can can someone tell me how to file-in text and apply its style chunk? The method below skips the style chunk:
[ReadWriteStream>>] fileInAnnouncing: announcement "This is special for reading expressions from text that has been formatted with exclamation delimitors. The expressions are read and passed to the Compiler. Answer the result of compilation. Put up a progress report with the given announcement as the title." | val chunk | announcement displayProgressAt: Sensor cursorPoint from: 0 to: self size during: [:bar | [self atEnd] whileFalse: [bar value: self position. self skipSeparators. val _ (self peekFor: $!) ifTrue: [(Compiler evaluate: self nextChunk logged: false) scanFrom: self] ifFalse: [chunk _ self nextChunk. self checkForPreamble: chunk. Compiler evaluate: chunk logged: true]. self skipStyleChunk]. self close]. ^ val
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.
Regards,
Shaping
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.
squeak-dev@lists.squeakfoundation.org