eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'TextStream':

Home

everywhere
www.exept.de
for:
[back]

Class: TextStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--PeekableStream
         |
         +--PositionableStream
            |
            +--WriteStream
               |
               +--CharacterWriteStream
                  |
                  +--TextStream

Package:
stx:libbasic2
Category:
Streams
Version:
rev: 1.12 date: 2008/11/06 11:00:39
user: stefan
file: TextStream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


a textStream is much like a regular writeStream;
however, in addition to collecting characters, it keeps
track of any change of the emphasis, and returns a Text instance
as its contents (in contrast to a String instance).
Can be used to collect up attributed text.


Related information:

    WriteStream
    Text
    String

Instance protocol:

accessing
o  contents
return the streams collected contents

o  emphasis
return the current emphasis

o  emphasis: newEmphasis
change the emphasis; all followup elements are appended with
that emphasis in effect

o  stringContents
return the streams collected string contents

private
o  closeRun

writing
o  nextPutAllText: aText
write some text to the stream and keep the emphasis


Examples:



     |s|

     s := TextStream on:''.
     s emphasis:#italic;
       nextPutAll:'hello';
       emphasis:nil;
       space;
       emphasis:#bold;
       nextPutAll:'world ';
       nextPut:(Character codePoint:16r3C7).
     s contents inspect


     |s|

     s := TextStream on:''.
     s emphasis:#italic;
       nextPutAll:'hello';
       emphasis:nil;
       space;
       emphasis:#bold;
       nextPutAll:'world'.

     Transcript nextPutAll:(s contents)


     |s|

     s := TextStream on:''.
     s emphasis:#italic;
       nextPutAll:'hello';
       emphasis:nil;
       space;
       emphasis:#bold;
       nextPutAll:'world'.

     Dialog
        warn:(s contents)


     |s1 s2 flipFlop|

     s1 := PipeStream readingFrom:'ls -l'.
     s2 := TextStream on:''.

     flipFlop := true.
     [s1 atEnd] whileFalse:[
        flipFlop ifTrue:[
            s2 emphasis:(#color->Color red)
        ] ifFalse:[
            s2 emphasis:nil
        ].
        flipFlop := flipFlop not.
        s2 nextPutAll:(s1 nextLine).
        s2 cr.
     ].
     s1 close.

     (EditTextView new contents:s2 contents) open


ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 21:34:02 GMT