CharacterArray.st
changeset 3073 0b361b3b168b
parent 3060 0faf242e1142
child 3195 0a1a7a4c6184
--- a/CharacterArray.st	Sun Nov 02 18:16:21 1997 +0100
+++ b/CharacterArray.st	Sun Nov 02 18:20:39 1997 +0100
@@ -10,8 +10,6 @@
  hereby transferred.
 "
 
-'From Smalltalk/X, Version:3.2.1 on 25-oct-1997 at 9:24:23 pm'                  !
-
 ByteArray subclass:#CharacterArray
 	instanceVariableNames:''
 	classVariableNames:'PreviousMatch DecoderTables EncoderTables DecodingFailedSignal
@@ -2091,6 +2089,91 @@
     "
 ! !
 
+!CharacterArray methodsFor:'Compatibility - ST80'!
+
+expandMacrosWith:arg
+    "ST80 compatibility - expand '<..>' macros with
+     argument strings. Similar to #bindWith:.
+     Read the comment in #expandMacrosWithArguments: about
+     limited compatibility issues."
+
+    ^ self expandMacrosWithArguments:(Array with:arg)
+
+    "Created: / 1.11.1997 / 13:01:28 / cg"
+    "Modified: / 1.11.1997 / 13:30:50 / cg"
+!
+
+expandMacrosWithArguments:argArray
+    "ST80 compatibility - expand '<..>' macros with
+     argument strings. Similar to #bindWith:.
+     WARNING: possibly not all ST80 expansions are supported here."
+
+    "/ supported expansions:
+    "/
+    "/   <#p>   # is arg Number; slice in the args printString
+    "/   <#s>   # is arg Number; slice in the arg itself (must be a String)
+    "/   <n>    replace by a newLine character
+
+    |in out c fmt nr|
+
+    in := self readStream.
+    out := '' writeStream.
+
+    [in atEnd] whileFalse:[
+        c := in next.
+        c == $< ifTrue:[
+            in peek == $n ifTrue:[
+                out nextPut:Character cr.
+                in next
+            ] ifFalse:[
+                "/ start an argument expansion ...
+                nr := Integer readFrom:in onError:nil.
+                nr isNil ifTrue:[
+                    "/ what does VW do here ?
+                    self halt:'invalid format'.
+                    ^ self
+                ] ifFalse:[
+                    (nr between:1 and:argArray size) ifFalse:[
+                        "/ what does VW do here ?
+                        self halt:'invalid format'.
+                        ^ self
+                    ] ifTrue:[
+                        fmt := in next.
+                        (fmt == $p) ifTrue:[
+                            "/ expand with args printString
+                            out nextPutAll:(argArray at:nr) printString.
+                        ] ifFalse:[
+                            (fmt == $s) ifTrue:[
+                                "/ expand with arg itself
+                                out nextPutAll:(argArray at:nr).
+                            ] ifFalse:[
+                                "/ what does VW do here ?
+                                self halt:'invalid format'.
+                                ^ self
+                            ]
+                        ]
+                    ]
+                ].
+            ].
+            c := in next.
+            c ~~ $> ifTrue:[
+                "/ what does VW do here ?
+                self halt:'invalid format'.
+                ^ self
+            ]
+        ] ifFalse:[
+            out nextPut:c
+        ].
+    ].
+    ^ out contents
+
+    "
+     'hello <1p> how are you' expandMacrosWith:(OperatingSystem getLoginName)
+    "
+
+    "Modified: / 1.11.1997 / 13:31:50 / cg"
+! !
+
 !CharacterArray methodsFor:'Compatibility - V''Age'!
 
 addLineDelimiter
@@ -3133,16 +3216,6 @@
     "Modified: 11.5.1996 / 14:42:48 / cg"
 !
 
-displayOpaqueOn:aGc x:x y:y
-    "display the receiver in a graphicsContext - this method allows
-     strings to be used like DisplayObjects."
-
-    self displayOn:aGc x:x y:y opaque:true
-
-    "Modified: 11.5.1996 / 14:42:48 / cg"
-    "Created: 12.5.1996 / 12:28:40 / cg"
-!
-
 displayOpaqueOn:aGC x:x y:y from:start to:stop
     "display the receiver on a GC"
 
@@ -5040,6 +5113,6 @@
 !CharacterArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.139 1997-10-28 19:12:59 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.140 1997-11-02 17:20:39 cg Exp $'
 ! !
 CharacterArray initialize!