FileBrowser.st
changeset 3448 1310d33d3134
parent 3446 b32c20a49200
child 3454 3a6a5b6827a1
equal deleted inserted replaced
3447:f1a20a8ba485 3448:1310d33d3134
     1 "
     1 "
     2  COPYRIGHT (c) 1991 by Claus Gittinger
     2  COPYRIGHT (c) 1991 by Claus Gittinger
     3 	      All Rights Reserved
     3               All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
    11 "
    11 "
    12 
    12 
    13 "{ Package: 'stx:libtool' }"
    13 "{ Package: 'stx:libtool' }"
    14 
    14 
    15 StandardSystemView subclass:#FileBrowser
    15 StandardSystemView subclass:#FileBrowser
    16 	instanceVariableNames:'menuPanel labelView filterField fileListView subView
    16         instanceVariableNames:'menuPanel labelView filterField fileListView subView
    17 		currentDirectory fileList checkBlock checkDelta timeOfLastCheck
    17                 currentDirectory fileList checkBlock checkDelta timeOfLastCheck
    18 		myName killButton pauseToggle compressTabs lockUpdate
    18                 myName killButton pauseToggle compressTabs lockUpdate
    19 		previousDirectory currentFileName timeOfFileRead tabSpec
    19                 previousDirectory currentFileName timeOfFileRead tabSpec
    20 		commandView commandIndex fileEncoding tabRulerView scrollView
    20                 commandView commandIndex fileEncoding tabRulerView scrollView
    21 		icons listUpdateProcess currentFileInFileName
    21                 icons listUpdateProcess currentFileInFileName
    22 		lastFileDiffDirectory sortByWhat sortCaseless showingDetails
    22                 lastFileDiffDirectory sortByWhat sortCaseless showingDetails
    23 		showingHiddenFiles showingBigImagePreview imagePreviewView
    23                 showingTimeAndDate showingHiddenFiles showingBigImagePreview
    24 		imageRenderProcess dosEOLMode doAutoUpdate doNotShowFontDialog'
    24                 imagePreviewView imageRenderProcess dosEOLMode doAutoUpdate
    25 	classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon
    25                 doNotShowFontDialog'
    26 		CommandHistory CommandHistorySize Icons DefaultCommandPerSuffix
    26         classVariableNames:'DirectoryHistory DirectoryHistoryWhere DirectoryBookmarks
    27 		DefaultCommandPerMIME VisitedFileHistory'
    27                 HistorySize DefaultIcon CommandHistory CommandHistorySize Icons
    28 	poolDictionaries:''
    28                 DefaultCommandPerSuffix DefaultCommandPerMIME VisitedFileHistory'
    29 	category:'Interface-Browsers'
    29         poolDictionaries:''
       
    30         category:'Interface-Browsers'
    30 !
    31 !
    31 
    32 
    32 !FileBrowser class methodsFor:'documentation'!
    33 !FileBrowser class methodsFor:'documentation'!
    33 
    34 
    34 copyright
    35 copyright
    35 "
    36 "
    36  COPYRIGHT (c) 1991 by Claus Gittinger
    37  COPYRIGHT (c) 1991 by Claus Gittinger
    37 	      All Rights Reserved
    38               All Rights Reserved
    38 
    39 
    39  This software is furnished under a license and may be used
    40  This software is furnished under a license and may be used
    40  only in accordance with the terms of that license and with the
    41  only in accordance with the terms of that license and with the
    41  inclusion of the above copyright notice.   This software may not
    42  inclusion of the above copyright notice.   This software may not
    42  be provided or otherwise made available to, or used by, any
    43  be provided or otherwise made available to, or used by, any
    56     were not available)
    57     were not available)
    57 
    58 
    58     See additional information in 'doc/misc/fbrowser.doc'.
    59     See additional information in 'doc/misc/fbrowser.doc'.
    59 
    60 
    60     WARNING: files edited with FileBrowser will have leading spaces (multiple-8)
    61     WARNING: files edited with FileBrowser will have leading spaces (multiple-8)
    61 	     being replaced by tabs. If tabs are to be preserved at other
    62              being replaced by tabs. If tabs are to be preserved at other
    62 	     positions (for example, sendmail-config files) they will be
    63              positions (for example, sendmail-config files) they will be
    63 	     corrupt after being written.
    64              corrupt after being written.
    64 
    65 
    65     [instance variables]:
    66     [instance variables]:
    66 
    67 
    67 	checkDelta      <Integer>       number of seconds of check interval
    68         checkDelta      <Integer>       number of seconds of check interval
    68 					(looks ever so often if shown directory
    69                                         (looks ever so often if shown directory
    69 					 has changed). You may make this number
    70                                          has changed). You may make this number
    70 					higher, if your network-times are
    71                                         higher, if your network-times are
    71 					incorrect and thus, the filebrowser
    72                                         incorrect and thus, the filebrowser
    72 					checks too often.
    73                                         checks too often.
    73 
    74 
    74 	compressTabs    <Boolean>       if true, leading spaces will be
    75         compressTabs    <Boolean>       if true, leading spaces will be
    75 					replaced by tabs when saving text
    76                                         replaced by tabs when saving text
    76 
    77 
    77     some of the defaults (long/short list etc.) can be set by the resource file;
    78     some of the defaults (long/short list etc.) can be set by the resource file;
    78     see FileBrowser>>initialize for more details..
    79     see FileBrowser>>initialize for more details..
    79 
    80 
    80     [author:]
    81     [author:]
    81 	Claus Gittinger
    82         Claus Gittinger
    82 
    83 
    83     [start with:]
    84     [start with:]
    84 	FileBrowser open
    85         FileBrowser open
    85 "
    86 "
    86 ! !
    87 ! !
    87 
    88 
    88 !FileBrowser class methodsFor:'instance creation'!
    89 !FileBrowser class methodsFor:'instance creation'!
    89 
    90 
   145      FileBrowser openOnFileNamed:'../Makefile'
   146      FileBrowser openOnFileNamed:'../Makefile'
   146      FileBrowser openOnFileNamed:'/tmp/foo'
   147      FileBrowser openOnFileNamed:'/tmp/foo'
   147     "
   148     "
   148 
   149 
   149     "Modified: / 17.6.1998 / 11:25:29 / cg"
   150     "Modified: / 17.6.1998 / 11:25:29 / cg"
   150 ! !
       
   151 
       
   152 !FileBrowser class methodsFor:'aspects'!
       
   153 
       
   154 hasVisitHistory
       
   155     ^ [DirectoryHistory size > 0]
       
   156 
       
   157     "Created: / 14.8.1998 / 19:17:02 / cg"
       
   158     "Modified: / 14.8.1998 / 19:17:17 / cg"
       
   159 ! !
   151 ! !
   160 
   152 
   161 !FileBrowser class methodsFor:'class initialization'!
   153 !FileBrowser class methodsFor:'class initialization'!
   162 
   154 
   163 icons
   155 icons
   264 
   256 
   265 addToCommandHistory:aCommandString for:aFilename
   257 addToCommandHistory:aCommandString for:aFilename
   266     |cmd suffix|
   258     |cmd suffix|
   267 
   259 
   268     (aCommandString notNil and:[aCommandString notEmpty]) ifTrue:[
   260     (aCommandString notNil and:[aCommandString notEmpty]) ifTrue:[
   269 	CommandHistory notNil ifTrue:[
   261         CommandHistory notNil ifTrue:[
   270 	    CommandHistory addFirst:aCommandString.
   262             CommandHistory addFirst:aCommandString.
   271 	    CommandHistory size > CommandHistorySize ifTrue:[
   263             CommandHistory size > CommandHistorySize ifTrue:[
   272 		CommandHistory removeLast
   264                 CommandHistory removeLast
   273 	    ]
   265             ]
   274 	].
   266         ].
   275 	aFilename notNil ifTrue:[
   267         aFilename notNil ifTrue:[
   276 	    cmd := aCommandString copyTo:(aCommandString indexOf:Character space ifAbsent:[aCommandString size + 1])-1.
   268             cmd := aCommandString copyTo:(aCommandString indexOf:Character space ifAbsent:[aCommandString size + 1])-1.
   277 	    DefaultCommandPerSuffix isNil ifTrue:[
   269             DefaultCommandPerSuffix isNil ifTrue:[
   278 		DefaultCommandPerSuffix := Dictionary new.
   270                 DefaultCommandPerSuffix := Dictionary new.
   279 	    ].
   271             ].
   280 	    suffix := aFilename asFilename suffix.
   272             suffix := aFilename asFilename suffix.
   281 	    suffix notNil ifTrue:[
   273             suffix notNil ifTrue:[
   282 		DefaultCommandPerSuffix at:suffix put:cmd.
   274                 DefaultCommandPerSuffix at:suffix put:cmd.
   283 	    ]
   275             ]
   284 	]
   276         ]
   285     ]
   277     ]
   286 
   278 
   287     "Created: 14.11.1996 / 14:58:13 / cg"
   279     "Created: 14.11.1996 / 14:58:13 / cg"
   288 !
   280 !
   289 
   281 
   343     <resource: #canvas>
   335     <resource: #canvas>
   344 
   336 
   345     ^
   337     ^
   346      
   338      
   347        #(#FullSpec
   339        #(#FullSpec
   348 	  #window: 
   340           #window: 
   349 	   #(#WindowSpec
   341            #(#WindowSpec
   350 	      #name: 'File Search'
   342               #name: 'File Search'
   351 	      #layout: #(#LayoutFrame 4 0 50 0 315 0 349 0)
   343               #layout: #(#LayoutFrame 4 0 50 0 315 0 349 0)
   352 	      #level: 0
   344               #level: 0
   353 	      #label: 'File Search'
   345               #label: 'File Search'
   354 	      #min: #(#Point 10 10)
   346               #min: #(#Point 10 10)
   355 	      #max: #(#Point 1280 1024)
   347               #max: #(#Point 1280 1024)
   356 	      #bounds: #(#Rectangle 4 50 316 350)
   348               #bounds: #(#Rectangle 4 50 316 350)
   357 	      #usePreferredExtent: false
   349               #usePreferredExtent: false
   358 	      #returnIsOKInDialog: true
   350               #returnIsOKInDialog: true
   359 	      #escapeIsCancelInDialog: true
   351               #escapeIsCancelInDialog: true
   360 	  )
   352           )
   361 	  #component: 
   353           #component: 
   362 	   #(#SpecCollection
   354            #(#SpecCollection
   363 	      #collection: 
   355               #collection: 
   364 	       #(
   356                #(
   365 		 #(#LabelSpec
   357                  #(#LabelSpec
   366 		    #name: 'Label1'
   358                     #name: 'Label1'
   367 		    #layout: #(#LayoutFrame 0 0 10 0 0 1 32 0)
   359                     #layout: #(#LayoutFrame 0 0 10 0 0 1 32 0)
   368 		    #label: 'Search for files named:'
   360                     #label: 'Search for files named:'
   369 		    #translateLabel: true
   361                     #translateLabel: true
   370 		    #adjust: #left
   362                     #adjust: #left
   371 		)
   363                 )
   372 		 #(#InputFieldSpec
   364                  #(#InputFieldSpec
   373 		    #name: 'EntryField1'
   365                     #name: 'EntryField1'
   374 		    #layout: #(#LayoutFrame 10 0 36 0 305 0 58 0)
   366                     #layout: #(#LayoutFrame 10 0 36 0 305 0 58 0)
   375 		    #tabable: true
   367                     #tabable: true
   376 		    #model: #namePatternHolder
   368                     #model: #namePatternHolder
   377 		)
   369                 )
   378 		 #(#CheckBoxSpec
   370                  #(#CheckBoxSpec
   379 		    #name: 'CheckBox1'
   371                     #name: 'CheckBox1'
   380 		    #layout: #(#LayoutFrame 7 0 66 0 143 0 88 0)
   372                     #layout: #(#LayoutFrame 7 0 66 0 143 0 88 0)
   381 		    #tabable: true
   373                     #tabable: true
   382 		    #model: #ignoreCaseInName
   374                     #model: #ignoreCaseInName
   383 		    #label: 'Ignore case'
   375                     #label: 'Ignore case'
   384 		    #translateLabel: true
   376                     #translateLabel: true
   385 		)
   377                 )
   386 		 #(#LabelSpec
   378                  #(#LabelSpec
   387 		    #name: 'Label2'
   379                     #name: 'Label2'
   388 		    #layout: #(#LayoutFrame 0 0.0 107 0 0 1.0 129 0)
   380                     #layout: #(#LayoutFrame 0 0.0 107 0 0 1.0 129 0)
   389 		    #label: 'Containing the string:'
   381                     #label: 'Containing the string:'
   390 		    #translateLabel: true
   382                     #translateLabel: true
   391 		    #adjust: #left
   383                     #adjust: #left
   392 		)
   384                 )
   393 		 #(#InputFieldSpec
   385                  #(#InputFieldSpec
   394 		    #name: 'EntryField2'
   386                     #name: 'EntryField2'
   395 		    #layout: #(#LayoutFrame 10 0 133 0 305 0 155 0)
   387                     #layout: #(#LayoutFrame 10 0 133 0 305 0 155 0)
   396 		    #enableChannel: #notSearchForSameContents
   388                     #enableChannel: #notSearchForSameContents
   397 		    #tabable: true
   389                     #tabable: true
   398 		    #model: #contentsPatternHolder
   390                     #model: #contentsPatternHolder
   399 		)
   391                 )
   400 		 #(#CheckBoxSpec
   392                  #(#CheckBoxSpec
   401 		    #name: 'CheckBox2'
   393                     #name: 'CheckBox2'
   402 		    #layout: #(#LayoutFrame 6 0 163 0 142 0 185 0)
   394                     #layout: #(#LayoutFrame 6 0 163 0 142 0 185 0)
   403 		    #enableChannel: #notSearchForSameContents
   395                     #enableChannel: #notSearchForSameContents
   404 		    #tabable: true
   396                     #tabable: true
   405 		    #model: #ignoreCaseInContents
   397                     #model: #ignoreCaseInContents
   406 		    #label: 'Ignore case'
   398                     #label: 'Ignore case'
   407 		    #translateLabel: true
   399                     #translateLabel: true
   408 		)
   400                 )
   409 		 #(#LabelSpec
   401                  #(#LabelSpec
   410 		    #name: 'Label3'
   402                     #name: 'Label3'
   411 		    #layout: #(#LayoutFrame 0 0.0 223 0 -30 1.0 245 0)
   403                     #layout: #(#LayoutFrame 0 0.0 223 0 -30 1.0 245 0)
   412 		    #label: 'Containing same contents as selected:'
   404                     #label: 'Containing same contents as selected:'
   413 		    #translateLabel: true
   405                     #translateLabel: true
   414 		    #adjust: #left
   406                     #adjust: #left
   415 		)
   407                 )
   416 		 #(#DividerSpec
   408                  #(#DividerSpec
   417 		    #name: 'Separator1'
   409                     #name: 'Separator1'
   418 		    #layout: #(#LayoutFrame 0 0.0 97 0 0 1.0 101 0)
   410                     #layout: #(#LayoutFrame 0 0.0 97 0 0 1.0 101 0)
   419 		)
   411                 )
   420 		 #(#CheckToggleSpec
   412                  #(#CheckToggleSpec
   421 		    #name: 'CheckToggle1'
   413                     #name: 'CheckToggle1'
   422 		    #layout: #(#LayoutOrigin -25 1 225 0)
   414                     #layout: #(#LayoutOrigin -25 1 225 0)
   423 		    #tabable: true
   415                     #tabable: true
   424 		    #model: #searchForSameContents
   416                     #model: #searchForSameContents
   425 		    #enableChannel: #searchForSameContentsEnabled
   417                     #enableChannel: #searchForSameContentsEnabled
   426 		    #isTriggerOnDown: true
   418                     #isTriggerOnDown: true
   427 		    #showLamp: false
   419                     #showLamp: false
   428 		    #lampColor: #(#Color 100.0 100.0 0.0)
   420                     #lampColor: #(#Color 100.0 100.0 0.0)
   429 		)
   421                 )
   430 		 #(#HorizontalPanelViewSpec
   422                  #(#HorizontalPanelViewSpec
   431 		    #name: 'HorizontalPanel1'
   423                     #name: 'HorizontalPanel1'
   432 		    #layout: #(#LayoutFrame 0 0.0 -30 1 0 1.0 0 1.0)
   424                     #layout: #(#LayoutFrame 0 0.0 -30 1 0 1.0 0 1.0)
   433 		    #component: 
   425                     #component: 
   434 		     #(#SpecCollection
   426                      #(#SpecCollection
   435 			#collection: 
   427                         #collection: 
   436 			 #(
   428                          #(
   437 			   #(#ActionButtonSpec
   429                            #(#ActionButtonSpec
   438 			      #name: 'Button1'
   430                               #name: 'Button1'
   439 			      #label: 'Cancel'
   431                               #label: 'Cancel'
   440 			      #translateLabel: true
   432                               #translateLabel: true
   441 			      #tabable: true
   433                               #tabable: true
   442 			      #model: #cancel
   434                               #model: #cancel
   443 			      #extent: #(#Point 151 25)
   435                               #extent: #(#Point 151 25)
   444 			  )
   436                           )
   445 			   #(#ActionButtonSpec
   437                            #(#ActionButtonSpec
   446 			      #name: 'Button2'
   438                               #name: 'Button2'
   447 			      #label: 'Search'
   439                               #label: 'Search'
   448 			      #translateLabel: true
   440                               #translateLabel: true
   449 			      #tabable: true
   441                               #tabable: true
   450 			      #model: #accept
   442                               #model: #accept
   451 			      #isDefault: true
   443                               #isDefault: true
   452 			      #extent: #(#Point 152 25)
   444                               #extent: #(#Point 152 25)
   453 			  )
   445                           )
   454 			)
   446                         )
   455 		    )
   447                     )
   456 		    #horizontalLayout: #fitSpace
   448                     #horizontalLayout: #fitSpace
   457 		    #verticalLayout: #centerMax
   449                     #verticalLayout: #centerMax
   458 		    #horizontalSpace: 3
   450                     #horizontalSpace: 3
   459 		    #verticalSpace: 3
   451                     #verticalSpace: 3
   460 		)
   452                 )
   461 	      )
   453               )
   462 	  )
   454           )
   463       )
   455       )
   464 ! !
   456 ! !
   465 
   457 
   466 !FileBrowser class methodsFor:'menu specs'!
   458 !FileBrowser class methodsFor:'menu specs'!
       
   459 
       
   460 baseBookmarksMenuSpec
       
   461     "This resource specification was automatically generated
       
   462      by the MenuEditor of ST/X."
       
   463 
       
   464     "Do not manually edit this!! If it is corrupted,
       
   465      the MenuEditor may not be able to read the specification."
       
   466 
       
   467     "
       
   468      MenuEditor new openOnClass:FileBrowser andSelector:#baseBookmarksMenuSpec
       
   469      (Menu new fromLiteralArrayEncoding:(FileBrowser baseBookmarksMenuSpec)) startUp
       
   470     "
       
   471 
       
   472     <resource: #menu>
       
   473 
       
   474     ^
       
   475      
       
   476        #(#Menu
       
   477           
       
   478            #(
       
   479              #(#MenuItem
       
   480                 #label: 'Add Bookmark'
       
   481                 #translateLabel: true
       
   482                 #value: #addBookmark
       
   483             )
       
   484              #(#MenuItem
       
   485                 #label: 'Remove Bookmark'
       
   486                 #translateLabel: true
       
   487                 #value: #removeBookmark
       
   488                 #enabled: #hasBookmarksToRemove
       
   489             )
       
   490           ) nil
       
   491           nil
       
   492       )
       
   493 
       
   494     "Created: / 4.8.1998 / 17:21:16 / cg"
       
   495     "Modified: / 14.8.1998 / 19:19:06 / cg"
       
   496 !
   467 
   497 
   468 baseDirectoryMenuSpec
   498 baseDirectoryMenuSpec
   469     "This resource specification was automatically generated
   499     "This resource specification was automatically generated
   470      by the MenuEditor of ST/X."
   500      by the MenuEditor of ST/X."
   471 
   501 
   481 
   511 
   482     ^
   512     ^
   483      
   513      
   484        #(#Menu
   514        #(#Menu
   485           
   515           
   486 	   #(
   516            #(
   487 	     #(#MenuItem
   517              #(#MenuItem
   488 		#label: 'Copy Path'
   518                 #label: 'Copy Path'
   489 		#translateLabel: true
   519                 #translateLabel: true
   490 		#value: #copyPath
   520                 #value: #copyPath
   491 	    )
   521             )
   492 	     #(#MenuItem
   522              #(#MenuItem
   493 		#label: '-'
   523                 #label: '-'
   494 	    )
   524             )
   495 	     #(#MenuItem
   525              #(#MenuItem
   496 		#label: 'Up'
   526                 #label: 'Up'
   497 		#translateLabel: true
   527                 #translateLabel: true
   498 		#value: #changeToParentDirectory
   528                 #value: #changeToParentDirectory
   499 		#enabled: #currentDirectoryIsNotTop
   529                 #enabled: #currentDirectoryIsNotTop
   500 	    )
   530             )
   501 	     #(#MenuItem
   531              #(#MenuItem
   502 		#label: 'Back'
   532                 #label: 'Back'
   503 		#translateLabel: true
   533                 #translateLabel: true
   504 		#value: #changeToPreviousDirectory
   534                 #value: #changeToPreviousDirectory
   505 	    )
   535             )
   506 	     #(#MenuItem
   536              #(#MenuItem
   507 		#label: 'Home'
   537                 #label: 'Home'
   508 		#translateLabel: true
   538                 #translateLabel: true
   509 		#value: #changeToHomeDirectory
   539                 #value: #changeToHomeDirectory
   510 	    )
   540             )
   511 	     #(#MenuItem
   541              #(#MenuItem
   512 		#label: 'Default'
   542                 #label: 'Default'
   513 		#translateLabel: true
   543                 #translateLabel: true
   514 		#value: #changeToDefaultDirectory
   544                 #value: #changeToDefaultDirectory
   515 	    )
   545             )
   516 	     #(#MenuItem
   546              #(#MenuItem
   517 		#label: 'Goto...'
   547                 #label: 'Goto...'
   518 		#translateLabel: true
   548                 #translateLabel: true
   519 		#value: #changeCurrentDirectory
   549                 #value: #changeCurrentDirectory
   520 	    )
   550             )
   521 	  ) nil
   551              #(#MenuItem
   522 	  nil
   552                 #label: '-'
       
   553             )
       
   554              #(#MenuItem
       
   555                 #label: 'History'
       
   556                 #translateLabel: true
       
   557                 #submenuChannel: #historyMenuSpec
       
   558               )
       
   559              #(#MenuItem
       
   560                 #label: 'Bookmarks'
       
   561                 #translateLabel: true
       
   562                 #submenuChannel: #bookmarksMenuSpec
       
   563               )
       
   564           ) nil
       
   565           nil
   523       )
   566       )
   524 
   567 
   525     "Created: / 4.8.1998 / 17:21:16 / cg"
   568     "Created: / 4.8.1998 / 17:21:16 / cg"
   526     "Modified: / 14.8.1998 / 19:19:06 / cg"
   569     "Modified: / 14.8.1998 / 19:19:06 / cg"
       
   570 !
       
   571 
       
   572 bookmarksMenuSpec
       
   573     "This resource specification was automatically generated
       
   574      by the MenuEditor of ST/X."
       
   575 
       
   576     "Do not manually edit this!! If it is corrupted,
       
   577      the MenuEditor may not be able to read the specification."
       
   578 
       
   579     "
       
   580      MenuEditor new openOnClass:FileBrowser andSelector:#bookmarksMenuSpec
       
   581      (Menu new fromLiteralArrayEncoding:(FileBrowser bookmarksMenuSpec)) startUp
       
   582     "
       
   583 
       
   584     <resource: #programMenu>
       
   585 
       
   586     |m|
       
   587 
       
   588     m := self baseBookmarksMenuSpec.
       
   589     m := m decodeAsLiteralArray.
       
   590 
       
   591     "/ add the history items ...
       
   592 
       
   593     DirectoryBookmarks size > 0 ifTrue:[
       
   594         m addItem:(MenuItem labeled:'-').
       
   595         DirectoryBookmarks do:[:dirName |
       
   596             m addItem:((MenuItem label:dirName value:#changeDirectoryTo:)
       
   597                             argument:dirName;
       
   598                             yourself).
       
   599         ].
       
   600     ].
       
   601 
       
   602     "/ m receiver:self.
       
   603     m findGuiResourcesIn:self.
       
   604     ^ m
       
   605 
       
   606     "Modified: / 17.8.1998 / 10:13:05 / cg"
   527 !
   607 !
   528 
   608 
   529 directoryMenuSpec
   609 directoryMenuSpec
   530     "This resource specification was automatically generated
   610     "This resource specification was automatically generated
   531      by the MenuEditor of ST/X."
   611      by the MenuEditor of ST/X."
   536     "
   616     "
   537      MenuEditor new openOnClass:FileBrowser andSelector:#directoryMenuSpec
   617      MenuEditor new openOnClass:FileBrowser andSelector:#directoryMenuSpec
   538      (Menu new fromLiteralArrayEncoding:(FileBrowser directoryMenuSpec)) startUp
   618      (Menu new fromLiteralArrayEncoding:(FileBrowser directoryMenuSpec)) startUp
   539     "
   619     "
   540 
   620 
       
   621     <resource: #menu>
       
   622 
       
   623     ^
       
   624      
       
   625        #(#Menu
       
   626           
       
   627            #(
       
   628              #(#MenuItem
       
   629                 #label: 'Copy Path'
       
   630                 #translateLabel: true
       
   631                 #value: #copyPath
       
   632             )
       
   633              #(#MenuItem
       
   634                 #label: '-'
       
   635             )
       
   636              #(#MenuItem
       
   637                 #label: 'Up'
       
   638                 #translateLabel: true
       
   639                 #value: #changeToParentDirectory
       
   640                 #enabled: #currentDirectoryIsNotTop
       
   641             )
       
   642              #(#MenuItem
       
   643                 #label: 'Goto...'
       
   644                 #translateLabel: true
       
   645                 #value: #changeCurrentDirectory
       
   646             )
       
   647              #(#MenuItem
       
   648                 #label: '-'
       
   649             )
       
   650              #(#MenuItem
       
   651                 #label: 'Back'
       
   652                 #translateLabel: true
       
   653                 #value: #changeToPreviousDirectory
       
   654             )
       
   655              #(#MenuItem
       
   656                 #label: 'History'
       
   657                 #translateLabel: true
       
   658                 #submenuChannel: #historyMenuSpec
       
   659               )
       
   660              #(#MenuItem
       
   661                 #label: '-'
       
   662             )
       
   663              #(#MenuItem
       
   664                 #label: 'Default'
       
   665                 #translateLabel: true
       
   666                 #value: #changeToDefaultDirectory
       
   667             )
       
   668              #(#MenuItem
       
   669                 #label: 'Home'
       
   670                 #translateLabel: true
       
   671                 #value: #changeToHomeDirectory
       
   672             )
       
   673              #(#MenuItem
       
   674                 #label: 'Bookmarks'
       
   675                 #translateLabel: true
       
   676                 #submenuChannel: #bookmarksMenuSpec
       
   677               )
       
   678           ) nil
       
   679           nil
       
   680       )
       
   681 
       
   682     "Created: / 4.8.1998 / 17:21:16 / cg"
       
   683     "Modified: / 14.8.1998 / 19:19:06 / cg"
       
   684 !
       
   685 
       
   686 historyMenuSpec
       
   687     "This resource specification was automatically generated
       
   688      by the MenuEditor of ST/X."
       
   689 
       
   690     "Do not manually edit this!! If it is corrupted,
       
   691      the MenuEditor may not be able to read the specification."
       
   692 
       
   693     "
       
   694      MenuEditor new openOnClass:FileBrowser andSelector:#directoryMenuSpec
       
   695      (Menu new fromLiteralArrayEncoding:(FileBrowser directoryMenuSpec)) startUp
       
   696     "
       
   697 
   541     <resource: #programMenu>
   698     <resource: #programMenu>
   542 
   699 
   543     |m|
   700     |m|
   544 
   701 
   545     m := self baseDirectoryMenuSpec.
       
   546     m := m decodeAsLiteralArray.
       
   547 
       
   548     "/ add the history items ...
   702     "/ add the history items ...
   549 
   703 
   550     DirectoryHistory size > 0 ifTrue:[
   704     DirectoryHistory size > 0 ifTrue:[
   551 	m addItem:(MenuItem labeled:'-').
   705         m := Menu new.
   552 	DirectoryHistory do:[:dirName |
   706 
   553 	    m addItem:((MenuItem label:dirName value:#changeDirectoryTo:)
   707         DirectoryHistory do:[:dirName |
   554 			    argument:dirName;
   708             m addItem:((MenuItem label:dirName value:#changeDirectoryTo:)
   555 			    yourself).
   709                             argument:dirName;
   556 	].
   710                             yourself).
       
   711         ].
   557     ].
   712     ].
   558 
   713 
   559     m findGuiResourcesIn:self.
   714     m findGuiResourcesIn:self.
   560     ^ m
   715     ^ m
   561 
   716 
   907             #translateLabel: true
  1062             #translateLabel: true
   908             #submenu: 
  1063             #submenu: 
   909            #(#Menu
  1064            #(#Menu
   910               #(
  1065               #(
   911                #(#MenuItem
  1066                #(#MenuItem
   912                   #label: 'Details'
  1067                   #label: 'Show Details'
   913                   #translateLabel: true
  1068                   #translateLabel: true
   914                   #indication: #showingDetails
  1069                   #indication: #showingDetails
       
  1070                 )
       
  1071                #(#MenuItem
       
  1072                   #label: 'Show Time && Date'
       
  1073                   #translateLabel: true
       
  1074                   #indication: #showingTimeAndDate
       
  1075                   #enabled: #showingDetails
   915                 )
  1076                 )
   916                #(#MenuItem
  1077                #(#MenuItem
   917                   #label: 'Show Hidden Files'
  1078                   #label: 'Show Hidden Files'
   918                   #translateLabel: true
  1079                   #translateLabel: true
   919                   #indication: #showingHiddenFiles
  1080                   #indication: #showingHiddenFiles
   920                 )
  1081                 )
   921                #(#MenuItem
  1082                #(#MenuItem
   922                   #label: 'Big Image Preview'
  1083                   #label: 'Show Big Image Preview'
   923                   #translateLabel: true
  1084                   #translateLabel: true
   924                   #indication: #showingBigImagePreview
  1085                   #indication: #showingBigImagePreview
   925                 )
  1086                 )
   926                #(#MenuItem
  1087                #(#MenuItem
   927                   #label: '-'
  1088                   #label: '-'
   943                   #translateLabel: true
  1104                   #translateLabel: true
   944                   #choice: #sortByWhat
  1105                   #choice: #sortByWhat
   945                   #choiceValue: #time
  1106                   #choiceValue: #time
   946                 )
  1107                 )
   947                #(#MenuItem
  1108                #(#MenuItem
   948                   #label: 'Ignore Case'
  1109                   #label: 'Ignore Case in Sort'
   949                   #translateLabel: true
  1110                   #translateLabel: true
   950                   #indication: #sortCaseless
  1111                   #indication: #sortCaseless
   951                 )
  1112                 )
   952                #(#MenuItem
  1113                #(#MenuItem
   953                   #label: '-'
  1114                   #label: '-'
  1365 !
  1526 !
  1366 
  1527 
  1367 canRemoveCVSContainer
  1528 canRemoveCVSContainer
  1368     ^ [ |cvsDir|
  1529     ^ [ |cvsDir|
  1369 
  1530 
  1370 	currentDirectory notNil
  1531         currentDirectory notNil
  1371 	and:[fileListView selection size > 0
  1532         and:[fileListView selection size > 0
  1372 	and:[(cvsDir := currentDirectory construct:'CVS') exists
  1533         and:[(cvsDir := currentDirectory construct:'CVS') exists
  1373 	and:[cvsDir isDirectory]]]]
  1534         and:[cvsDir isDirectory]]]]
  1374 !
  1535 !
  1375 
  1536 
  1376 canRemoveFromClassPath
  1537 canRemoveFromClassPath
  1377     ^ [ |f|
  1538     ^ [ |f|
  1378 
  1539 
  1434     ^ [ fileListView selection size > 0
  1595     ^ [ fileListView selection size > 0
  1435         and:[OSI::ASN1Parser notNil 
  1596         and:[OSI::ASN1Parser notNil 
  1436         and:[OSI::ASN1Parser isLoaded]]]
  1597         and:[OSI::ASN1Parser isLoaded]]]
  1437 !
  1598 !
  1438 
  1599 
       
  1600 hasBookmarks
       
  1601     ^ DirectoryBookmarks size > 0
       
  1602 
       
  1603     "Created: / 14.8.1998 / 19:17:02 / cg"
       
  1604     "Modified: / 14.8.1998 / 19:17:17 / cg"
       
  1605 !
       
  1606 
       
  1607 hasBookmarksToRemove
       
  1608     ^ DirectoryBookmarks size > 0
       
  1609       and:[ DirectoryBookmarks includes:(currentDirectory asFilename pathName) ]
       
  1610 
       
  1611     "Created: / 14.8.1998 / 19:17:02 / cg"
       
  1612     "Modified: / 14.8.1998 / 19:17:17 / cg"
       
  1613 !
       
  1614 
  1439 hasCBrowser
  1615 hasCBrowser
  1440     ^ [ CC::Browser notNil ]
  1616     ^ [ CC::Browser notNil ]
  1441 
  1617 
  1442 !
  1618 !
  1443 
  1619 
  1444 hasFilenameSelectionInCodeView
  1620 hasFilenameSelectionInCodeView
  1445     ^ [ |val sel|
  1621     ^ [ |val sel|
  1446 
  1622 
  1447 	val := false.
  1623         val := false.
  1448 	sel := subView selection.
  1624         sel := subView selection.
  1449 	sel notNil ifTrue:[
  1625         sel notNil ifTrue:[
  1450 	    sel := sel asString withoutSeparators.
  1626             sel := sel asString withoutSeparators.
  1451 	    sel asFilename exists ifTrue:[
  1627             sel asFilename exists ifTrue:[
  1452 		val := sel asFilename isReadable
  1628                 val := sel asFilename isReadable
  1453 	    ]
  1629             ]
  1454 	].
  1630         ].
  1455 	val
  1631         val
  1456     ]
  1632     ]
  1457 
  1633 
  1458     "Created: / 4.2.1999 / 17:34:57 / cg"
  1634     "Created: / 4.2.1999 / 17:34:57 / cg"
  1459     "Modified: / 4.2.1999 / 17:39:32 / cg"
  1635     "Modified: / 4.2.1999 / 17:39:32 / cg"
  1460 !
  1636 !
  1461 
  1637 
  1462 hasJava
  1638 hasJava
  1463     ^ [ JavaClassReader notNil 
  1639     ^ [ JavaClassReader notNil 
  1464 	and:[JavaClassReader isLoaded]]
  1640         and:[JavaClassReader isLoaded]]
  1465 
  1641 
  1466     "Modified: / 17.10.1998 / 16:57:14 / cg"
  1642     "Modified: / 17.10.1998 / 16:57:14 / cg"
  1467     "Created: / 17.10.1998 / 22:58:25 / cg"
  1643     "Created: / 17.10.1998 / 22:58:25 / cg"
  1468 !
  1644 !
  1469 
  1645 
  1470 hasJavaAndSelection
  1646 hasJavaAndSelection
  1471     ^ [ fileListView selection size > 0
  1647     ^ [ fileListView selection size > 0
  1472 	and:[JavaClassReader notNil 
  1648         and:[JavaClassReader notNil 
  1473 	and:[JavaClassReader isLoaded]]]
  1649         and:[JavaClassReader isLoaded]]]
  1474 
  1650 
  1475     "Modified: / 17.10.1998 / 16:57:14 / cg"
  1651     "Modified: / 17.10.1998 / 16:57:14 / cg"
  1476     "Created: / 17.10.1998 / 22:58:03 / cg"
  1652     "Created: / 17.10.1998 / 22:58:03 / cg"
  1477 !
  1653 !
  1478 
  1654 
  1501 
  1677 
  1502     "Created: / 4.8.1998 / 14:10:31 / cg"
  1678     "Created: / 4.8.1998 / 14:10:31 / cg"
  1503     "Modified: / 4.8.1998 / 14:10:57 / cg"
  1679     "Modified: / 4.8.1998 / 14:10:57 / cg"
  1504 !
  1680 !
  1505 
  1681 
       
  1682 hasVisitHistory
       
  1683     ^ [DirectoryHistory size > 0]
       
  1684 
       
  1685     "Created: / 14.8.1998 / 19:17:02 / cg"
       
  1686     "Modified: / 14.8.1998 / 19:17:17 / cg"
       
  1687 !
       
  1688 
  1506 hasZipFileSelected
  1689 hasZipFileSelected
  1507     ^ [|sel f fn suff|
  1690     ^ [|sel f fn suff|
  1508 
  1691 
  1509 	sel := fileListView selection.
  1692         sel := fileListView selection.
  1510 	sel size == 1 ifTrue:[
  1693         sel size == 1 ifTrue:[
  1511 	    f := fileList at:sel first ifAbsent:nil.
  1694             f := fileList at:sel first ifAbsent:nil.
  1512 	    f notNil ifTrue:[
  1695             f notNil ifTrue:[
  1513 		suff := f asFilename suffix asLowercase.
  1696                 suff := f asFilename suffix asLowercase.
  1514 		suff = 'zip' or:[suff = 'jar']
  1697                 suff = 'zip' or:[suff = 'jar']
  1515 	    ] ifFalse:[
  1698             ] ifFalse:[
  1516 		false
  1699                 false
  1517 	    ]
  1700             ]
  1518 	] ifFalse:[
  1701         ] ifFalse:[
  1519 	    false
  1702             false
  1520 	]
  1703         ]
  1521       ]
  1704       ]
  1522 
  1705 
  1523     "Created: / 26.8.1998 / 16:15:26 / cg"
  1706     "Created: / 26.8.1998 / 16:15:26 / cg"
  1524     "Modified: / 30.1.1999 / 19:05:59 / cg"
  1707     "Modified: / 30.1.1999 / 19:05:59 / cg"
  1525 !
  1708 !
  1526 
  1709 
  1527 javaSupportLoaded
  1710 javaSupportLoaded
  1528     ^ [ JavaClassReader notNil 
  1711     ^ [ JavaClassReader notNil 
  1529 	and:[JavaClassReader isLoaded]]
  1712         and:[JavaClassReader isLoaded]]
  1530 
  1713 
  1531     "Created: / 9.11.1998 / 05:33:17 / cg"
  1714     "Created: / 9.11.1998 / 05:33:17 / cg"
  1532 !
  1715 !
  1533 
  1716 
  1534 showingBigImagePreview
  1717 showingBigImagePreview
  1543     "Created: / 14.8.1998 / 14:15:15 / cg"
  1726     "Created: / 14.8.1998 / 14:15:15 / cg"
  1544 !
  1727 !
  1545 
  1728 
  1546 showingHiddenFiles
  1729 showingHiddenFiles
  1547     ^ showingHiddenFiles
  1730     ^ showingHiddenFiles
       
  1731 
       
  1732     "Created: / 14.8.1998 / 14:15:44 / cg"
       
  1733 !
       
  1734 
       
  1735 showingTimeAndDate
       
  1736     ^ showingTimeAndDate
  1548 
  1737 
  1549     "Created: / 14.8.1998 / 14:15:44 / cg"
  1738     "Created: / 14.8.1998 / 14:15:44 / cg"
  1550 !
  1739 !
  1551 
  1740 
  1552 singleSelectedFile
  1741 singleSelectedFile
  1617 
  1806 
  1618 canDrop:aCollectionOfDropObjects
  1807 canDrop:aCollectionOfDropObjects
  1619     "I accept fileObjects only"
  1808     "I accept fileObjects only"
  1620 
  1809 
  1621     aCollectionOfDropObjects do:[:aDropObject |
  1810     aCollectionOfDropObjects do:[:aDropObject |
  1622 	aDropObject isFileObject ifFalse:[
  1811         aDropObject isFileObject ifFalse:[
  1623 	    aDropObject isTextObject ifFalse:[^ false].
  1812             aDropObject isTextObject ifFalse:[^ false].
  1624 	]
  1813         ]
  1625     ].
  1814     ].
  1626     ^ true
  1815     ^ true
  1627 
  1816 
  1628     "Modified: 11.4.1997 / 12:41:59 / cg"
  1817     "Modified: 11.4.1997 / 12:41:59 / cg"
  1629 !
  1818 !
  1653      If its text, paste it into the codeView."
  1842      If its text, paste it into the codeView."
  1654 
  1843 
  1655     |newDir newFile|
  1844     |newDir newFile|
  1656 
  1845 
  1657     someObject isFileObject ifTrue:[
  1846     someObject isFileObject ifTrue:[
  1658 	someObject isDirectory ifTrue:[
  1847         someObject isDirectory ifTrue:[
  1659 	    newDir := someObject theObject pathName.
  1848             newDir := someObject theObject pathName.
  1660 	] ifFalse:[
  1849         ] ifFalse:[
  1661 	    newDir := someObject theObject directoryName.
  1850             newDir := someObject theObject directoryName.
  1662 	    newFile := someObject theObject baseName.
  1851             newFile := someObject theObject baseName.
  1663 	].
  1852         ].
  1664 
  1853 
  1665 	newDir notNil ifTrue:[
  1854         newDir notNil ifTrue:[
  1666 	    newDir ~= currentDirectory pathName ifTrue:[
  1855             newDir ~= currentDirectory pathName ifTrue:[
  1667 		self changeDirectoryTo:newDir.
  1856                 self changeDirectoryTo:newDir.
  1668 	    ]
  1857             ]
  1669 	].
  1858         ].
  1670 	newFile notNil ifTrue:[
  1859         newFile notNil ifTrue:[
  1671 	    newFile ~= currentFileName ifTrue:[
  1860             newFile ~= currentFileName ifTrue:[
  1672 		fileListView selection:(fileList indexOf:newFile).
  1861                 fileListView selection:(fileList indexOf:newFile).
  1673 		self doFileGet:false.
  1862                 self doFileGet:false.
  1674 	    ]
  1863             ]
  1675 	].
  1864         ].
  1676 	^ self
  1865         ^ self
  1677     ].
  1866     ].
  1678 
  1867 
  1679     someObject isTextObject ifTrue:[
  1868     someObject isTextObject ifTrue:[
  1680 	subView paste:someObject theObject.
  1869         subView paste:someObject theObject.
  1681 	^ self
  1870         ^ self
  1682     ].
  1871     ].
  1683 
  1872 
  1684     "Modified: 6.4.1997 / 14:46:44 / cg"
  1873     "Modified: 6.4.1997 / 14:46:44 / cg"
  1685 ! !
  1874 ! !
  1686 
  1875 
  1795     |wasVisible|
  1984     |wasVisible|
  1796 
  1985 
  1797     wasVisible := shown.
  1986     wasVisible := shown.
  1798     super visibilityChange:how.
  1987     super visibilityChange:how.
  1799     (wasVisible not and:[shown]) ifTrue:[
  1988     (wasVisible not and:[shown]) ifTrue:[
  1800 	"
  1989         "
  1801 	 start checking again
  1990          start checking again
  1802 	"
  1991         "
  1803 	Processor removeTimedBlock:checkBlock.
  1992         Processor removeTimedBlock:checkBlock.
  1804 	Processor addTimedBlock:checkBlock afterSeconds:checkDelta.
  1993         Processor addTimedBlock:checkBlock afterSeconds:checkDelta.
  1805     ]
  1994     ]
  1806 
  1995 
  1807     "Modified: / 18.2.1998 / 17:57:44 / cg"
  1996     "Modified: / 18.2.1998 / 17:57:44 / cg"
  1808 ! !
  1997 ! !
  1809 
  1998 
  1814 
  2003 
  1815     |fh|
  2004     |fh|
  1816 
  2005 
  1817     (showingBigImagePreview value == true 
  2006     (showingBigImagePreview value == true 
  1818     and:[showingDetails value == true]) ifTrue:[
  2007     and:[showingDetails value == true]) ifTrue:[
  1819 	fh := fileListView font height.
  2008         fh := fileListView font height.
  1820 	fileListView lineSpacing:(34 - fh max:0).
  2009         fileListView lineSpacing:(34 - fh max:0).
  1821     ] ifFalse:[
  2010     ] ifFalse:[
  1822 	fileListView clear.
  2011         fileListView clear.
  1823 	self updateCurrentDirectory.
  2012         self updateCurrentDirectory.
  1824 	fileListView lineSpacing:2.
  2013         fileListView lineSpacing:2.
  1825     ].
  2014     ].
  1826     fileListView clear.
  2015     fileListView clear.
  1827     self updateCurrentDirectory
  2016     self updateCurrentDirectory
  1828 
  2017 
  1829     "Modified: / 4.8.1998 / 13:43:54 / cg"
  2018     "Modified: / 4.8.1998 / 13:43:54 / cg"
  1927 
  2116 
  1928     dialog addAbortAndOkButtons.
  2117     dialog addAbortAndOkButtons.
  1929     dialog open.
  2118     dialog open.
  1930 
  2119 
  1931     dialog accepted ifTrue:[
  2120     dialog accepted ifTrue:[
  1932 	idx := list selectionIndex.
  2121         idx := list selectionIndex.
  1933 	fileEncoding := encodings at:idx.
  2122         fileEncoding := encodings at:idx.
  1934 	subView externalEncoding:fileEncoding.
  2123         subView externalEncoding:fileEncoding.
  1935 
  2124 
  1936 	self validateFontEncodingFor:fileEncoding ask:true.
  2125         self validateFontEncodingFor:fileEncoding ask:true.
  1937     ].
  2126     ].
  1938 
  2127 
  1939     "Modified: 30.6.1997 / 14:41:12 / cg"
  2128     "Modified: 30.6.1997 / 14:41:12 / cg"
  1940 !
  2129 !
  1941 
  2130 
  2071 
  2260 
  2072     |fileNames dir infoDir filesBySize
  2261     |fileNames dir infoDir filesBySize
  2073      result info dirPrefix|
  2262      result info dirPrefix|
  2074 
  2263 
  2075     (self askIfModified:'contents has not been saved.\\Modifications will be lost when you proceed.'
  2264     (self askIfModified:'contents has not been saved.\\Modifications will be lost when you proceed.'
  2076 	      yesButton:'proceed') ifFalse:[^ self].
  2265               yesButton:'proceed') ifFalse:[^ self].
  2077 
  2266 
  2078     self withWaitCursorDo:[
  2267     self withWaitCursorDo:[
  2079 	result := Dictionary new.
  2268         result := Dictionary new.
  2080 
  2269 
  2081 	dir := currentDirectory asFilename.
  2270         dir := currentDirectory asFilename.
  2082 	self label:myName , '- gathering file names ...'.
  2271         self label:myName , '- gathering file names ...'.
  2083 	fileNames := dir recursiveDirectoryContents.
  2272         fileNames := dir recursiveDirectoryContents.
  2084 	fileNames := fileNames collect:[:fn | dir construct:fn].
  2273         fileNames := fileNames collect:[:fn | dir construct:fn].
  2085 	fileNames := fileNames select:[:fn | fn isDirectory not].
  2274         fileNames := fileNames select:[:fn | fn isDirectory not].
  2086 
  2275 
  2087 	self label:myName , '- gathering sizes ...'.
  2276         self label:myName , '- gathering sizes ...'.
  2088 	infoDir := Dictionary new.
  2277         infoDir := Dictionary new.
  2089 	fileNames do:[:fn |
  2278         fileNames do:[:fn |
  2090 	    infoDir at:fn put:(fn fileSize)
  2279             infoDir at:fn put:(fn fileSize)
  2091 	].
  2280         ].
  2092 
  2281 
  2093 	"/ for each, get the files size.
  2282         "/ for each, get the files size.
  2094 	"/ in a first pass, look for files of the same size and
  2283         "/ in a first pass, look for files of the same size and
  2095 	"/ compare them ...
  2284         "/ compare them ...
  2096 
  2285 
  2097 	self label:myName , '- preselect possible duplicates ...'.
  2286         self label:myName , '- preselect possible duplicates ...'.
  2098 	filesBySize := Dictionary new.
  2287         filesBySize := Dictionary new.
  2099 	infoDir keysAndValuesDo:[:fn :sz |
  2288         infoDir keysAndValuesDo:[:fn :sz |
  2100 	    |entry|
  2289             |entry|
  2101 
  2290 
  2102 	    entry := filesBySize at:sz ifAbsentPut:[Set new].
  2291             entry := filesBySize at:sz ifAbsentPut:[Set new].
  2103 	    entry add:fn.
  2292             entry add:fn.
  2104 	].
  2293         ].
  2105 
  2294 
  2106 	"/ any of same size ?
  2295         "/ any of same size ?
  2107 
  2296 
  2108 	self label:myName , '- checking for duplicates ...'.
  2297         self label:myName , '- checking for duplicates ...'.
  2109 	filesBySize do:[:entry |
  2298         filesBySize do:[:entry |
  2110 	    |files|
  2299             |files|
  2111 
  2300 
  2112 	    entry size > 1 ifTrue:[
  2301             entry size > 1 ifTrue:[
  2113 		files := entry asArray.
  2302                 files := entry asArray.
  2114 		1 to:files size-1 do:[:idx1 |
  2303                 1 to:files size-1 do:[:idx1 |
  2115 		    idx1+1 to:files size do:[:idx2 |
  2304                     idx1+1 to:files size do:[:idx2 |
  2116 			|fn1 fn2|
  2305                         |fn1 fn2|
  2117 
  2306 
  2118 			fn1 := files at:idx1.
  2307                         fn1 := files at:idx1.
  2119 			fn2 := files at:idx2.
  2308                         fn2 := files at:idx2.
  2120 
  2309 
  2121 "/                        self label:myName , '- checking ' , fn1 baseName , ' vs. ' , fn2 baseName , ' ...'.
  2310 "/                        self label:myName , '- checking ' , fn1 baseName , ' vs. ' , fn2 baseName , ' ...'.
  2122 			(result at:fn2 ifAbsent:nil) ~= fn1 ifTrue:[
  2311                         (result at:fn2 ifAbsent:nil) ~= fn1 ifTrue:[
  2123 			    "/ compare the files
  2312                             "/ compare the files
  2124 			    (fn1 sameContentsAs:fn2) ifTrue:[
  2313                             (fn1 sameContentsAs:fn2) ifTrue:[
  2125 "/                                Transcript show:'Same: '; show:fn1 baseName; show:' and '; showCR:fn2 baseName.
  2314 "/                                Transcript show:'Same: '; show:fn1 baseName; show:' and '; showCR:fn2 baseName.
  2126 				result at:fn1 put:fn2.
  2315                                 result at:fn1 put:fn2.
  2127 			    ]
  2316                             ]
  2128 			]
  2317                         ]
  2129 		    ]
  2318                     ]
  2130 		]
  2319                 ]
  2131 	    ]
  2320             ]
  2132 	].
  2321         ].
  2133 
  2322 
  2134 	self label:myName , '- sorting ...'.
  2323         self label:myName , '- sorting ...'.
  2135 	dirPrefix := currentDirectory asFilename pathName.
  2324         dirPrefix := currentDirectory asFilename pathName.
  2136 	result := result associations.
  2325         result := result associations.
  2137 	result := result collect:[:assoc |
  2326         result := result collect:[:assoc |
  2138 					|f1 f2|
  2327                                         |f1 f2|
  2139 
  2328 
  2140 					f1 := assoc key name.
  2329                                         f1 := assoc key name.
  2141 					f2 := assoc value name.
  2330                                         f2 := assoc value name.
  2142 					(f1 startsWith:dirPrefix) ifTrue:[
  2331                                         (f1 startsWith:dirPrefix) ifTrue:[
  2143 					    f1 := f1 copyFrom:dirPrefix size + 2.
  2332                                             f1 := f1 copyFrom:dirPrefix size + 2.
  2144 					].
  2333                                         ].
  2145 					(f2 startsWith:dirPrefix) ifTrue:[
  2334                                         (f2 startsWith:dirPrefix) ifTrue:[
  2146 					    f2 := f2 copyFrom:dirPrefix size + 2.
  2335                                             f2 := f2 copyFrom:dirPrefix size + 2.
  2147 					].
  2336                                         ].
  2148 					f1 < f2 ifTrue:[
  2337                                         f1 < f2 ifTrue:[
  2149 					    f2 -> f1
  2338                                             f2 -> f1
  2150 					] ifFalse:[
  2339                                         ] ifFalse:[
  2151 					    f1 -> f2
  2340                                             f1 -> f2
  2152 					]
  2341                                         ]
  2153 				].
  2342                                 ].
  2154 	result sort:[:f1 :f2 | f2 value < f1 value].
  2343         result sort:[:f1 :f2 | f2 value < f1 value].
  2155 
  2344 
  2156 	info := OrderedCollection new.
  2345         info := OrderedCollection new.
  2157 	result do:[:assoc |
  2346         result do:[:assoc |
  2158 	    info add:(assoc key , ' same as ' , assoc value)
  2347             info add:(assoc key , ' same as ' , assoc value)
  2159 	].
  2348         ].
  2160 	info isEmpty ifTrue:[
  2349         info isEmpty ifTrue:[
  2161 	    info := 'No duplicate files found.'
  2350             info := 'No duplicate files found.'
  2162 	].
  2351         ].
  2163     ].
  2352     ].
  2164 
  2353 
  2165     subView contents:info.
  2354     subView contents:info.
  2166     self label:myName.
  2355     self label:myName.
  2167 
  2356 
  2174 
  2363 
  2175     |fileNames dir infoDir filesBySize
  2364     |fileNames dir infoDir filesBySize
  2176      result info|
  2365      result info|
  2177 
  2366 
  2178     (self askIfModified:'contents has not been saved.\\Modifications will be lost when you proceed.'
  2367     (self askIfModified:'contents has not been saved.\\Modifications will be lost when you proceed.'
  2179 	      yesButton:'proceed') ifFalse:[^ self].
  2368               yesButton:'proceed') ifFalse:[^ self].
  2180 
  2369 
  2181     self withWaitCursorDo:[
  2370     self withWaitCursorDo:[
  2182 	result := Dictionary new.
  2371         result := Dictionary new.
  2183 
  2372 
  2184 	dir := currentDirectory asFilename.
  2373         dir := currentDirectory asFilename.
  2185 	fileNames := dir directoryContents.
  2374         fileNames := dir directoryContents.
  2186 	fileNames := fileNames collect:[:fn | dir construct:fn].
  2375         fileNames := fileNames collect:[:fn | dir construct:fn].
  2187 	fileNames := fileNames select:[:fn | fn isDirectory not].
  2376         fileNames := fileNames select:[:fn | fn isDirectory not].
  2188 
  2377 
  2189 	infoDir := Dictionary new.
  2378         infoDir := Dictionary new.
  2190 	fileNames do:[:fn |
  2379         fileNames do:[:fn |
  2191 	    infoDir at:fn put:(fn info)
  2380             infoDir at:fn put:(fn info)
  2192 	].
  2381         ].
  2193 
  2382 
  2194 	"/ for each, get the files size.
  2383         "/ for each, get the files size.
  2195 	"/ in a first pass, look for files of the same size and
  2384         "/ in a first pass, look for files of the same size and
  2196 	"/ compare them ...
  2385         "/ compare them ...
  2197 
  2386 
  2198 	filesBySize := Dictionary new.
  2387         filesBySize := Dictionary new.
  2199 	infoDir keysAndValuesDo:[:fn :info |
  2388         infoDir keysAndValuesDo:[:fn :info |
  2200 	    |sz entry|
  2389             |sz entry|
  2201 
  2390 
  2202 	    sz := info size.
  2391             sz := info size.
  2203 	    entry := filesBySize at:sz ifAbsentPut:[Set new].
  2392             entry := filesBySize at:sz ifAbsentPut:[Set new].
  2204 	    entry add:fn.
  2393             entry add:fn.
  2205 	].
  2394         ].
  2206 
  2395 
  2207 	"/ any of same size ?
  2396         "/ any of same size ?
  2208 
  2397 
  2209 	filesBySize do:[:entry |
  2398         filesBySize do:[:entry |
  2210 	    |files|
  2399             |files|
  2211 
  2400 
  2212 	    entry size > 1 ifTrue:[
  2401             entry size > 1 ifTrue:[
  2213 		files := entry asArray.
  2402                 files := entry asArray.
  2214 		1 to:files size-1 do:[:idx1 |
  2403                 1 to:files size-1 do:[:idx1 |
  2215 		    idx1+1 to:files size do:[:idx2 |
  2404                     idx1+1 to:files size do:[:idx2 |
  2216 			|fn1 fn2|
  2405                         |fn1 fn2|
  2217 
  2406 
  2218 			fn1 := files at:idx1.
  2407                         fn1 := files at:idx1.
  2219 			fn2 := files at:idx2.
  2408                         fn2 := files at:idx2.
  2220 
  2409 
  2221 			(result at:fn2 ifAbsent:nil) ~= fn1 ifTrue:[
  2410                         (result at:fn2 ifAbsent:nil) ~= fn1 ifTrue:[
  2222 			    "/ compare the files
  2411                             "/ compare the files
  2223 			    (fn1 sameContentsAs:fn2) ifTrue:[
  2412                             (fn1 sameContentsAs:fn2) ifTrue:[
  2224 "/                                Transcript show:'Same: '; show:fn1 baseName; show:' and '; showCR:fn2 baseName.
  2413 "/                                Transcript show:'Same: '; show:fn1 baseName; show:' and '; showCR:fn2 baseName.
  2225 				result at:fn1 put:fn2.
  2414                                 result at:fn1 put:fn2.
  2226 			    ]
  2415                             ]
  2227 			]
  2416                         ]
  2228 		    ]
  2417                     ]
  2229 		]
  2418                 ]
  2230 	    ]
  2419             ]
  2231 	].
  2420         ].
  2232 
  2421 
  2233 	result := result associations.
  2422         result := result associations.
  2234 	result := result collect:[:assoc |
  2423         result := result collect:[:assoc |
  2235 					|f1 f2|
  2424                                         |f1 f2|
  2236 
  2425 
  2237 					f1 := assoc key baseName.
  2426                                         f1 := assoc key baseName.
  2238 					f2 := assoc value baseName.
  2427                                         f2 := assoc value baseName.
  2239 					f1 < f2 ifTrue:[
  2428                                         f1 < f2 ifTrue:[
  2240 					    f2 -> f1
  2429                                             f2 -> f1
  2241 					] ifFalse:[
  2430                                         ] ifFalse:[
  2242 					    f1 -> f2
  2431                                             f1 -> f2
  2243 					]
  2432                                         ]
  2244 				].
  2433                                 ].
  2245 	result sort:[:f1 :f2 | f2 value < f1 value].
  2434         result sort:[:f1 :f2 | f2 value < f1 value].
  2246 
  2435 
  2247 	info := OrderedCollection new.
  2436         info := OrderedCollection new.
  2248 	result do:[:assoc |
  2437         result do:[:assoc |
  2249 	    info add:(assoc key , ' same as ' , assoc value)
  2438             info add:(assoc key , ' same as ' , assoc value)
  2250 	].
  2439         ].
  2251 	info isEmpty ifTrue:[
  2440         info isEmpty ifTrue:[
  2252 	    info := 'No duplicate files found.'
  2441             info := 'No duplicate files found.'
  2253 	].
  2442         ].
  2254     ].
  2443     ].
  2255 
  2444 
  2256     subView contents:info
  2445     subView contents:info
  2257 
  2446 
  2258     "Created: / 3.10.1998 / 17:59:00 / cg"
  2447     "Created: / 3.10.1998 / 17:59:00 / cg"
  2485 
  2674 
  2486     |string box updater|
  2675     |string box updater|
  2487 
  2676 
  2488     string := self getFileInfoString:longInfo.
  2677     string := self getFileInfoString:longInfo.
  2489     string notNil ifTrue:[
  2678     string notNil ifTrue:[
  2490 	box := InfoBox title:string.
  2679         box := InfoBox title:string.
  2491 	updater := [
  2680         updater := [
  2492 	    [true] whileTrue:[
  2681             [true] whileTrue:[
  2493 		Delay waitForSeconds:2.
  2682                 Delay waitForSeconds:2.
  2494 		string := self getFileInfoString:longInfo.
  2683                 string := self getFileInfoString:longInfo.
  2495 		box title:string
  2684                 box title:string
  2496 	    ] 
  2685             ] 
  2497 	] fork.
  2686         ] fork.
  2498 
  2687 
  2499 	box showAtPointer.
  2688         box showAtPointer.
  2500 	updater terminate.
  2689         updater terminate.
  2501 	box destroy
  2690         box destroy
  2502     ]
  2691     ]
  2503 !
  2692 !
  2504 
  2693 
  2505 fileGetLongInfo
  2694 fileGetLongInfo
  2506     "show long stat (file)-info"
  2695     "show long stat (file)-info"
  2597 
  2786 
  2598     |fileName|
  2787     |fileName|
  2599 
  2788 
  2600     fileName := self getSelectedFileName.
  2789     fileName := self getSelectedFileName.
  2601     fileName notNil ifTrue:[
  2790     fileName notNil ifTrue:[
  2602 	self showFile:fileName insert:true encoding:fileEncoding
  2791         self showFile:fileName insert:true encoding:fileEncoding
  2603     ]
  2792     ]
  2604 
  2793 
  2605     "Modified: 23.4.1997 / 13:06:06 / cg"
  2794     "Modified: 23.4.1997 / 13:06:06 / cg"
  2606 !
  2795 !
  2607 
  2796 
  2639     <resource: #programMenu>
  2828     <resource: #programMenu>
  2640 
  2829 
  2641     |items m sel ns subMenu subItems|
  2830     |items m sel ns subMenu subItems|
  2642 
  2831 
  2643     items := #(
  2832     items := #(
  2644 		 ('spawn'            fileSpawn        )
  2833                  ('spawn'            fileSpawn        )
  2645 		 ('-'                nil              )  
  2834                  ('-'                nil              )  
  2646 		 ('get contents'     fileGet          GotoLine)      
  2835                  ('get contents'     fileGet          GotoLine)      
  2647 		 ('insert contents'  fileInsert       )            
  2836                  ('insert contents'  fileInsert       )            
  2648 		 ('show info'        fileGetInfo      InspectIt)
  2837                  ('show info'        fileGetInfo      InspectIt)
  2649 		 ('show full info'   fileGetLongInfo  CmdI)
  2838                  ('show full info'   fileGetLongInfo  CmdI)
  2650 	       ).
  2839                ).
  2651 
  2840 
  2652     ((ns := Project current defaultNameSpace) notNil 
  2841     ((ns := Project current defaultNameSpace) notNil 
  2653     and:[ns ~~ Smalltalk]) ifTrue:[
  2842     and:[ns ~~ Smalltalk]) ifTrue:[
  2654 	items := items copyWith:(Array 
  2843         items := items copyWith:(Array 
  2655 				    with:(resources string:'fileIn (into ''%1'')' with:(Project current defaultNameSpace name))
  2844                                     with:(resources string:'fileIn (into ''%1'')' with:(Project current defaultNameSpace name))
  2656 				    with:#fileFileIn
  2845                                     with:#fileFileIn
  2657 				    with:#Accept)
  2846                                     with:#Accept)
  2658                                 
  2847                                 
  2659     ] ifFalse:[
  2848     ] ifFalse:[
  2660 	items := items copyWith:#( 'fileIn'  #fileFileIn  #Accept)
  2849         items := items copyWith:#( 'fileIn'  #fileFileIn  #Accept)
  2661     ].
  2850     ].
  2662 
  2851 
  2663     items := items , #(
  2852     items := items , #(
  2664 		 ('-'                                                   )
  2853                  ('-'                                                   )
  2665 		 ('update'                    updateCurrentDirectory    Cmdu)
  2854                  ('update'                    updateCurrentDirectory    Cmdu)
  2666 		 ('-'                                                   )
  2855                  ('-'                                                   )
  2667 		 ('execute unix command ...'  fileExecute               DoIt)
  2856                  ('execute unix command ...'  fileExecute               DoIt)
  2668 		 ('st/x tools'                stxTools                  )
  2857                  ('st/x tools'                stxTools                  )
  2669 		 ('-'                                                   )
  2858                  ('-'                                                   )
  2670 		 ('remove'                    fileRemove                Delete)
  2859                  ('remove'                    fileRemove                Delete)
  2671 		 ('rename ...'                fileRename                )
  2860                  ('rename ...'                fileRename                )
  2672 		 ('-'                                                   )
  2861                  ('-'                                                   )
  2673 		 ('display long list'         changeDisplayMode         )
  2862                  ('display long list'         changeDisplayMode         )
  2674 		 ('show all files'            changeDotFileVisibility   )
  2863                  ('show all files'            changeDotFileVisibility   )
  2675 		 ('encoding ...'              fileEncoding              )
  2864                  ('encoding ...'              fileEncoding              )
  2676 		 ('-'                                                   )
  2865                  ('-'                                                   )
  2677 		 ('create directory ...'      newDirectory              CmdD)
  2866                  ('create directory ...'      newDirectory              CmdD)
  2678 		 ('create file ...'           newFile                   CmdF)
  2867                  ('create file ...'           newFile                   CmdF)
  2679 	       ).             
  2868                ).             
  2680 
  2869 
  2681     m := PopUpMenu 
  2870     m := PopUpMenu 
  2682 	    itemList:items
  2871             itemList:items
  2683 	    resources:resources.
  2872             resources:resources.
  2684 
  2873 
  2685     showingHiddenFiles value "showDotFiles" ifTrue:[
  2874     showingHiddenFiles value "showDotFiles" ifTrue:[
  2686 	m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files')
  2875         m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files')
  2687     ].
  2876     ].
  2688     showingDetails value "showLongList" ifTrue:[
  2877     showingDetails value "showLongList" ifTrue:[
  2689 	m labelAt:#changeDisplayMode put:(resources string:'display short list')
  2878         m labelAt:#changeDisplayMode put:(resources string:'display short list')
  2690     ].
  2879     ].
  2691 
  2880 
  2692     items := #(
  2881     items := #(
  2693 			      ('Changes browser'       openChangesBrowser  )
  2882                               ('Changes browser'       openChangesBrowser  )
  2694 			      ('Editor'                openEditor          )
  2883                               ('Editor'                openEditor          )
  2695 			      ('HTML reader'           openHTMLReader      )
  2884                               ('HTML reader'           openHTMLReader      )
  2696 			      ('Image inspect'         openImageInspector  )
  2885                               ('Image inspect'         openImageInspector  )
  2697 			      ('show file differences' openDiffView        )
  2886                               ('show file differences' openDiffView        )
  2698 		  ).
  2887                   ).
  2699 
  2888 
  2700     OperatingSystem isUNIXlike ifTrue:[
  2889     OperatingSystem isUNIXlike ifTrue:[
  2701 	items := items , #( ('terminal'              openTerminal )).
  2890         items := items , #( ('terminal'              openTerminal )).
  2702     ].
  2891     ].
  2703 
  2892 
  2704     JavaInterpreter notNil ifTrue:[
  2893     JavaInterpreter notNil ifTrue:[
  2705 	items := items , #( ('Java Applet Viewer' openAppletViewer)).
  2894         items := items , #( ('Java Applet Viewer' openAppletViewer)).
  2706     ].
  2895     ].
  2707 
  2896 
  2708     m subMenuAt:#stxTools 
  2897     m subMenuAt:#stxTools 
  2709 	    put:(PopUpMenu
  2898             put:(PopUpMenu
  2710 		    itemList:items
  2899                     itemList:items
  2711 		    resources:resources).
  2900                     resources:resources).
  2712 
  2901 
  2713     ((sel := fileListView selection) isNil 
  2902     ((sel := fileListView selection) isNil 
  2714     or:[sel isEmpty]) ifTrue:[
  2903     or:[sel isEmpty]) ifTrue:[
  2715 	m disableAll:#(fileGet fileInsert
  2904         m disableAll:#(fileGet fileInsert
  2716 		       fileGetInfo fileGetLongInfo
  2905                        fileGetInfo fileGetLongInfo
  2717 		       fileFileIn fileFileInLazy
  2906                        fileFileIn fileFileInLazy
  2718 		       fileRemove fileRename).
  2907                        fileRemove fileRename).
  2719 	(m subMenuAt:#stxTools)
  2908         (m subMenuAt:#stxTools)
  2720 	    disableAll:#(openChangesBrowser openEditor openHTMLReader openImageInspector)
  2909             disableAll:#(openChangesBrowser openEditor openHTMLReader openImageInspector)
  2721     ] ifFalse:[
  2910     ] ifFalse:[
  2722 	fileListView selection size > 1 ifTrue:[
  2911         fileListView selection size > 1 ifTrue:[
  2723 	    m disableAll:#( fileGet fileInsert fileGetInfo fileGetLongInfo fileRename )
  2912             m disableAll:#( fileGet fileInsert fileGetInfo fileGetLongInfo fileRename )
  2724 	]
  2913         ]
  2725     ].
  2914     ].
  2726 
  2915 
  2727     ^m
  2916     ^m
  2728 
  2917 
  2729     "Modified: / 16.1.1998 / 16:42:59 / stefan"
  2918     "Modified: / 16.1.1998 / 16:42:59 / stefan"
  2735     "send a files contents to the printer (not in the menu)"
  2924     "send a files contents to the printer (not in the menu)"
  2736 
  2925 
  2737     |fileName path inStream printStream line|
  2926     |fileName path inStream printStream line|
  2738 
  2927 
  2739     self withWaitCursorDo:[
  2928     self withWaitCursorDo:[
  2740 	fileName := self getSelectedFileName.
  2929         fileName := self getSelectedFileName.
  2741 	fileName notNil ifTrue:[
  2930         fileName notNil ifTrue:[
  2742 	    path := currentDirectory filenameFor:fileName.
  2931             path := currentDirectory filenameFor:fileName.
  2743 	    (path type == #regular) ifTrue:[
  2932             (path type == #regular) ifTrue:[
  2744 		inStream := path readStream.
  2933                 inStream := path readStream.
  2745 		inStream isNil ifFalse:[
  2934                 inStream isNil ifFalse:[
  2746 		    printStream := PrinterStream new.
  2935                     printStream := PrinterStream new.
  2747 		    printStream notNil ifTrue:[
  2936                     printStream notNil ifTrue:[
  2748 			[inStream atEnd] whileFalse:[
  2937                         [inStream atEnd] whileFalse:[
  2749 			    line := inStream nextLine.
  2938                             line := inStream nextLine.
  2750 			    printStream nextPutLine:line.
  2939                             printStream nextPutLine:line.
  2751 			].
  2940                         ].
  2752 			printStream close
  2941                         printStream close
  2753 		    ].
  2942                     ].
  2754 		    inStream close
  2943                     inStream close
  2755 		]
  2944                 ]
  2756 	    ]
  2945             ]
  2757 	].
  2946         ].
  2758 	0 "compiler hint"
  2947         0 "compiler hint"
  2759     ]
  2948     ]
  2760 
  2949 
  2761     "Modified: 23.4.1997 / 13:05:40 / cg"
  2950     "Modified: 23.4.1997 / 13:05:40 / cg"
  2762     "Modified: 18.9.1997 / 16:29:17 / stefan"
  2951     "Modified: 18.9.1997 / 16:29:17 / stefan"
  2763 !
  2952 !
  2862     "selected a file - do nothing here"
  3051     "selected a file - do nothing here"
  2863 
  3052 
  2864     |fn|
  3053     |fn|
  2865 
  3054 
  2866     imagePreviewView notNil ifTrue:[
  3055     imagePreviewView notNil ifTrue:[
  2867 	self stopImageRenderProcess.
  3056         self stopImageRenderProcess.
  2868 
  3057 
  2869 	fn := self getSelectedFileName.
  3058         fn := self getSelectedFileName.
  2870 	(Image isImageFileSuffix:(fn asFilename suffix)) ifTrue:[
  3059         (Image isImageFileSuffix:(fn asFilename suffix)) ifTrue:[
  2871 	    imageRenderProcess := [
  3060             imageRenderProcess := [
  2872 		self loadImageAndPerform:[:img | 
  3061                 self loadImageAndPerform:[:img | 
  2873 						imagePreviewView beVisible.
  3062                                                 imagePreviewView beVisible.
  2874 						imagePreviewView image:img
  3063                                                 imagePreviewView image:img
  2875 					 ]
  3064                                          ]
  2876 	    ] forkAt:(Processor activePriority - 1).
  3065             ] forkAt:(Processor activePriority - 1).
  2877 	] ifFalse:[
  3066         ] ifFalse:[
  2878 	    imagePreviewView beInvisible
  3067             imagePreviewView beInvisible
  2879 	].
  3068         ].
  2880     ]
  3069     ]
  2881 
  3070 
  2882     "Modified: 23.4.1997 / 13:04:55 / cg"
  3071     "Modified: 23.4.1997 / 13:04:55 / cg"
  2883 !
  3072 !
  2884 
  3073 
  2895             self class openOn:(path pathName).
  3084             self class openOn:(path pathName).
  2896             any := true
  3085             any := true
  2897         ]
  3086         ]
  2898     ].
  3087     ].
  2899     any ifFalse:[
  3088     any ifFalse:[
  2900         self class openOn:currentDirectory pathName withExtent:self topView extent
  3089         "/ access by name, to get most up-to-date version 
       
  3090         "/ (if changed in the browser, and the running one is old)
       
  3091         (Smalltalk at:(self class name))
       
  3092             openOn:currentDirectory pathName withExtent:self topView extent
  2901     ]
  3093     ]
  2902 
  3094 
  2903     "Modified: 18.9.1997 / 16:32:39 / stefan"
  3095     "Modified: 18.9.1997 / 16:32:39 / stefan"
  2904 !
  3096 !
  2905 
  3097 
  2906 loadImageAndPerform:aSelectorOrBlock
  3098 loadImageAndPerform:aSelectorOrBlock
  2907     |img path|
  3099     |img path|
  2908 
  3100 
  2909     self selectedFilesDo:[:fileName |
  3101     self selectedFilesDo:[:fileName |
  2910 	path := currentDirectory filenameFor:fileName.
  3102         path := currentDirectory filenameFor:fileName.
  2911 	path isDirectory ifFalse:[
  3103         path isDirectory ifFalse:[
  2912 	    img := Image fromFile:(path pathName).
  3104             img := Image fromFile:(path pathName).
  2913 	    img notNil ifTrue:[
  3105             img notNil ifTrue:[
  2914 		aSelectorOrBlock isSymbol ifTrue:[
  3106                 aSelectorOrBlock isSymbol ifTrue:[
  2915 		    img perform:aSelectorOrBlock
  3107                     img perform:aSelectorOrBlock
  2916 		] ifFalse:[
  3108                 ] ifFalse:[
  2917 		    aSelectorOrBlock value:img
  3109                     aSelectorOrBlock value:img
  2918 		]
  3110                 ]
  2919 	    ] ifFalse:[
  3111             ] ifFalse:[
  2920 		self warn:'unknown format: ' , fileName
  3112                 self warn:'unknown format: ' , fileName
  2921 	    ]
  3113             ]
  2922 	]
  3114         ]
  2923     ].
  3115     ].
  2924 
  3116 
  2925     "Modified: / 17.9.1995 / 17:41:24 / claus"
  3117     "Modified: / 17.9.1995 / 17:41:24 / claus"
  2926     "Modified: / 18.9.1997 / 17:05:04 / stefan"
  3118     "Modified: / 18.9.1997 / 17:05:04 / stefan"
  2927     "Created: / 26.8.1998 / 16:20:18 / cg"
  3119     "Created: / 26.8.1998 / 16:20:18 / cg"
  3107 
  3299 
  3108 openAppletViewer
  3300 openAppletViewer
  3109     |numItems|
  3301     |numItems|
  3110 
  3302 
  3111     (numItems := fileListView selection size) > 2 ifTrue:[
  3303     (numItems := fileListView selection size) > 2 ifTrue:[
  3112 	(self 
  3304         (self 
  3113 	    confirm:(resources string:'open for each of the %1 items ?' 
  3305             confirm:(resources string:'open for each of the %1 items ?' 
  3114 				 with:numItems)) ifFalse:[^ self].
  3306                                  with:numItems)) ifFalse:[^ self].
  3115     ].
  3307     ].
  3116 
  3308 
  3117     Java startupJavaSystem.
  3309     Java startupJavaSystem.
  3118 "/    Java markAllClassesUninitialized.
  3310 "/    Java markAllClassesUninitialized.
  3119 "/    Java initAllStaticFields.
  3311 "/    Java initAllStaticFields.
  3120 "/    Java initAllClasses.
  3312 "/    Java initAllClasses.
  3121 
  3313 
  3122     self selectedFilesDo:[:fileName |
  3314     self selectedFilesDo:[:fileName |
  3123 	|p path|
  3315         |p path|
  3124 
  3316 
  3125 	path := currentDirectory filenameFor:fileName.
  3317         path := currentDirectory filenameFor:fileName.
  3126 	path isDirectory ifFalse:[
  3318         path isDirectory ifFalse:[
  3127 	    p := Java 
  3319             p := Java 
  3128 		    javaProcessForMainOf:(Java classForName:'sun.applet.AppletViewer')
  3320                     javaProcessForMainOf:(Java classForName:'sun.applet.AppletViewer')
  3129 		    argumentString:path pathName.
  3321                     argumentString:path pathName.
  3130 	    p resume.
  3322             p resume.
  3131 	]
  3323         ]
  3132     ].
  3324     ].
  3133 
  3325 
  3134     "Modified: / 18.9.1997 / 17:00:59 / stefan"
  3326     "Modified: / 18.9.1997 / 17:00:59 / stefan"
  3135     "Modified: / 17.10.1998 / 17:00:43 / cg"
  3327     "Modified: / 17.10.1998 / 17:00:43 / cg"
  3136 !
  3328 !
  3275     "Modified: / 7.9.1998 / 21:31:30 / cg"
  3467     "Modified: / 7.9.1998 / 21:31:30 / cg"
  3276 !
  3468 !
  3277 
  3469 
  3278 openImagePreview
  3470 openImagePreview
  3279     [self loadImageAndPerform:[:img |
  3471     [self loadImageAndPerform:[:img |
  3280 				|i top viewer|
  3472                                 |i top viewer|
  3281 
  3473 
  3282 				top := StandardSystemView new.
  3474                                 top := StandardSystemView new.
  3283 
  3475 
  3284 				viewer := ImageView origin:0.0@0.0 corner:1.0@1.0 in:top.
  3476                                 viewer := ImageView origin:0.0@0.0 corner:1.0@1.0 in:top.
  3285 				i := img.
  3477                                 i := img.
  3286 				top extent:200@200.
  3478                                 top extent:200@200.
  3287 				top label:(img fileName asFilename directoryName asFilename baseName , '/' , img fileName asFilename baseName).
  3479                                 top label:(img fileName asFilename directoryName asFilename baseName , '/' , img fileName asFilename baseName).
  3288 				top openAndWait.
  3480                                 top openAndWait.
  3289 
  3481 
  3290 				(i width > 200 or:[i height > 200]) ifTrue:[
  3482                                 (i width > 200 or:[i height > 200]) ifTrue:[
  3291 				    i := i magnifiedPreservingRatioTo:200@200.
  3483                                     i := i magnifiedPreservingRatioTo:200@200.
  3292 				].
  3484                                 ].
  3293 				viewer image:i.
  3485                                 viewer image:i.
  3294 			      ].
  3486                               ].
  3295     ] fork
  3487     ] fork
  3296 
  3488 
  3297     "Modified: / 4.12.1998 / 15:49:03 / cg"
  3489     "Modified: / 4.12.1998 / 15:49:03 / cg"
  3298 !
  3490 !
  3299 
  3491 
  3311 openSelectedFilename
  3503 openSelectedFilename
  3312     |sel|
  3504     |sel|
  3313 
  3505 
  3314     sel := subView selection.
  3506     sel := subView selection.
  3315     sel notNil ifTrue:[
  3507     sel notNil ifTrue:[
  3316 	sel := sel asString withoutSeparators.
  3508         sel := sel asString withoutSeparators.
  3317 	sel asFilename exists ifTrue:[
  3509         sel asFilename exists ifTrue:[
  3318 	    self doOpenFile:sel viaDoubleClick:false
  3510             self doOpenFile:sel viaDoubleClick:false
  3319 	]
  3511         ]
  3320     ].
  3512     ].
  3321 
  3513 
  3322     "Created: / 4.2.1999 / 17:40:42 / cg"
  3514     "Created: / 4.2.1999 / 17:40:42 / cg"
  3323     "Modified: / 4.2.1999 / 17:47:06 / cg"
  3515     "Modified: / 4.2.1999 / 17:47:06 / cg"
  3324 !
  3516 !
  3428 
  3620 
  3429 showOrHideTabView
  3621 showOrHideTabView
  3430     "depending on the showLongList setting, show or hde the tabSpec view"
  3622     "depending on the showLongList setting, show or hde the tabSpec view"
  3431 
  3623 
  3432     showingDetails value "showLongList" ifTrue:[
  3624     showingDetails value "showLongList" ifTrue:[
  3433 	tabRulerView isNil ifTrue:[
  3625         tabRulerView isNil ifTrue:[
  3434 	    self createTabRulerIn:scrollView superView.
  3626             self createTabRulerIn:scrollView superView.
  3435 	].
  3627         ].
  3436 	tabRulerView beVisible.
  3628         tabRulerView beVisible.
  3437         
  3629         
  3438 	false "self is3D" ifTrue:[
  3630         false "self is3D" ifTrue:[
  3439 	    scrollView topInset:(tabRulerView superView height).
  3631             scrollView topInset:(tabRulerView superView height).
  3440 	    tabRulerView superView leftInset:(fileListView originRelativeTo:scrollView) x.
  3632             tabRulerView superView leftInset:(fileListView originRelativeTo:scrollView) x.
  3441 	] ifFalse:[
  3633         ] ifFalse:[
  3442 	    scrollView topInset:(tabRulerView height).
  3634             scrollView topInset:(tabRulerView height).
  3443 	    tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x.
  3635             tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x.
  3444 	].
  3636         ].
  3445 	tabRulerView hiddenTabs:#(1).
  3637         tabRulerView hiddenTabs:#(1).
  3446 	tabRulerView fixedTabs:#(1).
  3638         tabRulerView fixedTabs:#(1).
  3447     ] ifFalse:[
  3639     ] ifFalse:[
  3448 	tabRulerView notNil ifTrue:[
  3640         tabRulerView notNil ifTrue:[
  3449 	    tabRulerView beInvisible.
  3641             tabRulerView beInvisible.
  3450 	].
  3642         ].
  3451 	scrollView topInset:0
  3643         scrollView topInset:0
  3452     ].
  3644     ].
  3453     tabSpec := nil.
  3645     tabSpec := nil.
  3454 
  3646 
  3455     "Created: / 19.4.1997 / 09:50:02 / cg"
  3647     "Created: / 19.4.1997 / 09:50:02 / cg"
  3456     "Modified: / 4.8.1998 / 13:44:14 / cg"
  3648     "Modified: / 4.8.1998 / 13:44:14 / cg"
  3460 
  3652 
  3461 helpTextFor:aComponent
  3653 helpTextFor:aComponent
  3462     |s|
  3654     |s|
  3463 
  3655 
  3464     aComponent == subView ifTrue:[
  3656     aComponent == subView ifTrue:[
  3465 	s := 'HELP_SUBVIEW'
  3657         s := 'HELP_SUBVIEW'
  3466     ].
  3658     ].
  3467     aComponent == fileListView ifTrue:[
  3659     aComponent == fileListView ifTrue:[
  3468 	s := 'HELP_FILELIST'
  3660         s := 'HELP_FILELIST'
  3469     ].
  3661     ].
  3470     aComponent == filterField ifTrue:[
  3662     aComponent == filterField ifTrue:[
  3471 	s := 'HELP_FILTER'
  3663         s := 'HELP_FILTER'
  3472     ].
  3664     ].
  3473     aComponent == labelView ifTrue:[
  3665     aComponent == labelView ifTrue:[
  3474 	s := 'HELP_PATHFIELD'
  3666         s := 'HELP_PATHFIELD'
  3475     ].
  3667     ].
  3476     aComponent == commandView ifTrue:[
  3668     aComponent == commandView ifTrue:[
  3477 	s := 'HELP_COMMANDVIEW'
  3669         s := 'HELP_COMMANDVIEW'
  3478     ].
  3670     ].
  3479     s notNil ifTrue:[
  3671     s notNil ifTrue:[
  3480 	^ resources string:s
  3672         ^ resources string:s
  3481     ].
  3673     ].
  3482     ^ nil
  3674     ^ nil
  3483 ! !
  3675 ! !
  3484 
  3676 
  3485 !FileBrowser methodsFor:'initialize / release'!
  3677 !FileBrowser methodsFor:'initialize / release'!
  3596     "
  3788     "
  3597      showing small icons by default
  3789      showing small icons by default
  3598     "
  3790     "
  3599     showingBigImagePreview := (resources at:'BIG_IMAGE_PREVIEW' default:false) asValue.
  3791     showingBigImagePreview := (resources at:'BIG_IMAGE_PREVIEW' default:false) asValue.
  3600     showingBigImagePreview onChangeSend:#bigImagePreviewSettingChanged to:self.
  3792     showingBigImagePreview onChangeSend:#bigImagePreviewSettingChanged to:self.
       
  3793 
       
  3794     showingTimeAndDate := (resources at:'SHOW_TIME_AND_DATE' default:false) asValue.
       
  3795     showingTimeAndDate onChangeSend:#updateCurrentDirectory to:self.
  3601 
  3796 
  3602     sortByWhat := #name asValue.
  3797     sortByWhat := #name asValue.
  3603     sortByWhat onChangeSend:#sortChanged to:self.
  3798     sortByWhat onChangeSend:#sortChanged to:self.
  3604 
  3799 
  3605     sortCaseless := (Filename isCaseSensitive not) asValue.
  3800     sortCaseless := (Filename isCaseSensitive not) asValue.
  3953     "Created: 24.7.1997 / 18:13:46 / cg"
  4148     "Created: 24.7.1997 / 18:13:46 / cg"
  3954 ! !
  4149 ! !
  3955 
  4150 
  3956 !FileBrowser methodsFor:'menu actions'!
  4151 !FileBrowser methodsFor:'menu actions'!
  3957 
  4152 
       
  4153 addBookmark
       
  4154     self addBookmark:currentDirectory asFilename pathName
       
  4155 !
       
  4156 
       
  4157 addBookmark:path
       
  4158     |idx|
       
  4159 
       
  4160     DirectoryBookmarks isNil ifTrue:[
       
  4161         DirectoryBookmarks := OrderedCollection new
       
  4162     ].
       
  4163     idx := DirectoryBookmarks indexOf:path.
       
  4164     idx == 0 ifTrue:[
       
  4165 "/        DirectoryBookmarks size >= HistorySize ifTrue:[
       
  4166 "/            DirectoryBookmarks removeLast.
       
  4167 "/        ].
       
  4168         DirectoryBookmarks addLast:path.
       
  4169     ].
       
  4170 !
       
  4171 
  3958 copyCommandHistory
  4172 copyCommandHistory
  3959     "copy the command history to the clipBoard"
  4173     "copy the command history to the clipBoard"
  3960 
  4174 
  3961     self setTextSelection:(CommandHistory asStringCollection asString).
  4175     self setTextSelection:(CommandHistory asStringCollection asString).
  3962 
  4176 
  3965 
  4179 
  3966 copyFileList
  4180 copyFileList
  3967     "copy fileList to the clipBoard"
  4181     "copy fileList to the clipBoard"
  3968 
  4182 
  3969     self setTextSelection:(fileListView list 
  4183     self setTextSelection:(fileListView list 
  3970 			      collect:[:l | |ll|
  4184                               collect:[:l | |ll|
  3971 					ll := l string withoutSeparators.
  4185                                         ll := l string withoutSeparators.
  3972 					(ll endsWith:' ...') ifTrue:[
  4186                                         (ll endsWith:' ...') ifTrue:[
  3973 					    ll copyWithoutLast:4
  4187                                             ll copyWithoutLast:4
  3974 					] ifFalse:[
  4188                                         ] ifFalse:[
  3975 					    ll
  4189                                             ll
  3976 					]
  4190                                         ]
  3977 				      ]) 
  4191                                       ]) 
  3978 				asStringCollection asString.
  4192                                 asStringCollection asString.
  3979 
  4193 
  3980     "Modified: / 17.8.1998 / 10:13:10 / cg"
  4194     "Modified: / 17.8.1998 / 10:13:10 / cg"
  3981 !
  4195 !
  3982 
  4196 
  3983 copySelectedFileName
  4197 copySelectedFileName
  3985 
  4199 
  3986     |sel fileName|
  4200     |sel fileName|
  3987 
  4201 
  3988     sel := fileListView selection.
  4202     sel := fileListView selection.
  3989     sel size == 1 ifTrue:[
  4203     sel size == 1 ifTrue:[
  3990 	fileName := fileList at:sel first.
  4204         fileName := fileList at:sel first.
  3991 	self setTextSelection:fileName
  4205         self setTextSelection:fileName
  3992     ].
  4206     ].
  3993 !
  4207 !
  3994 
  4208 
  3995 copySelectedPathName
  4209 copySelectedPathName
  3996     "copy the selected files pathname to the clipBoard (for easy paste)"
  4210     "copy the selected files pathname to the clipBoard (for easy paste)"
  4052     myClass := self class.
  4266     myClass := self class.
  4053 
  4267 
  4054     (clsRev := myClass revision) notNil ifTrue: [rev := '  (rev: ', clsRev printString, ')'].
  4268     (clsRev := myClass revision) notNil ifTrue: [rev := '  (rev: ', clsRev printString, ')'].
  4055 
  4269 
  4056     msg := '\' withCRs , myClass name asBoldText, rev.
  4270     msg := '\' withCRs , myClass name asBoldText, rev.
       
  4271 
       
  4272     AboutBox isNil ifTrue:[
       
  4273         "/ this handles bad installations of ST/X,
       
  4274         "/ where the AboutBox is missing.
       
  4275         "/ (May vanish in the future)
       
  4276         ^ self information:msg
       
  4277     ].
  4057 
  4278 
  4058     Dialog
  4279     Dialog
  4059         about:(resources string:msg)
  4280         about:(resources string:msg)
  4060         label:(resources string:'About FileBrowser')
  4281         label:(resources string:'About FileBrowser')
  4061         icon:self class defaultIcon
  4282         icon:self class defaultIcon
  4083 "/    m findGuiResourcesIn:self.
  4304 "/    m findGuiResourcesIn:self.
  4084 "/    ^ m.
  4305 "/    ^ m.
  4085 
  4306 
  4086     "Modified: / 14.8.1998 / 14:09:12 / cg"
  4307     "Modified: / 14.8.1998 / 14:09:12 / cg"
  4087     "Created: / 14.8.1998 / 14:14:16 / cg"
  4308     "Created: / 14.8.1998 / 14:14:16 / cg"
       
  4309 !
       
  4310 
       
  4311 removeBookmark
       
  4312     DirectoryBookmarks isNil ifTrue:[ ^ self].
       
  4313     DirectoryBookmarks remove:(currentDirectory asFilename pathName) ifAbsent:nil.
  4088 !
  4314 !
  4089 
  4315 
  4090 showAboutSTX
  4316 showAboutSTX
  4091     ToolApplicationModel openAboutSTX
  4317     ToolApplicationModel openAboutSTX
  4092 
  4318 
  4197 
  4423 
  4198 cvsUpdateDirectoryLocal
  4424 cvsUpdateDirectoryLocal
  4199     "update this directory"
  4425     "update this directory"
  4200 
  4426 
  4201     self
  4427     self
  4202 	doExecuteCommand:'cvs upd -l' replace:false
  4428         doExecuteCommand:'cvs upd -l' replace:false
  4203 
  4429 
  4204     "Modified: / 16.12.1998 / 17:30:31 / cg"
  4430     "Modified: / 16.12.1998 / 17:30:31 / cg"
  4205 !
  4431 !
  4206 
  4432 
  4207 cvsUpdateDirectoryRecursive
  4433 cvsUpdateDirectoryRecursive
  4208     "update this directory"
  4434     "update this directory"
  4209 
  4435 
  4210     self
  4436     self
  4211 	doExecuteCommand:'cvs upd -d' replace:false
  4437         doExecuteCommand:'cvs upd -d' replace:false
  4212 
  4438 
  4213     "Modified: / 16.12.1998 / 17:30:31 / cg"
  4439     "Modified: / 16.12.1998 / 17:30:31 / cg"
  4214 !
  4440 !
  4215 
  4441 
  4216 cvsUpdateSelection
  4442 cvsUpdateSelection
  4218 
  4444 
  4219     |sel|
  4445     |sel|
  4220 
  4446 
  4221     sel := fileListView selection.
  4447     sel := fileListView selection.
  4222     sel size > 0 ifTrue:[
  4448     sel size > 0 ifTrue:[
  4223 	sel := sel collect:[:rawIndex | fileList at:rawIndex].
  4449         sel := sel collect:[:rawIndex | fileList at:rawIndex].
  4224 	sel do:[:fn |
  4450         sel do:[:fn |
  4225 	    self
  4451             self
  4226 		doExecuteCommand:('cvs upd ' , fn) replace:false
  4452                 doExecuteCommand:('cvs upd ' , fn) replace:false
  4227 	]
  4453         ]
  4228     ].
  4454     ].
  4229 !
  4455 !
  4230 
  4456 
  4231 doRemoveAndRemoveFromCVS:filesToRemove
  4457 doRemoveAndRemoveFromCVS:filesToRemove
  4232     "remove the selected file(s) and their CVS containers - no questions asked"
  4458     "remove the selected file(s) and their CVS containers - no questions asked"
  4243     needUpdate := (currentDirectory modificationTime > timeOfLastCheck).
  4469     needUpdate := (currentDirectory modificationTime > timeOfLastCheck).
  4244 
  4470 
  4245     yesToAll := false.
  4471     yesToAll := false.
  4246     lockUpdate := true.
  4472     lockUpdate := true.
  4247     [
  4473     [
  4248 	filesToRemove do:[:fileName |
  4474         filesToRemove do:[:fileName |
  4249 	    |f|
  4475             |f|
  4250 
  4476 
  4251 	    f := currentDirectory construct:fileName.
  4477             f := currentDirectory construct:fileName.
  4252 	    OperatingSystem accessDeniedErrorSignal handle:[:ex|
  4478             OperatingSystem accessDeniedErrorSignal handle:[:ex|
  4253 		"was not able to remove it"
  4479                 "was not able to remove it"
  4254 		msg := (resources string:'cannot remove ''%1'' !!' with:fileName).
  4480                 msg := (resources string:'cannot remove ''%1'' !!' with:fileName).
  4255 		self showAlert:msg with:(OperatingSystem lastErrorString)
  4481                 self showAlert:msg with:(OperatingSystem lastErrorString)
  4256 	    ] do:[
  4482             ] do:[
  4257 		|answer contents|
  4483                 |answer contents|
  4258 
  4484 
  4259 		(f isSymbolicLink not) ifTrue:[
  4485                 (f isSymbolicLink not) ifTrue:[
  4260 		    self
  4486                     self
  4261 			doExecuteCommand:('cvs remove -f ' , f baseName)
  4487                         doExecuteCommand:('cvs remove -f ' , f baseName)
  4262 			replace:false.
  4488                         replace:false.
  4263 
  4489 
  4264 "
  4490 "
  4265 		self show:nil
  4491                 self show:nil
  4266 "
  4492 "
  4267 		    idx := fileList indexOf:fileName.
  4493                     idx := fileList indexOf:fileName.
  4268 		    idx ~~ 0 ifTrue:[
  4494                     idx ~~ 0 ifTrue:[
  4269 			toRemove add:idx.
  4495                         toRemove add:idx.
  4270 		    ]
  4496                     ]
  4271 		]
  4497                 ]
  4272 	    ].
  4498             ].
  4273 	].
  4499         ].
  4274     ] valueNowOrOnUnwindDo:[
  4500     ] valueNowOrOnUnwindDo:[
  4275 	lockUpdate := false.
  4501         lockUpdate := false.
  4276 	fileListView setSelection:nil.
  4502         fileListView setSelection:nil.
  4277 
  4503 
  4278 	"/
  4504         "/
  4279 	"/ remove reverse - otherwise indices are wrong
  4505         "/ remove reverse - otherwise indices are wrong
  4280 	"/
  4506         "/
  4281 	toRemove sort.
  4507         toRemove sort.
  4282 	toRemove reverseDo:[:idx |
  4508         toRemove reverseDo:[:idx |
  4283 	    fileList removeIndex:idx.
  4509             fileList removeIndex:idx.
  4284 	    fileListView removeIndex:idx.
  4510             fileListView removeIndex:idx.
  4285 	].
  4511         ].
  4286 
  4512 
  4287 	updateRunning ifTrue:[
  4513         updateRunning ifTrue:[
  4288 	    self updateCurrentDirectory
  4514             self updateCurrentDirectory
  4289 	] ifFalse:[
  4515         ] ifFalse:[
  4290 	    "
  4516             "
  4291 	     install a new check after some time
  4517              install a new check after some time
  4292 	    "
  4518             "
  4293 	    needUpdate ifFalse:[timeOfLastCheck := AbsoluteTime now].
  4519             needUpdate ifFalse:[timeOfLastCheck := AbsoluteTime now].
  4294 	    Processor removeTimedBlock:checkBlock.
  4520             Processor removeTimedBlock:checkBlock.
  4295 	    Processor addTimedBlock:checkBlock afterSeconds:checkDelta.
  4521             Processor addTimedBlock:checkBlock afterSeconds:checkDelta.
  4296 	]
  4522         ]
  4297     ].
  4523     ].
  4298 
  4524 
  4299     self
  4525     self
  4300 	doExecuteCommand:('cvs commit -m ''removed via FileBrowser''')
  4526         doExecuteCommand:('cvs commit -m ''removed via FileBrowser''')
  4301 	replace:false.
  4527         replace:false.
  4302 
  4528 
  4303     "Modified: / 21.10.1998 / 17:02:11 / cg"
  4529     "Modified: / 21.10.1998 / 17:02:11 / cg"
  4304 ! !
  4530 ! !
  4305 
  4531 
  4306 !FileBrowser methodsFor:'misc user interaction'!
  4532 !FileBrowser methodsFor:'misc user interaction'!
  4322 discardChangesDialog
  4548 discardChangesDialog
  4323     "ask the user if changes should be discarded,
  4549     "ask the user if changes should be discarded,
  4324      return true if changes should be discarded, false otherwise"
  4550      return true if changes should be discarded, false otherwise"
  4325 
  4551 
  4326     ^ self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
  4552     ^ self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
  4327 	       yesButton:'change'
  4553                yesButton:'change'
  4328 
  4554 
  4329     "Created: 2.10.1997 / 14:08:37 / stefan"
  4555     "Created: 2.10.1997 / 14:08:37 / stefan"
  4330 !
  4556 !
  4331 
  4557 
  4332 entryCompletion:contents
  4558 entryCompletion:contents
  4407 
  4633 
  4408 update:what with:someArgument from:changedObject
  4634 update:what with:someArgument from:changedObject
  4409     realized ifFalse:[^ self].
  4635     realized ifFalse:[^ self].
  4410 
  4636 
  4411     (what == #aboutToExit) ifTrue:[
  4637     (what == #aboutToExit) ifTrue:[
  4412 	"system wants to shut down this
  4638         "system wants to shut down this
  4413 	 - if text was modified, pop up, and ask user and save if requested."
  4639          - if text was modified, pop up, and ask user and save if requested."
  4414 
  4640 
  4415 	(subView modified and:[subView contentsWasSaved not]) ifTrue:[
  4641         (subView modified and:[subView contentsWasSaved not]) ifTrue:[
  4416 	    self raiseDeiconified.
  4642             self raiseDeiconified.
  4417 
  4643 
  4418 	    (self 
  4644             (self 
  4419 		ask:(resources at:'FileBrowser:\\contents has not been saved.\\Save before exiting ?')
  4645                 ask:(resources at:'FileBrowser:\\contents has not been saved.\\Save before exiting ?')
  4420 		yesButton:'save'
  4646                 yesButton:'save'
  4421 		noButton:'don''t save')
  4647                 noButton:'don''t save')
  4422 	    ifTrue:[
  4648             ifTrue:[
  4423 		subView acceptAction notNil ifTrue:[
  4649                 subView acceptAction notNil ifTrue:[
  4424 		    subView accept
  4650                     subView accept
  4425 		] ifFalse:[
  4651                 ] ifFalse:[
  4426 		    subView save
  4652                     subView save
  4427 		]
  4653                 ]
  4428 	    ]
  4654             ]
  4429 	].
  4655         ].
  4430 	^ self
  4656         ^ self
  4431     ].
  4657     ].
  4432     changedObject == tabSpec ifTrue:[
  4658     changedObject == tabSpec ifTrue:[
  4433 	fileListView invalidate
  4659         fileListView invalidate
  4434     ].
  4660     ].
  4435 
  4661 
  4436     "Modified: 29.5.1996 / 16:13:43 / cg"
  4662     "Modified: 29.5.1996 / 16:13:43 / cg"
  4437 ! !
  4663 ! !
  4438 
  4664 
  4456 
  4682 
  4457     "Modified: 14.12.1996 / 15:37:47 / cg"
  4683     "Modified: 14.12.1996 / 15:37:47 / cg"
  4458     "Created: 2.8.1997 / 14:11:19 / cg"
  4684     "Created: 2.8.1997 / 14:11:19 / cg"
  4459 !
  4685 !
  4460 
  4686 
       
  4687 bookmarksMenuSpec
       
  4688     "return the bookmarksMenu for the path label"
       
  4689 
       
  4690     <resource: #programMenu>
       
  4691 
       
  4692     ^ self menuFromSpec:(self class bookmarksMenuSpec).
       
  4693 !
       
  4694 
  4461 changeCurrentDirectory
  4695 changeCurrentDirectory
  4462     "if text was modified show a queryBox, 
  4696     "if text was modified show a queryBox, 
  4463      otherwise ask for & change to that directory"
  4697      otherwise ask for & change to that directory"
  4464 
  4698 
  4465     self discardChangesDialog ifTrue:[
  4699     self discardChangesDialog ifTrue:[
  4466 	self queryForDirectoryToChange
  4700         self queryForDirectoryToChange
  4467     ]
  4701     ]
  4468 
  4702 
  4469     "Modified: 21.9.1997 / 23:45:35 / cg"
  4703     "Modified: 21.9.1997 / 23:45:35 / cg"
  4470     "Modified: 2.10.1997 / 14:09:02 / stefan"
  4704     "Modified: 2.10.1997 / 14:09:02 / stefan"
  4471 !
  4705 !
  4472 
  4706 
  4473 changeDirectoryTo:aDirectoryName
  4707 changeDirectoryTo:aDirectoryName
  4474     "sent from label menu to change back to a previous directory"
  4708     "sent from label menu to change back to a previous directory"
  4475 
  4709 
  4476     self discardChangesDialog ifTrue:[
  4710     self discardChangesDialog ifTrue:[
  4477 	self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:true "/false.
  4711         self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:true "/false.
  4478     ].
  4712     ].
  4479 
  4713 
  4480     "Modified: / 2.10.1997 / 14:09:24 / stefan"
  4714     "Modified: / 2.10.1997 / 14:09:24 / stefan"
  4481     "Modified: / 21.7.1998 / 16:38:03 / cg"
  4715     "Modified: / 21.7.1998 / 16:38:03 / cg"
  4482 !
  4716 !
  4484 changeToDefaultDirectory
  4718 changeToDefaultDirectory
  4485     "if text was modified show a queryBox, 
  4719     "if text was modified show a queryBox, 
  4486      otherwise change immediately to the default directory"
  4720      otherwise change immediately to the default directory"
  4487 
  4721 
  4488     self discardChangesDialog ifTrue:[
  4722     self discardChangesDialog ifTrue:[
  4489 	 self doChangeToDefaultDirectory
  4723          self doChangeToDefaultDirectory
  4490     ]
  4724     ]
  4491 
  4725 
  4492     "Modified: 21.9.1997 / 23:45:04 / cg"
  4726     "Modified: 21.9.1997 / 23:45:04 / cg"
  4493     "Modified: 2.10.1997 / 14:09:33 / stefan"
  4727     "Modified: 2.10.1997 / 14:09:33 / stefan"
  4494 !
  4728 !
  4496 changeToHomeDirectory
  4730 changeToHomeDirectory
  4497     "if text was modified show a queryBox, 
  4731     "if text was modified show a queryBox, 
  4498      otherwise change immediately to the home directory"
  4732      otherwise change immediately to the home directory"
  4499 
  4733 
  4500     self discardChangesDialog ifTrue:[
  4734     self discardChangesDialog ifTrue:[
  4501 	 self doChangeToHomeDirectory
  4735          self doChangeToHomeDirectory
  4502     ]
  4736     ]
  4503 
  4737 
  4504     "Modified: 21.9.1997 / 23:45:10 / cg"
  4738     "Modified: 21.9.1997 / 23:45:10 / cg"
  4505     "Modified: 2.10.1997 / 14:09:42 / stefan"
  4739     "Modified: 2.10.1997 / 14:09:42 / stefan"
  4506 !
  4740 !
  4508 changeToParentDirectory
  4742 changeToParentDirectory
  4509     "if text was modified show a queryBox, 
  4743     "if text was modified show a queryBox, 
  4510      otherwise change immediately to the parent directory"
  4744      otherwise change immediately to the parent directory"
  4511 
  4745 
  4512     self discardChangesDialog ifTrue:[
  4746     self discardChangesDialog ifTrue:[
  4513 	 self doChangeToParentDirectory
  4747          self doChangeToParentDirectory
  4514     ]
  4748     ]
  4515 
  4749 
  4516     "Modified: 21.9.1997 / 23:45:15 / cg"
  4750     "Modified: 21.9.1997 / 23:45:15 / cg"
  4517     "Modified: 2.10.1997 / 14:09:55 / stefan"
  4751     "Modified: 2.10.1997 / 14:09:55 / stefan"
  4518 !
  4752 !
  4531 
  4765 
  4532     |f|
  4766     |f|
  4533 
  4767 
  4534     f := self getSelectedFileName.
  4768     f := self getSelectedFileName.
  4535     f isNil ifTrue:[
  4769     f isNil ifTrue:[
  4536 	^ self addDirToJavaClassPath
  4770         ^ self addDirToJavaClassPath
  4537     ].
  4771     ].
  4538     f := currentDirectory asFilename construct:f.
  4772     f := currentDirectory asFilename construct:f.
  4539     Java addToClassPath:(f pathName)
  4773     Java addToClassPath:(f pathName)
  4540 
  4774 
  4541     "Created: / 9.11.1998 / 05:41:34 / cg"
  4775     "Created: / 9.11.1998 / 05:41:34 / cg"
  4591 
  4825 
  4592     "Created: / 9.11.1998 / 05:42:05 / cg"
  4826     "Created: / 9.11.1998 / 05:42:05 / cg"
  4593     "Modified: / 9.11.1998 / 05:56:14 / cg"
  4827     "Modified: / 9.11.1998 / 05:56:14 / cg"
  4594 !
  4828 !
  4595 
  4829 
       
  4830 historyMenuSpec
       
  4831     "return the historyMenu for the path label"
       
  4832 
       
  4833     <resource: #programMenu>
       
  4834 
       
  4835     ^ self menuFromSpec:(self class historyMenuSpec).
       
  4836 !
       
  4837 
  4596 labelMenu
  4838 labelMenu
  4597     "return the popUpMenu for the path label"
  4839     "return the popUpMenu for the path label"
  4598 
  4840 
  4599     <resource: #programMenu>
  4841     <resource: #programMenu>
  4600 
  4842 
  4601     |m|
  4843     ^ self menuFromSpec:(self class directoryMenuSpec).
  4602 
       
  4603     m := self class directoryMenuSpec.
       
  4604     m menuPerformer:self.
       
  4605     ^ m
       
  4606 
       
  4607     "Modified: / 14.8.1998 / 12:11:16 / cg"
       
  4608 !
  4844 !
  4609 
  4845 
  4610 labelMenu_old
  4846 labelMenu_old
  4611     "return the popUpMenu for the path label"
  4847     "return the popUpMenu for the path label"
  4612 
  4848 
  4613     <resource: #programMenu>
  4849     <resource: #programMenu>
  4614 
  4850 
  4615     |items menu currentIndex|
  4851     |items menu currentIndex|
  4616 
  4852 
  4617     items := #(
  4853     items := #(
  4618 		   ('copy path'                   copyPath                  )
  4854                    ('copy path'                   copyPath                  )
  4619 		   ('-'                                                     )
  4855                    ('-'                                                     )
  4620 		   ('up'                          changeToParentDirectory   )
  4856                    ('up'                          changeToParentDirectory   )
  4621 		   ('back'                        changeToPreviousDirectory )
  4857                    ('back'                        changeToPreviousDirectory )
  4622 		   ('change to home-directory'    changeToHomeDirectory     )
  4858                    ('change to home-directory'    changeToHomeDirectory     )
  4623 		   ('change to default-directory' changeToDefaultDirectory  )
  4859                    ('change to default-directory' changeToDefaultDirectory  )
  4624 		   ('change directory ...'        changeCurrentDirectory    )
  4860                    ('change directory ...'        changeCurrentDirectory    )
  4625 	       ).             
  4861                ).             
  4626 
  4862 
  4627     (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
  4863     (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
  4628 	items := items , #(
  4864         items := items , #(
  4629 			    ( '-')
  4865                             ( '-')
  4630 			    ( 'add to JavaClassPath'       addDirToJavaClassPath)
  4866                             ( 'add to JavaClassPath'       addDirToJavaClassPath)
  4631 			    ( 'add to JavaSourcePath'      addDirToJavaSourcePath)
  4867                             ( 'add to JavaSourcePath'      addDirToJavaSourcePath)
  4632 			    ( 'remove from JavaClassPath'  removeDirFromJavaClassPath)
  4868                             ( 'remove from JavaClassPath'  removeDirFromJavaClassPath)
  4633 			    ( 'remove from JavaSourcePath' removeDirFromJavaSourcePath)
  4869                             ( 'remove from JavaSourcePath' removeDirFromJavaSourcePath)
  4634 			  ).
  4870                           ).
  4635     ].
  4871     ].
  4636 
  4872 
  4637     DirectoryHistory size > 0 ifTrue:[
  4873     DirectoryHistory size > 0 ifTrue:[
  4638 	items := items copyWith:#('-').
  4874         items := items copyWith:#('-').
  4639 	items := items ,
  4875         items := items ,
  4640 		 (DirectoryHistory 
  4876                  (DirectoryHistory 
  4641 			collect:[:dirName |
  4877                         collect:[:dirName |
  4642 				    Array 
  4878                                     Array 
  4643 					with:dirName 
  4879                                         with:dirName 
  4644 					with:#changeDirectoryTo:
  4880                                         with:#changeDirectoryTo:
  4645 					with:nil
  4881                                         with:nil
  4646 					with:dirName
  4882                                         with:dirName
  4647 				]
  4883                                 ]
  4648 		 ).
  4884                  ).
  4649 	currentIndex := items findFirst:[:i | (i at:1) = currentDirectory pathName].
  4885         currentIndex := items findFirst:[:i | (i at:1) = currentDirectory pathName].
  4650 	currentIndex == 0 ifTrue:[currentIndex := nil].
  4886         currentIndex == 0 ifTrue:[currentIndex := nil].
  4651     ].
  4887     ].
  4652 
  4888 
  4653     menu := PopUpMenu 
  4889     menu := PopUpMenu 
  4654 		itemList:items
  4890                 itemList:items
  4655 		resources:resources.
  4891                 resources:resources.
  4656 
  4892 
  4657     previousDirectory isNil ifTrue:[
  4893     previousDirectory isNil ifTrue:[
  4658 	menu disable:#changeToPreviousDirectory.
  4894         menu disable:#changeToPreviousDirectory.
  4659     ].
  4895     ].
  4660     currentIndex notNil ifTrue:[
  4896     currentIndex notNil ifTrue:[
  4661 	menu disable:currentIndex
  4897         menu disable:currentIndex
  4662     ].
  4898     ].
  4663     (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
  4899     (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
  4664 	(Java classPath includes:currentDirectory pathName) ifTrue:[
  4900         (Java classPath includes:currentDirectory pathName) ifTrue:[
  4665 	    menu disable:#addDirToJavaClassPath
  4901             menu disable:#addDirToJavaClassPath
  4666 	] ifFalse:[
  4902         ] ifFalse:[
  4667 	    menu disable:#removeDirFromJavaClassPath
  4903             menu disable:#removeDirFromJavaClassPath
  4668 	].
  4904         ].
  4669 	(Java sourcePath includes:currentDirectory pathName) ifTrue:[
  4905         (Java sourcePath includes:currentDirectory pathName) ifTrue:[
  4670 	    menu disable:#addDirToJavaSourcePath
  4906             menu disable:#addDirToJavaSourcePath
  4671 	] ifFalse:[
  4907         ] ifFalse:[
  4672 	    menu disable:#removeDirFromJavaSourcePath
  4908             menu disable:#removeDirFromJavaSourcePath
  4673 	].
  4909         ].
  4674     ].
  4910     ].
  4675     ^menu.
  4911     ^menu.
  4676 
  4912 
  4677     "Modified: / 21.7.1998 / 16:43:25 / cg"
  4913     "Modified: / 21.7.1998 / 16:43:25 / cg"
  4678     "Created: / 14.8.1998 / 12:10:02 / cg"
  4914     "Created: / 14.8.1998 / 12:10:02 / cg"
  4716     "query for new directory"
  4952     "query for new directory"
  4717 
  4953 
  4718     |queryBox dirName|
  4954     |queryBox dirName|
  4719 
  4955 
  4720     queryBox := FilenameEnterBox 
  4956     queryBox := FilenameEnterBox 
  4721 		    title:(resources at:'change directory to:') withCRs
  4957                     title:(resources at:'change directory to:') withCRs
  4722 		    okText:(resources at:'change')
  4958                     okText:(resources at:'change')
  4723 		    action:[:newName | dirName := newName].
  4959                     action:[:newName | dirName := newName].
  4724 "/    queryBox initialText:''.
  4960 "/    queryBox initialText:''.
  4725     queryBox showAtPointer.
  4961     queryBox showAtPointer.
  4726     queryBox destroy.
  4962     queryBox destroy.
  4727     self doChangeCurrentDirectoryTo:dirName updateHistory:true.
  4963     self doChangeCurrentDirectoryTo:dirName updateHistory:true.
  4728 
  4964 
  4760 
  4996 
  4761 ask:question yesButton:yesButtonText noButton:noButtonText
  4997 ask:question yesButton:yesButtonText noButton:noButtonText
  4762     "common method to ask a yes/no question"
  4998     "common method to ask a yes/no question"
  4763 
  4999 
  4764     ^ Dialog 
  5000     ^ Dialog 
  4765 	confirm:question withCRs
  5001         confirm:question withCRs
  4766 	yesLabel:(resources at:yesButtonText)
  5002         yesLabel:(resources at:yesButtonText)
  4767 	noLabel:(resources at:noButtonText)
  5003         noLabel:(resources at:noButtonText)
  4768 
  5004 
  4769     "Modified: 21.2.1996 / 01:19:21 / cg"
  5005     "Modified: 21.2.1996 / 01:19:21 / cg"
  4770 !
  5006 !
  4771 
  5007 
  4772 askForCommandFor:fileName thenDo:aBlock
  5008 askForCommandFor:fileName thenDo:aBlock
  4796 
  5032 
  4797 askIfModified:question yesButton:yesButtonText
  5033 askIfModified:question yesButton:yesButtonText
  4798     "tell user, that code has been modified - let her confirm"
  5034     "tell user, that code has been modified - let her confirm"
  4799 
  5035 
  4800     (subView modified not or:[subView contentsWasSaved]) ifTrue:[
  5036     (subView modified not or:[subView contentsWasSaved]) ifTrue:[
  4801 	^ true
  5037         ^ true
  4802     ].
  5038     ].
  4803     (self ask:(resources string:question) yesButton:yesButtonText) ifTrue:[
  5039     (self ask:(resources string:question) yesButton:yesButtonText) ifTrue:[
  4804 	"/ reset modified flag so question is asked only once
  5040         "/ reset modified flag so question is asked only once
  4805 	subView modified:false.
  5041         subView modified:false.
  4806 	^ true
  5042         ^ true
  4807     ].
  5043     ].
  4808     ^ false
  5044     ^ false
  4809 
  5045 
  4810     "Modified: 2.10.1997 / 14:23:47 / stefan"
  5046     "Modified: 2.10.1997 / 14:23:47 / stefan"
  4811 !
  5047 !
  4849 
  5085 
  4850     |sel action|
  5086     |sel action|
  4851 
  5087 
  4852     sel := fileListView selection.
  5088     sel := fileListView selection.
  4853     sel notNil ifTrue:[
  5089     sel notNil ifTrue:[
  4854 	sel := sel collect:[:aSelectionIndex | 
  5090         sel := sel collect:[:aSelectionIndex | 
  4855 	    |nm|
  5091             |nm|
  4856 
  5092 
  4857 	    nm := fileList at:aSelectionIndex ifAbsent:nil.
  5093             nm := fileList at:aSelectionIndex ifAbsent:nil.
  4858 	    nm notNil ifTrue:[
  5094             nm notNil ifTrue:[
  4859 		nm := nm string.
  5095                 nm := nm string.
  4860 		(nm endsWith:' ...') ifTrue:[
  5096                 (nm endsWith:' ...') ifTrue:[
  4861 		    nm := (nm copyWithoutLast:4) withoutSpaces
  5097                     nm := (nm copyWithoutLast:4) withoutSpaces
  4862 		].
  5098                 ].
  4863 	    ].
  5099             ].
  4864 	    nm
  5100             nm
  4865 	].
  5101         ].
  4866 	action := [
  5102         action := [
  4867 	    sel do:[:nm |
  5103             sel do:[:nm |
  4868 		nm notNil ifTrue:[
  5104                 nm notNil ifTrue:[
  4869 		    aBlock value:nm
  5105                     aBlock value:nm
  4870 		]
  5106                 ]
  4871 	    ]
  5107             ]
  4872 	].
  5108         ].
  4873 	Processor activeProcess == self windowGroup process ifTrue:[
  5109         Processor activeProcess == self windowGroup process ifTrue:[
  4874 	    self withWaitCursorDo:action
  5110             self withWaitCursorDo:action
  4875 	] ifFalse:[
  5111         ] ifFalse:[
  4876 	    action value
  5112             action value
  4877 	]
  5113         ]
  4878     ]
  5114     ]
  4879 
  5115 
  4880     "Modified: / 16.12.1998 / 17:30:57 / cg"
  5116     "Modified: / 16.12.1998 / 17:30:57 / cg"
  4881 !
  5117 !
  4882 
  5118 
  4893     "show an alertbox, displaying the last Unix-error"
  5129     "show an alertbox, displaying the last Unix-error"
  4894 
  5130 
  4895     |msg|
  5131     |msg|
  4896 
  5132 
  4897     anErrorString isNil ifTrue:[
  5133     anErrorString isNil ifTrue:[
  4898 	msg := aString
  5134         msg := aString
  4899     ] ifFalse:[
  5135     ] ifFalse:[
  4900 	msg := aString , '\\(' , anErrorString , ')'
  5136         msg := aString , '\\(' , anErrorString , ')'
  4901     ].
  5137     ].
  4902     self warn:msg withCRs
  5138     self warn:msg withCRs
  4903 !
  5139 !
  4904 
  5140 
  4905 withoutHiddenFiles:aCollection
  5141 withoutHiddenFiles:aCollection
  4908 
  5144 
  4909     |newCollection|
  5145     |newCollection|
  4910 
  5146 
  4911     newCollection := aCollection species new.
  5147     newCollection := aCollection species new.
  4912     aCollection do:[:fname |
  5148     aCollection do:[:fname |
  4913 	|ignore|
  5149         |ignore|
  4914 
  5150 
  4915 	ignore := false.
  5151         ignore := false.
  4916 
  5152 
  4917 	((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[
  5153         ((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[
  4918 	    showingHiddenFiles value "showDotFiles" ifFalse:[
  5154             showingHiddenFiles value "showDotFiles" ifFalse:[
  4919 		ignore := true
  5155                 ignore := true
  4920 	    ]
  5156             ]
  4921 	].
  5157         ].
  4922 	ignore ifFalse:[
  5158         ignore ifFalse:[
  4923 	    newCollection add:fname
  5159             newCollection add:fname
  4924 	]
  5160         ]
  4925     ].
  5161     ].
  4926     ^ newCollection
  5162     ^ newCollection
  4927 
  5163 
  4928     "Modified: / 4.8.1998 / 13:46:27 / cg"
  5164     "Modified: / 4.8.1998 / 13:46:27 / cg"
  4929 ! !
  5165 ! !
  5442     "if text was modified show a queryBox, 
  5678     "if text was modified show a queryBox, 
  5443      otherwise change immediately to previous directory."
  5679      otherwise change immediately to previous directory."
  5444 
  5680 
  5445     previousDirectory isNil ifTrue:[^ self].
  5681     previousDirectory isNil ifTrue:[^ self].
  5446     self discardChangesDialog ifTrue:[
  5682     self discardChangesDialog ifTrue:[
  5447 	self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false 
  5683         self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false 
  5448     ]
  5684     ]
  5449 
  5685 
  5450     "Modified: 2.10.1997 / 14:13:40 / stefan"
  5686     "Modified: 2.10.1997 / 14:13:40 / stefan"
  5451 !
  5687 !
  5452 
  5688 
  5550 
  5786 
  5551     |msg path idx f|
  5787     |msg path idx f|
  5552 
  5788 
  5553     self label:myName; iconLabel:myName.
  5789     self label:myName; iconLabel:myName.
  5554     fileName notNil ifTrue:[
  5790     fileName notNil ifTrue:[
  5555 	(f := fileName asFilename) isAbsolute ifFalse:[
  5791         (f := fileName asFilename) isAbsolute ifFalse:[
  5556 	    f := currentDirectory filenameFor:fileName.
  5792             f := currentDirectory filenameFor:fileName.
  5557 	].
  5793         ].
  5558 	f := f asAbsoluteFilename.
  5794         f := f asAbsoluteFilename.
  5559 	(f isDirectory) ifTrue:[
  5795         (f isDirectory) ifTrue:[
  5560 	    (f isReadable) ifTrue:[
  5796             (f isReadable) ifTrue:[
  5561 		(f isExecutable) ifTrue:[
  5797                 (f isExecutable) ifTrue:[
  5562 		    path := currentDirectory pathName.
  5798                     path := currentDirectory pathName.
  5563 		    previousDirectory := path.
  5799                     previousDirectory := path.
  5564 
  5800 
  5565 		    "
  5801                     "
  5566 		     remember where we are positioned in the fileList
  5802                      remember where we are positioned in the fileList
  5567 		     (in case we want to return)
  5803                      (in case we want to return)
  5568 		    "
  5804                     "
  5569 		    idx := DirectoryHistory indexOf:path.
  5805                     idx := DirectoryHistory indexOf:path.
  5570 		    idx ~~ 0 ifTrue:[
  5806                     idx ~~ 0 ifTrue:[
  5571 			DirectoryHistoryWhere at:idx put:fileListView firstLineShown
  5807                         DirectoryHistoryWhere at:idx put:fileListView firstLineShown
  5572 		    ].
  5808                     ].
  5573 
  5809 
  5574 		    updateHistory ifTrue:[
  5810                     updateHistory ifTrue:[
  5575 			self addToHistory:path.
  5811                         self addToHistory:path.
  5576 		    ].
  5812                     ].
  5577 
  5813 
  5578 		    self setCurrentDirectory:(f pathName).
  5814                     self setCurrentDirectory:(f pathName).
  5579 
  5815 
  5580 		    "/ fetch the new path.
  5816                     "/ fetch the new path.
  5581 		    path := currentDirectory pathName.
  5817                     path := currentDirectory pathName.
  5582 
  5818 
  5583 		    "
  5819                     "
  5584 		     if we have already been there, look for the
  5820                      if we have already been there, look for the
  5585 		     position offset, and scroll the fileList
  5821                      position offset, and scroll the fileList
  5586 		    "
  5822                     "
  5587 		    idx := DirectoryHistory indexOf:path.
  5823                     idx := DirectoryHistory indexOf:path.
  5588 		    idx ~~ 0 ifTrue:[
  5824                     idx ~~ 0 ifTrue:[
  5589 			|pos|
  5825                         |pos|
  5590 
  5826 
  5591 			pos := DirectoryHistoryWhere at:idx.
  5827                         pos := DirectoryHistoryWhere at:idx.
  5592 			pos notNil ifTrue:[
  5828                         pos notNil ifTrue:[
  5593 			    fileListView scrollToLine:pos.
  5829                             fileListView scrollToLine:pos.
  5594 			]
  5830                         ]
  5595 		    ].
  5831                     ].
  5596 
  5832 
  5597 		    updateHistory ifTrue:[
  5833                     updateHistory ifTrue:[
  5598 			self addToHistory:path.
  5834                         self addToHistory:path.
  5599 		    ].
  5835                     ].
  5600 
  5836 
  5601 		    ^ self
  5837                     ^ self
  5602 		].
  5838                 ].
  5603 		msg := 'cannot change directory to ''%1'' !!'
  5839                 msg := 'cannot change directory to ''%1'' !!'
  5604 	    ] ifFalse:[
  5840             ] ifFalse:[
  5605 		msg := 'cannot read directory ''%1'' !!'
  5841                 msg := 'cannot read directory ''%1'' !!'
  5606 	    ]
  5842             ]
  5607 	] ifFalse:[
  5843         ] ifFalse:[
  5608 	    OperatingSystem isVMSlike ifTrue:[
  5844             OperatingSystem isVMSlike ifTrue:[
  5609 		"/ cannot tell if it exists or is simply invisible ...
  5845                 "/ cannot tell if it exists or is simply invisible ...
  5610 		msg := '''%1'' is not a directory or unreadable !!'
  5846                 msg := '''%1'' is not a directory or unreadable !!'
  5611 	    ] ifFalse:[
  5847             ] ifFalse:[
  5612 		msg := '''%1'' is not a directory !!'
  5848                 msg := '''%1'' is not a directory !!'
  5613 	    ]
  5849             ]
  5614 	].
  5850         ].
  5615 	Dialog warn:(resources string:msg withCRs with:fileName).
  5851         Dialog warn:(resources string:msg withCRs with:fileName).
  5616     ]
  5852     ]
  5617 
  5853 
  5618     "Modified: / 18.9.1997 / 18:22:30 / stefan"
  5854     "Modified: / 18.9.1997 / 18:22:30 / stefan"
  5619     "Modified: / 27.4.1999 / 17:10:14 / cg"
  5855     "Modified: / 27.4.1999 / 17:10:14 / cg"
  5620 !
  5856 !
  5642 doCreateDirectory:newName
  5878 doCreateDirectory:newName
  5643     |f|
  5879     |f|
  5644 
  5880 
  5645     f := currentDirectory filenameFor:newName.
  5881     f := currentDirectory filenameFor:newName.
  5646     f exists ifTrue:[
  5882     f exists ifTrue:[
  5647 	self warn:'%1 already exists.' with:newName.
  5883         self warn:'%1 already exists.' with:newName.
  5648 	^ self
  5884         ^ self
  5649     ].
  5885     ].
  5650 
  5886 
  5651     f makeDirectory ifTrue:[
  5887     f makeDirectory ifTrue:[
  5652 	self updateCurrentDirectory
  5888         self updateCurrentDirectory
  5653     ] ifFalse:[
  5889     ] ifFalse:[
  5654 	self showAlert:(resources string:'cannot create directory ''%1'' !!' with:newName)
  5890         self showAlert:(resources string:'cannot create directory ''%1'' !!' with:newName)
  5655 		  with:(OperatingSystem lastErrorString)
  5891                   with:(OperatingSystem lastErrorString)
  5656     ]
  5892     ]
  5657 
  5893 
  5658     "Modified: / 18.9.1997 / 17:21:25 / stefan"
  5894     "Modified: / 18.9.1997 / 17:21:25 / stefan"
  5659     "Modified: / 30.1.1999 / 16:24:12 / cg"
  5895     "Modified: / 30.1.1999 / 16:24:12 / cg"
  5660 !
  5896 !
  5665     |newDirectory|
  5901     |newDirectory|
  5666 
  5902 
  5667     aPathName isEmpty ifTrue:[^ self].
  5903     aPathName isEmpty ifTrue:[^ self].
  5668     newDirectory := currentDirectory filenameFor:aPathName.
  5904     newDirectory := currentDirectory filenameFor:aPathName.
  5669     newDirectory isDirectory ifTrue:[
  5905     newDirectory isDirectory ifTrue:[
  5670 	self currentDirectory:newDirectory.
  5906         self currentDirectory:newDirectory.
  5671 	currentFileName notNil ifTrue:[
  5907         currentFileName notNil ifTrue:[
  5672 	    fileListView contents:nil.
  5908             fileListView contents:nil.
  5673 	    currentFileName := nil.
  5909             currentFileName := nil.
  5674 	] ifFalse:[
  5910         ] ifFalse:[
  5675 	    fileListView setSelection:nil.
  5911             fileListView setSelection:nil.
  5676 	    fileListView scrollToTop.
  5912             fileListView scrollToTop.
  5677 	].
  5913         ].
  5678 	self updateCurrentDirectory.
  5914         self updateCurrentDirectory.
  5679 	self showInfo.
  5915         self showInfo.
  5680     ]
  5916     ]
  5681 
  5917 
  5682     "Modified: 21.9.1995 / 11:22:45 / claus"
  5918     "Modified: 21.9.1995 / 11:22:45 / claus"
  5683     "Modified: 25.5.1996 / 12:27:01 / cg"
  5919     "Modified: 25.5.1996 / 12:27:01 / cg"
  5684     "Modified: 18.9.1997 / 17:08:07 / stefan"
  5920     "Modified: 18.9.1997 / 17:08:07 / stefan"
  5704 
  5940 
  5705 !FileBrowser methodsFor:'private - encoding'!
  5941 !FileBrowser methodsFor:'private - encoding'!
  5706 
  5942 
  5707 guessEncodingFrom:aBuffer
  5943 guessEncodingFrom:aBuffer
  5708     "look for a string
  5944     "look for a string
  5709 	encoding #name
  5945         encoding #name
  5710      or:
  5946      or:
  5711 	encoding: name
  5947         encoding: name
  5712      within the given buffer 
  5948      within the given buffer 
  5713      (which is usually the first few bytes of a textFile).
  5949      (which is usually the first few bytes of a textFile).
  5714      If thats not found, use heuristics (in CharacterArray) to guess."
  5950      If thats not found, use heuristics (in CharacterArray) to guess."
  5715 
  5951 
  5716     |n "{Class: SmallInteger }"
  5952     |n "{Class: SmallInteger }"
  5718 
  5954 
  5719     binary := false.
  5955     binary := false.
  5720     n := aBuffer size.
  5956     n := aBuffer size.
  5721 
  5957 
  5722     (idx := aBuffer findString:'charset=') ~~ 0 ifTrue:[
  5958     (idx := aBuffer findString:'charset=') ~~ 0 ifTrue:[
  5723 	s := ReadStream on:aBuffer.
  5959         s := ReadStream on:aBuffer.
  5724 	s position:idx + 8.
  5960         s position:idx + 8.
  5725 	s skipSeparators.
  5961         s skipSeparators.
  5726 	w := s upToSeparator.
  5962         w := s upToSeparator.
  5727 	w notNil ifTrue:[
  5963         w notNil ifTrue:[
  5728 	    (idx := w indexOf:$") ~~ 0 ifTrue:[
  5964             (idx := w indexOf:$") ~~ 0 ifTrue:[
  5729 		w := w copyTo:idx-1
  5965                 w := w copyTo:idx-1
  5730 	    ].
  5966             ].
  5731 	    ^ w asSymbol
  5967             ^ w asSymbol
  5732 	].
  5968         ].
  5733     ].
  5969     ].
  5734     (idx := aBuffer findString:'encoding') ~~ 0 ifTrue:[
  5970     (idx := aBuffer findString:'encoding') ~~ 0 ifTrue:[
  5735 	s := ReadStream on:aBuffer.
  5971         s := ReadStream on:aBuffer.
  5736 	s position:idx + 8.
  5972         s position:idx + 8.
  5737 	s skipSeparators.
  5973         s skipSeparators.
  5738 	s peek == $: ifTrue:[
  5974         s peek == $: ifTrue:[
  5739 	    s next.
  5975             s next.
  5740 	    s skipSeparators. 
  5976             s skipSeparators. 
  5741 	].
  5977         ].
  5742 
  5978 
  5743 	s peek == $# ifTrue:[
  5979         s peek == $# ifTrue:[
  5744 	    s next.
  5980             s next.
  5745 	    s skipSeparators. 
  5981             s skipSeparators. 
  5746 	].
  5982         ].
  5747 	w := s upToSeparator.
  5983         w := s upToSeparator.
  5748 	w notNil ifTrue:[
  5984         w notNil ifTrue:[
  5749 	    ^ w asSymbol
  5985             ^ w asSymbol
  5750 	].
  5986         ].
  5751     ].
  5987     ].
  5752 
  5988 
  5753     1 to:n do:[:i |
  5989     1 to:n do:[:i |
  5754 	(aBuffer at:i) isPrintable ifFalse:[binary := true].
  5990         (aBuffer at:i) isPrintable ifFalse:[binary := true].
  5755     ].
  5991     ].
  5756 
  5992 
  5757     binary ifTrue:[
  5993     binary ifTrue:[
  5758 	"/ look for JIS7 / EUC encoding
  5994         "/ look for JIS7 / EUC encoding
  5759 
  5995 
  5760 	enc := CharacterArray guessEncodingFrom:aBuffer.
  5996         enc := CharacterArray guessEncodingFrom:aBuffer.
  5761 	enc notNil ifTrue:[
  5997         enc notNil ifTrue:[
  5762 	    ^ enc
  5998             ^ enc
  5763 	].
  5999         ].
  5764 
  6000 
  5765 	"/ if the encoding has been set to any non iso setting,
  6001         "/ if the encoding has been set to any non iso setting,
  5766 	"/ assume its what we defined ...
  6002         "/ assume its what we defined ...
  5767 
  6003 
  5768 	(('iso*' match:fileEncoding) or:['ascii*' match:fileEncoding]) ifTrue:[
  6004         (('iso*' match:fileEncoding) or:['ascii*' match:fileEncoding]) ifTrue:[
  5769 	    ^ #binary
  6005             ^ #binary
  5770 	].
  6006         ].
  5771 	^ fileEncoding ? #binary
  6007         ^ fileEncoding ? #binary
  5772     ].
  6008     ].
  5773     ^ #ascii
  6009     ^ #ascii
  5774 
  6010 
  5775     "Created: 26.2.1996 / 17:43:08 / cg"
  6011     "Created: 26.2.1996 / 17:43:08 / cg"
  5776     "Modified: 1.7.1997 / 00:00:27 / cg"
  6012     "Modified: 1.7.1997 / 00:00:27 / cg"
  5799     fontsEncoding := subView font encoding.
  6035     fontsEncoding := subView font encoding.
  5800 
  6036 
  5801     pref := self preferredFontEncodingFor:newEncoding.
  6037     pref := self preferredFontEncodingFor:newEncoding.
  5802 
  6038 
  5803     (pref match:fontsEncoding) ifTrue:[
  6039     (pref match:fontsEncoding) ifTrue:[
  5804 	^ self
  6040         ^ self
  5805     ].
  6041     ].
  5806     "/ stupid ...
  6042     "/ stupid ...
  5807     pref = 'ascii*' ifTrue:[
  6043     pref = 'ascii*' ifTrue:[
  5808 	(fontsEncoding match:'iso8859*') ifTrue:[
  6044         (fontsEncoding match:'iso8859*') ifTrue:[
  5809 	    ^ self
  6045             ^ self
  5810 	]
  6046         ]
  5811     ].
  6047     ].
  5812 
  6048 
  5813     filter := [:f | |coding|
  6049     filter := [:f | |coding|
  5814 		    (coding := f encoding) notNil 
  6050                     (coding := f encoding) notNil 
  5815 		    and:[pref match:coding]].
  6051                     and:[pref match:coding]].
  5816 
  6052 
  5817     defaultFont := TextView defaultFont onDevice:device.
  6053     defaultFont := TextView defaultFont onDevice:device.
  5818     (pref match:(defaultFont encoding)) ifFalse:[
  6054     (pref match:(defaultFont encoding)) ifFalse:[
  5819 	defaultFont := nil.
  6055         defaultFont := nil.
  5820     ].
  6056     ].
  5821 
  6057 
  5822     defaultFont isNil ifTrue:[
  6058     defaultFont isNil ifTrue:[
  5823 	(pref = 'ascii*'
  6059         (pref = 'ascii*'
  5824 	or:[pref = 'iso8859*']) ifTrue:[
  6060         or:[pref = 'iso8859*']) ifTrue:[
  5825 	    defaultFont := FontDescription family:'courier' face:'medium' style:'roman' size:12
  6061             defaultFont := FontDescription family:'courier' face:'medium' style:'roman' size:12
  5826 	]
  6062         ]
  5827     ].
  6063     ].
  5828 
  6064 
  5829     defaultFont isNil ifTrue:[
  6065     defaultFont isNil ifTrue:[
  5830 	defaultFont := device 
  6066         defaultFont := device 
  5831 			    listOfAvailableFonts 
  6067                             listOfAvailableFonts 
  5832 				detect:[:f | filter value:f]
  6068                                 detect:[:f | filter value:f]
  5833 				ifNone:nil.
  6069                                 ifNone:nil.
  5834 	defaultFont isNil ifTrue:[
  6070         defaultFont isNil ifTrue:[
  5835 
  6071 
  5836 	    "/ flush list, and refetch font list
  6072             "/ flush list, and refetch font list
  5837 	    "/ (in case someone just changed the font path ...)
  6073             "/ (in case someone just changed the font path ...)
  5838 
  6074 
  5839 	    device flushListOfAvailableFonts.
  6075             device flushListOfAvailableFonts.
  5840 	    defaultFont := device 
  6076             defaultFont := device 
  5841 				listOfAvailableFonts 
  6077                                 listOfAvailableFonts 
  5842 				    detect:[:f | filter value:f]
  6078                                     detect:[:f | filter value:f]
  5843 				    ifNone:nil.
  6079                                     ifNone:nil.
  5844 	].
  6080         ].
  5845 
  6081 
  5846 	defaultFont isNil ifTrue:[
  6082         defaultFont isNil ifTrue:[
  5847 	    self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
  6083             self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
  5848 	    ^ self.
  6084             ^ self.
  5849 	]
  6085         ]
  5850     ].
  6086     ].
  5851 
  6087 
  5852     msg := 'switch to a %1 encoded font ?'.
  6088     msg := 'switch to a %1 encoded font ?'.
  5853     (ask not or:[self confirm:(resources string:msg with:pref) withCRs])
  6089     (ask not or:[self confirm:(resources string:msg with:pref) withCRs])
  5854     ifTrue:[
  6090     ifTrue:[
  5855 	self withWaitCursorDo:[
  6091         self withWaitCursorDo:[
  5856 	    f := FontPanel 
  6092             f := FontPanel 
  5857 		fontFromUserInitial:defaultFont
  6093                 fontFromUserInitial:defaultFont
  5858 			      title:(resources string:'font selection')
  6094                               title:(resources string:'font selection')
  5859 			     filter:filter.
  6095                              filter:filter.
  5860 	    f notNil ifTrue:[
  6096             f notNil ifTrue:[
  5861 		subView font:f
  6097                 subView font:f
  5862 	    ]
  6098             ]
  5863 	]
  6099         ]
  5864     ]
  6100     ]
  5865 
  6101 
  5866     "Created: 26.10.1996 / 12:06:54 / cg"
  6102     "Created: 26.10.1996 / 12:06:54 / cg"
  5867     "Modified: 30.6.1997 / 17:46:46 / cg"
  6103     "Modified: 30.6.1997 / 17:46:46 / cg"
  5868 ! !
  6104 ! !
  5911 
  6147 
  5912     |fileName|
  6148     |fileName|
  5913 
  6149 
  5914     fileName := self getSelectedFileName.
  6150     fileName := self getSelectedFileName.
  5915     fileName notNil ifTrue:[
  6151     fileName notNil ifTrue:[
  5916 	self doOpenFile:fileName viaDoubleClick:viaDoubleClick
  6152         self doOpenFile:fileName viaDoubleClick:viaDoubleClick
  5917     ]
  6153     ]
  5918 
  6154 
  5919     "Created: / 19.6.1996 / 09:39:07 / cg"
  6155     "Created: / 19.6.1996 / 09:39:07 / cg"
  5920     "Modified: / 18.9.1997 / 17:35:31 / stefan"
  6156     "Modified: / 18.9.1997 / 17:35:31 / stefan"
  5921     "Modified: / 4.2.1999 / 17:43:51 / cg"
  6157     "Modified: / 4.2.1999 / 17:43:51 / cg"
  6246 
  6482 
  6247     |commentStrings|
  6483     |commentStrings|
  6248 
  6484 
  6249     commentStrings := self fileCommentStrings.
  6485     commentStrings := self fileCommentStrings.
  6250     commentStrings notNil ifTrue:[
  6486     commentStrings notNil ifTrue:[
  6251 	subView perform:#commentStrings: with:commentStrings ifNotUnderstood:nil
  6487         subView perform:#commentStrings: with:commentStrings ifNotUnderstood:nil
  6252     ].
  6488     ].
  6253 
  6489 
  6254     "Modified: 7.1.1997 / 20:30:54 / cg"
  6490     "Modified: 7.1.1997 / 20:30:54 / cg"
  6255 !
  6491 !
  6256 
  6492 
  6343        'Readme.txt'
  6579        'Readme.txt'
  6344        'Info.txt'
  6580        'Info.txt'
  6345        'info.txt'
  6581        'info.txt'
  6346        'INFO.TXT'
  6582        'INFO.TXT'
  6347     ) do:[:f | 
  6583     ) do:[:f | 
  6348 	|n|
  6584         |n|
  6349 	n := currentDirectory construct:f.
  6585         n := currentDirectory construct:f.
  6350 	(n isReadable and:[n isDirectory not]) ifTrue:[
  6586         (n isReadable and:[n isDirectory not]) ifTrue:[
  6351 	    ^ f.
  6587             ^ f.
  6352 	]
  6588         ]
  6353     ].
  6589     ].
  6354     ^ nil
  6590     ^ nil
  6355 
  6591 
  6356     "Modified: 3.8.1997 / 16:50:33 / cg"
  6592     "Modified: 3.8.1997 / 16:50:33 / cg"
  6357     "Modified: 16.9.1997 / 15:26:53 / stefan"
  6593     "Modified: 16.9.1997 / 15:26:53 / stefan"
  6360 getModeString:modeBits
  6596 getModeString:modeBits
  6361     "convert file-mode bits into a more user-friendly string.
  6597     "convert file-mode bits into a more user-friendly string.
  6362      This is wrong here - should be moved into OperatingSystem."
  6598      This is wrong here - should be moved into OperatingSystem."
  6363 
  6599 
  6364     ^ self getModeString:modeBits 
  6600     ^ self getModeString:modeBits 
  6365 		    with:#( 'owner:' $r $w $x 
  6601                     with:#( 'owner:' $r $w $x 
  6366 			    ' group:' $r $w $x 
  6602                             ' group:' $r $w $x 
  6367 			    ' others:' $r $w $x )
  6603                             ' others:' $r $w $x )
  6368 !
  6604 !
  6369 
  6605 
  6370 getModeString:modeBits with:texts
  6606 getModeString:modeBits with:texts
  6371     "convert file-mode bits into a more user-friendly string.
  6607     "convert file-mode bits into a more user-friendly string.
  6372      This is wrong here - should be moved into OperatingSystem."
  6608      This is wrong here - should be moved into OperatingSystem."
  6376     bits := modeBits bitAnd:8r777.
  6612     bits := modeBits bitAnd:8r777.
  6377     modeString := ''.
  6613     modeString := ''.
  6378 
  6614 
  6379     #( nil 8r400 8r200 8r100 nil 8r040 8r020 8r010 nil 8r004 8r002 8r001 ) 
  6615     #( nil 8r400 8r200 8r100 nil 8r040 8r020 8r010 nil 8r004 8r002 8r001 ) 
  6380     with: texts do:[:bitMask :access |
  6616     with: texts do:[:bitMask :access |
  6381 	|ch|
  6617         |ch|
  6382 
  6618 
  6383 	bitMask isNil ifTrue:[
  6619         bitMask isNil ifTrue:[
  6384 	    modeString := modeString , (resources string:access)
  6620             modeString := modeString , (resources string:access)
  6385 	] ifFalse:[
  6621         ] ifFalse:[
  6386 	    (bits bitAnd:bitMask) == 0 ifTrue:[
  6622             (bits bitAnd:bitMask) == 0 ifTrue:[
  6387 		ch := $-
  6623                 ch := $-
  6388 	    ] ifFalse:[
  6624             ] ifFalse:[
  6389 		ch := access
  6625                 ch := access
  6390 	    ].
  6626             ].
  6391 	    modeString := modeString copyWith:ch 
  6627             modeString := modeString copyWith:ch 
  6392 	]
  6628         ]
  6393     ].
  6629     ].
  6394     ^ modeString
  6630     ^ modeString
  6395 !
  6631 !
  6396 
  6632 
  6397 showInfo
  6633 showInfo
  6399 
  6635 
  6400     |info txt|
  6636     |info txt|
  6401 
  6637 
  6402     info := self getInfoFile.
  6638     info := self getInfoFile.
  6403     info notNil ifTrue:[
  6639     info notNil ifTrue:[
  6404 	txt := self readFile:info
  6640         txt := self readFile:info
  6405     ].
  6641     ].
  6406     self show:txt.
  6642     self show:txt.
  6407 !
  6643 !
  6408 
  6644 
  6409 sizePrintString:size
  6645 sizePrintString:size
  6416 "
  6652 "
  6417     ^ size printString.
  6653     ^ size printString.
  6418 "
  6654 "
  6419     unitString := ''.
  6655     unitString := ''.
  6420     size < (500 * 1024) ifTrue:[
  6656     size < (500 * 1024) ifTrue:[
  6421 	size < 1024 ifTrue:[
  6657         size < 1024 ifTrue:[
  6422 	    n := size
  6658             n := size
  6423 	] ifFalse:[
  6659         ] ifFalse:[
  6424 	    n := (size * 10 // 1024 / 10.0).
  6660             n := (size * 10 // 1024 / 10.0).
  6425 	    unitString := ' Kb'
  6661             unitString := ' Kb'
  6426 	]
  6662         ]
  6427     ] ifFalse:[
  6663     ] ifFalse:[
  6428 	n := (size * 10 // 1024 // 1024 / 10.0).
  6664         n := (size * 10 // 1024 // 1024 / 10.0).
  6429 	unitString := ' Mb'
  6665         unitString := ' Mb'
  6430     ].
  6666     ].
  6431     ^ (n printStringLeftPaddedTo:5) , unitString.
  6667     ^ (n printStringLeftPaddedTo:5) , unitString.
  6432 ! !
  6668 ! !
  6433 
  6669 
  6434 !FileBrowser methodsFor:'private - file-I/O'!
  6670 !FileBrowser methodsFor:'private - file-I/O'!
  6448      that symbol, and #decodeString: should be able to convert it."
  6684      that symbol, and #decodeString: should be able to convert it."
  6449 
  6685 
  6450     |f stream text msg sz|
  6686     |f stream text msg sz|
  6451 
  6687 
  6452     (f := fileName asFilename) isAbsolute ifFalse:[
  6688     (f := fileName asFilename) isAbsolute ifFalse:[
  6453 	f := (currentDirectory construct:fileName)
  6689         f := (currentDirectory construct:fileName)
  6454     ].
  6690     ].
  6455     stream := f readStream.
  6691     stream := f readStream.
  6456     stream isNil ifTrue:[
  6692     stream isNil ifTrue:[
  6457 	msg := (resources string:'cannot read file ''%1'' !!' with:fileName).
  6693         msg := (resources string:'cannot read file ''%1'' !!' with:fileName).
  6458 	self showAlert:msg with:(FileStream lastErrorString).
  6694         self showAlert:msg with:(FileStream lastErrorString).
  6459 	^ nil
  6695         ^ nil
  6460     ].
  6696     ].
  6461 
  6697 
  6462     "
  6698     "
  6463      for very big files, give ObjectMemory a hint, to preallocate more
  6699      for very big files, give ObjectMemory a hint, to preallocate more
  6464     "
  6700     "
  6465     (sz := stream fileSize) > 1000000 ifTrue:[
  6701     (sz := stream fileSize) > 1000000 ifTrue:[
  6466 	Processor activeProcess withPriority:Processor userBackgroundPriority do:[
  6702         Processor activeProcess withPriority:Processor userBackgroundPriority do:[
  6467 	    ObjectMemory announceSpaceNeed:(sz + (sz // 5)) "/ add 20% for tab expansion
  6703             ObjectMemory announceSpaceNeed:(sz + (sz // 5)) "/ add 20% for tab expansion
  6468 	].
  6704         ].
  6469     ].
  6705     ].
  6470 
  6706 
  6471     text := self readStream:stream lineDelimiter:aCharacter encoding:encoding.
  6707     text := self readStream:stream lineDelimiter:aCharacter encoding:encoding.
  6472     stream close.
  6708     stream close.
  6473     ^ text
  6709     ^ text
  6495 
  6731 
  6496     text := StringCollection new.
  6732     text := StringCollection new.
  6497 
  6733 
  6498     enc := encoding.
  6734     enc := encoding.
  6499     enc == #iso8859 ifTrue:[
  6735     enc == #iso8859 ifTrue:[
  6500 	enc := nil
  6736         enc := nil
  6501     ].
  6737     ].
  6502 
  6738 
  6503     aCharacter == Character cr ifTrue:[
  6739     aCharacter == Character cr ifTrue:[
  6504 	FileStream lineTooLongErrorSignal handle:[:ex |
  6740         FileStream lineTooLongErrorSignal handle:[:ex |
  6505 	    |s partialLine|
  6741             |s partialLine|
  6506 
  6742 
  6507 	    s := ex parameter at:1.
  6743             s := ex parameter at:1.
  6508 	    partialLine := ex parameter at:2.
  6744             partialLine := ex parameter at:2.
  6509 	    ex proceedWith:(partialLine , s upTo:aCharacter)
  6745             ex proceedWith:(partialLine , s upTo:aCharacter)
  6510 	] do:[
  6746         ] do:[
  6511 	    [aStream atEnd] whileFalse:[
  6747             [aStream atEnd] whileFalse:[
  6512 		line := aStream nextLine withTabsExpanded.
  6748                 line := aStream nextLine withTabsExpanded.
  6513 		enc notNil ifTrue:[
  6749                 enc notNil ifTrue:[
  6514 		    line := line decodeFrom:enc
  6750                     line := line decodeFrom:enc
  6515 		].
  6751                 ].
  6516 		text add:line
  6752                 text add:line
  6517 	    ].
  6753             ].
  6518 	].
  6754         ].
  6519     ] ifFalse:[
  6755     ] ifFalse:[
  6520 	[aStream atEnd] whileFalse:[
  6756         [aStream atEnd] whileFalse:[
  6521 	    line := (aStream upTo:aCharacter) withTabsExpanded.
  6757             line := (aStream upTo:aCharacter) withTabsExpanded.
  6522 	    enc notNil ifTrue:[
  6758             enc notNil ifTrue:[
  6523 		line := line decodeFrom:enc
  6759                 line := line decodeFrom:enc
  6524 	    ].
  6760             ].
  6525 	    text add:line
  6761             text add:line
  6526 	].
  6762         ].
  6527     ].
  6763     ].
  6528     ^ text
  6764     ^ text
  6529 
  6765 
  6530     "Created: / 22.2.1996 / 14:58:25 / cg"
  6766     "Created: / 22.2.1996 / 14:58:25 / cg"
  6531     "Modified: / 5.2.1999 / 00:53:22 / cg"
  6767     "Modified: / 5.2.1999 / 00:53:22 / cg"
  6542 
  6778 
  6543 showFile:fileName insert:insert encoding:encoding
  6779 showFile:fileName insert:insert encoding:encoding
  6544     "show/insert contents of fileName in subView"
  6780     "show/insert contents of fileName in subView"
  6545 
  6781 
  6546     ^ self 
  6782     ^ self 
  6547 	showFile:fileName insert:insert encoding:encoding doubleClick:false
  6783         showFile:fileName insert:insert encoding:encoding doubleClick:false
  6548 
  6784 
  6549     "Modified: 19.6.1996 / 09:40:19 / cg"
  6785     "Modified: 19.6.1996 / 09:40:19 / cg"
  6550 !
  6786 !
  6551 
  6787 
  6552 showFile:fileNameString insert:insert encoding:encoding doubleClick:viaDoubleClick
  6788 showFile:fileNameString insert:insert encoding:encoding doubleClick:viaDoubleClick
  6796     "                   icon  name"
  7032     "                   icon  name"
  6797     tabSpec align:    #(#left #left).
  7033     tabSpec align:    #(#left #left).
  6798     tabSpec addDependent:self.
  7034     tabSpec addDependent:self.
  6799 
  7035 
  6800     tabRulerView notNil ifTrue:[
  7036     tabRulerView notNil ifTrue:[
  6801 	tabRulerView tabulatorSpecification:tabSpec.
  7037         tabRulerView tabulatorSpecification:tabSpec.
  6802     ].
  7038     ].
  6803 
  7039 
  6804     "Created: / 17.4.1997 / 02:51:41 / cg"
  7040     "Created: / 17.4.1997 / 02:51:41 / cg"
  6805     "Modified: / 27.7.1998 / 20:23:34 / cg"
  7041     "Modified: / 27.7.1998 / 20:23:34 / cg"
  6806 !
  7042 !
  6903     "Modified: / 23.12.1999 / 22:28:00 / cg"
  7139     "Modified: / 23.12.1999 / 22:28:00 / cg"
  6904 !
  7140 !
  6905 
  7141 
  6906 stopImageRenderProcess
  7142 stopImageRenderProcess
  6907     imageRenderProcess notNil ifTrue:[
  7143     imageRenderProcess notNil ifTrue:[
  6908 	imageRenderProcess terminate.
  7144         imageRenderProcess terminate.
  6909 	imageRenderProcess := nil
  7145         imageRenderProcess := nil
  6910     ].
  7146     ].
  6911 
  7147 
  6912     "Created: 19.4.1997 / 13:51:34 / cg"
  7148     "Created: 19.4.1997 / 13:51:34 / cg"
  6913 !
  7149 !
  6914 
  7150 
  6915 stopUpdateProcess
  7151 stopUpdateProcess
  6916     Processor removeTimedBlock:checkBlock.
  7152     Processor removeTimedBlock:checkBlock.
  6917     listUpdateProcess notNil ifTrue:[
  7153     listUpdateProcess notNil ifTrue:[
  6918 	listUpdateProcess terminate.
  7154         listUpdateProcess terminate.
  6919 	listUpdateProcess := nil.
  7155         listUpdateProcess := nil.
  6920     ].
  7156     ].
  6921 
  7157 
  6922     "Created: 19.4.1997 / 13:51:34 / cg"
  7158     "Created: 19.4.1997 / 13:51:34 / cg"
  6923 !
  7159 !
  6924 
  7160 
  7060             |prevUid prevGid fileNameString nameString groupString 
  7296             |prevUid prevGid fileNameString nameString groupString 
  7061              modeString info line len
  7297              modeString info line len
  7062              anyImages lineIndex aFileName
  7298              anyImages lineIndex aFileName
  7063              entry typ f p typeString done endIndex 
  7299              entry typ f p typeString done endIndex 
  7064              state stopAtEnd nextState img prevFirstLine prevLastLine
  7300              state stopAtEnd nextState img prevFirstLine prevLastLine
  7065              numVisible dirSuffix prevWidth|
  7301              numVisible dirSuffix prevWidth t|
  7066 
  7302 
  7067             dirSuffix := Filename directorySuffix.
  7303             dirSuffix := Filename directorySuffix.
  7068             dirSuffix size > 0 ifTrue:[
  7304             dirSuffix size > 0 ifTrue:[
  7069                 dirSuffix := '.' , dirSuffix asLowercase.
  7305                 dirSuffix := '.' , dirSuffix asLowercase.
  7070             ].
  7306             ].
  7226                                                             with:#( '' $r $w $x 
  7462                                                             with:#( '' $r $w $x 
  7227                                                                     '  ' $r $w $x 
  7463                                                                     '  ' $r $w $x 
  7228                                                                     '  ' $r $w $x ).
  7464                                                                     '  ' $r $w $x ).
  7229                                 entry colAt:3 put:modeString.
  7465                                 entry colAt:3 put:modeString.
  7230 
  7466 
  7231                                 ((info uid) ~~ prevUid) ifTrue:[
  7467                                 showingTimeAndDate value ifTrue:[
  7232                                     prevUid := (info uid).
  7468                                     t := f isSymbolicLink 
  7233                                     nameString := OperatingSystem getUserNameFromID:prevUid.
  7469                                         ifFalse:[f modificationTime]
  7234                                     nameString := nameString contractTo:10.
  7470                                         ifTrue:[f linkInfo modified].
  7235                                     nameString := nameString , (String new:(10 - nameString size))
  7471                                     entry colAt:4 put:t asDate printString.
       
  7472                                     entry colAt:5 put:t asTime printString.
       
  7473                                 ] ifFalse:[
       
  7474                                     ((info uid) ~~ prevUid) ifTrue:[
       
  7475                                         prevUid := (info uid).
       
  7476                                         nameString := OperatingSystem getUserNameFromID:prevUid.
       
  7477                                         nameString := nameString contractTo:10.
       
  7478                                         nameString := nameString , (String new:(10 - nameString size))
       
  7479                                     ].
       
  7480                                     nameString isNil ifTrue:[nameString := '???'].
       
  7481                                     entry colAt:4 put:nameString withoutSpaces.
       
  7482 
       
  7483                                     ((info gid) ~~ prevGid) ifTrue:[
       
  7484                                         prevGid := (info gid).
       
  7485                                         groupString := OperatingSystem getGroupNameFromID:prevGid.
       
  7486                                         groupString := groupString contractTo:10.
       
  7487                                         groupString := groupString , (String new:(10 - groupString size))
       
  7488                                     ].
       
  7489                                     groupString isNil ifTrue:[groupString := '???'].
       
  7490                                     entry colAt:5 put:groupString withoutSpaces.
  7236                                 ].
  7491                                 ].
  7237                                 nameString isNil ifTrue:[nameString := '???'].
       
  7238                                 entry colAt:4 put:nameString withoutSpaces.
       
  7239 
       
  7240                                 ((info gid) ~~ prevGid) ifTrue:[
       
  7241                                     prevGid := (info gid).
       
  7242                                     groupString := OperatingSystem getGroupNameFromID:prevGid.
       
  7243                                     groupString := groupString contractTo:10.
       
  7244                                     groupString := groupString , (String new:(10 - groupString size))
       
  7245                                 ].
       
  7246                                 groupString isNil ifTrue:[groupString := '???'].
       
  7247                                 entry colAt:5 put:groupString withoutSpaces.
       
  7248 
  7492 
  7249                                 (typ == #regular) ifTrue:[
  7493                                 (typ == #regular) ifTrue:[
  7250                                     entry colAt:6 put:(self sizePrintString:(info size)).
  7494                                     entry colAt:6 put:(self sizePrintString:(info size)).
  7251                                 ].
  7495                                 ].
  7252 
  7496 
  7400     "
  7644     "
  7401 
  7645 
  7402     "Modified: / 18.6.1998 / 15:27:35 / cg"
  7646     "Modified: / 18.6.1998 / 15:27:35 / cg"
  7403 !
  7647 !
  7404 
  7648 
  7405 hasVisitHistory
       
  7406     ^ self class hasVisitHistory
       
  7407 !
       
  7408 
       
  7409 path
  7649 path
  7410     "return my currentDirectories pathName;
  7650     "return my currentDirectories pathName;
  7411      sent from the pathField to aquire the pathname when I changed directory"
  7651      sent from the pathField to aquire the pathname when I changed directory"
  7412 
  7652 
  7413     "/ somewhat tricky: first ask it for the full pathName,
  7653     "/ somewhat tricky: first ask it for the full pathName,
  7420 ! !
  7660 ! !
  7421 
  7661 
  7422 !FileBrowser class methodsFor:'documentation'!
  7662 !FileBrowser class methodsFor:'documentation'!
  7423 
  7663 
  7424 version
  7664 version
  7425     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.442 2001-11-19 08:07:03 cg Exp $'
  7665     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.443 2001-11-19 15:14:52 cg Exp $'
  7426 ! !
  7666 ! !