TextStream.st
author Stefan Vogel <sv@exept.de>
Wed, 09 Apr 2008 08:02:33 +0200
changeset 1943 63b23152a6d2
parent 1941 3f0b0b5df9ab
child 2053 7592e3ecdca4
permissions -rw-r--r--
#contents does not convert the underlying collection to a Text, if there is no emphasis information (i.e. TextStream behaves like a CharacterWriteStream in zhis case)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1996 by Claus Gittinger
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
1002
ff7c1f0de146 code now independent of actual zeroPosition
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
ff7c1f0de146 code now independent of actual zeroPosition
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    13
1941
3f0b0b5df9ab Inherit from CharacterWriteStream, in order to support Unicode
Stefan Vogel <sv@exept.de>
parents: 1899
diff changeset
    14
CharacterWriteStream subclass:#TextStream
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'runs currentEmphasis'
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Streams'
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!TextStream class methodsFor:'documentation'!
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 1996 by Claus Gittinger
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
              All Rights Reserved
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
documentation
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
562
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    40
    a textStream is much like a regular writeStream;
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    however, in addition to collecting characters, it keeps
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    track of any change of the emphasis, and returns a Text instance
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    as its contents (in contrast to a String instance).
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    Can be used to collect up attributed text.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    [author:]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
        Claus Gittinger
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    [see also:]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
        WriteStream
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
        Text String
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
"
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
examples
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
"
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
                                                                [exBegin]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
     |s|
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
     s := TextStream on:''.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
     s emphasis:#italic;
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
       nextPutAll:'hello';
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
       emphasis:nil;
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
       space;
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
       emphasis:#bold;
1941
3f0b0b5df9ab Inherit from CharacterWriteStream, in order to support Unicode
Stefan Vogel <sv@exept.de>
parents: 1899
diff changeset
    67
       nextPutAll:'world ';
3f0b0b5df9ab Inherit from CharacterWriteStream, in order to support Unicode
Stefan Vogel <sv@exept.de>
parents: 1899
diff changeset
    68
       nextPut:(Character codePoint:16r3C7).
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
     s contents inspect
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
                                                                [exEnd]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
                                                                [exBegin]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
     |s|
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
     s := TextStream on:''.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
     s emphasis:#italic;
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
       nextPutAll:'hello';
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
       emphasis:nil;
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
       space;
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
       emphasis:#bold;
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
       nextPutAll:'world'.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
562
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    83
     Transcript nextPutAll:(s contents)
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    84
                                                                [exEnd]
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    85
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    86
                                                                [exBegin]
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    87
     |s|
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    88
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    89
     s := TextStream on:''.
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    90
     s emphasis:#italic;
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    91
       nextPutAll:'hello';
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    92
       emphasis:nil;
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    93
       space;
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    94
       emphasis:#bold;
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    95
       nextPutAll:'world'.
