Christoph Thiede uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ct.1035.mcz
==================== Summary ====================
Name: Collections-ct.1035
Author: ct
Time: 20 May 2023, 5:16:35.545462 pm
UUID: c36b5e22-b60e-7148-ba41-35c553fb023a
Ancestors: Collections-ct.1034
Adds SequenceableCollection>>groupsCollect: (analogously to #groupsDo: and #pairsCollect:). Especially useful for tests.
=============== Diff against Collections-ct.1034 ===============
Item was added:
+ ----- Method: SequenceableCollection>>groupsCollect: (in category 'enumerating') -----
+ groupsCollect: aBlock
+ "Evaluate aBlock with my elements taken n at a time, where n is the number of arguments of aBlock, and asnwer an Array with the results. Ignore any leftovers at the end."
+
+ | index argumentArray results numArgs endIndex |
+ numArgs := aBlock numArgs.
+ numArgs
+ caseOf: {
+ [ 0 ] -> [ ^self error: 'At least one block argument expected.' ].
+ [ 1 ] -> [ ^self collect: aBlock ].
+ [ 2 ] -> [ ^self pairsCollect: aBlock ] }
+ otherwise: [].
+ argumentArray := Array new: numArgs.
+ results := (Array new: self size // numArgs) writeStream.
+ index := 1.
+ endIndex := self size - numArgs + 1.
+ [ index <= endIndex ] whileTrue: [
+ argumentArray
+ replaceFrom: 1
+ to: numArgs
+ with: self
+ startingAt: index.
+ results nextPut: (aBlock valueWithArguments: argumentArray).
+ index := index + numArgs ].
+ ^ results contents!
Christoph Thiede uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ct.1034.mcz
==================== Summary ====================
Name: Collections-ct.1034
Author: ct
Time: 20 May 2023, 1:33:29.111278 pm
UUID: e23dc425-a4b4-de4c-91bc-19772d83f449
Ancestors: Collections-ct.1033
Adds String>>#beginsWith:caseSensitive: and #endsWith:caseSensitive:.
=============== Diff against Collections-ct.1033 ===============
Item was added:
+ ----- Method: String>>beginsWith:caseSensitive: (in category 'testing') -----
+ beginsWith: sequence caseSensitive: caseSensitive
+ "Answer if the receiver starts with the argument collection."
+
+ | index sequenceSize |
+ caseSensitive ifTrue: [^ self beginsWith: sequence].
+ sequenceSize := sequence size.
+ self size < sequenceSize ifTrue: [ ^false ].
+ index := 0.
+ [ (index := index + 1) <= sequenceSize ] whileTrue: [
+ ((sequence at: index) sameAs: (self at: index)) ifFalse: [ ^false ] ].
+ ^true!
Item was added:
+ ----- Method: String>>endsWith:caseSensitive: (in category 'testing') -----
+ endsWith: sequence caseSensitive: caseSensitive
+ "Answer if the receiver ends with the argument collection."
+
+ | index sequenceSize offset |
+ caseSensitive ifTrue: [^ self endsWith: sequence].
+ sequence isString ifFalse: [ ^super endsWith: sequence ].
+ sequenceSize := sequence size.
+ (offset := self size - sequenceSize) < 0 ifTrue: [ ^false ].
+ index := 0.
+ [ (index := index + 1) <= sequenceSize ] whileTrue: [
+ ((sequence at: index) sameAs: (self at: index + offset)) ifFalse: [ ^false ] ].
+ ^true!
Item was changed:
----- Method: String>>linesDo: (in category 'accessing') -----
linesDo: aBlock
+ "Execute aBlock with each line in the receiver. The terminating line delimiters CR, LF or CRLF pairs are not included in what is passed to aBlock."
- "Execute aBlock with each line in this string. The terminating line delimiters CR, LF or CRLF pairs are not included in what is passed to aBlock"
self lineIndicesDo: [:start :endWithoutDelimiters :end |
aBlock value: (self copyFrom: start to: endWithoutDelimiters)]!
Christoph Thiede uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ct.1033.mcz
==================== Summary ====================
Name: Collections-ct.1033
Author: ct
Time: 20 May 2023, 1:04:49.847278 pm
UUID: 52d747d7-dbb4-464d-b619-ba629ff9e2ec
Ancestors: Collections-mt.1032
Complements Text protocols for #findString:, #lines, #empty, and #withoutTrailingBlanks. Revises #withBlanksTrimmed and #withoutLeadingBlanks to answer an empty text rather than an empty string when no separator was found.
See https://lists.squeakfoundation.org/archives/list/squeak-dev@lists.squeakfou….
=============== Diff against Collections-mt.1032 ===============
Item was added:
+ ----- Method: Text class>>empty (in category 'instance creation') -----
+ empty
+
+ ^ self new!
Item was added:
+ ----- Method: Text>>findString: (in category 'accessing') -----
+ findString: subString
+ "Answer the index of subString within the receiver, starting at start. If the receiver does not contain subString, answer 0."
+
+ ^ self findString: subString startingAt: 1!
Item was added:
+ ----- Method: Text>>lineCorrespondingToIndex: (in category 'accessing') -----
+ lineCorrespondingToIndex: anIndex
+ "Answer a text containing the line at the given character position."
+
+ self lineIndicesDo: [:start :endWithoutDelimiters :end |
+ anIndex <= end ifTrue: [^ self copyFrom: start to: endWithoutDelimiters]].
+ ^ Text empty!
Item was added:
+ ----- Method: Text>>lineIndicesDo: (in category 'accessing') -----
+ lineIndicesDo: aBlock
+ "execute aBlock with 3 arguments for each line:
+ - start index of line
+ - end index of line without line delimiter
+ - end index of line including line delimiter(s) CR, LF or CRLF"
+
+ ^ self string lineIndicesDo: aBlock!
Item was added:
+ ----- Method: Text>>lineNumber: (in category 'accessing') -----
+ lineNumber: anIndex
+ "Answer a text containing the characters in the given line number."
+
+ | lineCount |
+ lineCount := 0.
+ self lineIndicesDo: [:start :endWithoutDelimiters :end |
+ (lineCount := lineCount + 1) = anIndex ifTrue: [
+ ^ self copyFrom: start to: endWithoutDelimiters]].
+ ^ nil!
Item was added:
+ ----- Method: Text>>lines (in category 'accessing') -----
+ lines
+ "Answer an array of lines composing this receiver without the line ending delimiters."
+
+ ^ Array new: (self size // 60 max: 16) streamContents: [:lines |
+ self linesDo: [:aLine | lines nextPut: aLine]]!
Item was added:
+ ----- Method: Text>>linesDo: (in category 'accessing') -----
+ linesDo: aBlock
+ "Execute aBlock with each line in the receiver. The terminating line delimiters CR, LF or CRLF pairs are not included in what is passed to aBlock."
+
+ self lineIndicesDo: [:start :endWithoutDelimiters :end |
+ aBlock value: (self copyFrom: start to: endWithoutDelimiters)].!
Item was changed:
----- Method: Text>>withBlanksTrimmed (in category 'converting') -----
withBlanksTrimmed
"Return a copy of the receiver from which leading and trailing blanks have been trimmed."
| first last |
first := string indexOfAnyOf: CharacterSet nonSeparators startingAt: 1.
+ first = 0 ifTrue: [ ^Text empty ]. "no non-separator character"
- first = 0 ifTrue: [ ^'' ]. "no non-separator character"
last := string lastIndexOfAnyOf: CharacterSet nonSeparators startingAt: self size ifAbsent: [self size].
(first = 1 and: [ last = self size ]) ifTrue: [ ^self copy ].
^self
copyFrom: first
to: last
!
Item was changed:
----- Method: Text>>withoutLeadingBlanks (in category 'converting') -----
withoutLeadingBlanks
"Return a copy of the receiver from which leading blanks have been trimmed."
| first |
first := string indexOfAnyOf: CharacterSet nonSeparators startingAt: 1.
+ first = 0 ifTrue: [ ^Text empty ]. "no non-separator character"
- first = 0 ifTrue: [ ^'' ]. "no non-separator character"
first = 1 ifTrue: [ ^self copy ].
^self
copyFrom: first
to: self size
!
Item was added:
+ ----- Method: Text>>withoutTrailingBlanks (in category 'converting') -----
+ withoutTrailingBlanks
+ "Answer a copy of the receiver from which trailing blanks have been trimmed."
+
+ | last |
+ last := self findLast: [:c | c isSeparator not].
+ last = 0 ifTrue: [^ Text empty]. "no non-separator character"
+ ^ self copyFrom: 1 to: last!
Christoph Thiede uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-ct.2108.mcz
==================== Summary ====================
Name: Morphic-ct.2108
Author: ct
Time: 19 May 2023, 2:12:13.929069 pm
UUID: 6a5d7c0a-b332-3a4b-a3e8-d39454db7b07
Ancestors: Morphic-mt.2107
Immediately update ClockMorph contents after changing its configuration. This fixes the issue of seeing a 12hr time in the docking bar during an update stream update which updates the docking bar through a script.
=============== Diff against Morphic-mt.2107 ===============
Item was changed:
----- Method: ClockMorph>>show24hr: (in category '24hr') -----
show24hr: aBoolean
+ show24hr := aBoolean.
+ self step.!
- show24hr := aBoolean!
Item was changed:
----- Method: ClockMorph>>showSeconds: (in category 'seconds') -----
showSeconds: aBoolean
+ showSeconds := aBoolean.
+ self step.!
- showSeconds := aBoolean!