Marcel Taeumel uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-mt.363.mcz
==================== Summary ====================
Name: CollectionsTests-mt.363
Author: mt
Time: 2 December 2021, 2:53:50.194715 pm
UUID: 2e5af8dd-1822-9c41-8cab-2ad1e733146c
Ancestors: CollectionsTests-ul.362
Complements Collections-mt.965
=============== Diff against CollectionsTests-ul.362 ===============
Item was changed:
----- Method: HtmlReadWriterTest>>test03FontTag (in category 'tests') -----
test03FontTag
{
'<font color="#FFFF00">Hello, World!!</font>'.
'Hello, World!!' asText
addAttribute: (TextColor color: Color yellow).
+
+ '<font face="Accula" size="12">Hello, World!!</font>'.
+ 'Hello, World!!' asText
+ addAttribute: (TextFontReference toFont: (StrikeFont familyName: 'Accula' pointSize: 12)).
+
+ "Note that we cannot directly use both face/size and color in the same font tag because of how #openHtmlOn: works in fonts. Works in general, but just not in this test setup."
+ '<font face="Accula" size="12"><font color="#FFFF00">Hello, World!!</font></font>'.
+ 'Hello, World!!' asText
+ addAttribute: (TextFontReference toFont: (StrikeFont familyName: 'Accula' pointSize: 12));
+ addAttribute: (TextColor color: Color yellow).
+
} pairsDo: [:expectedHtml :expectedText |
self convertHtml: expectedHtml.
self assert: expectedText string equals: text string.
self assert: expectedText runs equals: text runs.
self convertText: expectedText.
self assert: expectedHtml equals: html].!
Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ct.1419.mcz
==================== Summary ====================
Name: Kernel-ct.1419
Author: ct
Time: 27 October 2021, 10:21:05.275233 pm
UUID: ecfac90e-ea85-774f-b13d-0ecad50c894a
Ancestors: Kernel-eem.1418
Makes it possible to specify a different default base in number parsers. There is no need to hard-code the 10 and I am actually building something with a different default number system. Clients can still change the base via the radix notation.
(ExtendedNumberParser on: '10')
defaultBase: 16;
nextNumber. "16"
(ExtendedNumberParser on: '2r10')
defaultBase: 16;
nextNumber. "2"
(ExtendedNumberParser on: 'ar10')
defaultBase: 16;
nextNumber. "10".
Also adds Integer class >> #readFrom:base:ifFail: for convenience. Removes redundant class-side overrides on SqNumberParser.
=============== Diff against Kernel-eem.1418 ===============
Item was changed:
----- Method: ExtendedNumberParser>>nextFraction (in category 'parsing-public') -----
nextFraction
| numerator denominator numberOfTrailingZeroInIntegerPart |
+ base := self defaultBase.
- base := 10.
neg := self peekSignIsMinus.
(integerPart := self nextUnsignedIntegerOrNilBase: base)
ifNil: [numberOfTrailingZeroInIntegerPart := 0]
ifNotNil: [
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero.
(sourceStream peekFor: $r)
ifTrue: ["<base>r<integer>"
(base := integerPart) < 2
ifTrue: [
sourceStream skip: -1.
^ self expected: 'an integer greater than 1 as valid radix'].
self peekSignIsMinus
ifTrue: [neg := neg not].
integerPart := self nextUnsignedIntegerBase: base.
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero]].
(sourceStream peekFor: $.)
ifTrue:
[^self readFractionPartNumberOfTrailingZeroInIntegerPart: numberOfTrailingZeroInIntegerPart].
integerPart
ifNil:
["No integerPart, raise an error"
^ self expected: 'a digit'].
numerator := neg
ifTrue: [integerPart negated]
ifFalse: [integerPart].
self readExponent ifTrue: [numerator := numerator * (base raisedToInteger: exponent)].
(sourceStream peekFor: $/) ifFalse: [^numerator].
base := 10.
+ base := self defaultBase.
(denominator := self nextUnsignedIntegerOrNilBase: base)
ifNil:
[sourceStream skip: -1. "Not a valid denominator, ungobble / and return numerator"
^numerator].
(sourceStream peekFor: $r)
ifTrue: ["<base>r<integer>"
(base := denominator) < 2
ifTrue: [
sourceStream skip: -1.
^ self expected: 'an integer greater than 1 as valid radix'].
denominator := self nextUnsignedIntegerBase: base].
self readExponent ifTrue: [denominator := denominator * (base raisedToInteger: exponent)].
^numerator / denominator!
Item was changed:
----- Method: ExtendedNumberParser>>nextNumber (in category 'parsing-public') -----
nextNumber
"main method for reading a number.
This one can read Float Integer and ScaledDecimal"
| numberOfTrailingZeroInIntegerPart |
+ base := self defaultBase.
- base := 10.
neg := self peekSignIsMinus.
integerPart := self nextUnsignedIntegerOrNilBase: base.
integerPart ifNil: [(sourceStream peekFor: $.)
ifTrue: [
"Try .1 syntax"
^self readNumberWithoutIntegerPart]
ifFalse: [
"This is not a regular number beginning with a digit
It is time to check for exceptional condition NaN and Infinity"
^self readNamedFloatOrFail]].
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero.
(sourceStream peekFor: $r)
ifTrue: ["<base>r<integer>"
| oldNeg pos |
pos := sourceStream position - 1.
(base := integerPart) < 2
ifTrue: ["A radix currently need to be greater than 1, ungobble the r and return the integer part"
sourceStream skip: -1.
^neg
ifTrue: [base negated]
ifFalse: [base]].
oldNeg := neg.
self peekSignIsMinus ifTrue: [neg := neg not].
integerPart := self nextUnsignedIntegerOrNilBase: base.
integerPart ifNil: [
(sourceStream peekFor: $.) ifTrue: [self readNumberWithoutIntegerPartOrNil ifNotNil: [:aNumber | ^aNumber]].
sourceStream position: pos.
^oldNeg
ifTrue: [base negated]
ifFalse: [base]].
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero].
^ (sourceStream peekFor: $.)
ifTrue: [self readNumberWithFractionPartNumberOfTrailingZeroInIntegerPart: numberOfTrailingZeroInIntegerPart]
ifFalse: [self makeIntegerOrScaledInteger]!
Item was changed:
----- Method: FORTRANNumberParser>>nextNumber (in category 'parsing-public') -----
nextNumber
"main method for reading a number with FORTRAN syntax.
This one can read Real and Integer (not complex)"
| numberOfTrailingZeroInIntegerPart numberOfNonZeroFractionDigits mantissa value numberOfTrailingZeroInFractionPart noInt |
+ base := self defaultBase..
- base := 10.
(self nextMatchAll: 'NaN') ifTrue: [^Float nan].
neg := self peekSignIsMinus.
(self nextMatchAll: 'Infinity')
ifTrue: [^neg ifTrue: [Float negativeInfinity] ifFalse: [Float infinity]].
(noInt := sourceStream peekFor: $.)
ifTrue:
[integerPart := 0.
numberOfTrailingZeroInIntegerPart := 0]
ifFalse:
[integerPart := self nextUnsignedIntegerBase: base.
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero].
(noInt or: [sourceStream peekFor: $.])
ifTrue:
[fractionPart := self nextUnsignedIntegerBase: base ifFail: [nil].
fractionPart isNil
ifTrue:
[noInt
ifTrue:
["no interger part, no fraction part..."
self expected: 'a digit 0 to 9'.
^nil].
fractionPart := 0]
ifFalse:
[numberOfNonZeroFractionDigits := lastNonZero.
numberOfTrailingZeroInFractionPart := nDigits - lastNonZero].
self readExponent]
ifFalse:
[self readExponent ifFalse: [^neg ifTrue: [integerPart negated] ifFalse: [integerPart]].
fractionPart := 0].
fractionPart isZero
ifTrue:
[mantissa := integerPart // (base raisedTo: numberOfTrailingZeroInIntegerPart).
exponent := exponent + numberOfTrailingZeroInIntegerPart]
ifFalse:
[mantissa := integerPart * (base raisedTo: numberOfNonZeroFractionDigits)
+ (fractionPart // (base raisedTo: numberOfTrailingZeroInFractionPart)).
exponent := exponent - numberOfNonZeroFractionDigits].
value := self
makeFloatFromMantissa: mantissa
exponent: exponent
base: base.
^neg ifTrue: [value isZero ifTrue: [Float negativeZero] ifFalse: [value negated]] ifFalse: [value]!
Item was added:
+ ----- Method: Integer class>>readFrom:base:ifFail: (in category 'instance creation') -----
+ readFrom: aStringOrStream base: base ifFail: aBlock
+ "Answer an instance of one of the concrete subclasses if Integer.
+ Initial plus or minus sign accepted, and bases > 10 use letters A-Z.
+ Imbedded radix specifiers not allowed; use Number class readFrom: for that.
+ Execute aBlock if there are no digits."
+
+ ^(ExtendedNumberParser on: aStringOrStream) nextIntegerBase: base ifFail: aBlock!
Item was changed:
Object subclass: #NumberParser
+ instanceVariableNames: 'sourceStream base neg integerPart fractionPart exponent scale nDigits lastNonZero requestor failBlock defaultBase'
- instanceVariableNames: 'sourceStream base neg integerPart fractionPart exponent scale nDigits lastNonZero requestor failBlock'
classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Numbers'!
+ !NumberParser commentStamp: 'ct 10/27/2021 22:04' prior: 0!
- !NumberParser commentStamp: 'nice 3/15/2010 00:16' prior: 0!
NumberParser is an abstract class for parsing and building numbers from string/stream.
It offers a framework with utility methods and exception handling.
Number syntax is not defined and should be subclassResponsibility.
Instance variables:
sourceStream <Stream> the stream of characters from which the number is read
base <Integer> the radix in which to interpret digits
neg <Boolean> true in case of minus sign
integerPart <Integer> the integer part of the number
fractionPart <Integer> the fraction part of the number if any
exponent <Integer> the exponent used in scientific notation if any
scale <Integer> the scale used in case of ScaledDecimal number if any
nDigits <Integer> number of digits read to form an Integer
lasNonZero <Integer> position of last non zero digit, starting at 1 from left, 0 if all digits are zero
requestor <TextEditor | nil> can be used to insert an error message in the requestor
failBlock <BlockClosure> Block to execute whenever an error occurs.
The fail block can have 0, 1 or 2 arguments (errorString and source position)
+ defaultBase <Integer> the default radix in which to interpret digits, unless specified differently via radix notation!
- !
Item was added:
+ ----- Method: NumberParser>>defaultBase (in category 'accessing') -----
+ defaultBase
+
+ ^ defaultBase!
Item was added:
+ ----- Method: NumberParser>>defaultBase: (in category 'accessing') -----
+ defaultBase: anInteger
+
+ self assert: anInteger < 28 description: 'Default base must be lower than 28 to keep radix r distinguishable from digits. For higher bases, pass the base manually to #nextNumberBase: autc.'.
+ defaultBase := anInteger!
Item was added:
+ ----- Method: NumberParser>>defaultRadixBase (in category 'accessing') -----
+ defaultRadixBase
+
+ ^ 10!
Item was added:
+ ----- Method: NumberParser>>initialize (in category 'initialize-release') -----
+ initialize
+
+ defaultBase := 10!
Item was changed:
----- Method: NumberParser>>nextInteger (in category 'parsing-public') -----
nextInteger
"Read an Integer from sourceStream, asnwser that Integer.
This is a generic version dealing with an optional sign and a simple sequence of decimal digits.
Subclass might define extended syntax."
+ base := self defaultBase.
- base := 10.
^self nextIntegerBase: base ifFail: [^self expected: ('a digit between 0 and ' copyWith: (Character digitValue: base - 1))]!
Item was changed:
----- Method: NumberParser>>nextUnsignedInteger (in category 'parsing-public') -----
nextUnsignedInteger
"Read an Integer from sourceStream, asnwser that Integer.
This is a generic version dealing with a simple sequence of decimal digits.
Subclass might define extended syntax."
+
+ base := self defaultBase.
-
- base := 10.
^self nextUnsignedIntegerBase: base ifFail: [^self expected: ('a digit between 0 and ' copyWith: (Character digitValue: base - 1))]!
Item was changed:
----- Method: NumberParser>>on: (in category 'initialize-release') -----
on: aStringOrStream
sourceStream := aStringOrStream isString
ifTrue: [ aStringOrStream readStream ]
ifFalse: [ aStringOrStream ].
+ base := self defaultBase.
- base := 10.
neg := false.
integerPart := fractionPart := exponent := scale := 0.
requestor := failBlock := nil!
Item was changed:
----- Method: NumberParser>>readExponent (in category 'parsing-private') -----
readExponent
"read the exponent if any (stored in instVar).
Answer true if found, answer false if none.
If exponent letter is not followed by a digit,
this is not considered as an error.
Exponent are always read in base 10."
| eneg epos |
exponent := 0.
(self isExponentLetter: sourceStream peek) ifFalse: [^ false].
sourceStream next.
eneg := sourceStream peekFor: $-.
epos := eneg not and: [self allowPlusSignInExponent and: [sourceStream peekFor: $+]].
+ exponent := self nextUnsignedIntegerOrNilBase: self defaultBase.
- exponent := self nextUnsignedIntegerOrNilBase: 10.
exponent ifNil: ["Oops, there was no digit after the exponent letter.Ungobble the letter"
exponent := 0.
sourceStream
skip: ((eneg or: [epos])
ifTrue: [-2]
ifFalse: [-1]).
^ false].
eneg ifTrue: [exponent := exponent negated].
^true!
Item was removed:
- ----- Method: SqNumberParser class>>on: (in category 'instance creation') -----
- on: aStringOrStream
- ^self new on: aStringOrStream!
Item was removed:
- ----- Method: SqNumberParser class>>parse: (in category 'instance creation') -----
- parse: aStringOrStream
- ^(self new)
- on: aStringOrStream;
- nextNumber!
Item was removed:
- ----- Method: SqNumberParser class>>parse:onError: (in category 'instance creation') -----
- parse: aStringOrStream onError: failBlock
- ^(self new)
- on: aStringOrStream;
- failBlock: failBlock;
- nextNumber!
Item was changed:
----- Method: SqNumberParser>>nextFraction (in category 'parsing-public') -----
nextFraction
| numerator denominator numberOfTrailingZeroInIntegerPart |
+ base := self defaultBase.
- base := 10.
neg := self peekSignIsMinus.
(integerPart := self nextUnsignedIntegerOrNilBase: base)
ifNil: ["No integerPart, raise an error"
^ self expected: 'a digit'].
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero.
(sourceStream peekFor: $r)
ifTrue: ["<base>r<integer>"
(base := integerPart) < 2
ifTrue: [
sourceStream skip: -1.
^ self expected: 'an integer greater than 1 as valid radix'].
self peekSignIsMinus
ifTrue: [neg := neg not].
integerPart := self nextUnsignedIntegerBase: base.
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero].
(sourceStream peekFor: $.)
ifTrue:
[^self readFractionPartNumberOfTrailingZeroInIntegerPart: numberOfTrailingZeroInIntegerPart].
numerator := neg
ifTrue: [integerPart negated]
ifFalse: [integerPart].
self readExponent ifTrue: [numerator := numerator * (base raisedToInteger: exponent)].
(sourceStream peekFor: $/) ifFalse: [^numerator].
+ base := self defaultBase.
- base := 10.
(denominator := self nextUnsignedIntegerOrNilBase: base)
ifNil:
[sourceStream skip: -1. "Not a valid denominator, ungobble / and return numerator"
^numerator].
(sourceStream peekFor: $r)
ifTrue: ["<base>r<integer>"
(base := denominator) < 2
ifTrue: [
sourceStream skip: -1.
^ self expected: 'an integer greater than 1 as valid radix'].
denominator := self nextUnsignedIntegerBase: base].
self readExponent ifTrue: [denominator := denominator * (base raisedToInteger: exponent)].
^numerator / denominator!
Item was changed:
----- Method: SqNumberParser>>nextInteger (in category 'parsing-public') -----
nextInteger
"Read an Integer from sourceStream, asnwser that Integer.
In Smalltalk syntax, a radix can be specified, and an exponent too."
| numberOfTrailingZeroInIntegerPart |
+ base := self defaultBase.
- base := 10.
neg := self peekSignIsMinus.
integerPart := self nextUnsignedIntegerOrNilBase: base.
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero.
(sourceStream peekFor: $r)
ifTrue: ["<base>r<integer>"
(base := integerPart) < 2
ifTrue: [
sourceStream skip: -1.
^ self expected: 'an integer greater than 1 as valid radix'].
self peekSignIsMinus
ifTrue: [neg := neg not].
integerPart := self nextUnsignedIntegerBase: base.
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero].
^ self makeIntegerOrScaledInteger!
Item was changed:
----- Method: SqNumberParser>>nextNumber (in category 'parsing-public') -----
nextNumber
"main method for reading a number.
This one can read Float Integer and ScaledDecimal"
| numberOfTrailingZeroInIntegerPart |
+ base := self defaultBase.
- base := 10.
neg := self peekSignIsMinus.
integerPart := self nextUnsignedIntegerOrNilBase: base.
integerPart ifNil: [
"This is not a regular number beginning with a digit
It is time to check for exceptional condition NaN and Infinity"
^self readNamedFloatOrFail].
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero.
(sourceStream peekFor: $r)
ifTrue: ["<base>r<integer>"
(base := integerPart) < 2
ifTrue: [
sourceStream skip: -1.
^ self expected: 'an integer greater than 1 as valid radix'].
self peekSignIsMinus
ifTrue: [neg := neg not].
integerPart := self nextUnsignedIntegerBase: base.
numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero].
^ (sourceStream peekFor: $.)
ifTrue: [self readNumberWithFractionPartNumberOfTrailingZeroInIntegerPart: numberOfTrailingZeroInIntegerPart]
ifFalse: [self makeIntegerOrScaledInteger]!
Item was changed:
----- Method: SqNumberParser>>nextScaledDecimal (in category 'parsing-public') -----
nextScaledDecimal
"Main method for reading a (scaled) decimal number.
Good Gracious, do not accept a decimal in another base than 10!!
In other words, do not accept radix notation like 2r1.1, even not 10r5.3
Do not accept exponent notation neither, like 1.0e-3"
| numberOfNonZeroFractionDigits numberOfTrailingZeroInFractionPart |
+ base := self defaultBase.
- base := 10.
neg := sourceStream peekFor: $-.
integerPart := self nextUnsignedIntegerBase: base.
(sourceStream peekFor: $.)
ifTrue: [fractionPart := self nextUnsignedIntegerOrNilBase: base.
fractionPart ifNil: ["Oops, the decimal point seems not part of this number"
sourceStream skip: -1.
^ neg
ifTrue: [integerPart negated asScaledDecimal: 0]
ifFalse: [integerPart asScaledDecimal: 0]].
numberOfNonZeroFractionDigits := lastNonZero.
numberOfTrailingZeroInFractionPart := nDigits - lastNonZero.
(self readScaleWithDefaultNumberOfDigits: nDigits)
ifFalse: ["No scale were provided. use number of digits after decimal point as scale"
scale := nDigits].
^self makeScaledDecimalWithNumberOfNonZeroFractionDigits: numberOfNonZeroFractionDigits andNumberOfTrailingZeroInFractionPart: numberOfTrailingZeroInFractionPart].
self readScaleWithDefaultNumberOfDigits: 0.
neg ifTrue: [integerPart := integerPart negated].
^integerPart asScaledDecimal: scale!
Item was changed:
----- Method: SqNumberParser>>nextUnsignedInteger (in category 'parsing-public') -----
nextUnsignedInteger
"Read an unsigned Integer from sourceStream, asnwser that Integer.
In Smalltalk syntax, a radix can be specified, and an exponent too."
+ base := self defaultBase.
- base := 10.
neg := false.
integerPart := self nextUnsignedIntegerOrNilBase: base.
(sourceStream peekFor: $r)
ifTrue: ["<base>r<integer>"
(base := integerPart) < 2
ifTrue: [
sourceStream skip: -1.
^ self expected: 'an integer greater than 1 as valid radix'].
integerPart := self nextUnsignedIntegerBase: base].
^ self makeIntegerOrScaledInteger!
Item was changed:
----- Method: SqNumberParser>>readScaleWithDefaultNumberOfDigits: (in category 'parsing-private') -----
readScaleWithDefaultNumberOfDigits: anInteger
"Read the scale if any and store it into scale instance Variable.
Answer true if found, answer false if none.
The scale is specified by letter s, optionnally followed by a positive integer in base 10.
If no integer is specified, that means using as many digits as provided after the fraction separator, as provided by parameter anInteger.
A letter s followed by another letter is not considered as a scale specification, because it could be part of a message."
scale := 0.
sourceStream atEnd
ifTrue: [ ^ false ].
(sourceStream peekFor: $s)
ifFalse: [ ^ false ].
+ scale := self nextUnsignedIntegerOrNilBase: self defaultBase.
- scale := self nextUnsignedIntegerOrNilBase: 10.
scale
ifNil: [
scale := anInteger.
(sourceStream peek ifNil: [ false ] ifNotNil: [ :nextChar | nextChar isLetter ])
ifTrue: [
sourceStream skip: -1. "ungobble the s"
^ false ]
ifFalse: [ ^ true ] ].
^ true!
A new version of System was added to project The Inbox:
http://source.squeak.org/inbox/System-dtl.1254.mcz
==================== Summary ====================
Name: System-dtl.1254
Author: dtl
Time: 26 November 2021, 11:06:19.584405 am
UUID: 3856329c-1404-4bd5-9b94-d9c47f663d7c
Ancestors: System-mt.1253
Let vmParameterAt:ifAbsent: treat nil as an absent parameter. Previously only out of range parameter requests were treated as absent.
Handles the case of parameter 54 which is numeric for Spur VM, nil for Cog VM, and out of range for interpreter VM. Update bytesUsedString to use 0 as default for parameter 54.
=============== Diff against System-mt.1253 ===============
Item was changed:
----- Method: SmalltalkImage>>bytesUsedString (in category 'memory space') -----
bytesUsedString
"Answer a string describing the amount of memory in use."
"Smalltalk bytesUsedString"
| totalUsed |
totalUsed := (self vmParameterAt: 2 "used eden + used past space")
+ + ((self vmParameterAt: 1 "old space size")
+ - (self vmParameterAt: 54 ifAbsent: 0 "free old space")).
- + ((self vmParameterAt: 1 "old space size") - (self vmParameterAt: 54 "free old space")).
^totalUsed asStringWithCommas, ' bytes in use'!
Item was changed:
----- Method: SmalltalkImage>>vmParameterAt:ifAbsent: (in category 'vm parameters') -----
vmParameterAt: parameterIndex ifAbsent: defaultValueOrBlock
+ "Answer a VM parameter or defaultValueOrBlock value if out of range
+ or if the VM does not provide a value for this parameter. A VM parameter
+ is typically numeric or boolean, and if not implemented will be nil."
+ ^ [(self vmParameterAt: parameterIndex)
+ ifNil: defaultValueOrBlock value]
- "Answer a VM parameter or defaultValueOrBlock value if out of range."
- ^ [self vmParameterAt: parameterIndex]
on: Error
do: [defaultValueOrBlock value]!
David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.1261.mcz
==================== Summary ====================
Name: System-dtl.1261
Author: dtl
Time: 1 December 2021, 6:27:02.182458 pm
UUID: 9cead45b-ffbd-4606-ab13-fe1180a9c763
Ancestors: System-mt.1260
Let vmParameterAt:ifAbsent: treat nil as an absent parameter. Previously only out of range parameter requests were treated as absent.
Handles the case of parameter 54 which is numeric for Spur VM, nil for Cog VM, and out of range for interpreter VM. Update bytesUsedString to use 0 as default for parameter 54.
(Originally submitted as System-dtl.1254, moved to treated inbox)
=============== Diff against System-mt.1260 ===============
Item was changed:
----- Method: SmalltalkImage>>bytesUsedString (in category 'memory space') -----
bytesUsedString
"Answer a string describing the amount of memory in use."
"Smalltalk bytesUsedString"
| totalUsed |
totalUsed := (self vmParameterAt: 2 "used eden + used past space")
+ + ((self vmParameterAt: 1 "old space size")
+ - (self vmParameterAt: 54 ifAbsent: 0 "free old space")).
- + ((self vmParameterAt: 1 "old space size") - (self vmParameterAt: 54 "free old space")).
^totalUsed asStringWithCommas, ' bytes in use'!
Item was changed:
----- Method: SmalltalkImage>>vmParameterAt:ifAbsent: (in category 'vm parameters') -----
vmParameterAt: parameterIndex ifAbsent: defaultValueOrBlock
+ "Answer a VM parameter or defaultValueOrBlock value if out of range
+ or if the VM does not provide a value for this parameter. A VM parameter
+ is typically numeric or boolean, and if not implemented will be nil."
+ ^ [(self vmParameterAt: parameterIndex)
+ ifNil: defaultValueOrBlock value]
- "Answer a VM parameter or defaultValueOrBlock value if out of range."
- ^ [self vmParameterAt: parameterIndex]
on: Error
do: [defaultValueOrBlock value]!
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-ct.1681.mcz
==================== Summary ====================
Name: Morphic-ct.1681
Author: ct
Time: 8 September 2020, 1:48:12.211798 pm
UUID: 9e91205a-93e1-c143-ae8f-4aa3428bf197
Ancestors: Morphic-mt.1679
Fixes use of custom attributes in DialogWindows
Things like the following did NOT work properly before this patch:
self inform: 'normal ' asText
, ('red ' asText addAttribute: TextColor red; yourself)
, ('font ' asText addAttribute: (TextFontReference toFont: ((TextStyle named: 'BitstreamVeraSansMono') fontOfSize: 20)); yourself)
, ('url ' asText addAttribute: TextURL new; yourself)
This was because DialogWindow added its own styling attributes on top of all existing attributes. For color, this is not necessary because #textColor: is sufficient. For font size, in theory, TextFontChange should be sufficient, but currently it does not support relative changes to the font size.
=============== Diff against Morphic-mt.1679 ===============
Item was changed:
----- Method: DialogWindow>>setMessageParameters (in category 'initialization') -----
setMessageParameters
+
+ messageMorph ifNil: [^ self].
+ messageMorph
+ hResizing: #shrinkWrap;
+ vResizing: #shrinkWrap.
+
+ self userInterfaceTheme textColor ifNotNil: [:color |
+ messageMorph textColor: color].
+ self userInterfaceTheme font ifNotNil: [:font |
+ self flag: #todo. "ct: Develop a relative text font change attribute. At the moment, all prior font sizes will be overwritten."
+ messageMorph contents addAttribute: (
+ TextFontChange fontNumber: (font textStyle fontIndexOf: font))].!
- messageMorph ifNotNil: [
- | fontToUse colorToUse |
- fontToUse := self userInterfaceTheme font ifNil: [TextStyle defaultFont].
- colorToUse := self userInterfaceTheme textColor ifNil: [Color black].
-
- messageMorph
- hResizing: #shrinkWrap;
- vResizing: #shrinkWrap.
-
- messageMorph contents
- addAttribute: (TextFontReference toFont: fontToUse);
- addAttribute: (TextColor color: colorToUse).
- messageMorph textColor: colorToUse].!
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1806.mcz
==================== Summary ====================
Name: Morphic-mt.1806
Author: mt
Time: 1 December 2021, 6:21:24.587194 pm
UUID: e086ee00-0503-c441-ab61-f2a5128330d7
Ancestors: Morphic-mt.1805, Morphic-ct.1681
Merges/treats Morphic-ct.1681, but emphasize the need to use text attributes properly. We must style the text contents via text attributes, both color and font. We must not rely on TextMorph internals such as how #textColor: is used by default. For example, TextMorph >> #font: behaves very differently in this regard.
***
Morphic-ct.1681:
Fixes use of custom attributes in DialogWindows
Things like the following did NOT work properly before this patch:
self inform: 'normal ' asText
, ('red ' asText addAttribute: TextColor red; yourself)
, ('font ' asText addAttribute: (TextFontReference toFont: ((TextStyle named: 'BitstreamVeraSansMono') fontOfSize: 20)); yourself)
, ('url ' asText addAttribute: TextURL new; yourself)
This was because DialogWindow added its own styling attributes on top of all existing attributes. For color, this is not necessary because #textColor: is sufficient. For font size, in theory, TextFontChange should be sufficient, but currently it does not support relative changes to the font size.
=============== Diff against Morphic-mt.1805 ===============
Item was changed:
----- Method: DialogWindow>>setMessageParameters (in category 'initialization') -----
setMessageParameters
+
+ | fontToUse colorToUse fontAttr offset |
+ messageMorph ifNil: [^ self].
+
+ fontToUse := self userInterfaceTheme font ifNil: [TextStyle defaultFont].
+ colorToUse := self userInterfaceTheme textColor ifNil: [Color black].
+ messageMorph
+ hResizing: #shrinkWrap;
+ vResizing: #shrinkWrap;
+ textColor: colorToUse.
+
+ "Only set text attributes for ranges that have none."
+ self flag: #todo. "mt: Add interface to Text?"
+ self flag: #todo. "mt: Do the same for TextColor. We must not know that #textColor: above does all the magic already."
+ fontAttr := TextFontReference toFont: fontToUse.
+ offset := nil.
+ messageMorph contents runs withIndexDo: [:attrs :index |
+ (attrs anySatisfy: [:each | each isKindOf: TextFontChange])
+ ifFalse: [offset ifNil: [offset := index]]
+ ifTrue: [offset ifNotNil: [
+ messageMorph contents
+ addAttribute: fontAttr
+ from: offset to: index - 1.
+ offset := nil]]].
+ offset ifNotNil: [
- messageMorph ifNotNil: [
- | fontToUse colorToUse |
- fontToUse := self userInterfaceTheme font ifNil: [TextStyle defaultFont].
- colorToUse := self userInterfaceTheme textColor ifNil: [Color black].
-
- messageMorph
- hResizing: #shrinkWrap;
- vResizing: #shrinkWrap.
-
messageMorph contents
+ addAttribute: fontAttr
+ from: offset to: messageMorph contents size].
+ !
- addAttribute: (TextFontReference toFont: fontToUse);
- addAttribute: (TextColor color: colorToUse).
- messageMorph textColor: colorToUse].!