--- a/FBrowser.st Mon Jun 30 20:28:13 1997 +0200
+++ b/FBrowser.st Mon Jun 30 20:52:37 1997 +0200
@@ -2289,7 +2289,8 @@
].
s peek == $# ifTrue:[
- s next
+ s next.
+ s skipSeparators.
].
w := s upToSeparator.
w notNil ifTrue:[
@@ -2320,7 +2321,7 @@
^ #ascii
"Created: 26.2.1996 / 17:43:08 / cg"
- "Modified: 30.6.1997 / 16:41:11 / cg"
+ "Modified: 30.6.1997 / 17:12:19 / cg"
!
preferredFontEncodingFor:fileEncoding
@@ -2344,9 +2345,10 @@
(fileEncoding == #unicode) ifTrue:[
^ 'uni*'
].
- ^ 'iso*'
+ ^ 'iso8859*'
"Created: 28.6.1997 / 20:47:35 / cg"
+ "Modified: 30.6.1997 / 17:46:30 / cg"
!
validateFontEncodingFor:newEncoding ask:ask
@@ -2357,136 +2359,73 @@
fontsEncoding := subView font encoding.
-"/ for now: keep that stupid code below - just for the dialog boxes text ...
-"/ pref := self preferredFontEncodingFor:newEncoding.
-"/ (pref match:fontsEncoding) ifTrue:[
-"/ ^ self
-"/ ].
-
- ((newEncoding == #jis7)
- or:[newEncoding == #euc
- or:[newEncoding == #sjis]]) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'jis']) ifTrue:[
- ^ self
- ].
-
- msg := 'switch to a JIS encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[coding asLowercase startsWith:'jis']].
+ pref := self preferredFontEncodingFor:newEncoding.
+
+ (pref match:fontsEncoding) ifTrue:[
+ ^ self
].
- (newEncoding == #gb) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'gb']) ifTrue:[
- ^ self
- ].
-
- msg := 'switch to a GB encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['gb*' match:coding]].
- ].
- (newEncoding == #big5) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'big5']) ifTrue:[
- ^ self
- ].
-
- msg := 'switch to a BIG-5 encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['big5*' match:coding]].
- ].
- (newEncoding == #ksc) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'ksc']) ifTrue:[
+ "/ stupid ...
+ pref = 'ascii*' ifTrue:[
+ (fontsEncoding match:'iso8859*') ifTrue:[
^ self
- ].
-
- msg := 'switch to a KSC encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['ksc*' match:coding]].
- ].
- (newEncoding == #unicode) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'uni']) ifTrue:[
- ^ self
- ].
-
- msg := 'switch to a Unicode encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['uni*' match:coding]].
- ].
-
-
- (msg isNil) ifTrue:[
- "/ none of the above encodings ...
-
- fontsEncoding notNil ifTrue:[
- ((fontsEncoding startsWith:'jis')
- or:[(fontsEncoding startsWith:'gb')
- or:[(fontsEncoding startsWith:'ksc')
- or:[(fontsEncoding startsWith:'big5')]]])
- ifTrue:[
- msg := 'switch back to an ASCII encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[('ascii' match:coding)
- or:['iso*' match:coding]]].
- defaultFont := TextView defaultFont
- ] ifFalse:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'iso8859']) ifTrue:[
- msg := 'switch to a ''' , newEncoding , ''' encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[newEncoding asLowercase = coding asLowercase]].
- ].
- ].
]
].
- msg isNil ifTrue:[
- "/ mhmh - can be represented in current font
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:[pref match:coding]].
+
+ defaultFont := TextView defaultFont onDevice:device.
+ (pref match:(defaultFont encoding)) ifFalse:[
+ defaultFont := nil.
].
- msg notNil ifTrue:[
+ defaultFont isNil ifTrue:[
+ (pref = 'ascii*'
+ or:[pref = 'iso8859*']) ifTrue:[
+ defaultFont := FontDescription family:'courier' face:'medium' style:'roman' size:12
+ ]
+ ].
+
+ defaultFont isNil ifTrue:[
+ defaultFont := device
+ listOfAvailableFonts
+ detect:[:f | filter value:f]
+ ifNone:nil.
defaultFont isNil ifTrue:[
+
+ "/ flush list, and refetch font list
+ "/ (in case someone just changed the font path ...)
+
+ device flushListOfAvailableFonts.
defaultFont := device
listOfAvailableFonts
detect:[:f | filter value:f]
ifNone:nil.
- defaultFont isNil ifTrue:[
-
- "/ flush list, and refetch font list
- "/ (in case someone just changed the font path ...)
-
- device flushListOfAvailableFonts.
- defaultFont := device
- listOfAvailableFonts
- detect:[:f | filter value:f]
- ifNone:nil.
- ].
-
- defaultFont isNil ifTrue:[
- self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
- ^ self.
- ]
].
- (ask not or:[self confirm:(resources string:msg) withCRs])
- ifTrue:[
- self withWaitCursorDo:[
- f := FontPanel
- fontFromUserInitial:defaultFont
- title:(resources string:'font selection')
- filter:filter.
- f notNil ifTrue:[
- subView font:f
- ]
+ defaultFont isNil ifTrue:[
+ self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
+ ^ self.
+ ]
+ ].
+
+ msg := 'switch to a %1 encoded font ?'.
+ (ask not or:[self confirm:(resources string:msg with:pref) withCRs])
+ ifTrue:[
+ self withWaitCursorDo:[
+ f := FontPanel
+ fontFromUserInitial:defaultFont
+ title:(resources string:'font selection')
+ filter:filter.
+ f notNil ifTrue:[
+ subView font:f
]
]
]
"Created: 26.10.1996 / 12:06:54 / cg"
- "Modified: 30.6.1997 / 15:27:07 / cg"
+ "Modified: 30.6.1997 / 17:46:46 / cg"
! !
!FileBrowser methodsFor:'private - file stuff'!
@@ -3025,32 +2964,32 @@
(self nonBinaryFileAction:fileName) ifTrue:[^ self].
].
- "/ ascii should work in any font ...
-
- guess ~~ #ascii ifTrue:[
- fileEncoding ~~ guess ifTrue:[
- fontsEncoding := subView font encoding.
- pref := self preferredFontEncodingFor:guess.
- ok := pref match:fontsEncoding.
- ok ifFalse:[
- pref = 'iso*' ifTrue:[
- ok := 'ascii*' match:fontsEncoding
- ]
- ].
- ok ifFalse:[
- action := Dialog choose:(resources string:'''%1'' seems to be ' , guess , ' encoded.' with:fileName)
- labels:(resources array:#('cancel' 'show' 'change font'))
- values:#(nil #show #encoding)
- default:#encoding.
- action isNil ifTrue:[^ self].
- action == #encoding ifTrue:[
- fileEncoding := guess asSymbol.
- subView externalEncoding:fileEncoding.
- self validateFontEncodingFor:fileEncoding ask:false.
- enc := fileEncoding.
- ]
- ]
- ]
+ fontsEncoding := subView font encoding.
+ pref := self preferredFontEncodingFor:guess.
+
+ ok := pref match:fontsEncoding.
+ ok ifFalse:[
+ pref = 'iso8859*' ifTrue:[
+ ok := 'ascii*' match:fontsEncoding
+ ]
+ ].
+ ok ifTrue:[
+ fileEncoding := guess.
+ enc := guess.
+ ] ifFalse:[
+ action := Dialog choose:(resources string:'''%1'' seems to be %2 encoded.' with:fileName with:guess)
+ labels:(resources array:#('cancel' 'show' 'change font'))
+ values:#(nil #show #encoding)
+ default:#encoding.
+ action isNil ifTrue:[^ self].
+ action == #encoding ifTrue:[
+ fileEncoding := guess asSymbol.
+ subView externalEncoding:fileEncoding.
+ self validateFontEncodingFor:fileEncoding ask:false.
+ ] ifFalse:[
+ self information:(resources string:'Individual characters may be invisible/wrong in this font.')
+ ].
+ enc := fileEncoding.
].
].
@@ -3088,8 +3027,13 @@
failWarning := false.
CharacterArray decodingFailedSignal handle:[:ex |
+ |errStr|
+
failWarning ifFalse:[
- (self confirm:'An error occurred while decoding.\The file has either a different encoding or is corrupted.\\Continue ?' withCRs)
+ errStr := resources string:ex errorString.
+ (self confirm:(resources
+ string:'An error occurred while decoding:\%1\\The file has either a different encoding or is corrupted.\\Continue ?'
+ with:errStr) withCRs)
ifFalse:[
^ self
].
@@ -3107,7 +3051,7 @@
].
"Created: 19.6.1996 / 09:39:52 / cg"
- "Modified: 28.6.1997 / 21:06:29 / cg"
+ "Modified: 30.6.1997 / 19:21:51 / cg"
!
writeFile:fileName text:someText encoding:encoding
@@ -3619,5 +3563,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.168 1997-06-30 14:44:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.169 1997-06-30 18:52:37 cg Exp $'
! !
--- a/FileBrowser.st Mon Jun 30 20:28:13 1997 +0200
+++ b/FileBrowser.st Mon Jun 30 20:52:37 1997 +0200
@@ -2289,7 +2289,8 @@
].
s peek == $# ifTrue:[
- s next
+ s next.
+ s skipSeparators.
].
w := s upToSeparator.
w notNil ifTrue:[
@@ -2320,7 +2321,7 @@
^ #ascii
"Created: 26.2.1996 / 17:43:08 / cg"
- "Modified: 30.6.1997 / 16:41:11 / cg"
+ "Modified: 30.6.1997 / 17:12:19 / cg"
!
preferredFontEncodingFor:fileEncoding
@@ -2344,9 +2345,10 @@
(fileEncoding == #unicode) ifTrue:[
^ 'uni*'
].
- ^ 'iso*'
+ ^ 'iso8859*'
"Created: 28.6.1997 / 20:47:35 / cg"
+ "Modified: 30.6.1997 / 17:46:30 / cg"
!
validateFontEncodingFor:newEncoding ask:ask
@@ -2357,136 +2359,73 @@
fontsEncoding := subView font encoding.
-"/ for now: keep that stupid code below - just for the dialog boxes text ...
-"/ pref := self preferredFontEncodingFor:newEncoding.
-"/ (pref match:fontsEncoding) ifTrue:[
-"/ ^ self
-"/ ].
-
- ((newEncoding == #jis7)
- or:[newEncoding == #euc
- or:[newEncoding == #sjis]]) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'jis']) ifTrue:[
- ^ self
- ].
-
- msg := 'switch to a JIS encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[coding asLowercase startsWith:'jis']].
+ pref := self preferredFontEncodingFor:newEncoding.
+
+ (pref match:fontsEncoding) ifTrue:[
+ ^ self
].
- (newEncoding == #gb) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'gb']) ifTrue:[
- ^ self
- ].
-
- msg := 'switch to a GB encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['gb*' match:coding]].
- ].
- (newEncoding == #big5) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'big5']) ifTrue:[
- ^ self
- ].
-
- msg := 'switch to a BIG-5 encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['big5*' match:coding]].
- ].
- (newEncoding == #ksc) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'ksc']) ifTrue:[
+ "/ stupid ...
+ pref = 'ascii*' ifTrue:[
+ (fontsEncoding match:'iso8859*') ifTrue:[
^ self
- ].
-
- msg := 'switch to a KSC encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['ksc*' match:coding]].
- ].
- (newEncoding == #unicode) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'uni']) ifTrue:[
- ^ self
- ].
-
- msg := 'switch to a Unicode encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['uni*' match:coding]].
- ].
-
-
- (msg isNil) ifTrue:[
- "/ none of the above encodings ...
-
- fontsEncoding notNil ifTrue:[
- ((fontsEncoding startsWith:'jis')
- or:[(fontsEncoding startsWith:'gb')
- or:[(fontsEncoding startsWith:'ksc')
- or:[(fontsEncoding startsWith:'big5')]]])
- ifTrue:[
- msg := 'switch back to an ASCII encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[('ascii' match:coding)
- or:['iso*' match:coding]]].
- defaultFont := TextView defaultFont
- ] ifFalse:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'iso8859']) ifTrue:[
- msg := 'switch to a ''' , newEncoding , ''' encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[newEncoding asLowercase = coding asLowercase]].
- ].
- ].
]
].
- msg isNil ifTrue:[
- "/ mhmh - can be represented in current font
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:[pref match:coding]].
+
+ defaultFont := TextView defaultFont onDevice:device.
+ (pref match:(defaultFont encoding)) ifFalse:[
+ defaultFont := nil.
].
- msg notNil ifTrue:[
+ defaultFont isNil ifTrue:[
+ (pref = 'ascii*'
+ or:[pref = 'iso8859*']) ifTrue:[
+ defaultFont := FontDescription family:'courier' face:'medium' style:'roman' size:12
+ ]
+ ].
+
+ defaultFont isNil ifTrue:[
+ defaultFont := device
+ listOfAvailableFonts
+ detect:[:f | filter value:f]
+ ifNone:nil.
defaultFont isNil ifTrue:[
+
+ "/ flush list, and refetch font list
+ "/ (in case someone just changed the font path ...)
+
+ device flushListOfAvailableFonts.
defaultFont := device
listOfAvailableFonts
detect:[:f | filter value:f]
ifNone:nil.
- defaultFont isNil ifTrue:[
-
- "/ flush list, and refetch font list
- "/ (in case someone just changed the font path ...)
-
- device flushListOfAvailableFonts.
- defaultFont := device
- listOfAvailableFonts
- detect:[:f | filter value:f]
- ifNone:nil.
- ].
-
- defaultFont isNil ifTrue:[
- self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
- ^ self.
- ]
].
- (ask not or:[self confirm:(resources string:msg) withCRs])
- ifTrue:[
- self withWaitCursorDo:[
- f := FontPanel
- fontFromUserInitial:defaultFont
- title:(resources string:'font selection')
- filter:filter.
- f notNil ifTrue:[
- subView font:f
- ]
+ defaultFont isNil ifTrue:[
+ self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
+ ^ self.
+ ]
+ ].
+
+ msg := 'switch to a %1 encoded font ?'.
+ (ask not or:[self confirm:(resources string:msg with:pref) withCRs])
+ ifTrue:[
+ self withWaitCursorDo:[
+ f := FontPanel
+ fontFromUserInitial:defaultFont
+ title:(resources string:'font selection')
+ filter:filter.
+ f notNil ifTrue:[
+ subView font:f
]
]
]
"Created: 26.10.1996 / 12:06:54 / cg"
- "Modified: 30.6.1997 / 15:27:07 / cg"
+ "Modified: 30.6.1997 / 17:46:46 / cg"
! !
!FileBrowser methodsFor:'private - file stuff'!
@@ -3025,32 +2964,32 @@
(self nonBinaryFileAction:fileName) ifTrue:[^ self].
].
- "/ ascii should work in any font ...
-
- guess ~~ #ascii ifTrue:[
- fileEncoding ~~ guess ifTrue:[
- fontsEncoding := subView font encoding.
- pref := self preferredFontEncodingFor:guess.
- ok := pref match:fontsEncoding.
- ok ifFalse:[
- pref = 'iso*' ifTrue:[
- ok := 'ascii*' match:fontsEncoding
- ]
- ].
- ok ifFalse:[
- action := Dialog choose:(resources string:'''%1'' seems to be ' , guess , ' encoded.' with:fileName)
- labels:(resources array:#('cancel' 'show' 'change font'))
- values:#(nil #show #encoding)
- default:#encoding.
- action isNil ifTrue:[^ self].
- action == #encoding ifTrue:[
- fileEncoding := guess asSymbol.
- subView externalEncoding:fileEncoding.
- self validateFontEncodingFor:fileEncoding ask:false.
- enc := fileEncoding.
- ]
- ]
- ]
+ fontsEncoding := subView font encoding.
+ pref := self preferredFontEncodingFor:guess.
+
+ ok := pref match:fontsEncoding.
+ ok ifFalse:[
+ pref = 'iso8859*' ifTrue:[
+ ok := 'ascii*' match:fontsEncoding
+ ]
+ ].
+ ok ifTrue:[
+ fileEncoding := guess.
+ enc := guess.
+ ] ifFalse:[
+ action := Dialog choose:(resources string:'''%1'' seems to be %2 encoded.' with:fileName with:guess)
+ labels:(resources array:#('cancel' 'show' 'change font'))
+ values:#(nil #show #encoding)
+ default:#encoding.
+ action isNil ifTrue:[^ self].
+ action == #encoding ifTrue:[
+ fileEncoding := guess asSymbol.
+ subView externalEncoding:fileEncoding.
+ self validateFontEncodingFor:fileEncoding ask:false.
+ ] ifFalse:[
+ self information:(resources string:'Individual characters may be invisible/wrong in this font.')
+ ].
+ enc := fileEncoding.
].
].
@@ -3088,8 +3027,13 @@
failWarning := false.
CharacterArray decodingFailedSignal handle:[:ex |
+ |errStr|
+
failWarning ifFalse:[
- (self confirm:'An error occurred while decoding.\The file has either a different encoding or is corrupted.\\Continue ?' withCRs)
+ errStr := resources string:ex errorString.
+ (self confirm:(resources
+ string:'An error occurred while decoding:\%1\\The file has either a different encoding or is corrupted.\\Continue ?'
+ with:errStr) withCRs)
ifFalse:[
^ self
].
@@ -3107,7 +3051,7 @@
].
"Created: 19.6.1996 / 09:39:52 / cg"
- "Modified: 28.6.1997 / 21:06:29 / cg"
+ "Modified: 30.6.1997 / 19:21:51 / cg"
!
writeFile:fileName text:someText encoding:encoding
@@ -3619,5 +3563,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.168 1997-06-30 14:44:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.169 1997-06-30 18:52:37 cg Exp $'
! !