Levente Uzonyi uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-ul.159.mcz
==================== Summary ====================
Name: Graphics-ul.159
Author: ul
Time: 23 November 2010, 1:41:39.684 pm
UUID: c544e4b7-24ef-f047-88e3-1c22e5e021a0
Ancestors: Graphics-tbn.157, Graphics-mt.158
- a forgotten merge
=============== Diff against Graphics-tbn.157 ===============
Item was changed:
----- Method: BitBlt>>installStrikeFont:foregroundColor:backgroundColor: (in category 'private') -----
installStrikeFont: aStrikeFont foregroundColor: foregroundColor backgroundColor: backgroundColor
| lastSourceDepth targetColor |
sourceForm ifNotNil:[lastSourceDepth := sourceForm depth].
sourceForm := aStrikeFont glyphs.
"Ignore any halftone pattern since we use a color map approach here"
halftoneForm := nil.
sourceY := 0.
height := aStrikeFont height.
sourceForm depth = 1 ifTrue: [
self combinationRule: Form paint.
(colorMap notNil and:[lastSourceDepth = sourceForm depth]) ifFalse: [
"Set up color map for a different source depth (color font)"
"Uses caching for reasonable efficiency"
colorMap := self cachedFontColormapFrom: sourceForm depth to: destForm depth.
colorMap at: 1 put: (destForm pixelValueFor: backgroundColor)].
colorMap at: 2 put: (destForm pixelValueFor: foregroundColor).
]
ifFalse: [
+ (Preferences subPixelRenderFonts and: [ foregroundColor = Color black
+ "Only use rgbMul with opaque colors as alpha values get lost for translucent colors."
+ or: [ Preferences subPixelRenderColorFonts and: [foregroundColor isOpaque] ]]) ifTrue: [
- (Preferences subPixelRenderFonts and: [ foregroundColor = Color black or: [ Preferences subPixelRenderColorFonts ]]) ifTrue: [
destForm depth > 8 ifTrue: [
+ "rgbMul is equivalent to component alpha blend if text is black (only faster, hehe)"
+ self combinationRule: Form rgbMul.
- "Only force #rgbMul if color is not translucent for better result quality. Alpha values are ignored with #rgbMul."
- foregroundColor isTranslucent
- ifFalse: [self combinationRule: Form rgbMul].
colorMap := (destForm depth = 32 or: [ (foregroundColor = Color black) not ]) ifTrue: [
"rgbMul / rgbAdd IS component alpha blend for any color of text (neat trick, eh!!)"
"This colorMap is to be used on the second pass with rule 20 (rgbAdd)
See #displayString:from:to:at:strikeFont:kern:"
"Note: In 32bpp we always need the second pass, as the source could have transparent pixels, and we need to add to the alpha channel"
self colorConvertingMap: foregroundColor from: sourceForm depth to: destForm depth keepSubPixelAA: true]]
ifFalse: [
+ self combinationRule: Form paint.
- self combinationRule: 25. "Paint"
targetColor := foregroundColor = Color black ifFalse: [ foregroundColor ].
colorMap := self colorConvertingMap: targetColor from: sourceForm depth to: destForm depth keepSubPixelAA: true]
]
ifFalse: [
"Do not use rule 34 for 16bpp display. TTCFont uses it, but it builds a glyphs cache for each color used!!"
+ self combinationRule: (destForm depth = 32 ifTrue: [Form blendAlphaScaled] ifFalse: [Form paint]).
- self combinationRule: (destForm depth = 32 ifTrue: [34 "alphaBlendScaled"] ifFalse: [25 "Paint"]).
colorMap := self colorConvertingMap: foregroundColor from: sourceForm depth to: destForm depth keepSubPixelAA: false
]
].!
Item was added:
+ ----- Method: Form class>>blendAlphaScaled (in category 'mode constants') -----
+ blendAlphaScaled
+ "Answer the integer denoting BitBlt's blend-with-alpha-scaled rule."
+
+ ^ 34!
Levente Uzonyi uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-ul.159.mcz
==================== Summary ====================
Name: Graphics-ul.159
Author: ul
Time: 23 November 2010, 1:41:39.684 pm
UUID: c544e4b7-24ef-f047-88e3-1c22e5e021a0
Ancestors: Graphics-tbn.157, Graphics-mt.158
- a forgotten merge
=============== Diff against Graphics-tbn.157 ===============
Item was changed:
----- Method: BitBlt>>installStrikeFont:foregroundColor:backgroundColor: (in category 'private') -----
installStrikeFont: aStrikeFont foregroundColor: foregroundColor backgroundColor: backgroundColor
| lastSourceDepth targetColor |
sourceForm ifNotNil:[lastSourceDepth := sourceForm depth].
sourceForm := aStrikeFont glyphs.
"Ignore any halftone pattern since we use a color map approach here"
halftoneForm := nil.
sourceY := 0.
height := aStrikeFont height.
sourceForm depth = 1 ifTrue: [
self combinationRule: Form paint.
(colorMap notNil and:[lastSourceDepth = sourceForm depth]) ifFalse: [
"Set up color map for a different source depth (color font)"
"Uses caching for reasonable efficiency"
colorMap := self cachedFontColormapFrom: sourceForm depth to: destForm depth.
colorMap at: 1 put: (destForm pixelValueFor: backgroundColor)].
colorMap at: 2 put: (destForm pixelValueFor: foregroundColor).
]
ifFalse: [
+ (Preferences subPixelRenderFonts and: [ foregroundColor = Color black
+ "Only use rgbMul with opaque colors as alpha values get lost for translucent colors."
+ or: [ Preferences subPixelRenderColorFonts and: [foregroundColor isOpaque] ]]) ifTrue: [
- (Preferences subPixelRenderFonts and: [ foregroundColor = Color black or: [ Preferences subPixelRenderColorFonts ]]) ifTrue: [
destForm depth > 8 ifTrue: [
+ "rgbMul is equivalent to component alpha blend if text is black (only faster, hehe)"
+ self combinationRule: Form rgbMul.
- "Only force #rgbMul if color is not translucent for better result quality. Alpha values are ignored with #rgbMul."
- foregroundColor isTranslucent
- ifFalse: [self combinationRule: Form rgbMul].
colorMap := (destForm depth = 32 or: [ (foregroundColor = Color black) not ]) ifTrue: [
"rgbMul / rgbAdd IS component alpha blend for any color of text (neat trick, eh!!)"
"This colorMap is to be used on the second pass with rule 20 (rgbAdd)
See #displayString:from:to:at:strikeFont:kern:"
"Note: In 32bpp we always need the second pass, as the source could have transparent pixels, and we need to add to the alpha channel"
self colorConvertingMap: foregroundColor from: sourceForm depth to: destForm depth keepSubPixelAA: true]]
ifFalse: [
+ self combinationRule: Form paint.
- self combinationRule: 25. "Paint"
targetColor := foregroundColor = Color black ifFalse: [ foregroundColor ].
colorMap := self colorConvertingMap: targetColor from: sourceForm depth to: destForm depth keepSubPixelAA: true]
]
ifFalse: [
"Do not use rule 34 for 16bpp display. TTCFont uses it, but it builds a glyphs cache for each color used!!"
+ self combinationRule: (destForm depth = 32 ifTrue: [Form blendAlphaScaled] ifFalse: [Form paint]).
- self combinationRule: (destForm depth = 32 ifTrue: [34 "alphaBlendScaled"] ifFalse: [25 "Paint"]).
colorMap := self colorConvertingMap: foregroundColor from: sourceForm depth to: destForm depth keepSubPixelAA: false
]
].!
Item was added:
+ ----- Method: Form class>>blendAlphaScaled (in category 'mode constants') -----
+ blendAlphaScaled
+ "Answer the integer denoting BitBlt's blend-with-alpha-scaled rule."
+
+ ^ 34!
Levente Uzonyi uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-ul.159.mcz
==================== Summary ====================
Name: Graphics-ul.159
Author: ul
Time: 23 November 2010, 1:41:39.684 pm
UUID: c544e4b7-24ef-f047-88e3-1c22e5e021a0
Ancestors: Graphics-tbn.157, Graphics-mt.158
- a forgotten merge
=============== Diff against Graphics-tbn.157 ===============
Item was changed:
----- Method: BitBlt>>installStrikeFont:foregroundColor:backgroundColor: (in category 'private') -----
installStrikeFont: aStrikeFont foregroundColor: foregroundColor backgroundColor: backgroundColor
| lastSourceDepth targetColor |
sourceForm ifNotNil:[lastSourceDepth := sourceForm depth].
sourceForm := aStrikeFont glyphs.
"Ignore any halftone pattern since we use a color map approach here"
halftoneForm := nil.
sourceY := 0.
height := aStrikeFont height.
sourceForm depth = 1 ifTrue: [
self combinationRule: Form paint.
(colorMap notNil and:[lastSourceDepth = sourceForm depth]) ifFalse: [
"Set up color map for a different source depth (color font)"
"Uses caching for reasonable efficiency"
colorMap := self cachedFontColormapFrom: sourceForm depth to: destForm depth.
colorMap at: 1 put: (destForm pixelValueFor: backgroundColor)].
colorMap at: 2 put: (destForm pixelValueFor: foregroundColor).
]
ifFalse: [
+ (Preferences subPixelRenderFonts and: [ foregroundColor = Color black
+ "Only use rgbMul with opaque colors as alpha values get lost for translucent colors."
+ or: [ Preferences subPixelRenderColorFonts and: [foregroundColor isOpaque] ]]) ifTrue: [
- (Preferences subPixelRenderFonts and: [ foregroundColor = Color black or: [ Preferences subPixelRenderColorFonts ]]) ifTrue: [
destForm depth > 8 ifTrue: [
+ "rgbMul is equivalent to component alpha blend if text is black (only faster, hehe)"
+ self combinationRule: Form rgbMul.
- "Only force #rgbMul if color is not translucent for better result quality. Alpha values are ignored with #rgbMul."
- foregroundColor isTranslucent
- ifFalse: [self combinationRule: Form rgbMul].
colorMap := (destForm depth = 32 or: [ (foregroundColor = Color black) not ]) ifTrue: [
"rgbMul / rgbAdd IS component alpha blend for any color of text (neat trick, eh!!)"
"This colorMap is to be used on the second pass with rule 20 (rgbAdd)
See #displayString:from:to:at:strikeFont:kern:"
"Note: In 32bpp we always need the second pass, as the source could have transparent pixels, and we need to add to the alpha channel"
self colorConvertingMap: foregroundColor from: sourceForm depth to: destForm depth keepSubPixelAA: true]]
ifFalse: [
+ self combinationRule: Form paint.
- self combinationRule: 25. "Paint"
targetColor := foregroundColor = Color black ifFalse: [ foregroundColor ].
colorMap := self colorConvertingMap: targetColor from: sourceForm depth to: destForm depth keepSubPixelAA: true]
]
ifFalse: [
"Do not use rule 34 for 16bpp display. TTCFont uses it, but it builds a glyphs cache for each color used!!"
+ self combinationRule: (destForm depth = 32 ifTrue: [Form blendAlphaScaled] ifFalse: [Form paint]).
- self combinationRule: (destForm depth = 32 ifTrue: [34 "alphaBlendScaled"] ifFalse: [25 "Paint"]).
colorMap := self colorConvertingMap: foregroundColor from: sourceForm depth to: destForm depth keepSubPixelAA: false
]
].!
Item was added:
+ ----- Method: Form class>>blendAlphaScaled (in category 'mode constants') -----
+ blendAlphaScaled
+ "Answer the integer denoting BitBlt's blend-with-alpha-scaled rule."
+
+ ^ 34!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-ul.280.mcz
==================== Summary ====================
Name: Tools-ul.280
Author: ul
Time: 23 November 2010, 11:12:15.617 am
UUID: e7340a84-6734-b44b-8a68-457846da8f87
Ancestors: Tools-ul.279
- fix: FileList2 open should work now
- fix: the service used for project loading from FileList is also used by the drop handler, this should be probably changed in the future.
=============== Diff against Tools-ul.279 ===============
Item was changed:
----- Method: FileList2>>initialize (in category 'initialize-release') -----
initialize
+ super initialize.
showDirsInFileList := false.
fileSelectionBlock := [ :entry :myPattern |
entry isDirectory ifTrue: [
showDirsInFileList
] ifFalse: [
myPattern = '*' or: [myPattern match: entry name]
]
].
dirSelectionBlock := [ :dirName | true].!
Item was added:
+ ----- Method: StandardFileStream>>dirAndFileName (in category '*Tools-FileList') -----
+ dirAndFileName
+ "A temporary solution for supporting project loading via drag and drop."
+
+ ^{ self directory. self localName }!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-ul.280.mcz
==================== Summary ====================
Name: Tools-ul.280
Author: ul
Time: 23 November 2010, 11:12:15.617 am
UUID: e7340a84-6734-b44b-8a68-457846da8f87
Ancestors: Tools-ul.279
- fix: FileList2 open should work now
- fix: the service used for project loading from FileList is also used by the drop handler, this should be probably changed in the future.
=============== Diff against Tools-ul.279 ===============
Item was changed:
----- Method: FileList2>>initialize (in category 'initialize-release') -----
initialize
+ super initialize.
showDirsInFileList := false.
fileSelectionBlock := [ :entry :myPattern |
entry isDirectory ifTrue: [
showDirsInFileList
] ifFalse: [
myPattern = '*' or: [myPattern match: entry name]
]
].
dirSelectionBlock := [ :dirName | true].!
Item was added:
+ ----- Method: StandardFileStream>>dirAndFileName (in category '*Tools-FileList') -----
+ dirAndFileName
+ "A temporary solution for supporting project loading via drag and drop."
+
+ ^{ self directory. self localName }!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-ul.280.mcz
==================== Summary ====================
Name: Tools-ul.280
Author: ul
Time: 23 November 2010, 11:12:15.617 am
UUID: e7340a84-6734-b44b-8a68-457846da8f87
Ancestors: Tools-ul.279
- fix: FileList2 open should work now
- fix: the service used for project loading from FileList is also used by the drop handler, this should be probably changed in the future.
=============== Diff against Tools-ul.279 ===============
Item was changed:
----- Method: FileList2>>initialize (in category 'initialize-release') -----
initialize
+ super initialize.
showDirsInFileList := false.
fileSelectionBlock := [ :entry :myPattern |
entry isDirectory ifTrue: [
showDirsInFileList
] ifFalse: [
myPattern = '*' or: [myPattern match: entry name]
]
].
dirSelectionBlock := [ :dirName | true].!
Item was added:
+ ----- Method: StandardFileStream>>dirAndFileName (in category '*Tools-FileList') -----
+ dirAndFileName
+ "A temporary solution for supporting project loading via drag and drop."
+
+ ^{ self directory. self localName }!
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.410.mcz
==================== Summary ====================
Name: Collections-ul.410
Author: ul
Time: 23 November 2010, 8:24:12.434 am
UUID: a68748b5-3380-9645-8686-fc80a9710dc6
Ancestors: Collections-ul.409
- added a translation table to String for exchanging cr and lf characters
- simplified and enhanced String's #withSqueakLineEndings and #withUnixLineEndings
=============== Diff against Collections-ul.409 ===============
Item was changed:
ArrayedCollection subclass: #String
instanceVariableNames: ''
+ classVariableNames: 'AsciiOrder CSLineEnders CSNonSeparators CSSeparators CaseInsensitiveOrder CaseSensitiveOrder CrLfExchangeTable HtmlEntities LowercasingTable Tokenish UppercasingTable'
- classVariableNames: 'AsciiOrder CSLineEnders CSNonSeparators CSSeparators CaseInsensitiveOrder CaseSensitiveOrder HtmlEntities LowercasingTable Tokenish UppercasingTable'
poolDictionaries: ''
category: 'Collections-Strings'!
!String commentStamp: '<historical>' prior: 0!
A String is an indexed collection of Characters. Class String provides the abstract super class for ByteString (that represents an array of 8-bit Characters) and WideString (that represents an array of 32-bit characters). In the similar manner of LargeInteger and SmallInteger, those subclasses are chosen accordingly for a string; namely as long as the system can figure out so, the String is used to represent the given string.
Strings support a vast array of useful methods, which can best be learned by browsing and trying out examples as you find them in the code.
Here are a few useful methods to look at...
String match:
String contractTo:
String also inherits many useful methods from its hierarchy, such as
SequenceableCollection ,
SequenceableCollection copyReplaceAll:with:
!
Item was added:
+ ----- Method: String class>>crLfExchangeTable (in category 'accessing') -----
+ crLfExchangeTable
+
+ ^CrLfExchangeTable!
Item was changed:
----- Method: String class>>initialize (in category 'initialization') -----
initialize "self initialize"
| order |
AsciiOrder := (0 to: 255) as: ByteArray.
CaseInsensitiveOrder := AsciiOrder copy.
($a to: $z) do:
[:c | CaseInsensitiveOrder at: c asciiValue + 1
put: (CaseInsensitiveOrder at: c asUppercase asciiValue +1)].
"Case-sensitive compare sorts space, digits, letters, all the rest..."
CaseSensitiveOrder := ByteArray new: 256 withAll: 255.
order := -1.
' 0123456789' do: "0..10"
[:c | CaseSensitiveOrder at: c asciiValue + 1 put: (order := order+1)].
($a to: $z) do: "11-64"
[:c | CaseSensitiveOrder at: c asUppercase asciiValue + 1 put: (order := order+1).
CaseSensitiveOrder at: c asciiValue + 1 put: (order := order+1)].
1 to: CaseSensitiveOrder size do:
[:i | (CaseSensitiveOrder at: i) = 255 ifTrue:
[CaseSensitiveOrder at: i put: (order := order+1)]].
order = 255 ifFalse: [self error: 'order problem'].
"a table for translating to lower case"
LowercasingTable := String withAll: (Character allByteCharacters collect: [:c | c asLowercase]).
"a table for translating to upper case"
UppercasingTable := String withAll: (Character allByteCharacters collect: [:c | c asUppercase]).
"a table for testing tokenish (for fast numArgs)"
Tokenish := String withAll: (Character allByteCharacters collect:
[:c | c tokenish ifTrue: [c] ifFalse: [$~]]).
"CR and LF--characters that terminate a line"
CSLineEnders := CharacterSet crlf.
"separators and non-separators"
CSSeparators := CharacterSet separators.
+ CSNonSeparators := CSSeparators complement.
+
+ "a table for exchanging cr with lf and vica versa"
+ CrLfExchangeTable := Character allByteCharacters collect: [ :each |
+ each
+ caseOf: {
+ [ Character cr ] -> [ Character lf ].
+ [ Character lf ] -> [ Character cr ] }
+ otherwise: [ each ] ]!
- CSNonSeparators := CSSeparators complement.!
Item was changed:
----- Method: String>>withSqueakLineEndings (in category 'internet') -----
withSqueakLineEndings
"Assume the string is textual, and that CR, LF, and CRLF are all valid line endings.
Replace each occurence with a single CR."
- | cr lf indexLF indexCR |
- lf := Character linefeed.
- indexLF := self indexOf: lf startingAt: 1.
- indexLF = 0 ifTrue: [^self].
-
- cr := Character cr.
- indexCR := self indexOf: cr startingAt: 1.
- indexCR = 0 ifTrue: [^self copy replaceAll: lf with: cr].
+ (self includes: Character lf) ifFalse: [ ^self ].
+ (self includes: Character cr) ifFalse: [
+ ^self translateWith: String crLfExchangeTable ].
^self withLineEndings: String cr!
Item was changed:
----- Method: String>>withUnixLineEndings (in category 'internet') -----
withUnixLineEndings
"Assume the string is textual, and that CR, LF, and CRLF are all valid line endings.
Replace each occurence with a single LF."
- | cr lf indexLF indexCR |
- cr := Character cr.
- indexCR := self indexOf: cr startingAt: 1.
- indexCR = 0 ifTrue: [^self].
-
- lf := Character linefeed.
- indexLF := self indexOf: lf startingAt: 1.
- indexLF = 0 ifTrue: [^self copy replaceAll: cr with: lf].
+ (self includes: Character cr) ifFalse: [ ^self ].
+ (self includes: Character lf) ifFalse: [
+ ^self translateWith: String crLfExchangeTable ].
^self withLineEndings: String lf!
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.410.mcz
==================== Summary ====================
Name: Collections-ul.410
Author: ul
Time: 23 November 2010, 8:24:12.434 am
UUID: a68748b5-3380-9645-8686-fc80a9710dc6
Ancestors: Collections-ul.409
- added a translation table to String for exchanging cr and lf characters
- simplified and enhanced String's #withSqueakLineEndings and #withUnixLineEndings
=============== Diff against Collections-ul.409 ===============
Item was changed:
ArrayedCollection subclass: #String
instanceVariableNames: ''
+ classVariableNames: 'AsciiOrder CSLineEnders CSNonSeparators CSSeparators CaseInsensitiveOrder CaseSensitiveOrder CrLfExchangeTable HtmlEntities LowercasingTable Tokenish UppercasingTable'
- classVariableNames: 'AsciiOrder CSLineEnders CSNonSeparators CSSeparators CaseInsensitiveOrder CaseSensitiveOrder HtmlEntities LowercasingTable Tokenish UppercasingTable'
poolDictionaries: ''
category: 'Collections-Strings'!
!String commentStamp: '<historical>' prior: 0!
A String is an indexed collection of Characters. Class String provides the abstract super class for ByteString (that represents an array of 8-bit Characters) and WideString (that represents an array of 32-bit characters). In the similar manner of LargeInteger and SmallInteger, those subclasses are chosen accordingly for a string; namely as long as the system can figure out so, the String is used to represent the given string.
Strings support a vast array of useful methods, which can best be learned by browsing and trying out examples as you find them in the code.
Here are a few useful methods to look at...
String match:
String contractTo:
String also inherits many useful methods from its hierarchy, such as
SequenceableCollection ,
SequenceableCollection copyReplaceAll:with:
!
Item was added:
+ ----- Method: String class>>crLfExchangeTable (in category 'accessing') -----
+ crLfExchangeTable
+
+ ^CrLfExchangeTable!
Item was changed:
----- Method: String class>>initialize (in category 'initialization') -----
initialize "self initialize"
| order |
AsciiOrder := (0 to: 255) as: ByteArray.
CaseInsensitiveOrder := AsciiOrder copy.
($a to: $z) do:
[:c | CaseInsensitiveOrder at: c asciiValue + 1
put: (CaseInsensitiveOrder at: c asUppercase asciiValue +1)].
"Case-sensitive compare sorts space, digits, letters, all the rest..."
CaseSensitiveOrder := ByteArray new: 256 withAll: 255.
order := -1.
' 0123456789' do: "0..10"
[:c | CaseSensitiveOrder at: c asciiValue + 1 put: (order := order+1)].
($a to: $z) do: "11-64"
[:c | CaseSensitiveOrder at: c asUppercase asciiValue + 1 put: (order := order+1).
CaseSensitiveOrder at: c asciiValue + 1 put: (order := order+1)].
1 to: CaseSensitiveOrder size do:
[:i | (CaseSensitiveOrder at: i) = 255 ifTrue:
[CaseSensitiveOrder at: i put: (order := order+1)]].
order = 255 ifFalse: [self error: 'order problem'].
"a table for translating to lower case"
LowercasingTable := String withAll: (Character allByteCharacters collect: [:c | c asLowercase]).
"a table for translating to upper case"
UppercasingTable := String withAll: (Character allByteCharacters collect: [:c | c asUppercase]).
"a table for testing tokenish (for fast numArgs)"
Tokenish := String withAll: (Character allByteCharacters collect:
[:c | c tokenish ifTrue: [c] ifFalse: [$~]]).
"CR and LF--characters that terminate a line"
CSLineEnders := CharacterSet crlf.
"separators and non-separators"
CSSeparators := CharacterSet separators.
+ CSNonSeparators := CSSeparators complement.
+
+ "a table for exchanging cr with lf and vica versa"
+ CrLfExchangeTable := Character allByteCharacters collect: [ :each |
+ each
+ caseOf: {
+ [ Character cr ] -> [ Character lf ].
+ [ Character lf ] -> [ Character cr ] }
+ otherwise: [ each ] ]!
- CSNonSeparators := CSSeparators complement.!
Item was changed:
----- Method: String>>withSqueakLineEndings (in category 'internet') -----
withSqueakLineEndings
"Assume the string is textual, and that CR, LF, and CRLF are all valid line endings.
Replace each occurence with a single CR."
- | cr lf indexLF indexCR |
- lf := Character linefeed.
- indexLF := self indexOf: lf startingAt: 1.
- indexLF = 0 ifTrue: [^self].
-
- cr := Character cr.
- indexCR := self indexOf: cr startingAt: 1.
- indexCR = 0 ifTrue: [^self copy replaceAll: lf with: cr].
+ (self includes: Character lf) ifFalse: [ ^self ].
+ (self includes: Character cr) ifFalse: [
+ ^self translateWith: String crLfExchangeTable ].
^self withLineEndings: String cr!
Item was changed:
----- Method: String>>withUnixLineEndings (in category 'internet') -----
withUnixLineEndings
"Assume the string is textual, and that CR, LF, and CRLF are all valid line endings.
Replace each occurence with a single LF."
- | cr lf indexLF indexCR |
- cr := Character cr.
- indexCR := self indexOf: cr startingAt: 1.
- indexCR = 0 ifTrue: [^self].
-
- lf := Character linefeed.
- indexLF := self indexOf: lf startingAt: 1.
- indexLF = 0 ifTrue: [^self copy replaceAll: cr with: lf].
+ (self includes: Character cr) ifFalse: [ ^self ].
+ (self includes: Character lf) ifFalse: [
+ ^self translateWith: String crLfExchangeTable ].
^self withLineEndings: String lf!