[squeak-dev] The Inbox: Compiler-mt.480.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Jul 20 07:49:54 UTC 2022
A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-mt.480.mcz
==================== Summary ====================
Name: Compiler-mt.480
Author: mt
Time: 20 July 2022, 9:49:52.740589 am
UUID: 45def11a-0bef-8440-96b8-3a64f8f746b1
Ancestors: Compiler-eem.479
Alternative to Compiler-cmm.480. Let pretty-print insert line breaks in comments at 75 characters boundary.
=============== Diff against Compiler-eem.479 ===============
Item was changed:
----- Method: ParseNode>>printSingleComment:on:indent: (in category 'private') -----
printSingleComment: aString on: aStream indent: indent
"Print the comment string, assuming it has been indented indent tabs.
Break the string at word breaks, given the widths in the default
+ font, at 75 characters per line on average. For a mono-spaced default font, this
+ upper bound is exact. See TextStyle >> #defaultFont."
- font, at 450 points."
+ (aString asText withNoLineLongerThan: 75) asString
+ linesDo: [:line | aStream nextPutAll: line; crtab: indent].
+ aStream skip: -1 + indent negated. "Remove trailing line break."!
- | readStream word position lineBreak font wordWidth tabWidth spaceWidth lastChar |
- readStream := ReadStream on: aString.
- font := TextStyle default defaultFont.
- tabWidth := TextStyle default tabWidth.
- spaceWidth := font widthOf: Character space.
- position := indent * tabWidth.
- lineBreak := 450.
- [readStream atEnd]
- whileFalse:
- [word := self nextWordFrom: readStream setCharacter: [:lc | lastChar := lc].
- wordWidth := word inject: 0 into: [:width :char | width + (font widthOf: char)].
- position := position + wordWidth.
- position > lineBreak
- ifTrue:
- [aStream skip: -1; crtab: indent.
- position := indent * tabWidth + wordWidth + spaceWidth.
- lastChar = Character cr
- ifTrue: [[readStream peekFor: Character tab] whileTrue].
- word isEmpty ifFalse: [aStream nextPutAll: word; space]]
- ifFalse:
- [aStream nextPutAll: word.
- readStream atEnd
- ifFalse:
- [position := position + spaceWidth.
- aStream space].
- lastChar = Character cr
- ifTrue:
- [aStream skip: -1; crtab: indent.
- position := indent * tabWidth.
- [readStream peekFor: Character tab] whileTrue]]]!
More information about the Squeak-dev
mailing list
|