FileBrowser.st
changeset 5508 39c6055939f4
parent 5507 05741fb52724
child 5509 d1c7613923c5
equal deleted inserted replaced
5507:05741fb52724 5508:39c6055939f4
  6001 
  6001 
  6002     "Created: 26.2.1996 / 17:43:08 / cg"
  6002     "Created: 26.2.1996 / 17:43:08 / cg"
  6003     "Modified: 1.7.1997 / 00:00:27 / cg"
  6003     "Modified: 1.7.1997 / 00:00:27 / cg"
  6004 !
  6004 !
  6005 
  6005 
  6006 preferredFontEncodingFor:fileEncoding
       
  6007     "given a file encoding, return corresponding preferred fontEncoding
       
  6008      match pattern"
       
  6009 
       
  6010     |ce fe|
       
  6011 
       
  6012     ce := FontDescription characterSetForCharacterEncoding:fileEncoding.
       
  6013     ce isNil ifTrue:[
       
  6014         ce := fileEncoding.
       
  6015     ].
       
  6016 
       
  6017     fe := FontDescription fontNamePatternForCharset:ce.
       
  6018     fe notNil ifTrue:[^ fe].
       
  6019     ^ ce ? 'iso8859*'
       
  6020 
       
  6021     "Created: 28.6.1997 / 20:47:35 / cg"
       
  6022     "Modified: 1.7.1997 / 00:04:56 / cg"
       
  6023 !
       
  6024 
       
  6025 validateFontEncodingFor:newEncoding ask:ask
  6006 validateFontEncodingFor:newEncoding ask:ask
  6026     "if required, query user if he/she wants to change to another font,
  6007     "if required, query user if he/she wants to change to another font,
  6027      which is able to display text encoded as specified by newEncoding"
  6008      which is able to display text encoded as specified by newEncoding"
  6028 
  6009 
  6029     |fontsEncoding msg filter f defaultFont pref|
  6010     |fontsEncoding msg filter f defaultFont pref|
  6030 
  6011 
  6031     fontsEncoding := subView font encoding.
  6012     fontsEncoding := subView font encoding.
  6032 
  6013 
  6033     pref := self preferredFontEncodingFor:newEncoding.
  6014     pref := FontDescription preferredFontEncodingFor:newEncoding.
  6034 
  6015 
  6035     (pref match:fontsEncoding) ifTrue:[
  6016     (pref match:fontsEncoding) ifTrue:[
  6036         ^ self
  6017         ^ self
  6037     ].
  6018     ].
  6038     "/ stupid ...
  6019     "/ stupid ...
  6050     (pref match:(defaultFont encoding)) ifFalse:[
  6031     (pref match:(defaultFont encoding)) ifFalse:[
  6051         defaultFont := nil.
  6032         defaultFont := nil.
  6052     ].
  6033     ].
  6053 
  6034 
  6054     defaultFont isNil ifTrue:[
  6035     defaultFont isNil ifTrue:[
  6055         (pref = 'ascii*'
  6036         (pref = 'ascii*' or:[pref = 'iso8859*']) ifTrue:[
  6056         or:[pref = 'iso8859*']) ifTrue:[
       
  6057             defaultFont := FontDescription family:'courier' face:'medium' style:'roman' size:12
  6037             defaultFont := FontDescription family:'courier' face:'medium' style:'roman' size:12
  6058         ]
  6038         ]
  6059     ].
  6039     ].
  6060 
  6040 
  6061     defaultFont isNil ifTrue:[
  6041     defaultFont isNil ifTrue:[
  6283         viaDoubleClick ifTrue:[
  6263         viaDoubleClick ifTrue:[
  6284             (self nonBinaryFileAction:fileNameString) ifTrue:[^ self].
  6264             (self nonBinaryFileAction:fileNameString) ifTrue:[^ self].
  6285         ].
  6265         ].
  6286 
  6266 
  6287         fontsEncoding := subView font encoding ? 'ascii'.
  6267         fontsEncoding := subView font encoding ? 'ascii'.
  6288         pref := self preferredFontEncodingFor:guess.
  6268         pref := FontDescription preferredFontEncodingFor:guess.
  6289         ok := CharacterEncoder isEncoding:pref subSetOf:fontsEncoding.
  6269         ok := CharacterEncoder isEncoding:pref subSetOf:fontsEncoding.
  6290 
  6270 
  6291         ok ifTrue:[
  6271         ok ifTrue:[
  6292             fileEncoding := guess.    
  6272             fileEncoding := guess.    
  6293             enc := guess.
  6273             enc := guess.
  7631 ! !
  7611 ! !
  7632 
  7612 
  7633 !FileBrowser class methodsFor:'documentation'!
  7613 !FileBrowser class methodsFor:'documentation'!
  7634 
  7614 
  7635 version
  7615 version
  7636     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.562 2004-02-12 18:39:35 cg Exp $'
  7616     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.563 2004-02-12 20:52:32 cg Exp $'
  7637 ! !
  7617 ! !