equal
deleted
inserted
replaced
|
1 "{ Package: 'stx:libbasic' }" |
|
2 |
1 WriteStream subclass:#TextCollectorStream |
3 WriteStream subclass:#TextCollectorStream |
2 instanceVariableNames:'access lineLimit partialLastLine' |
4 instanceVariableNames:'access lineLimit partialLastLine' |
3 classVariableNames:'' |
5 classVariableNames:'' |
4 poolDictionaries:'' |
6 poolDictionaries:'' |
5 category:'Streams-Misc' |
7 category:'Streams-Misc' |
131 |
133 |
132 |string newPartialLastLine size| |
134 |string newPartialLastLine size| |
133 |
135 |
134 (writeLimit notNil |
136 (writeLimit notNil |
135 and:[position >= writeLimit]) ifTrue:[ |
137 and:[position >= writeLimit]) ifTrue:[ |
136 WriteErrorSignal raiseErrorString:'write beyond writeLimit' |
138 WriteError raiseErrorString:'write beyond writeLimit' |
137 ]. |
139 ]. |
138 |
140 |
139 anObject isCharacter ifTrue:[ |
141 anObject isCharacter ifTrue:[ |
140 ((anObject == Character cr) or:[anObject == Character nl]) ifTrue:[ |
142 ((anObject == Character cr) or:[anObject == Character nl]) ifTrue:[ |
141 partialLastLine ifFalse:[ |
143 partialLastLine ifFalse:[ |
150 string := anObject printString. |
152 string := anObject printString. |
151 (string includes:Character cr) ifTrue:[ |
153 (string includes:Character cr) ifTrue:[ |
152 newPartialLastLine := (string last ~= Character cr). |
154 newPartialLastLine := (string last ~= Character cr). |
153 string := string asStringCollection. |
155 string := string asStringCollection. |
154 partialLastLine ifTrue:[ |
156 partialLastLine ifTrue:[ |
155 string at:1 put:(collection removeLast, (string at:1)). |
157 string at:1 put:((collection removeLast ? ''), (string at:1)). |
156 ]. |
158 ]. |
157 size := collection size + string size. |
159 size := collection size + string size. |
158 size > lineLimit ifTrue:[ |
160 size > lineLimit ifTrue:[ |
159 collection removeFirst:(size - lineLimit min:(collection size)). |
161 collection removeFirst:(size - lineLimit min:(collection size)). |
160 position := lineLimit. |
162 position := lineLimit. |
162 collection addAll:string. |
164 collection addAll:string. |
163 position := position + string size. |
165 position := position + string size. |
164 partialLastLine := newPartialLastLine. |
166 partialLastLine := newPartialLastLine. |
165 ] ifFalse:[ |
167 ] ifFalse:[ |
166 partialLastLine ifTrue:[ |
168 partialLastLine ifTrue:[ |
167 collection add:(collection removeLast, string). |
169 collection add:((collection removeLast ? ''), string). |
168 ] ifFalse:[ |
170 ] ifFalse:[ |
169 collection add:string. |
171 collection add:string. |
170 position := position + 1. |
172 position := position + 1. |
171 ]. |
173 ]. |
172 partialLastLine := true. |
174 partialLastLine := true. |
191 ! ! |
193 ! ! |
192 |
194 |
193 !TextCollectorStream class methodsFor:'documentation'! |
195 !TextCollectorStream class methodsFor:'documentation'! |
194 |
196 |
195 version |
197 version |
196 ^ '$Header: /cvs/stx/stx/libbasic/TextCollectorStream.st,v 1.1 1997-02-19 12:06:26 stefan Exp $' |
198 ^ '$Header: /cvs/stx/stx/libbasic/TextCollectorStream.st,v 1.2 2006-04-06 10:54:06 stefan Exp $' |
197 ! ! |
199 ! ! |