e41abf509444 comments
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
    96
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
     Dialog
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
        warn:(s contents)
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
                                                                [exEnd]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
                                                                [exBegin]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
     |s1 s2 flipFlop|
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
     s1 := PipeStream readingFrom:'ls -l'.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
     s2 := TextStream on:''.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
     flipFlop := true.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
     [s1 atEnd] whileFalse:[
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
        flipFlop ifTrue:[
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
            s2 emphasis:(#color->Color red)
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
        ] ifFalse:[
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
            s2 emphasis:nil
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
        ].
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
        flipFlop := flipFlop not.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
        s2 nextPutAll:(s1 nextLine).
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
        s2 cr.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
     ].
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
     s1 close.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
     (EditTextView new contents:s2 contents) open
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
                                                                [exEnd]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
"
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
! !
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
!TextStream methodsFor:'accessing'!
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
contents
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    "return the streams collected contents"
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
1943
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   130
    (currentEmphasis isNil and:[runs isEmptyOrNil]) ifTrue:[
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   131
        "no emphasis information: answer a string"
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   132
        ^ super contents
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   133
    ].
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    self closeRun.
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    ^ Text string:super contents emphasisCollection:runs
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    "
1943
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   138
     Answer a Text containing unicode characters:
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   139
         (TextStream on:'')
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   140
            emphasis:#italic;
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   141
            nextPutAll:'hello';
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   142
            emphasis:nil;
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   143
            space;
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   144
            emphasis:#bold;
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   145
            nextPutAll:'world';
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   146
            space;
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   147
            nextPut:Character euro;
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   148
            contents.
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
1943
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   150
     Answer a String:
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   151
         (TextStream on:'')
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   152
            nextPutAll:'hello';
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   153
            contents.
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   154
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   155
     Answer a Text:
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   156
         (TextStream on:Text new)
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   157
            nextPutAll:'hello';
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   158
            contents.
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    "
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
!
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
1159
5f674144ea70 emphasis access
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   162
emphasis
5f674144ea70 emphasis access
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   163
    "return the current emphasis"
5f674144ea70 emphasis access
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   164
5f674144ea70 emphasis access
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   165
    ^ currentEmphasis 
5f674144ea70 emphasis access
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   166
!
5f674144ea70 emphasis access
Claus Gittinger <cg@exept.de>
parents: 1158
diff changeset
   167
663
64bf2f5fec3c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 562
diff changeset
   168
emphasis:newEmphasis
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 340
diff changeset
   169
    "change the emphasis; all followup elements are appended with
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 340
diff changeset
   170
     that emphasis in effect"
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 340
diff changeset
   171
1158
30a06aebed97 position fixes
Claus Gittinger <cg@exept.de>
parents: 1002
diff changeset
   172
    position ~~ ZeroPosition ifTrue:[
1899
b856899327a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1159
diff changeset
   173
        currentEmphasis ~= newEmphasis ifTrue:[
663
64bf2f5fec3c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 562
diff changeset
   174
            self closeRun.
64bf2f5fec3c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 562
diff changeset
   175
        ]
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    ].
663
64bf2f5fec3c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 562
diff changeset
   177
    currentEmphasis := newEmphasis
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    "
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
     |s|
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
     s := TextStream on:String new.
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 340
diff changeset
   183
     s emphasis:#italic;
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 340
diff changeset
   184
       nextPutAll:'hello';
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 340
diff changeset
   185
       emphasis:nil;
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 340
diff changeset
   186
       space;
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 340
diff changeset
   187
       emphasis:#bold;
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 340
diff changeset
   188
       nextPutAll:'world'.
1899
b856899327a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1159
diff changeset
   189
     s contents.
b856899327a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1159
diff changeset
   190
     Transcript showCr:s contents.
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    "
663
64bf2f5fec3c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 562
diff changeset
   192
1899
b856899327a9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1159
diff changeset
   193
    "Modified: / 15-10-2007 / 16:27:31 / cg"
873
2582affa063b added #stringContents (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   194
!
2582affa063b added #stringContents (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   195
2582affa063b added #stringContents (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   196
stringContents
2582affa063b added #stringContents (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   197
    "return the streams collected string contents"
2582affa063b added #stringContents (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   198
2582affa063b added #stringContents (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   199
    ^ super contents
2582affa063b added #stringContents (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   200
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
! !
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
!TextStream methodsFor:'private'!
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
closeRun
1158
30a06aebed97 position fixes
Claus Gittinger <cg@exept.de>
parents: 1002
diff changeset
   206
    position ~~ ZeroPosition ifTrue:[
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
        runs isNil ifTrue:[
1943
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   208
            runs := RunArray new:position-ZeroPosition withAll:currentEmphasis.
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
        ] ifFalse:[
1158
30a06aebed97 position fixes
Claus Gittinger <cg@exept.de>
parents: 1002
diff changeset
   210
            runs add:currentEmphasis withOccurrences:(position-ZeroPosition-runs size)
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
        ]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    ]
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
! !
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
!TextStream class methodsFor:'documentation'!
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
version
1943
63b23152a6d2 #contents does not convert the underlying collection to a Text, if there is
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   218
    ^ '$Header: /cvs/stx/stx/libbasic2/TextStream.st,v 1.11 2008-04-09 06:02:33 stefan Exp $'
340
dcc2bb30c0c9 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
! !