--- a/CharacterArray.st Sat Oct 09 15:17:13 1999 +0200
+++ b/CharacterArray.st Sat Oct 09 17:31:41 1999 +0200
@@ -2263,6 +2263,63 @@
+!
+
+lastSpacePosition
+ ^ self lastIndexOfSeparator
+!
+
+withBlanksTrimmed
+ "Return a copy of the receiver from which leading and trailing blanks have been trimmed."
+
+ ^ self withoutSpaces
+
+ "
+ ' hello world ' withBlanksTrimmed
+ "
+
+
+
+!
+
+withNoLineLongerThan: aNumber
+ "Answer a string with the same content as receiver, but rewrapped so that no line has more characters than the given number"
+
+ | listOfLines currentLast currentStart resultString putativeLast putativeLine crPosition |
+
+ aNumber isNumber not | (aNumber < 1) ifTrue: [self error: 'too narrow'].
+ listOfLines _ OrderedCollection new.
+ currentLast _ 0.
+ [currentLast < self size] whileTrue:
+ [currentStart _ currentLast + 1.
+ putativeLast _ (currentStart + aNumber - 1) min: self size.
+ putativeLine _ self copyFrom: currentStart to: putativeLast.
+ (crPosition _ putativeLine indexOf: Character cr) > 0 ifTrue:
+ [putativeLast _ currentStart + crPosition - 1.
+ putativeLine _ self copyFrom: currentStart to: putativeLast].
+ currentLast _ putativeLast == self size
+ ifTrue:
+ [putativeLast]
+ ifFalse:
+ [currentStart + putativeLine lastSpacePosition - 1].
+ currentLast <= currentStart ifTrue:
+ ["line has NO spaces; baleout!!"
+ currentLast _ putativeLast].
+ listOfLines add: (self copyFrom: currentStart to: currentLast) withBlanksTrimmed].
+
+ listOfLines size > 0 ifFalse: [^ ''].
+ resultString _ listOfLines first.
+ 2 to: listOfLines size do:
+ [:i | resultString _ resultString, Character cr asString, (listOfLines at: i)].
+ ^ resultString
+
+ "
+ #(5 7 20) collect:
+ [:i | 'Fred the bear went down to the brook to read his book in silence' withNoLineLongerThan: i]
+ "
+
+
+
! !
!CharacterArray methodsFor:'Compatibility - V''Age'!
@@ -5399,6 +5456,6 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.168 1999-10-04 15:34:19 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.169 1999-10-09 15:31:28 cg Exp $'
! !
CharacterArray initialize!
--- a/Collection.st Sat Oct 09 15:17:13 1999 +0200
+++ b/Collection.st Sat Oct 09 17:31:41 1999 +0200
@@ -988,6 +988,15 @@
"
!
+collect:collectBlock thenSelect:selectBlock
+ "combination of collect followed by select.
+ May be redefined by some subclasses for optimal performance
+ (not creating a garbage collection)"
+
+ ^ (self collect: collectBlock) select: selectBlock
+
+!
+
conform:aBlock
"return true, if every element conforms to some condition.
I.e. return false, if aBlock returns false for any element;
@@ -1871,6 +1880,6 @@
!Collection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.86 1999-10-06 16:33:41 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.87 1999-10-09 15:30:44 cg Exp $'
! !
Collection initialize!
--- a/Rectangle.st Sat Oct 09 15:17:13 1999 +0200
+++ b/Rectangle.st Sat Oct 09 17:31:41 1999 +0200
@@ -67,6 +67,15 @@
!Rectangle class methodsFor:'instance creation'!
+center:centerPoint extent:extentPoint
+ "return an instance of me whose center is centerPoint and width
+ by height is extentPoint."
+
+ ^ self
+ origin:centerPoint - (extentPoint//2)
+ extent:extentPoint
+!
+
decodeFromLiteralArray:anArray
"create & return a new instance from information encoded in anArray.
Redefined for faster creation."
@@ -1016,6 +1025,18 @@
"Created: 12.2.1997 / 11:44:45 / cg"
!
+corners
+ "Return an array of corner points"
+
+ ^ Array
+ with: self topLeft
+ with: self bottomLeft
+ with: self bottomRight
+ with: self topRight
+
+
+!
+
isRectangle
"return true, if the receiver is some kind of rectangle"
@@ -1652,5 +1673,5 @@
!Rectangle class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.65 1999-10-07 10:57:21 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.66 1999-10-09 15:31:41 cg Exp $'
! !