RunArray.st
changeset 2127 dc0da410f2d7
parent 2049 310eea860aa2
child 2147 b2f5a09a6174
--- a/RunArray.st	Thu Feb 26 22:35:40 2009 +0100
+++ b/RunArray.st	Mon Mar 16 16:15:05 2009 +0100
@@ -848,6 +848,43 @@
 
 !RunArray methodsFor:'printing & storing'!
 
+displayOn:aGCOrStream 
+    "Append to aStream an expression which, if evaluated, will generate   
+    an object similar to the receiver."
+
+    "/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
+    "/ ST/X (and some old ST80's) mean: draw-yourself on a GC.
+    (aGCOrStream isStream or:[aGCOrStream == Transcript]) ifTrue:[
+        aGCOrStream nextPutAll: '(RunArray new'.
+        contentsArray notNil ifTrue:[
+            contentsArray pairWiseDo:[:len :val | 
+                aGCOrStream nextPutAll: ' add:'. val displayOn:aGCOrStream. 
+                len == 1 ifFalse:[
+                    aGCOrStream nextPutAll:' withOccurrences:'. len printOn:aGCOrStream.
+                ].
+                aGCOrStream nextPutAll:';'
+            ].
+            aGCOrStream nextPutAll:' yourself'
+        ].
+        aGCOrStream nextPutAll:')'.
+        ^ self.
+    ].
+    ^ self displayOn:aGCOrStream x:0 y:0.
+
+    "
+     (RunArray new 
+        add:1; 
+        add:1; 
+        add:2; 
+        add:3; 
+        add:4 withOccurrences:100; 
+        add:5; 
+        yourself) displayString 
+
+     RunArray new displayString 
+    "
+!
+
 storeOn:aStream 
     "Append to aStream an expression which, if evaluated, will generate   
     an object similar to the receiver."
@@ -855,9 +892,9 @@
     aStream nextPutAll: '(RunArray new'.
     contentsArray notNil ifTrue:[
         contentsArray pairWiseDo:[:len :val | 
-            aStream nextPutAll: ' add:'; nextPutAll:val storeString. 
+            aStream nextPutAll: ' add:'. val storeOn:aStream. 
             len == 1 ifFalse:[
-                aStream nextPutAll:' withOccurrences:'; nextPutAll:len printString.
+                aStream nextPutAll:' withOccurrences:'. len printOn:aStream.
             ].
             aStream nextPutAll:';'
         ].
@@ -1279,5 +1316,5 @@
 !RunArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.26 2008-11-05 16:37:43 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.27 2009-03-16 15:15:05 stefan Exp $'
 ! !