[squeak-dev] The Trunk: Graphics-nice.182.mcz
commits at source.squeak.org
commits at source.squeak.org
Sun May 8 20:54:22 UTC 2011
Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.182.mcz
==================== Summary ====================
Name: Graphics-nice.182
Author: nice
Time: 8 May 2011, 10:53:36.106 pm
UUID: 31e01b92-a09e-45a9-88b4-a2be8a8aa6fb
Ancestors: Graphics-nice.181
Simplify the emphasis code using #bitAt:
=============== Diff against Graphics-nice.181 ===============
Item was changed:
----- Method: AbstractFont class>>emphasisStringFor: (in category 'utilities') -----
emphasisStringFor: emphasisCode
"Answer a translated string that represents the attributes given in emphasisCode."
+ | emphases |
- | emphases bit |
emphasisCode = 0 ifTrue: [ ^'Normal' translated ].
+ emphases := #('Bold' 'Italic' 'Underlined' 'Narrow' 'StruckOut').
- emphases := (IdentityDictionary new)
- at: 1 put: 'Bold' translated;
- at: 2 put: 'Italic' translated;
- at: 4 put: 'Underlined' translated;
- at: 8 put: 'Narrow' translated;
- at: 16 put: 'StruckOut' translated;
- yourself.
- bit := 1.
^String streamContents: [ :s |
+ 1 to: emphases size do: [ :i |
+ (emphasisCode bitAt: i) isZero ifFalse: [ s nextPutAll: (emphases at: i) translated; space ] ].
+ s position isZero ifFalse: [ s skip: -1 ] ]!
- [ bit < 32 ] whileTrue: [ | code |
- code := emphasisCode bitAnd: bit.
- code isZero ifFalse: [ s nextPutAll: (emphases at: code); space ].
- bit := bit bitShift: 1 ].
- s position isZero ifFalse: [ s skip: -1 ].
- ]!
More information about the Squeak-dev
mailing list
|