17 TypeToFileSuffixMapping TypeToViewerApplicationMapping |
17 TypeToFileSuffixMapping TypeToViewerApplicationMapping |
18 SuffixToCommentStringMapping FileSuffixToTypeMapping |
18 SuffixToCommentStringMapping FileSuffixToTypeMapping |
19 FilenameToTypeMapping FileSuffixToImageReaderClassMapping |
19 FilenameToTypeMapping FileSuffixToImageReaderClassMapping |
20 CharSetToFontMapping LastSuffix LastType |
20 CharSetToFontMapping LastSuffix LastType |
21 DefaultCommandPerMIMEPerOS DefaultPrintCommandPerMIMEPerOS |
21 DefaultCommandPerMIMEPerOS DefaultPrintCommandPerMIMEPerOS |
22 TypeToParenthesisSpecMapping SuffixToParenthesisSpecMapping' |
22 TypeToParenthesisSpecMapping SuffixToParenthesisSpecMapping |
|
23 TypeToInfoMapping' |
23 poolDictionaries:'' |
24 poolDictionaries:'' |
24 category:'Net-Communication-Support' |
25 category:'Net-Communication-Support' |
25 ! |
26 ! |
26 |
27 |
27 String variableByteSubclass:#MIMEType |
28 ImmutableString variableByteSubclass:#MIMEType |
28 instanceVariableNames:'' |
29 instanceVariableNames:'' |
29 classVariableNames:'CachedTypes' |
30 classVariableNames:'CachedTypes' |
30 poolDictionaries:'' |
31 poolDictionaries:'' |
31 privateIn:MIMETypes |
32 privateIn:MIMETypes |
32 ! |
33 ! |
118 "Modified: / 10-04-2007 / 15:16:44 / cg" |
119 "Modified: / 10-04-2007 / 15:16:44 / cg" |
119 "Modified (comment): / 29-11-2011 / 19:11:51 / cg" |
120 "Modified (comment): / 29-11-2011 / 19:11:51 / cg" |
120 ! |
121 ! |
121 |
122 |
122 initializeCommentStringMappings |
123 initializeCommentStringMappings |
|
124 "these are used by the editor's comment/uncomment functions" |
|
125 |
123 TypeToCommentStringMapping := Dictionary new. |
126 TypeToCommentStringMapping := Dictionary new. |
124 SuffixToCommentStringMapping := Dictionary new. |
127 SuffixToCommentStringMapping := Dictionary new. |
125 |
128 |
126 TypeToCommentStringMapping |
129 TypeToCommentStringMapping |
127 at:'application/x-make' |
130 at:'application/x-make' |
128 put:#('#' (nil nil)). "/ '#' for EOL comments only |
131 put:#('#' (nil nil)). "/ '#' EOL comments only |
129 |
132 |
130 TypeToCommentStringMapping |
133 TypeToCommentStringMapping |
131 at:'application/x-sh' |
134 at:'application/x-sh' |
132 put:#('#' (nil nil)). "/ '#' for EOL comments only |
135 put:#('#' (nil nil)). "/ '#' EOL comments only |
133 |
136 |
134 #('text/html' 'text/xml' |
137 #('text/html' 'text/xml' |
135 'application/xml' |
138 'application/xml' |
136 'application/x-expecco-testsuite' |
139 'application/x-expecco-testsuite' |
137 'application/x-expecco-logfile' |
140 'application/x-expecco-logfile' |
153 "/ the following is ST/X specific |
156 "/ the following is ST/X specific |
154 TypeToCommentStringMapping |
157 TypeToCommentStringMapping |
155 at:'application/x-smalltalk-source' |
158 at:'application/x-smalltalk-source' |
156 put:#('"/' ('"' '"')). "/ '"/ ' for EOL; ".." for delimited comments |
159 put:#('"/' ('"' '"')). "/ '"/ ' for EOL; ".." for delimited comments |
157 |
160 |
158 |
|
159 "/ this is for standard smalltalk |
161 "/ this is for standard smalltalk |
160 "/ TypeToCommentStringMapping |
162 "/ TypeToCommentStringMapping |
161 "/ at:'application/x-smalltalk-source' |
163 "/ at:'application/x-smalltalk-source' |
162 "/ put:#(nil ('"' '"')). "/ ".." for delimited comments only |
164 "/ put:#(nil ('"' '"')). "/ ".." for delimited comments only |
163 |
165 |
164 |
166 |
165 TypeToCommentStringMapping |
167 TypeToCommentStringMapping |
166 at:'application/x-pascal-source' |
168 at:'application/x-pascal-source' |
167 put:#(nil ('{' '}')). "/ '{'..'}' for delimited comments |
169 put:#(nil ('{' '}')). "/ '{'..'}' for delimited comments |
168 |
170 |
169 |
|
170 "/ "/ the following is k&r |
|
171 "/ TypeToCommentStringMapping |
|
172 "/ at:'application/x-c-source' |
|
173 "/ put:#(nil ('/*' '*/')). "/ '/*'..'*/' for delimited comments |
|
174 "/ this is ANSI-c |
171 "/ this is ANSI-c |
175 TypeToCommentStringMapping |
172 TypeToCommentStringMapping |
176 at:'application/x-c-source' |
173 at:'application/x-c-source' |
177 put:#('//' ('/*' '*/')). |
174 put:#('//' ('/*' '*/')). |
178 |
175 |
212 |
209 |
213 "Modified: / 06-09-2011 / 10:46:27 / cg" |
210 "Modified: / 06-09-2011 / 10:46:27 / cg" |
214 ! |
211 ! |
215 |
212 |
216 initializeDefaultCommands |
213 initializeDefaultCommands |
217 "TODO: move this to OS" |
214 "these are used to select an application to be opened when a file of a particular |
|
215 type is double clicked in the browser. |
|
216 TODO: move this to OS" |
218 |
217 |
219 |unixCommands win32Commands unixPrintCommands win32PrintCommands listToTry| |
218 |unixCommands win32Commands unixPrintCommands win32PrintCommands listToTry| |
220 |
219 |
221 DefaultCommandPerMIMEPerOS := Dictionary new. |
220 DefaultCommandPerMIMEPerOS := Dictionary new. |
222 DefaultCommandPerMIMEPerOS at:#unix put:(unixCommands := Dictionary new). |
221 DefaultCommandPerMIMEPerOS at:#unix put:(unixCommands := Dictionary new). |
262 " |
261 " |
263 |
262 |
264 "Modified: / 12-05-2004 / 11:43:23 / cg" |
263 "Modified: / 12-05-2004 / 11:43:23 / cg" |
265 ! |
264 ! |
266 |
265 |
|
266 initializeFileInfoMappings |
|
267 "these are used by the file browser if a 'file' command is not present in the OS" |
|
268 |
|
269 TypeToInfoMapping := Dictionary new. |
|
270 |
|
271 TypeToInfoMapping at:'application/x-smalltalk-source' put:'Smalltalk source'. |
|
272 TypeToInfoMapping at:'text/html' put:'HTML document'. |
|
273 TypeToInfoMapping at:'text/xml' put:'XML document'. |
|
274 TypeToInfoMapping at:'application/xml' put:'XML document'. |
|
275 TypeToInfoMapping at:'application/x-c-source' put:'C source'. |
|
276 TypeToInfoMapping at:'application/x-c-header' put:'C header file'. |
|
277 TypeToInfoMapping at:'application/x-cpp-source' put:'C++ source'. |
|
278 TypeToInfoMapping at:'application/x-csharp-source' put:'C# source'. |
|
279 TypeToInfoMapping at:'application/x-java-source' put:'Java source'. |
|
280 TypeToInfoMapping at:'application/x-javascript' put:'Javascript source'. |
|
281 TypeToInfoMapping at:'application/x-lisp-source' put:'Lisp source'. |
|
282 |
|
283 TypeToInfoMapping at:'application/x-make' put:'make rules'. |
|
284 TypeToInfoMapping at:'application/binary' put:'binary object file'. |
|
285 |
|
286 " |
|
287 self initializeFileInfoMappings |
|
288 'foo.H' asFilename mimeTypeFromName |
|
289 'foo.o' asFilename mimeTypeFromName |
|
290 " |
|
291 ! |
|
292 |
267 initializeFileNameToMimeTypeMapping |
293 initializeFileNameToMimeTypeMapping |
268 "initialize wellKnown facts" |
294 "initialize wellKnown facts" |
269 |
295 |
270 |types| |
296 |types| |
271 |
297 |
315 self initializeFileNameToMimeTypeMapping |
341 self initializeFileNameToMimeTypeMapping |
316 " |
342 " |
317 ! |
343 ! |
318 |
344 |
319 initializeImageReaderMappings |
345 initializeImageReaderMappings |
|
346 "these are used so select an image reader, based on a bitmap image's mime type" |
|
347 |
320 |rdr| |
348 |rdr| |
321 |
349 |
322 FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
350 FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
323 FileSuffixToImageReaderClassMapping := Dictionary new |
351 FileSuffixToImageReaderClassMapping := Dictionary new |
324 ]. |
352 ]. |
407 (rdr := Smalltalk at:#CMURasterReader) notNil ifTrue:[ |
435 (rdr := Smalltalk at:#CMURasterReader) notNil ifTrue:[ |
408 TypeToImageReaderClassMapping at:'image/x-cmu-raster' put:rdr. |
436 TypeToImageReaderClassMapping at:'image/x-cmu-raster' put:rdr. |
409 FileSuffixToImageReaderClassMapping at:'ras' put:rdr. |
437 FileSuffixToImageReaderClassMapping at:'ras' put:rdr. |
410 ]. |
438 ]. |
411 |
439 |
412 "/ movie formats - experimantal and not yet complete / finished / delivered |
440 "/ movie formats - experimental and not yet complete / finished / delivered / published |
413 "/ (rdr := Smalltalk at:#FLIReader) notNil ifTrue:[ |
441 "/ (rdr := Smalltalk at:#FLIReader) notNil ifTrue:[ |
414 "/ TypeToImageReaderClassMapping at:'video/x-fli' put:rdr. |
442 "/ TypeToImageReaderClassMapping at:'video/x-fli' put:rdr. |
415 "/ FileSuffixToImageReaderClassMapping at:'fli' put:rdr. |
443 "/ FileSuffixToImageReaderClassMapping at:'fli' put:rdr. |
416 "/ ]. |
444 "/ ]. |
417 "/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ |
445 "/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ |
449 "/ FileSuffixToImageReaderClassMapping at:'movie' put:rdr. |
477 "/ FileSuffixToImageReaderClassMapping at:'movie' put:rdr. |
450 "/ ]. |
478 "/ ]. |
451 ! |
479 ! |
452 |
480 |
453 initializeParenthesisSpecMappings |
481 initializeParenthesisSpecMappings |
|
482 "these are used by the editors to mark matching parenthesis" |
|
483 |
454 |spec| |
484 |spec| |
455 |
485 |
456 TypeToParenthesisSpecMapping := Dictionary new. |
486 TypeToParenthesisSpecMapping := Dictionary new. |
457 SuffixToParenthesisSpecMapping := Dictionary new. |
487 SuffixToParenthesisSpecMapping := Dictionary new. |
458 |
488 |
459 "/ ST/X spec |
489 "/ ST/X spec |
460 |
|
461 spec := IdentityDictionary new. |
490 spec := IdentityDictionary new. |
462 spec at:#open put:#( $( $[ ${ ). |
491 spec at:#open put:#( $( $[ ${ ). |
463 spec at:#close put:#( $) $] $} ). |
492 spec at:#close put:#( $) $] $} ). |
464 spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
493 spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
465 spec at:#eolComment put:'"/'. |
494 spec at:#eolComment put:'"/'. |
466 TypeToParenthesisSpecMapping at:'application/x-smalltalk-source' put:spec. |
495 TypeToParenthesisSpecMapping at:'application/x-smalltalk-source' put:spec. |
467 |
496 |
468 "/ XML & HTML |
497 "/ XML & HTML |
469 |
|
470 spec := IdentityDictionary new. |
498 spec := IdentityDictionary new. |
471 spec at:#open put:#( $< ). |
499 spec at:#open put:#( $< ). |
472 spec at:#close put:#( $> ). |
500 spec at:#close put:#( $> ). |
473 spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
501 spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
474 #( 'text/html' 'text/xml' 'application/xml' ) do:[:eachXMLType | |
502 #( 'text/html' 'text/xml' 'application/xml' ) do:[:eachXMLType | |
475 TypeToParenthesisSpecMapping at:eachXMLType put:spec |
503 TypeToParenthesisSpecMapping at:eachXMLType put:spec |
476 ]. |
504 ]. |
477 |
505 |
478 "/ ANSI-c, Java, C# |
506 "/ ANSI-c, Java, C# |
479 |
|
480 spec := IdentityDictionary new. |
507 spec := IdentityDictionary new. |
481 spec at:#open put:#( $( $[ ${ ). |
508 spec at:#open put:#( $( $[ ${ ). |
482 spec at:#close put:#( $) $] $} ). |
509 spec at:#close put:#( $) $] $} ). |
483 spec at:#ignore put:#( $' $" ). |
510 spec at:#ignore put:#( $' $" ). |
484 spec at:#eolComment put:'//'. |
511 spec at:#eolComment put:'//'. |
486 TypeToParenthesisSpecMapping at:'application/x-cpp-source' put:spec. |
513 TypeToParenthesisSpecMapping at:'application/x-cpp-source' put:spec. |
487 TypeToParenthesisSpecMapping at:'application/x-csharp-source' put:spec. |
514 TypeToParenthesisSpecMapping at:'application/x-csharp-source' put:spec. |
488 TypeToParenthesisSpecMapping at:'application/x-java-source' put:spec. |
515 TypeToParenthesisSpecMapping at:'application/x-java-source' put:spec. |
489 TypeToParenthesisSpecMapping at:'application/x-javascript' put:spec. |
516 TypeToParenthesisSpecMapping at:'application/x-javascript' put:spec. |
490 |
517 |
491 "/ Lisp |
518 "/ Lisp / Scheme |
492 |
|
493 spec := IdentityDictionary new. |
519 spec := IdentityDictionary new. |
494 spec at:#open put:#( $( $[ ). |
520 spec at:#open put:#( $( $[ ). |
495 spec at:#close put:#( $) $] ). |
521 spec at:#close put:#( $) $] ). |
496 spec at:#ignore put:#( $" ). |
522 spec at:#ignore put:#( $" ). |
497 spec at:#eolComment put:';'. |
523 spec at:#eolComment put:';'. |
767 (aSuffix notNil and:[mimeType notNil]) ifTrue:[ |
793 (aSuffix notNil and:[mimeType notNil]) ifTrue:[ |
768 self mimeTypeForSuffix:aSuffix put:mimeType |
794 self mimeTypeForSuffix:aSuffix put:mimeType |
769 ]. |
795 ]. |
770 ! |
796 ! |
771 |
797 |
|
798 fileInfoForMimeType:mimeType |
|
799 "given a mimeType, return an info string similar to what the unix 'file' command |
|
800 provides. This info here is returned by systems which have no file (i.e. MSDOS) and |
|
801 for types of which file does not know about (smalltalk files, for example)" |
|
802 |
|
803 ^ TypeToInfoMapping at:mimeType ifAbsent:nil |
|
804 |
|
805 " |
|
806 self fileInfoForMimeType:(MIMEType fromString:'image/gif') |
|
807 " |
|
808 ! |
|
809 |
772 fileSuffixToImageReaderMapping |
810 fileSuffixToImageReaderMapping |
773 "return the suffix-to-imageReader mapping" |
811 "return the suffix-to-imageReader mapping" |
774 |
812 |
775 ^ FileSuffixToImageReaderClassMapping ? #() |
813 ^ FileSuffixToImageReaderClassMapping ? #() |
776 |
814 |
985 |
1023 |
986 ('---- encoding: ' #'application/x-smalltalk-source') |
1024 ('---- encoding: ' #'application/x-smalltalk-source') |
987 ('---- timestamp ' #'application/x-smalltalk-source') |
1025 ('---- timestamp ' #'application/x-smalltalk-source') |
988 ('from dolphin' #'application/x-smalltalk-source') |
1026 ('from dolphin' #'application/x-smalltalk-source') |
989 ('from visualworks' #'application/x-smalltalk-source') |
1027 ('from visualworks' #'application/x-smalltalk-source') |
|
1028 ('from squeak' #'application/x-smalltalk-source') |
|
1029 ('from smalltalk/x' #'application/x-smalltalk-source') |
|
1030 ('"{ Package:' #'application(x-smalltalk-source') |
990 ('categoriesforclass' #'application/x-smalltalk-source') |
1031 ('categoriesforclass' #'application/x-smalltalk-source') |
991 ('methodsfor!!' #'application/x-smalltalk-source') |
1032 ('methodsfor!!' #'application/x-smalltalk-source') |
992 ('subclass:' #'application/x-smalltalk-source') |
1033 ('subclass:' #'application/x-smalltalk-source') |
993 ('methodsfor:' #'application/x-smalltalk-source') |
1034 ('methodsfor:' #'application/x-smalltalk-source') |
994 ('interchangeversion:' #'application/x-smalltalk-source-sif') |
1035 ('interchangeversion:' #'application/x-smalltalk-source-sif') |
1382 "Modified: / 20-07-2012 / 17:36:31 / cg" |
1424 "Modified: / 20-07-2012 / 17:36:31 / cg" |
1383 ! ! |
1425 ! ! |
1384 |
1426 |
1385 !MIMETypes::MIMEType methodsFor:'queries'! |
1427 !MIMETypes::MIMEType methodsFor:'queries'! |
1386 |
1428 |
|
1429 fileTypeInfo |
|
1430 ^ MIMETypes fileTypeInfoForMimeType:self |
|
1431 |
|
1432 " |
|
1433 (MIMETypes mimeTypeFromString:'application/x-smalltalk-source') fileTypeInfo |
|
1434 " |
|
1435 ! |
|
1436 |
1387 isArchive |
1437 isArchive |
1388 <resource: #obsolete> |
1438 <resource: #obsolete> |
1389 "return true, if I represent an archive type (such as zip or tar)" |
1439 "return true, if I represent an archive type (such as zip or tar)" |
1390 |
1440 |
1391 ^ self isArchiveType |
1441 ^ self isArchiveType |
1496 ! ! |
1546 ! ! |
1497 |
1547 |
1498 !MIMETypes class methodsFor:'documentation'! |
1548 !MIMETypes class methodsFor:'documentation'! |
1499 |
1549 |
1500 version |
1550 version |
1501 ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.134 2014-05-14 18:30:35 cg Exp $' |
1551 ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.135 2014-07-10 19:45:59 cg Exp $' |
1502 ! |
1552 ! |
1503 |
1553 |
1504 version_CVS |
1554 version_CVS |
1505 ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.134 2014-05-14 18:30:35 cg Exp $' |
1555 ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.135 2014-07-10 19:45:59 cg Exp $' |
1506 ! ! |
1556 ! ! |
1507 |
1557 |
1508 |
1558 |
1509 MIMETypes initialize! |
1559 MIMETypes initialize! |