added #asStringWithoutEmphasis...
authorClaus Gittinger <cg@exept.de>
Wed, 17 Jun 1998 16:25:01 +0200
changeset 3602 dd53d372c250
parent 3601 c879b9a15f38
child 3603 ba736c503cb9
added #asStringWithoutEmphasis...
SeqColl.st
SequenceableCollection.st
--- a/SeqColl.st	Wed Jun 17 16:24:21 1998 +0200
+++ b/SeqColl.st	Wed Jun 17 16:25:01 1998 +0200
@@ -914,8 +914,28 @@
      taken as empty lines.
      If the argument compressTabs is true, leading spaces are converted
      to tab-characters (8col tabs). The last line is followed by a final
+     character (if non-nil)."
+
+    ^ self
+        asStringWith:sepCharacter 
+        from:firstLine 
+        to:lastLine 
+        compressTabs:compressTabs 
+        final:endCharacter 
+        withEmphasis:true
+
+    "Modified: / 17.6.1998 / 12:31:19 / cg"
+!
+
+asStringWith:sepCharacter from:firstLine to:lastLine compressTabs:compressTabs final:endCharacter withEmphasis:withEmphasis
+    "return part of myself as a string or text with embedded sepCharacters.
+     My elements must be strings or nil; nil entries and empty strings are
+     taken as empty lines.
+     If the argument compressTabs is true, leading spaces are converted
+     to tab-characters (8col tabs). The last line is followed by a final
      character (if non-nil).
-
+     The withEmphais argument controls if the returned string should preserve
+     any emphasis. If false, a plain string is returned.
      This method is tuned for big collections, in not creating many
      intermediate strings (has linear runtime). For very small collections
      and small strings, it may be faster to use the comma , operation."
@@ -948,12 +968,14 @@
         lineString isNil ifTrue:[
             totalLength := totalLength + sepCnt
         ] ifFalse: [
-            lineString hasChangeOfEmphasis ifTrue:[
-                needEmphasis := true
-            ].
-            (lineString bitsPerCharacter == 16) ifTrue:[
-                any16Bit := true.
-                stringClass := lineString class
+            withEmphasis ifTrue:[
+                lineString hasChangeOfEmphasis ifTrue:[
+                    needEmphasis := true
+                ].
+                (lineString bitsPerCharacter == 16) ifTrue:[
+                    any16Bit := true.
+                    stringClass := lineString class
+                ].
             ].
             totalLength := totalLength + lineString size + sepCnt
         ].
@@ -980,6 +1002,10 @@
         lineString := self at:lineIndex.
         thisLen := lineString size.
         thisLen ~~ 0 ifTrue:[
+            withEmphasis ifFalse:[
+                lineString := lineString string.
+            ].
+
             (anyTab := compressTabs) ifTrue:[
                 "
                  mhmh: could use withTabs from String-class here,
@@ -1107,7 +1133,8 @@
           final:(Character cr) 
     "
 
-    "Modified: 16.8.1997 / 04:44:46 / cg"
+    "Created: / 17.6.1998 / 12:30:32 / cg"
+    "Modified: / 17.6.1998 / 12:31:59 / cg"
 !
 
 asStringWithCRs
@@ -4088,5 +4115,5 @@
 !SequenceableCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/SeqColl.st,v 1.95 1998-05-25 11:40:58 tz Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/SeqColl.st,v 1.96 1998-06-17 14:25:01 cg Exp $'
 ! !
--- a/SequenceableCollection.st	Wed Jun 17 16:24:21 1998 +0200
+++ b/SequenceableCollection.st	Wed Jun 17 16:25:01 1998 +0200
@@ -914,8 +914,28 @@
      taken as empty lines.
      If the argument compressTabs is true, leading spaces are converted
      to tab-characters (8col tabs). The last line is followed by a final
+     character (if non-nil)."
+
+    ^ self
+        asStringWith:sepCharacter 
+        from:firstLine 
+        to:lastLine 
+        compressTabs:compressTabs 
+        final:endCharacter 
+        withEmphasis:true
+
+    "Modified: / 17.6.1998 / 12:31:19 / cg"
+!
+
+asStringWith:sepCharacter from:firstLine to:lastLine compressTabs:compressTabs final:endCharacter withEmphasis:withEmphasis
+    "return part of myself as a string or text with embedded sepCharacters.
+     My elements must be strings or nil; nil entries and empty strings are
+     taken as empty lines.
+     If the argument compressTabs is true, leading spaces are converted
+     to tab-characters (8col tabs). The last line is followed by a final
      character (if non-nil).
-
+     The withEmphais argument controls if the returned string should preserve
+     any emphasis. If false, a plain string is returned.
      This method is tuned for big collections, in not creating many
      intermediate strings (has linear runtime). For very small collections
      and small strings, it may be faster to use the comma , operation."
@@ -948,12 +968,14 @@
         lineString isNil ifTrue:[
             totalLength := totalLength + sepCnt
         ] ifFalse: [
-            lineString hasChangeOfEmphasis ifTrue:[
-                needEmphasis := true
-            ].
-            (lineString bitsPerCharacter == 16) ifTrue:[
-                any16Bit := true.
-                stringClass := lineString class
+            withEmphasis ifTrue:[
+                lineString hasChangeOfEmphasis ifTrue:[
+                    needEmphasis := true
+                ].
+                (lineString bitsPerCharacter == 16) ifTrue:[
+                    any16Bit := true.
+                    stringClass := lineString class
+                ].
             ].
             totalLength := totalLength + lineString size + sepCnt
         ].
@@ -980,6 +1002,10 @@
         lineString := self at:lineIndex.
         thisLen := lineString size.
         thisLen ~~ 0 ifTrue:[
+            withEmphasis ifFalse:[
+                lineString := lineString string.
+            ].
+
             (anyTab := compressTabs) ifTrue:[
                 "
                  mhmh: could use withTabs from String-class here,
@@ -1107,7 +1133,8 @@
           final:(Character cr) 
     "
 
-    "Modified: 16.8.1997 / 04:44:46 / cg"
+    "Created: / 17.6.1998 / 12:30:32 / cg"
+    "Modified: / 17.6.1998 / 12:31:59 / cg"
 !
 
 asStringWithCRs
@@ -4088,5 +4115,5 @@
 !SequenceableCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.95 1998-05-25 11:40:58 tz Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.96 1998-06-17 14:25:01 cg Exp $'
 ! !