Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.402.mcz ==================== Summary ==================== Name: Collections-ul.402 Author: ul Time: 2 November 2010, 10:03:54.289 pm UUID: c07fdead-7f3a-544f-82dd-4bfe4ef28365 Ancestors: Collections-ul.401 - enhanced AttributedTextStream so it can be used as a TextStream in some cases. - recategorized a few methods, fixed some comments =============== Diff against Collections-ul.401 =============== Item was changed: + ----- Method: AttributedTextStream>>contents (in category 'accessing') ----- - ----- Method: AttributedTextStream>>contents (in category 'retrieving the text') ----- contents | ans | currentRun > 0 ifTrue:[ attributeValues nextPut: currentAttributes. attributeRuns nextPut: currentRun. currentRun := 0]. ans := Text string: characters contents runs: (RunArray runs: attributeRuns contents values: attributeValues contents). ^ans! Item was added: + ----- Method: AttributedTextStream>>cr (in category 'character writing') ----- + cr + "Append a carriage return character to the receiver." + + self nextPut: Character cr! Item was added: + ----- Method: AttributedTextStream>>crlf (in category 'character writing') ----- + crlf + "Append a carriage return and a line feed to the receiver." + + self nextPut: Character cr; nextPut: Character lf! Item was changed: + ----- Method: AttributedTextStream>>currentAttributes (in category 'accessing') ----- - ----- Method: AttributedTextStream>>currentAttributes (in category 'access') ----- currentAttributes "return the current attributes" ^currentAttributes! Item was changed: + ----- Method: AttributedTextStream>>currentAttributes: (in category 'accessing') ----- - ----- Method: AttributedTextStream>>currentAttributes: (in category 'access') ----- currentAttributes: newAttributes "set the current attributes" (currentRun > 0 and:[currentAttributes ~= newAttributes]) ifTrue:[ attributeRuns nextPut: currentRun. attributeValues nextPut: currentAttributes. currentRun := 0. ]. currentAttributes := newAttributes. ! Item was changed: + ----- Method: AttributedTextStream>>initialize (in category 'initialize-release') ----- - ----- Method: AttributedTextStream>>initialize (in category 'private-initialization') ----- initialize + + characters := String new writeStream. + currentAttributes := #(). - characters := WriteStream on: String new. - currentAttributes := OrderedCollection new. currentRun := 0. + attributeValues := (Array new: 50) writeStream. + attributeRuns := (Array new: 50) writeStream! - attributeValues := WriteStream on: (Array new: 50). - attributeRuns := WriteStream on: (Array new: 50). ! Item was added: + ----- Method: AttributedTextStream>>lf (in category 'character writing') ----- + lf + "Append a line feed character to the receiver." + + self nextPut: Character lf! Item was changed: + ----- Method: AttributedTextStream>>nextPut: (in category 'accessing') ----- - ----- Method: AttributedTextStream>>nextPut: (in category 'stream protocol') ----- nextPut: aChar currentRun := currentRun + 1. ^characters nextPut: aChar! Item was changed: + ----- Method: AttributedTextStream>>nextPutAll: (in category 'accessing') ----- - ----- Method: AttributedTextStream>>nextPutAll: (in category 'stream protocol') ----- nextPutAll: aString "add an entire string with the same attributes" currentRun := currentRun + aString size. ^characters nextPutAll: aString.! Item was changed: + ----- Method: AttributedTextStream>>size (in category 'accessing') ----- - ----- Method: AttributedTextStream>>size (in category 'access') ----- size "number of characters in the stream so far" ^characters size! Item was added: + ----- Method: AttributedTextStream>>withAttribute:do: (in category 'accessing') ----- + withAttribute: attribute do: aBlock + + ^self withAttributes: { attribute } do: aBlock! Item was added: + ----- Method: AttributedTextStream>>withAttributes:do: (in category 'accessing') ----- + withAttributes: attributes do: aBlock + + | previousAttributes | + previousAttributes := currentAttributes. + [ + self currentAttributes: attributes. + aBlock value ] + ensure: [ self currentAttributes: previousAttributes ]! Item was changed: + ----- Method: Stream>>printOn: (in category 'printing') ----- - ----- Method: Stream>>printOn: (in category 'accessing') ----- printOn: stream super printOn: stream. stream space. self contents printOn: stream. ! Item was changed: ----- Method: WriteStream>>cr (in category 'character writing') ----- cr + "Append a carriage return character to the receiver." - "Append a return character to the receiver." self nextPut: Character cr! Item was changed: ----- Method: WriteStream>>crlf (in category 'character writing') ----- crlf + "Append a carriage return and a line feed to the receiver." - "Append a line feed character to the receiver." self nextPut: Character cr; nextPut: Character lf! |
Free forum by Nabble | Edit this page |