diff -r f1a20a8ba485 -r 1310d33d3134 FileBrowser.st --- a/FileBrowser.st Mon Nov 19 10:27:28 2001 +0100 +++ b/FileBrowser.st Mon Nov 19 16:14:52 2001 +0100 @@ -1,6 +1,6 @@ " COPYRIGHT (c) 1991 by Claus Gittinger - All Rights Reserved + All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the @@ -13,20 +13,21 @@ "{ Package: 'stx:libtool' }" StandardSystemView subclass:#FileBrowser - instanceVariableNames:'menuPanel labelView filterField fileListView subView - currentDirectory fileList checkBlock checkDelta timeOfLastCheck - myName killButton pauseToggle compressTabs lockUpdate - previousDirectory currentFileName timeOfFileRead tabSpec - commandView commandIndex fileEncoding tabRulerView scrollView - icons listUpdateProcess currentFileInFileName - lastFileDiffDirectory sortByWhat sortCaseless showingDetails - showingHiddenFiles showingBigImagePreview imagePreviewView - imageRenderProcess dosEOLMode doAutoUpdate doNotShowFontDialog' - classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon - CommandHistory CommandHistorySize Icons DefaultCommandPerSuffix - DefaultCommandPerMIME VisitedFileHistory' - poolDictionaries:'' - category:'Interface-Browsers' + instanceVariableNames:'menuPanel labelView filterField fileListView subView + currentDirectory fileList checkBlock checkDelta timeOfLastCheck + myName killButton pauseToggle compressTabs lockUpdate + previousDirectory currentFileName timeOfFileRead tabSpec + commandView commandIndex fileEncoding tabRulerView scrollView + icons listUpdateProcess currentFileInFileName + lastFileDiffDirectory sortByWhat sortCaseless showingDetails + showingTimeAndDate showingHiddenFiles showingBigImagePreview + imagePreviewView imageRenderProcess dosEOLMode doAutoUpdate + doNotShowFontDialog' + classVariableNames:'DirectoryHistory DirectoryHistoryWhere DirectoryBookmarks + HistorySize DefaultIcon CommandHistory CommandHistorySize Icons + DefaultCommandPerSuffix DefaultCommandPerMIME VisitedFileHistory' + poolDictionaries:'' + category:'Interface-Browsers' ! !FileBrowser class methodsFor:'documentation'! @@ -34,7 +35,7 @@ copyright " COPYRIGHT (c) 1991 by Claus Gittinger - All Rights Reserved + All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the @@ -58,30 +59,30 @@ See additional information in 'doc/misc/fbrowser.doc'. WARNING: files edited with FileBrowser will have leading spaces (multiple-8) - being replaced by tabs. If tabs are to be preserved at other - positions (for example, sendmail-config files) they will be - corrupt after being written. + being replaced by tabs. If tabs are to be preserved at other + positions (for example, sendmail-config files) they will be + corrupt after being written. [instance variables]: - checkDelta number of seconds of check interval - (looks ever so often if shown directory - has changed). You may make this number - higher, if your network-times are - incorrect and thus, the filebrowser - checks too often. - - compressTabs if true, leading spaces will be - replaced by tabs when saving text + checkDelta number of seconds of check interval + (looks ever so often if shown directory + has changed). You may make this number + higher, if your network-times are + incorrect and thus, the filebrowser + checks too often. + + compressTabs if true, leading spaces will be + replaced by tabs when saving text some of the defaults (long/short list etc.) can be set by the resource file; see FileBrowser>>initialize for more details.. [author:] - Claus Gittinger + Claus Gittinger [start with:] - FileBrowser open + FileBrowser open " ! ! @@ -149,15 +150,6 @@ "Modified: / 17.6.1998 / 11:25:29 / cg" ! ! -!FileBrowser class methodsFor:'aspects'! - -hasVisitHistory - ^ [DirectoryHistory size > 0] - - "Created: / 14.8.1998 / 19:17:02 / cg" - "Modified: / 14.8.1998 / 19:17:17 / cg" -! ! - !FileBrowser class methodsFor:'class initialization'! icons @@ -266,22 +258,22 @@ |cmd suffix| (aCommandString notNil and:[aCommandString notEmpty]) ifTrue:[ - CommandHistory notNil ifTrue:[ - CommandHistory addFirst:aCommandString. - CommandHistory size > CommandHistorySize ifTrue:[ - CommandHistory removeLast - ] - ]. - aFilename notNil ifTrue:[ - cmd := aCommandString copyTo:(aCommandString indexOf:Character space ifAbsent:[aCommandString size + 1])-1. - DefaultCommandPerSuffix isNil ifTrue:[ - DefaultCommandPerSuffix := Dictionary new. - ]. - suffix := aFilename asFilename suffix. - suffix notNil ifTrue:[ - DefaultCommandPerSuffix at:suffix put:cmd. - ] - ] + CommandHistory notNil ifTrue:[ + CommandHistory addFirst:aCommandString. + CommandHistory size > CommandHistorySize ifTrue:[ + CommandHistory removeLast + ] + ]. + aFilename notNil ifTrue:[ + cmd := aCommandString copyTo:(aCommandString indexOf:Character space ifAbsent:[aCommandString size + 1])-1. + DefaultCommandPerSuffix isNil ifTrue:[ + DefaultCommandPerSuffix := Dictionary new. + ]. + suffix := aFilename asFilename suffix. + suffix notNil ifTrue:[ + DefaultCommandPerSuffix at:suffix put:cmd. + ] + ] ] "Created: 14.11.1996 / 14:58:13 / cg" @@ -345,126 +337,164 @@ ^ #(#FullSpec - #window: - #(#WindowSpec - #name: 'File Search' - #layout: #(#LayoutFrame 4 0 50 0 315 0 349 0) - #level: 0 - #label: 'File Search' - #min: #(#Point 10 10) - #max: #(#Point 1280 1024) - #bounds: #(#Rectangle 4 50 316 350) - #usePreferredExtent: false - #returnIsOKInDialog: true - #escapeIsCancelInDialog: true - ) - #component: - #(#SpecCollection - #collection: - #( - #(#LabelSpec - #name: 'Label1' - #layout: #(#LayoutFrame 0 0 10 0 0 1 32 0) - #label: 'Search for files named:' - #translateLabel: true - #adjust: #left - ) - #(#InputFieldSpec - #name: 'EntryField1' - #layout: #(#LayoutFrame 10 0 36 0 305 0 58 0) - #tabable: true - #model: #namePatternHolder - ) - #(#CheckBoxSpec - #name: 'CheckBox1' - #layout: #(#LayoutFrame 7 0 66 0 143 0 88 0) - #tabable: true - #model: #ignoreCaseInName - #label: 'Ignore case' - #translateLabel: true - ) - #(#LabelSpec - #name: 'Label2' - #layout: #(#LayoutFrame 0 0.0 107 0 0 1.0 129 0) - #label: 'Containing the string:' - #translateLabel: true - #adjust: #left - ) - #(#InputFieldSpec - #name: 'EntryField2' - #layout: #(#LayoutFrame 10 0 133 0 305 0 155 0) - #enableChannel: #notSearchForSameContents - #tabable: true - #model: #contentsPatternHolder - ) - #(#CheckBoxSpec - #name: 'CheckBox2' - #layout: #(#LayoutFrame 6 0 163 0 142 0 185 0) - #enableChannel: #notSearchForSameContents - #tabable: true - #model: #ignoreCaseInContents - #label: 'Ignore case' - #translateLabel: true - ) - #(#LabelSpec - #name: 'Label3' - #layout: #(#LayoutFrame 0 0.0 223 0 -30 1.0 245 0) - #label: 'Containing same contents as selected:' - #translateLabel: true - #adjust: #left - ) - #(#DividerSpec - #name: 'Separator1' - #layout: #(#LayoutFrame 0 0.0 97 0 0 1.0 101 0) - ) - #(#CheckToggleSpec - #name: 'CheckToggle1' - #layout: #(#LayoutOrigin -25 1 225 0) - #tabable: true - #model: #searchForSameContents - #enableChannel: #searchForSameContentsEnabled - #isTriggerOnDown: true - #showLamp: false - #lampColor: #(#Color 100.0 100.0 0.0) - ) - #(#HorizontalPanelViewSpec - #name: 'HorizontalPanel1' - #layout: #(#LayoutFrame 0 0.0 -30 1 0 1.0 0 1.0) - #component: - #(#SpecCollection - #collection: - #( - #(#ActionButtonSpec - #name: 'Button1' - #label: 'Cancel' - #translateLabel: true - #tabable: true - #model: #cancel - #extent: #(#Point 151 25) - ) - #(#ActionButtonSpec - #name: 'Button2' - #label: 'Search' - #translateLabel: true - #tabable: true - #model: #accept - #isDefault: true - #extent: #(#Point 152 25) - ) - ) - ) - #horizontalLayout: #fitSpace - #verticalLayout: #centerMax - #horizontalSpace: 3 - #verticalSpace: 3 - ) - ) - ) + #window: + #(#WindowSpec + #name: 'File Search' + #layout: #(#LayoutFrame 4 0 50 0 315 0 349 0) + #level: 0 + #label: 'File Search' + #min: #(#Point 10 10) + #max: #(#Point 1280 1024) + #bounds: #(#Rectangle 4 50 316 350) + #usePreferredExtent: false + #returnIsOKInDialog: true + #escapeIsCancelInDialog: true + ) + #component: + #(#SpecCollection + #collection: + #( + #(#LabelSpec + #name: 'Label1' + #layout: #(#LayoutFrame 0 0 10 0 0 1 32 0) + #label: 'Search for files named:' + #translateLabel: true + #adjust: #left + ) + #(#InputFieldSpec + #name: 'EntryField1' + #layout: #(#LayoutFrame 10 0 36 0 305 0 58 0) + #tabable: true + #model: #namePatternHolder + ) + #(#CheckBoxSpec + #name: 'CheckBox1' + #layout: #(#LayoutFrame 7 0 66 0 143 0 88 0) + #tabable: true + #model: #ignoreCaseInName + #label: 'Ignore case' + #translateLabel: true + ) + #(#LabelSpec + #name: 'Label2' + #layout: #(#LayoutFrame 0 0.0 107 0 0 1.0 129 0) + #label: 'Containing the string:' + #translateLabel: true + #adjust: #left + ) + #(#InputFieldSpec + #name: 'EntryField2' + #layout: #(#LayoutFrame 10 0 133 0 305 0 155 0) + #enableChannel: #notSearchForSameContents + #tabable: true + #model: #contentsPatternHolder + ) + #(#CheckBoxSpec + #name: 'CheckBox2' + #layout: #(#LayoutFrame 6 0 163 0 142 0 185 0) + #enableChannel: #notSearchForSameContents + #tabable: true + #model: #ignoreCaseInContents + #label: 'Ignore case' + #translateLabel: true + ) + #(#LabelSpec + #name: 'Label3' + #layout: #(#LayoutFrame 0 0.0 223 0 -30 1.0 245 0) + #label: 'Containing same contents as selected:' + #translateLabel: true + #adjust: #left + ) + #(#DividerSpec + #name: 'Separator1' + #layout: #(#LayoutFrame 0 0.0 97 0 0 1.0 101 0) + ) + #(#CheckToggleSpec + #name: 'CheckToggle1' + #layout: #(#LayoutOrigin -25 1 225 0) + #tabable: true + #model: #searchForSameContents + #enableChannel: #searchForSameContentsEnabled + #isTriggerOnDown: true + #showLamp: false + #lampColor: #(#Color 100.0 100.0 0.0) + ) + #(#HorizontalPanelViewSpec + #name: 'HorizontalPanel1' + #layout: #(#LayoutFrame 0 0.0 -30 1 0 1.0 0 1.0) + #component: + #(#SpecCollection + #collection: + #( + #(#ActionButtonSpec + #name: 'Button1' + #label: 'Cancel' + #translateLabel: true + #tabable: true + #model: #cancel + #extent: #(#Point 151 25) + ) + #(#ActionButtonSpec + #name: 'Button2' + #label: 'Search' + #translateLabel: true + #tabable: true + #model: #accept + #isDefault: true + #extent: #(#Point 152 25) + ) + ) + ) + #horizontalLayout: #fitSpace + #verticalLayout: #centerMax + #horizontalSpace: 3 + #verticalSpace: 3 + ) + ) + ) ) ! ! !FileBrowser class methodsFor:'menu specs'! +baseBookmarksMenuSpec + "This resource specification was automatically generated + by the MenuEditor of ST/X." + + "Do not manually edit this!! If it is corrupted, + the MenuEditor may not be able to read the specification." + + " + MenuEditor new openOnClass:FileBrowser andSelector:#baseBookmarksMenuSpec + (Menu new fromLiteralArrayEncoding:(FileBrowser baseBookmarksMenuSpec)) startUp + " + + + + ^ + + #(#Menu + + #( + #(#MenuItem + #label: 'Add Bookmark' + #translateLabel: true + #value: #addBookmark + ) + #(#MenuItem + #label: 'Remove Bookmark' + #translateLabel: true + #value: #removeBookmark + #enabled: #hasBookmarksToRemove + ) + ) nil + nil + ) + + "Created: / 4.8.1998 / 17:21:16 / cg" + "Modified: / 14.8.1998 / 19:19:06 / cg" +! + baseDirectoryMenuSpec "This resource specification was automatically generated by the MenuEditor of ST/X." @@ -483,49 +513,99 @@ #(#Menu - #( - #(#MenuItem - #label: 'Copy Path' - #translateLabel: true - #value: #copyPath - ) - #(#MenuItem - #label: '-' - ) - #(#MenuItem - #label: 'Up' - #translateLabel: true - #value: #changeToParentDirectory - #enabled: #currentDirectoryIsNotTop - ) - #(#MenuItem - #label: 'Back' - #translateLabel: true - #value: #changeToPreviousDirectory - ) - #(#MenuItem - #label: 'Home' - #translateLabel: true - #value: #changeToHomeDirectory - ) - #(#MenuItem - #label: 'Default' - #translateLabel: true - #value: #changeToDefaultDirectory - ) - #(#MenuItem - #label: 'Goto...' - #translateLabel: true - #value: #changeCurrentDirectory - ) - ) nil - nil + #( + #(#MenuItem + #label: 'Copy Path' + #translateLabel: true + #value: #copyPath + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'Up' + #translateLabel: true + #value: #changeToParentDirectory + #enabled: #currentDirectoryIsNotTop + ) + #(#MenuItem + #label: 'Back' + #translateLabel: true + #value: #changeToPreviousDirectory + ) + #(#MenuItem + #label: 'Home' + #translateLabel: true + #value: #changeToHomeDirectory + ) + #(#MenuItem + #label: 'Default' + #translateLabel: true + #value: #changeToDefaultDirectory + ) + #(#MenuItem + #label: 'Goto...' + #translateLabel: true + #value: #changeCurrentDirectory + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'History' + #translateLabel: true + #submenuChannel: #historyMenuSpec + ) + #(#MenuItem + #label: 'Bookmarks' + #translateLabel: true + #submenuChannel: #bookmarksMenuSpec + ) + ) nil + nil ) "Created: / 4.8.1998 / 17:21:16 / cg" "Modified: / 14.8.1998 / 19:19:06 / cg" ! +bookmarksMenuSpec + "This resource specification was automatically generated + by the MenuEditor of ST/X." + + "Do not manually edit this!! If it is corrupted, + the MenuEditor may not be able to read the specification." + + " + MenuEditor new openOnClass:FileBrowser andSelector:#bookmarksMenuSpec + (Menu new fromLiteralArrayEncoding:(FileBrowser bookmarksMenuSpec)) startUp + " + + + + |m| + + m := self baseBookmarksMenuSpec. + m := m decodeAsLiteralArray. + + "/ add the history items ... + + DirectoryBookmarks size > 0 ifTrue:[ + m addItem:(MenuItem labeled:'-'). + DirectoryBookmarks do:[:dirName | + m addItem:((MenuItem label:dirName value:#changeDirectoryTo:) + argument:dirName; + yourself). + ]. + ]. + + "/ m receiver:self. + m findGuiResourcesIn:self. + ^ m + + "Modified: / 17.8.1998 / 10:13:05 / cg" +! + directoryMenuSpec "This resource specification was automatically generated by the MenuEditor of ST/X." @@ -538,22 +618,97 @@ (Menu new fromLiteralArrayEncoding:(FileBrowser directoryMenuSpec)) startUp " + + + ^ + + #(#Menu + + #( + #(#MenuItem + #label: 'Copy Path' + #translateLabel: true + #value: #copyPath + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'Up' + #translateLabel: true + #value: #changeToParentDirectory + #enabled: #currentDirectoryIsNotTop + ) + #(#MenuItem + #label: 'Goto...' + #translateLabel: true + #value: #changeCurrentDirectory + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'Back' + #translateLabel: true + #value: #changeToPreviousDirectory + ) + #(#MenuItem + #label: 'History' + #translateLabel: true + #submenuChannel: #historyMenuSpec + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'Default' + #translateLabel: true + #value: #changeToDefaultDirectory + ) + #(#MenuItem + #label: 'Home' + #translateLabel: true + #value: #changeToHomeDirectory + ) + #(#MenuItem + #label: 'Bookmarks' + #translateLabel: true + #submenuChannel: #bookmarksMenuSpec + ) + ) nil + nil + ) + + "Created: / 4.8.1998 / 17:21:16 / cg" + "Modified: / 14.8.1998 / 19:19:06 / cg" +! + +historyMenuSpec + "This resource specification was automatically generated + by the MenuEditor of ST/X." + + "Do not manually edit this!! If it is corrupted, + the MenuEditor may not be able to read the specification." + + " + MenuEditor new openOnClass:FileBrowser andSelector:#directoryMenuSpec + (Menu new fromLiteralArrayEncoding:(FileBrowser directoryMenuSpec)) startUp + " + |m| - m := self baseDirectoryMenuSpec. - m := m decodeAsLiteralArray. - "/ add the history items ... DirectoryHistory size > 0 ifTrue:[ - m addItem:(MenuItem labeled:'-'). - DirectoryHistory do:[:dirName | - m addItem:((MenuItem label:dirName value:#changeDirectoryTo:) - argument:dirName; - yourself). - ]. + m := Menu new. + + DirectoryHistory do:[:dirName | + m addItem:((MenuItem label:dirName value:#changeDirectoryTo:) + argument:dirName; + yourself). + ]. ]. m findGuiResourcesIn:self. @@ -909,17 +1064,23 @@ #(#Menu #( #(#MenuItem - #label: 'Details' + #label: 'Show Details' #translateLabel: true #indication: #showingDetails ) #(#MenuItem + #label: 'Show Time && Date' + #translateLabel: true + #indication: #showingTimeAndDate + #enabled: #showingDetails + ) + #(#MenuItem #label: 'Show Hidden Files' #translateLabel: true #indication: #showingHiddenFiles ) #(#MenuItem - #label: 'Big Image Preview' + #label: 'Show Big Image Preview' #translateLabel: true #indication: #showingBigImagePreview ) @@ -945,7 +1106,7 @@ #choiceValue: #time ) #(#MenuItem - #label: 'Ignore Case' + #label: 'Ignore Case in Sort' #translateLabel: true #indication: #sortCaseless ) @@ -1367,10 +1528,10 @@ canRemoveCVSContainer ^ [ |cvsDir| - currentDirectory notNil - and:[fileListView selection size > 0 - and:[(cvsDir := currentDirectory construct:'CVS') exists - and:[cvsDir isDirectory]]]] + currentDirectory notNil + and:[fileListView selection size > 0 + and:[(cvsDir := currentDirectory construct:'CVS') exists + and:[cvsDir isDirectory]]]] ! canRemoveFromClassPath @@ -1436,6 +1597,21 @@ and:[OSI::ASN1Parser isLoaded]]] ! +hasBookmarks + ^ DirectoryBookmarks size > 0 + + "Created: / 14.8.1998 / 19:17:02 / cg" + "Modified: / 14.8.1998 / 19:17:17 / cg" +! + +hasBookmarksToRemove + ^ DirectoryBookmarks size > 0 + and:[ DirectoryBookmarks includes:(currentDirectory asFilename pathName) ] + + "Created: / 14.8.1998 / 19:17:02 / cg" + "Modified: / 14.8.1998 / 19:17:17 / cg" +! + hasCBrowser ^ [ CC::Browser notNil ] @@ -1444,15 +1620,15 @@ hasFilenameSelectionInCodeView ^ [ |val sel| - val := false. - sel := subView selection. - sel notNil ifTrue:[ - sel := sel asString withoutSeparators. - sel asFilename exists ifTrue:[ - val := sel asFilename isReadable - ] - ]. - val + val := false. + sel := subView selection. + sel notNil ifTrue:[ + sel := sel asString withoutSeparators. + sel asFilename exists ifTrue:[ + val := sel asFilename isReadable + ] + ]. + val ] "Created: / 4.2.1999 / 17:34:57 / cg" @@ -1461,7 +1637,7 @@ hasJava ^ [ JavaClassReader notNil - and:[JavaClassReader isLoaded]] + and:[JavaClassReader isLoaded]] "Modified: / 17.10.1998 / 16:57:14 / cg" "Created: / 17.10.1998 / 22:58:25 / cg" @@ -1469,8 +1645,8 @@ hasJavaAndSelection ^ [ fileListView selection size > 0 - and:[JavaClassReader notNil - and:[JavaClassReader isLoaded]]] + and:[JavaClassReader notNil + and:[JavaClassReader isLoaded]]] "Modified: / 17.10.1998 / 16:57:14 / cg" "Created: / 17.10.1998 / 22:58:03 / cg" @@ -1503,21 +1679,28 @@ "Modified: / 4.8.1998 / 14:10:57 / cg" ! +hasVisitHistory + ^ [DirectoryHistory size > 0] + + "Created: / 14.8.1998 / 19:17:02 / cg" + "Modified: / 14.8.1998 / 19:17:17 / cg" +! + hasZipFileSelected ^ [|sel f fn suff| - sel := fileListView selection. - sel size == 1 ifTrue:[ - f := fileList at:sel first ifAbsent:nil. - f notNil ifTrue:[ - suff := f asFilename suffix asLowercase. - suff = 'zip' or:[suff = 'jar'] - ] ifFalse:[ - false - ] - ] ifFalse:[ - false - ] + sel := fileListView selection. + sel size == 1 ifTrue:[ + f := fileList at:sel first ifAbsent:nil. + f notNil ifTrue:[ + suff := f asFilename suffix asLowercase. + suff = 'zip' or:[suff = 'jar'] + ] ifFalse:[ + false + ] + ] ifFalse:[ + false + ] ] "Created: / 26.8.1998 / 16:15:26 / cg" @@ -1526,7 +1709,7 @@ javaSupportLoaded ^ [ JavaClassReader notNil - and:[JavaClassReader isLoaded]] + and:[JavaClassReader isLoaded]] "Created: / 9.11.1998 / 05:33:17 / cg" ! @@ -1549,6 +1732,12 @@ "Created: / 14.8.1998 / 14:15:44 / cg" ! +showingTimeAndDate + ^ showingTimeAndDate + + "Created: / 14.8.1998 / 14:15:44 / cg" +! + singleSelectedFile |f sel| @@ -1619,9 +1808,9 @@ "I accept fileObjects only" aCollectionOfDropObjects do:[:aDropObject | - aDropObject isFileObject ifFalse:[ - aDropObject isTextObject ifFalse:[^ false]. - ] + aDropObject isFileObject ifFalse:[ + aDropObject isTextObject ifFalse:[^ false]. + ] ]. ^ true @@ -1655,30 +1844,30 @@ |newDir newFile| someObject isFileObject ifTrue:[ - someObject isDirectory ifTrue:[ - newDir := someObject theObject pathName. - ] ifFalse:[ - newDir := someObject theObject directoryName. - newFile := someObject theObject baseName. - ]. - - newDir notNil ifTrue:[ - newDir ~= currentDirectory pathName ifTrue:[ - self changeDirectoryTo:newDir. - ] - ]. - newFile notNil ifTrue:[ - newFile ~= currentFileName ifTrue:[ - fileListView selection:(fileList indexOf:newFile). - self doFileGet:false. - ] - ]. - ^ self + someObject isDirectory ifTrue:[ + newDir := someObject theObject pathName. + ] ifFalse:[ + newDir := someObject theObject directoryName. + newFile := someObject theObject baseName. + ]. + + newDir notNil ifTrue:[ + newDir ~= currentDirectory pathName ifTrue:[ + self changeDirectoryTo:newDir. + ] + ]. + newFile notNil ifTrue:[ + newFile ~= currentFileName ifTrue:[ + fileListView selection:(fileList indexOf:newFile). + self doFileGet:false. + ] + ]. + ^ self ]. someObject isTextObject ifTrue:[ - subView paste:someObject theObject. - ^ self + subView paste:someObject theObject. + ^ self ]. "Modified: 6.4.1997 / 14:46:44 / cg" @@ -1797,11 +1986,11 @@ wasVisible := shown. super visibilityChange:how. (wasVisible not and:[shown]) ifTrue:[ - " - start checking again - " - Processor removeTimedBlock:checkBlock. - Processor addTimedBlock:checkBlock afterSeconds:checkDelta. + " + start checking again + " + Processor removeTimedBlock:checkBlock. + Processor addTimedBlock:checkBlock afterSeconds:checkDelta. ] "Modified: / 18.2.1998 / 17:57:44 / cg" @@ -1816,12 +2005,12 @@ (showingBigImagePreview value == true and:[showingDetails value == true]) ifTrue:[ - fh := fileListView font height. - fileListView lineSpacing:(34 - fh max:0). + fh := fileListView font height. + fileListView lineSpacing:(34 - fh max:0). ] ifFalse:[ - fileListView clear. - self updateCurrentDirectory. - fileListView lineSpacing:2. + fileListView clear. + self updateCurrentDirectory. + fileListView lineSpacing:2. ]. fileListView clear. self updateCurrentDirectory @@ -1929,11 +2118,11 @@ dialog open. dialog accepted ifTrue:[ - idx := list selectionIndex. - fileEncoding := encodings at:idx. - subView externalEncoding:fileEncoding. - - self validateFontEncodingFor:fileEncoding ask:true. + idx := list selectionIndex. + fileEncoding := encodings at:idx. + subView externalEncoding:fileEncoding. + + self validateFontEncodingFor:fileEncoding ask:true. ]. "Modified: 30.6.1997 / 14:41:12 / cg" @@ -2073,93 +2262,93 @@ result info dirPrefix| (self askIfModified:'contents has not been saved.\\Modifications will be lost when you proceed.' - yesButton:'proceed') ifFalse:[^ self]. + yesButton:'proceed') ifFalse:[^ self]. self withWaitCursorDo:[ - result := Dictionary new. - - dir := currentDirectory asFilename. - self label:myName , '- gathering file names ...'. - fileNames := dir recursiveDirectoryContents. - fileNames := fileNames collect:[:fn | dir construct:fn]. - fileNames := fileNames select:[:fn | fn isDirectory not]. - - self label:myName , '- gathering sizes ...'. - infoDir := Dictionary new. - fileNames do:[:fn | - infoDir at:fn put:(fn fileSize) - ]. - - "/ for each, get the files size. - "/ in a first pass, look for files of the same size and - "/ compare them ... - - self label:myName , '- preselect possible duplicates ...'. - filesBySize := Dictionary new. - infoDir keysAndValuesDo:[:fn :sz | - |entry| - - entry := filesBySize at:sz ifAbsentPut:[Set new]. - entry add:fn. - ]. - - "/ any of same size ? - - self label:myName , '- checking for duplicates ...'. - filesBySize do:[:entry | - |files| - - entry size > 1 ifTrue:[ - files := entry asArray. - 1 to:files size-1 do:[:idx1 | - idx1+1 to:files size do:[:idx2 | - |fn1 fn2| - - fn1 := files at:idx1. - fn2 := files at:idx2. + result := Dictionary new. + + dir := currentDirectory asFilename. + self label:myName , '- gathering file names ...'. + fileNames := dir recursiveDirectoryContents. + fileNames := fileNames collect:[:fn | dir construct:fn]. + fileNames := fileNames select:[:fn | fn isDirectory not]. + + self label:myName , '- gathering sizes ...'. + infoDir := Dictionary new. + fileNames do:[:fn | + infoDir at:fn put:(fn fileSize) + ]. + + "/ for each, get the files size. + "/ in a first pass, look for files of the same size and + "/ compare them ... + + self label:myName , '- preselect possible duplicates ...'. + filesBySize := Dictionary new. + infoDir keysAndValuesDo:[:fn :sz | + |entry| + + entry := filesBySize at:sz ifAbsentPut:[Set new]. + entry add:fn. + ]. + + "/ any of same size ? + + self label:myName , '- checking for duplicates ...'. + filesBySize do:[:entry | + |files| + + entry size > 1 ifTrue:[ + files := entry asArray. + 1 to:files size-1 do:[:idx1 | + idx1+1 to:files size do:[:idx2 | + |fn1 fn2| + + fn1 := files at:idx1. + fn2 := files at:idx2. "/ self label:myName , '- checking ' , fn1 baseName , ' vs. ' , fn2 baseName , ' ...'. - (result at:fn2 ifAbsent:nil) ~= fn1 ifTrue:[ - "/ compare the files - (fn1 sameContentsAs:fn2) ifTrue:[ + (result at:fn2 ifAbsent:nil) ~= fn1 ifTrue:[ + "/ compare the files + (fn1 sameContentsAs:fn2) ifTrue:[ "/ Transcript show:'Same: '; show:fn1 baseName; show:' and '; showCR:fn2 baseName. - result at:fn1 put:fn2. - ] - ] - ] - ] - ] - ]. - - self label:myName , '- sorting ...'. - dirPrefix := currentDirectory asFilename pathName. - result := result associations. - result := result collect:[:assoc | - |f1 f2| - - f1 := assoc key name. - f2 := assoc value name. - (f1 startsWith:dirPrefix) ifTrue:[ - f1 := f1 copyFrom:dirPrefix size + 2. - ]. - (f2 startsWith:dirPrefix) ifTrue:[ - f2 := f2 copyFrom:dirPrefix size + 2. - ]. - f1 < f2 ifTrue:[ - f2 -> f1 - ] ifFalse:[ - f1 -> f2 - ] - ]. - result sort:[:f1 :f2 | f2 value < f1 value]. - - info := OrderedCollection new. - result do:[:assoc | - info add:(assoc key , ' same as ' , assoc value) - ]. - info isEmpty ifTrue:[ - info := 'No duplicate files found.' - ]. + result at:fn1 put:fn2. + ] + ] + ] + ] + ] + ]. + + self label:myName , '- sorting ...'. + dirPrefix := currentDirectory asFilename pathName. + result := result associations. + result := result collect:[:assoc | + |f1 f2| + + f1 := assoc key name. + f2 := assoc value name. + (f1 startsWith:dirPrefix) ifTrue:[ + f1 := f1 copyFrom:dirPrefix size + 2. + ]. + (f2 startsWith:dirPrefix) ifTrue:[ + f2 := f2 copyFrom:dirPrefix size + 2. + ]. + f1 < f2 ifTrue:[ + f2 -> f1 + ] ifFalse:[ + f1 -> f2 + ] + ]. + result sort:[:f1 :f2 | f2 value < f1 value]. + + info := OrderedCollection new. + result do:[:assoc | + info add:(assoc key , ' same as ' , assoc value) + ]. + info isEmpty ifTrue:[ + info := 'No duplicate files found.' + ]. ]. subView contents:info. @@ -2176,81 +2365,81 @@ result info| (self askIfModified:'contents has not been saved.\\Modifications will be lost when you proceed.' - yesButton:'proceed') ifFalse:[^ self]. + yesButton:'proceed') ifFalse:[^ self]. self withWaitCursorDo:[ - result := Dictionary new. - - dir := currentDirectory asFilename. - fileNames := dir directoryContents. - fileNames := fileNames collect:[:fn | dir construct:fn]. - fileNames := fileNames select:[:fn | fn isDirectory not]. - - infoDir := Dictionary new. - fileNames do:[:fn | - infoDir at:fn put:(fn info) - ]. - - "/ for each, get the files size. - "/ in a first pass, look for files of the same size and - "/ compare them ... - - filesBySize := Dictionary new. - infoDir keysAndValuesDo:[:fn :info | - |sz entry| - - sz := info size. - entry := filesBySize at:sz ifAbsentPut:[Set new]. - entry add:fn. - ]. - - "/ any of same size ? - - filesBySize do:[:entry | - |files| - - entry size > 1 ifTrue:[ - files := entry asArray. - 1 to:files size-1 do:[:idx1 | - idx1+1 to:files size do:[:idx2 | - |fn1 fn2| - - fn1 := files at:idx1. - fn2 := files at:idx2. - - (result at:fn2 ifAbsent:nil) ~= fn1 ifTrue:[ - "/ compare the files - (fn1 sameContentsAs:fn2) ifTrue:[ + result := Dictionary new. + + dir := currentDirectory asFilename. + fileNames := dir directoryContents. + fileNames := fileNames collect:[:fn | dir construct:fn]. + fileNames := fileNames select:[:fn | fn isDirectory not]. + + infoDir := Dictionary new. + fileNames do:[:fn | + infoDir at:fn put:(fn info) + ]. + + "/ for each, get the files size. + "/ in a first pass, look for files of the same size and + "/ compare them ... + + filesBySize := Dictionary new. + infoDir keysAndValuesDo:[:fn :info | + |sz entry| + + sz := info size. + entry := filesBySize at:sz ifAbsentPut:[Set new]. + entry add:fn. + ]. + + "/ any of same size ? + + filesBySize do:[:entry | + |files| + + entry size > 1 ifTrue:[ + files := entry asArray. + 1 to:files size-1 do:[:idx1 | + idx1+1 to:files size do:[:idx2 | + |fn1 fn2| + + fn1 := files at:idx1. + fn2 := files at:idx2. + + (result at:fn2 ifAbsent:nil) ~= fn1 ifTrue:[ + "/ compare the files + (fn1 sameContentsAs:fn2) ifTrue:[ "/ Transcript show:'Same: '; show:fn1 baseName; show:' and '; showCR:fn2 baseName. - result at:fn1 put:fn2. - ] - ] - ] - ] - ] - ]. - - result := result associations. - result := result collect:[:assoc | - |f1 f2| - - f1 := assoc key baseName. - f2 := assoc value baseName. - f1 < f2 ifTrue:[ - f2 -> f1 - ] ifFalse:[ - f1 -> f2 - ] - ]. - result sort:[:f1 :f2 | f2 value < f1 value]. - - info := OrderedCollection new. - result do:[:assoc | - info add:(assoc key , ' same as ' , assoc value) - ]. - info isEmpty ifTrue:[ - info := 'No duplicate files found.' - ]. + result at:fn1 put:fn2. + ] + ] + ] + ] + ] + ]. + + result := result associations. + result := result collect:[:assoc | + |f1 f2| + + f1 := assoc key baseName. + f2 := assoc value baseName. + f1 < f2 ifTrue:[ + f2 -> f1 + ] ifFalse:[ + f1 -> f2 + ] + ]. + result sort:[:f1 :f2 | f2 value < f1 value]. + + info := OrderedCollection new. + result do:[:assoc | + info add:(assoc key , ' same as ' , assoc value) + ]. + info isEmpty ifTrue:[ + info := 'No duplicate files found.' + ]. ]. subView contents:info @@ -2487,18 +2676,18 @@ string := self getFileInfoString:longInfo. string notNil ifTrue:[ - box := InfoBox title:string. - updater := [ - [true] whileTrue:[ - Delay waitForSeconds:2. - string := self getFileInfoString:longInfo. - box title:string - ] - ] fork. - - box showAtPointer. - updater terminate. - box destroy + box := InfoBox title:string. + updater := [ + [true] whileTrue:[ + Delay waitForSeconds:2. + string := self getFileInfoString:longInfo. + box title:string + ] + ] fork. + + box showAtPointer. + updater terminate. + box destroy ] ! @@ -2599,7 +2788,7 @@ fileName := self getSelectedFileName. fileName notNil ifTrue:[ - self showFile:fileName insert:true encoding:fileEncoding + self showFile:fileName insert:true encoding:fileEncoding ] "Modified: 23.4.1997 / 13:06:06 / cg" @@ -2641,87 +2830,87 @@ |items m sel ns subMenu subItems| items := #( - ('spawn' fileSpawn ) - ('-' nil ) - ('get contents' fileGet GotoLine) - ('insert contents' fileInsert ) - ('show info' fileGetInfo InspectIt) - ('show full info' fileGetLongInfo CmdI) - ). + ('spawn' fileSpawn ) + ('-' nil ) + ('get contents' fileGet GotoLine) + ('insert contents' fileInsert ) + ('show info' fileGetInfo InspectIt) + ('show full info' fileGetLongInfo CmdI) + ). ((ns := Project current defaultNameSpace) notNil and:[ns ~~ Smalltalk]) ifTrue:[ - items := items copyWith:(Array - with:(resources string:'fileIn (into ''%1'')' with:(Project current defaultNameSpace name)) - with:#fileFileIn - with:#Accept) + items := items copyWith:(Array + with:(resources string:'fileIn (into ''%1'')' with:(Project current defaultNameSpace name)) + with:#fileFileIn + with:#Accept) ] ifFalse:[ - items := items copyWith:#( 'fileIn' #fileFileIn #Accept) + items := items copyWith:#( 'fileIn' #fileFileIn #Accept) ]. items := items , #( - ('-' ) - ('update' updateCurrentDirectory Cmdu) - ('-' ) - ('execute unix command ...' fileExecute DoIt) - ('st/x tools' stxTools ) - ('-' ) - ('remove' fileRemove Delete) - ('rename ...' fileRename ) - ('-' ) - ('display long list' changeDisplayMode ) - ('show all files' changeDotFileVisibility ) - ('encoding ...' fileEncoding ) - ('-' ) - ('create directory ...' newDirectory CmdD) - ('create file ...' newFile CmdF) - ). + ('-' ) + ('update' updateCurrentDirectory Cmdu) + ('-' ) + ('execute unix command ...' fileExecute DoIt) + ('st/x tools' stxTools ) + ('-' ) + ('remove' fileRemove Delete) + ('rename ...' fileRename ) + ('-' ) + ('display long list' changeDisplayMode ) + ('show all files' changeDotFileVisibility ) + ('encoding ...' fileEncoding ) + ('-' ) + ('create directory ...' newDirectory CmdD) + ('create file ...' newFile CmdF) + ). m := PopUpMenu - itemList:items - resources:resources. + itemList:items + resources:resources. showingHiddenFiles value "showDotFiles" ifTrue:[ - m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files') + m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files') ]. showingDetails value "showLongList" ifTrue:[ - m labelAt:#changeDisplayMode put:(resources string:'display short list') + m labelAt:#changeDisplayMode put:(resources string:'display short list') ]. items := #( - ('Changes browser' openChangesBrowser ) - ('Editor' openEditor ) - ('HTML reader' openHTMLReader ) - ('Image inspect' openImageInspector ) - ('show file differences' openDiffView ) - ). + ('Changes browser' openChangesBrowser ) + ('Editor' openEditor ) + ('HTML reader' openHTMLReader ) + ('Image inspect' openImageInspector ) + ('show file differences' openDiffView ) + ). OperatingSystem isUNIXlike ifTrue:[ - items := items , #( ('terminal' openTerminal )). + items := items , #( ('terminal' openTerminal )). ]. JavaInterpreter notNil ifTrue:[ - items := items , #( ('Java Applet Viewer' openAppletViewer)). + items := items , #( ('Java Applet Viewer' openAppletViewer)). ]. m subMenuAt:#stxTools - put:(PopUpMenu - itemList:items - resources:resources). + put:(PopUpMenu + itemList:items + resources:resources). ((sel := fileListView selection) isNil or:[sel isEmpty]) ifTrue:[ - m disableAll:#(fileGet fileInsert - fileGetInfo fileGetLongInfo - fileFileIn fileFileInLazy - fileRemove fileRename). - (m subMenuAt:#stxTools) - disableAll:#(openChangesBrowser openEditor openHTMLReader openImageInspector) + m disableAll:#(fileGet fileInsert + fileGetInfo fileGetLongInfo + fileFileIn fileFileInLazy + fileRemove fileRename). + (m subMenuAt:#stxTools) + disableAll:#(openChangesBrowser openEditor openHTMLReader openImageInspector) ] ifFalse:[ - fileListView selection size > 1 ifTrue:[ - m disableAll:#( fileGet fileInsert fileGetInfo fileGetLongInfo fileRename ) - ] + fileListView selection size > 1 ifTrue:[ + m disableAll:#( fileGet fileInsert fileGetInfo fileGetLongInfo fileRename ) + ] ]. ^m @@ -2737,25 +2926,25 @@ |fileName path inStream printStream line| self withWaitCursorDo:[ - fileName := self getSelectedFileName. - fileName notNil ifTrue:[ - path := currentDirectory filenameFor:fileName. - (path type == #regular) ifTrue:[ - inStream := path readStream. - inStream isNil ifFalse:[ - printStream := PrinterStream new. - printStream notNil ifTrue:[ - [inStream atEnd] whileFalse:[ - line := inStream nextLine. - printStream nextPutLine:line. - ]. - printStream close - ]. - inStream close - ] - ] - ]. - 0 "compiler hint" + fileName := self getSelectedFileName. + fileName notNil ifTrue:[ + path := currentDirectory filenameFor:fileName. + (path type == #regular) ifTrue:[ + inStream := path readStream. + inStream isNil ifFalse:[ + printStream := PrinterStream new. + printStream notNil ifTrue:[ + [inStream atEnd] whileFalse:[ + line := inStream nextLine. + printStream nextPutLine:line. + ]. + printStream close + ]. + inStream close + ] + ] + ]. + 0 "compiler hint" ] "Modified: 23.4.1997 / 13:05:40 / cg" @@ -2864,19 +3053,19 @@ |fn| imagePreviewView notNil ifTrue:[ - self stopImageRenderProcess. - - fn := self getSelectedFileName. - (Image isImageFileSuffix:(fn asFilename suffix)) ifTrue:[ - imageRenderProcess := [ - self loadImageAndPerform:[:img | - imagePreviewView beVisible. - imagePreviewView image:img - ] - ] forkAt:(Processor activePriority - 1). - ] ifFalse:[ - imagePreviewView beInvisible - ]. + self stopImageRenderProcess. + + fn := self getSelectedFileName. + (Image isImageFileSuffix:(fn asFilename suffix)) ifTrue:[ + imageRenderProcess := [ + self loadImageAndPerform:[:img | + imagePreviewView beVisible. + imagePreviewView image:img + ] + ] forkAt:(Processor activePriority - 1). + ] ifFalse:[ + imagePreviewView beInvisible + ]. ] "Modified: 23.4.1997 / 13:04:55 / cg" @@ -2897,7 +3086,10 @@ ] ]. any ifFalse:[ - self class openOn:currentDirectory pathName withExtent:self topView extent + "/ access by name, to get most up-to-date version + "/ (if changed in the browser, and the running one is old) + (Smalltalk at:(self class name)) + openOn:currentDirectory pathName withExtent:self topView extent ] "Modified: 18.9.1997 / 16:32:39 / stefan" @@ -2907,19 +3099,19 @@ |img path| self selectedFilesDo:[:fileName | - path := currentDirectory filenameFor:fileName. - path isDirectory ifFalse:[ - img := Image fromFile:(path pathName). - img notNil ifTrue:[ - aSelectorOrBlock isSymbol ifTrue:[ - img perform:aSelectorOrBlock - ] ifFalse:[ - aSelectorOrBlock value:img - ] - ] ifFalse:[ - self warn:'unknown format: ' , fileName - ] - ] + path := currentDirectory filenameFor:fileName. + path isDirectory ifFalse:[ + img := Image fromFile:(path pathName). + img notNil ifTrue:[ + aSelectorOrBlock isSymbol ifTrue:[ + img perform:aSelectorOrBlock + ] ifFalse:[ + aSelectorOrBlock value:img + ] + ] ifFalse:[ + self warn:'unknown format: ' , fileName + ] + ] ]. "Modified: / 17.9.1995 / 17:41:24 / claus" @@ -3109,9 +3301,9 @@ |numItems| (numItems := fileListView selection size) > 2 ifTrue:[ - (self - confirm:(resources string:'open for each of the %1 items ?' - with:numItems)) ifFalse:[^ self]. + (self + confirm:(resources string:'open for each of the %1 items ?' + with:numItems)) ifFalse:[^ self]. ]. Java startupJavaSystem. @@ -3120,15 +3312,15 @@ "/ Java initAllClasses. self selectedFilesDo:[:fileName | - |p path| - - path := currentDirectory filenameFor:fileName. - path isDirectory ifFalse:[ - p := Java - javaProcessForMainOf:(Java classForName:'sun.applet.AppletViewer') - argumentString:path pathName. - p resume. - ] + |p path| + + path := currentDirectory filenameFor:fileName. + path isDirectory ifFalse:[ + p := Java + javaProcessForMainOf:(Java classForName:'sun.applet.AppletViewer') + argumentString:path pathName. + p resume. + ] ]. "Modified: / 18.9.1997 / 17:00:59 / stefan" @@ -3277,21 +3469,21 @@ openImagePreview [self loadImageAndPerform:[:img | - |i top viewer| - - top := StandardSystemView new. - - viewer := ImageView origin:0.0@0.0 corner:1.0@1.0 in:top. - i := img. - top extent:200@200. - top label:(img fileName asFilename directoryName asFilename baseName , '/' , img fileName asFilename baseName). - top openAndWait. - - (i width > 200 or:[i height > 200]) ifTrue:[ - i := i magnifiedPreservingRatioTo:200@200. - ]. - viewer image:i. - ]. + |i top viewer| + + top := StandardSystemView new. + + viewer := ImageView origin:0.0@0.0 corner:1.0@1.0 in:top. + i := img. + top extent:200@200. + top label:(img fileName asFilename directoryName asFilename baseName , '/' , img fileName asFilename baseName). + top openAndWait. + + (i width > 200 or:[i height > 200]) ifTrue:[ + i := i magnifiedPreservingRatioTo:200@200. + ]. + viewer image:i. + ]. ] fork "Modified: / 4.12.1998 / 15:49:03 / cg" @@ -3313,10 +3505,10 @@ sel := subView selection. sel notNil ifTrue:[ - sel := sel asString withoutSeparators. - sel asFilename exists ifTrue:[ - self doOpenFile:sel viaDoubleClick:false - ] + sel := sel asString withoutSeparators. + sel asFilename exists ifTrue:[ + self doOpenFile:sel viaDoubleClick:false + ] ]. "Created: / 4.2.1999 / 17:40:42 / cg" @@ -3430,25 +3622,25 @@ "depending on the showLongList setting, show or hde the tabSpec view" showingDetails value "showLongList" ifTrue:[ - tabRulerView isNil ifTrue:[ - self createTabRulerIn:scrollView superView. - ]. - tabRulerView beVisible. + tabRulerView isNil ifTrue:[ + self createTabRulerIn:scrollView superView. + ]. + tabRulerView beVisible. - false "self is3D" ifTrue:[ - scrollView topInset:(tabRulerView superView height). - tabRulerView superView leftInset:(fileListView originRelativeTo:scrollView) x. - ] ifFalse:[ - scrollView topInset:(tabRulerView height). - tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x. - ]. - tabRulerView hiddenTabs:#(1). - tabRulerView fixedTabs:#(1). + false "self is3D" ifTrue:[ + scrollView topInset:(tabRulerView superView height). + tabRulerView superView leftInset:(fileListView originRelativeTo:scrollView) x. + ] ifFalse:[ + scrollView topInset:(tabRulerView height). + tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x. + ]. + tabRulerView hiddenTabs:#(1). + tabRulerView fixedTabs:#(1). ] ifFalse:[ - tabRulerView notNil ifTrue:[ - tabRulerView beInvisible. - ]. - scrollView topInset:0 + tabRulerView notNil ifTrue:[ + tabRulerView beInvisible. + ]. + scrollView topInset:0 ]. tabSpec := nil. @@ -3462,22 +3654,22 @@ |s| aComponent == subView ifTrue:[ - s := 'HELP_SUBVIEW' + s := 'HELP_SUBVIEW' ]. aComponent == fileListView ifTrue:[ - s := 'HELP_FILELIST' + s := 'HELP_FILELIST' ]. aComponent == filterField ifTrue:[ - s := 'HELP_FILTER' + s := 'HELP_FILTER' ]. aComponent == labelView ifTrue:[ - s := 'HELP_PATHFIELD' + s := 'HELP_PATHFIELD' ]. aComponent == commandView ifTrue:[ - s := 'HELP_COMMANDVIEW' + s := 'HELP_COMMANDVIEW' ]. s notNil ifTrue:[ - ^ resources string:s + ^ resources string:s ]. ^ nil ! ! @@ -3599,6 +3791,9 @@ showingBigImagePreview := (resources at:'BIG_IMAGE_PREVIEW' default:false) asValue. showingBigImagePreview onChangeSend:#bigImagePreviewSettingChanged to:self. + showingTimeAndDate := (resources at:'SHOW_TIME_AND_DATE' default:false) asValue. + showingTimeAndDate onChangeSend:#updateCurrentDirectory to:self. + sortByWhat := #name asValue. sortByWhat onChangeSend:#sortChanged to:self. @@ -3955,6 +4150,25 @@ !FileBrowser methodsFor:'menu actions'! +addBookmark + self addBookmark:currentDirectory asFilename pathName +! + +addBookmark:path + |idx| + + DirectoryBookmarks isNil ifTrue:[ + DirectoryBookmarks := OrderedCollection new + ]. + idx := DirectoryBookmarks indexOf:path. + idx == 0 ifTrue:[ +"/ DirectoryBookmarks size >= HistorySize ifTrue:[ +"/ DirectoryBookmarks removeLast. +"/ ]. + DirectoryBookmarks addLast:path. + ]. +! + copyCommandHistory "copy the command history to the clipBoard" @@ -3967,15 +4181,15 @@ "copy fileList to the clipBoard" self setTextSelection:(fileListView list - collect:[:l | |ll| - ll := l string withoutSeparators. - (ll endsWith:' ...') ifTrue:[ - ll copyWithoutLast:4 - ] ifFalse:[ - ll - ] - ]) - asStringCollection asString. + collect:[:l | |ll| + ll := l string withoutSeparators. + (ll endsWith:' ...') ifTrue:[ + ll copyWithoutLast:4 + ] ifFalse:[ + ll + ] + ]) + asStringCollection asString. "Modified: / 17.8.1998 / 10:13:10 / cg" ! @@ -3987,8 +4201,8 @@ sel := fileListView selection. sel size == 1 ifTrue:[ - fileName := fileList at:sel first. - self setTextSelection:fileName + fileName := fileList at:sel first. + self setTextSelection:fileName ]. ! @@ -4055,6 +4269,13 @@ msg := '\' withCRs , myClass name asBoldText, rev. + AboutBox isNil ifTrue:[ + "/ this handles bad installations of ST/X, + "/ where the AboutBox is missing. + "/ (May vanish in the future) + ^ self information:msg + ]. + Dialog about:(resources string:msg) label:(resources string:'About FileBrowser') @@ -4087,6 +4308,11 @@ "Created: / 14.8.1998 / 14:14:16 / cg" ! +removeBookmark + DirectoryBookmarks isNil ifTrue:[ ^ self]. + DirectoryBookmarks remove:(currentDirectory asFilename pathName) ifAbsent:nil. +! + showAboutSTX ToolApplicationModel openAboutSTX @@ -4199,7 +4425,7 @@ "update this directory" self - doExecuteCommand:'cvs upd -l' replace:false + doExecuteCommand:'cvs upd -l' replace:false "Modified: / 16.12.1998 / 17:30:31 / cg" ! @@ -4208,7 +4434,7 @@ "update this directory" self - doExecuteCommand:'cvs upd -d' replace:false + doExecuteCommand:'cvs upd -d' replace:false "Modified: / 16.12.1998 / 17:30:31 / cg" ! @@ -4220,11 +4446,11 @@ sel := fileListView selection. sel size > 0 ifTrue:[ - sel := sel collect:[:rawIndex | fileList at:rawIndex]. - sel do:[:fn | - self - doExecuteCommand:('cvs upd ' , fn) replace:false - ] + sel := sel collect:[:rawIndex | fileList at:rawIndex]. + sel do:[:fn | + self + doExecuteCommand:('cvs upd ' , fn) replace:false + ] ]. ! @@ -4245,60 +4471,60 @@ yesToAll := false. lockUpdate := true. [ - filesToRemove do:[:fileName | - |f| - - f := currentDirectory construct:fileName. - OperatingSystem accessDeniedErrorSignal handle:[:ex| - "was not able to remove it" - msg := (resources string:'cannot remove ''%1'' !!' with:fileName). - self showAlert:msg with:(OperatingSystem lastErrorString) - ] do:[ - |answer contents| - - (f isSymbolicLink not) ifTrue:[ - self - doExecuteCommand:('cvs remove -f ' , f baseName) - replace:false. + filesToRemove do:[:fileName | + |f| + + f := currentDirectory construct:fileName. + OperatingSystem accessDeniedErrorSignal handle:[:ex| + "was not able to remove it" + msg := (resources string:'cannot remove ''%1'' !!' with:fileName). + self showAlert:msg with:(OperatingSystem lastErrorString) + ] do:[ + |answer contents| + + (f isSymbolicLink not) ifTrue:[ + self + doExecuteCommand:('cvs remove -f ' , f baseName) + replace:false. " - self show:nil + self show:nil " - idx := fileList indexOf:fileName. - idx ~~ 0 ifTrue:[ - toRemove add:idx. - ] - ] - ]. - ]. + idx := fileList indexOf:fileName. + idx ~~ 0 ifTrue:[ + toRemove add:idx. + ] + ] + ]. + ]. ] valueNowOrOnUnwindDo:[ - lockUpdate := false. - fileListView setSelection:nil. - - "/ - "/ remove reverse - otherwise indices are wrong - "/ - toRemove sort. - toRemove reverseDo:[:idx | - fileList removeIndex:idx. - fileListView removeIndex:idx. - ]. - - updateRunning ifTrue:[ - self updateCurrentDirectory - ] ifFalse:[ - " - install a new check after some time - " - needUpdate ifFalse:[timeOfLastCheck := AbsoluteTime now]. - Processor removeTimedBlock:checkBlock. - Processor addTimedBlock:checkBlock afterSeconds:checkDelta. - ] + lockUpdate := false. + fileListView setSelection:nil. + + "/ + "/ remove reverse - otherwise indices are wrong + "/ + toRemove sort. + toRemove reverseDo:[:idx | + fileList removeIndex:idx. + fileListView removeIndex:idx. + ]. + + updateRunning ifTrue:[ + self updateCurrentDirectory + ] ifFalse:[ + " + install a new check after some time + " + needUpdate ifFalse:[timeOfLastCheck := AbsoluteTime now]. + Processor removeTimedBlock:checkBlock. + Processor addTimedBlock:checkBlock afterSeconds:checkDelta. + ] ]. self - doExecuteCommand:('cvs commit -m ''removed via FileBrowser''') - replace:false. + doExecuteCommand:('cvs commit -m ''removed via FileBrowser''') + replace:false. "Modified: / 21.10.1998 / 17:02:11 / cg" ! ! @@ -4324,7 +4550,7 @@ return true if changes should be discarded, false otherwise" ^ self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.' - yesButton:'change' + yesButton:'change' "Created: 2.10.1997 / 14:08:37 / stefan" ! @@ -4409,28 +4635,28 @@ realized ifFalse:[^ self]. (what == #aboutToExit) ifTrue:[ - "system wants to shut down this - - if text was modified, pop up, and ask user and save if requested." - - (subView modified and:[subView contentsWasSaved not]) ifTrue:[ - self raiseDeiconified. - - (self - ask:(resources at:'FileBrowser:\\contents has not been saved.\\Save before exiting ?') - yesButton:'save' - noButton:'don''t save') - ifTrue:[ - subView acceptAction notNil ifTrue:[ - subView accept - ] ifFalse:[ - subView save - ] - ] - ]. - ^ self + "system wants to shut down this + - if text was modified, pop up, and ask user and save if requested." + + (subView modified and:[subView contentsWasSaved not]) ifTrue:[ + self raiseDeiconified. + + (self + ask:(resources at:'FileBrowser:\\contents has not been saved.\\Save before exiting ?') + yesButton:'save' + noButton:'don''t save') + ifTrue:[ + subView acceptAction notNil ifTrue:[ + subView accept + ] ifFalse:[ + subView save + ] + ] + ]. + ^ self ]. changedObject == tabSpec ifTrue:[ - fileListView invalidate + fileListView invalidate ]. "Modified: 29.5.1996 / 16:13:43 / cg" @@ -4458,12 +4684,20 @@ "Created: 2.8.1997 / 14:11:19 / cg" ! +bookmarksMenuSpec + "return the bookmarksMenu for the path label" + + + + ^ self menuFromSpec:(self class bookmarksMenuSpec). +! + changeCurrentDirectory "if text was modified show a queryBox, otherwise ask for & change to that directory" self discardChangesDialog ifTrue:[ - self queryForDirectoryToChange + self queryForDirectoryToChange ] "Modified: 21.9.1997 / 23:45:35 / cg" @@ -4474,7 +4708,7 @@ "sent from label menu to change back to a previous directory" self discardChangesDialog ifTrue:[ - self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:true "/false. + self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:true "/false. ]. "Modified: / 2.10.1997 / 14:09:24 / stefan" @@ -4486,7 +4720,7 @@ otherwise change immediately to the default directory" self discardChangesDialog ifTrue:[ - self doChangeToDefaultDirectory + self doChangeToDefaultDirectory ] "Modified: 21.9.1997 / 23:45:04 / cg" @@ -4498,7 +4732,7 @@ otherwise change immediately to the home directory" self discardChangesDialog ifTrue:[ - self doChangeToHomeDirectory + self doChangeToHomeDirectory ] "Modified: 21.9.1997 / 23:45:10 / cg" @@ -4510,7 +4744,7 @@ otherwise change immediately to the parent directory" self discardChangesDialog ifTrue:[ - self doChangeToParentDirectory + self doChangeToParentDirectory ] "Modified: 21.9.1997 / 23:45:15 / cg" @@ -4533,7 +4767,7 @@ f := self getSelectedFileName. f isNil ifTrue:[ - ^ self addDirToJavaClassPath + ^ self addDirToJavaClassPath ]. f := currentDirectory asFilename construct:f. Java addToClassPath:(f pathName) @@ -4593,18 +4827,20 @@ "Modified: / 9.11.1998 / 05:56:14 / cg" ! +historyMenuSpec + "return the historyMenu for the path label" + + + + ^ self menuFromSpec:(self class historyMenuSpec). +! + labelMenu "return the popUpMenu for the path label" - |m| - - m := self class directoryMenuSpec. - m menuPerformer:self. - ^ m - - "Modified: / 14.8.1998 / 12:11:16 / cg" + ^ self menuFromSpec:(self class directoryMenuSpec). ! labelMenu_old @@ -4615,62 +4851,62 @@ |items menu currentIndex| items := #( - ('copy path' copyPath ) - ('-' ) - ('up' changeToParentDirectory ) - ('back' changeToPreviousDirectory ) - ('change to home-directory' changeToHomeDirectory ) - ('change to default-directory' changeToDefaultDirectory ) - ('change directory ...' changeCurrentDirectory ) - ). + ('copy path' copyPath ) + ('-' ) + ('up' changeToParentDirectory ) + ('back' changeToPreviousDirectory ) + ('change to home-directory' changeToHomeDirectory ) + ('change to default-directory' changeToDefaultDirectory ) + ('change directory ...' changeCurrentDirectory ) + ). (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[ - items := items , #( - ( '-') - ( 'add to JavaClassPath' addDirToJavaClassPath) - ( 'add to JavaSourcePath' addDirToJavaSourcePath) - ( 'remove from JavaClassPath' removeDirFromJavaClassPath) - ( 'remove from JavaSourcePath' removeDirFromJavaSourcePath) - ). + items := items , #( + ( '-') + ( 'add to JavaClassPath' addDirToJavaClassPath) + ( 'add to JavaSourcePath' addDirToJavaSourcePath) + ( 'remove from JavaClassPath' removeDirFromJavaClassPath) + ( 'remove from JavaSourcePath' removeDirFromJavaSourcePath) + ). ]. DirectoryHistory size > 0 ifTrue:[ - items := items copyWith:#('-'). - items := items , - (DirectoryHistory - collect:[:dirName | - Array - with:dirName - with:#changeDirectoryTo: - with:nil - with:dirName - ] - ). - currentIndex := items findFirst:[:i | (i at:1) = currentDirectory pathName]. - currentIndex == 0 ifTrue:[currentIndex := nil]. + items := items copyWith:#('-'). + items := items , + (DirectoryHistory + collect:[:dirName | + Array + with:dirName + with:#changeDirectoryTo: + with:nil + with:dirName + ] + ). + currentIndex := items findFirst:[:i | (i at:1) = currentDirectory pathName]. + currentIndex == 0 ifTrue:[currentIndex := nil]. ]. menu := PopUpMenu - itemList:items - resources:resources. + itemList:items + resources:resources. previousDirectory isNil ifTrue:[ - menu disable:#changeToPreviousDirectory. + menu disable:#changeToPreviousDirectory. ]. currentIndex notNil ifTrue:[ - menu disable:currentIndex + menu disable:currentIndex ]. (JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[ - (Java classPath includes:currentDirectory pathName) ifTrue:[ - menu disable:#addDirToJavaClassPath - ] ifFalse:[ - menu disable:#removeDirFromJavaClassPath - ]. - (Java sourcePath includes:currentDirectory pathName) ifTrue:[ - menu disable:#addDirToJavaSourcePath - ] ifFalse:[ - menu disable:#removeDirFromJavaSourcePath - ]. + (Java classPath includes:currentDirectory pathName) ifTrue:[ + menu disable:#addDirToJavaClassPath + ] ifFalse:[ + menu disable:#removeDirFromJavaClassPath + ]. + (Java sourcePath includes:currentDirectory pathName) ifTrue:[ + menu disable:#addDirToJavaSourcePath + ] ifFalse:[ + menu disable:#removeDirFromJavaSourcePath + ]. ]. ^menu. @@ -4718,9 +4954,9 @@ |queryBox dirName| queryBox := FilenameEnterBox - title:(resources at:'change directory to:') withCRs - okText:(resources at:'change') - action:[:newName | dirName := newName]. + title:(resources at:'change directory to:') withCRs + okText:(resources at:'change') + action:[:newName | dirName := newName]. "/ queryBox initialText:''. queryBox showAtPointer. queryBox destroy. @@ -4762,9 +4998,9 @@ "common method to ask a yes/no question" ^ Dialog - confirm:question withCRs - yesLabel:(resources at:yesButtonText) - noLabel:(resources at:noButtonText) + confirm:question withCRs + yesLabel:(resources at:yesButtonText) + noLabel:(resources at:noButtonText) "Modified: 21.2.1996 / 01:19:21 / cg" ! @@ -4798,12 +5034,12 @@ "tell user, that code has been modified - let her confirm" (subView modified not or:[subView contentsWasSaved]) ifTrue:[ - ^ true + ^ true ]. (self ask:(resources string:question) yesButton:yesButtonText) ifTrue:[ - "/ reset modified flag so question is asked only once - subView modified:false. - ^ true + "/ reset modified flag so question is asked only once + subView modified:false. + ^ true ]. ^ false @@ -4851,30 +5087,30 @@ sel := fileListView selection. sel notNil ifTrue:[ - sel := sel collect:[:aSelectionIndex | - |nm| - - nm := fileList at:aSelectionIndex ifAbsent:nil. - nm notNil ifTrue:[ - nm := nm string. - (nm endsWith:' ...') ifTrue:[ - nm := (nm copyWithoutLast:4) withoutSpaces - ]. - ]. - nm - ]. - action := [ - sel do:[:nm | - nm notNil ifTrue:[ - aBlock value:nm - ] - ] - ]. - Processor activeProcess == self windowGroup process ifTrue:[ - self withWaitCursorDo:action - ] ifFalse:[ - action value - ] + sel := sel collect:[:aSelectionIndex | + |nm| + + nm := fileList at:aSelectionIndex ifAbsent:nil. + nm notNil ifTrue:[ + nm := nm string. + (nm endsWith:' ...') ifTrue:[ + nm := (nm copyWithoutLast:4) withoutSpaces + ]. + ]. + nm + ]. + action := [ + sel do:[:nm | + nm notNil ifTrue:[ + aBlock value:nm + ] + ] + ]. + Processor activeProcess == self windowGroup process ifTrue:[ + self withWaitCursorDo:action + ] ifFalse:[ + action value + ] ] "Modified: / 16.12.1998 / 17:30:57 / cg" @@ -4895,9 +5131,9 @@ |msg| anErrorString isNil ifTrue:[ - msg := aString + msg := aString ] ifFalse:[ - msg := aString , '\\(' , anErrorString , ')' + msg := aString , '\\(' , anErrorString , ')' ]. self warn:msg withCRs ! @@ -4910,18 +5146,18 @@ newCollection := aCollection species new. aCollection do:[:fname | - |ignore| - - ignore := false. - - ((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[ - showingHiddenFiles value "showDotFiles" ifFalse:[ - ignore := true - ] - ]. - ignore ifFalse:[ - newCollection add:fname - ] + |ignore| + + ignore := false. + + ((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[ + showingHiddenFiles value "showDotFiles" ifFalse:[ + ignore := true + ] + ]. + ignore ifFalse:[ + newCollection add:fname + ] ]. ^ newCollection @@ -5444,7 +5680,7 @@ previousDirectory isNil ifTrue:[^ self]. self discardChangesDialog ifTrue:[ - self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false + self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false ] "Modified: 2.10.1997 / 14:13:40 / stefan" @@ -5552,67 +5788,67 @@ self label:myName; iconLabel:myName. fileName notNil ifTrue:[ - (f := fileName asFilename) isAbsolute ifFalse:[ - f := currentDirectory filenameFor:fileName. - ]. - f := f asAbsoluteFilename. - (f isDirectory) ifTrue:[ - (f isReadable) ifTrue:[ - (f isExecutable) ifTrue:[ - path := currentDirectory pathName. - previousDirectory := path. - - " - remember where we are positioned in the fileList - (in case we want to return) - " - idx := DirectoryHistory indexOf:path. - idx ~~ 0 ifTrue:[ - DirectoryHistoryWhere at:idx put:fileListView firstLineShown - ]. - - updateHistory ifTrue:[ - self addToHistory:path. - ]. - - self setCurrentDirectory:(f pathName). - - "/ fetch the new path. - path := currentDirectory pathName. - - " - if we have already been there, look for the - position offset, and scroll the fileList - " - idx := DirectoryHistory indexOf:path. - idx ~~ 0 ifTrue:[ - |pos| - - pos := DirectoryHistoryWhere at:idx. - pos notNil ifTrue:[ - fileListView scrollToLine:pos. - ] - ]. - - updateHistory ifTrue:[ - self addToHistory:path. - ]. - - ^ self - ]. - msg := 'cannot change directory to ''%1'' !!' - ] ifFalse:[ - msg := 'cannot read directory ''%1'' !!' - ] - ] ifFalse:[ - OperatingSystem isVMSlike ifTrue:[ - "/ cannot tell if it exists or is simply invisible ... - msg := '''%1'' is not a directory or unreadable !!' - ] ifFalse:[ - msg := '''%1'' is not a directory !!' - ] - ]. - Dialog warn:(resources string:msg withCRs with:fileName). + (f := fileName asFilename) isAbsolute ifFalse:[ + f := currentDirectory filenameFor:fileName. + ]. + f := f asAbsoluteFilename. + (f isDirectory) ifTrue:[ + (f isReadable) ifTrue:[ + (f isExecutable) ifTrue:[ + path := currentDirectory pathName. + previousDirectory := path. + + " + remember where we are positioned in the fileList + (in case we want to return) + " + idx := DirectoryHistory indexOf:path. + idx ~~ 0 ifTrue:[ + DirectoryHistoryWhere at:idx put:fileListView firstLineShown + ]. + + updateHistory ifTrue:[ + self addToHistory:path. + ]. + + self setCurrentDirectory:(f pathName). + + "/ fetch the new path. + path := currentDirectory pathName. + + " + if we have already been there, look for the + position offset, and scroll the fileList + " + idx := DirectoryHistory indexOf:path. + idx ~~ 0 ifTrue:[ + |pos| + + pos := DirectoryHistoryWhere at:idx. + pos notNil ifTrue:[ + fileListView scrollToLine:pos. + ] + ]. + + updateHistory ifTrue:[ + self addToHistory:path. + ]. + + ^ self + ]. + msg := 'cannot change directory to ''%1'' !!' + ] ifFalse:[ + msg := 'cannot read directory ''%1'' !!' + ] + ] ifFalse:[ + OperatingSystem isVMSlike ifTrue:[ + "/ cannot tell if it exists or is simply invisible ... + msg := '''%1'' is not a directory or unreadable !!' + ] ifFalse:[ + msg := '''%1'' is not a directory !!' + ] + ]. + Dialog warn:(resources string:msg withCRs with:fileName). ] "Modified: / 18.9.1997 / 18:22:30 / stefan" @@ -5644,15 +5880,15 @@ f := currentDirectory filenameFor:newName. f exists ifTrue:[ - self warn:'%1 already exists.' with:newName. - ^ self + self warn:'%1 already exists.' with:newName. + ^ self ]. f makeDirectory ifTrue:[ - self updateCurrentDirectory + self updateCurrentDirectory ] ifFalse:[ - self showAlert:(resources string:'cannot create directory ''%1'' !!' with:newName) - with:(OperatingSystem lastErrorString) + self showAlert:(resources string:'cannot create directory ''%1'' !!' with:newName) + with:(OperatingSystem lastErrorString) ] "Modified: / 18.9.1997 / 17:21:25 / stefan" @@ -5667,16 +5903,16 @@ aPathName isEmpty ifTrue:[^ self]. newDirectory := currentDirectory filenameFor:aPathName. newDirectory isDirectory ifTrue:[ - self currentDirectory:newDirectory. - currentFileName notNil ifTrue:[ - fileListView contents:nil. - currentFileName := nil. - ] ifFalse:[ - fileListView setSelection:nil. - fileListView scrollToTop. - ]. - self updateCurrentDirectory. - self showInfo. + self currentDirectory:newDirectory. + currentFileName notNil ifTrue:[ + fileListView contents:nil. + currentFileName := nil. + ] ifFalse:[ + fileListView setSelection:nil. + fileListView scrollToTop. + ]. + self updateCurrentDirectory. + self showInfo. ] "Modified: 21.9.1995 / 11:22:45 / claus" @@ -5706,9 +5942,9 @@ guessEncodingFrom:aBuffer "look for a string - encoding #name + encoding #name or: - encoding: name + encoding: name within the given buffer (which is usually the first few bytes of a textFile). If thats not found, use heuristics (in CharacterArray) to guess." @@ -5720,55 +5956,55 @@ n := aBuffer size. (idx := aBuffer findString:'charset=') ~~ 0 ifTrue:[ - s := ReadStream on:aBuffer. - s position:idx + 8. - s skipSeparators. - w := s upToSeparator. - w notNil ifTrue:[ - (idx := w indexOf:$") ~~ 0 ifTrue:[ - w := w copyTo:idx-1 - ]. - ^ w asSymbol - ]. + s := ReadStream on:aBuffer. + s position:idx + 8. + s skipSeparators. + w := s upToSeparator. + w notNil ifTrue:[ + (idx := w indexOf:$") ~~ 0 ifTrue:[ + w := w copyTo:idx-1 + ]. + ^ w asSymbol + ]. ]. (idx := aBuffer findString:'encoding') ~~ 0 ifTrue:[ - s := ReadStream on:aBuffer. - s position:idx + 8. - s skipSeparators. - s peek == $: ifTrue:[ - s next. - s skipSeparators. - ]. - - s peek == $# ifTrue:[ - s next. - s skipSeparators. - ]. - w := s upToSeparator. - w notNil ifTrue:[ - ^ w asSymbol - ]. + s := ReadStream on:aBuffer. + s position:idx + 8. + s skipSeparators. + s peek == $: ifTrue:[ + s next. + s skipSeparators. + ]. + + s peek == $# ifTrue:[ + s next. + s skipSeparators. + ]. + w := s upToSeparator. + w notNil ifTrue:[ + ^ w asSymbol + ]. ]. 1 to:n do:[:i | - (aBuffer at:i) isPrintable ifFalse:[binary := true]. + (aBuffer at:i) isPrintable ifFalse:[binary := true]. ]. binary ifTrue:[ - "/ look for JIS7 / EUC encoding - - enc := CharacterArray guessEncodingFrom:aBuffer. - enc notNil ifTrue:[ - ^ enc - ]. - - "/ if the encoding has been set to any non iso setting, - "/ assume its what we defined ... - - (('iso*' match:fileEncoding) or:['ascii*' match:fileEncoding]) ifTrue:[ - ^ #binary - ]. - ^ fileEncoding ? #binary + "/ look for JIS7 / EUC encoding + + enc := CharacterArray guessEncodingFrom:aBuffer. + enc notNil ifTrue:[ + ^ enc + ]. + + "/ if the encoding has been set to any non iso setting, + "/ assume its what we defined ... + + (('iso*' match:fileEncoding) or:['ascii*' match:fileEncoding]) ifTrue:[ + ^ #binary + ]. + ^ fileEncoding ? #binary ]. ^ #ascii @@ -5801,66 +6037,66 @@ pref := self preferredFontEncodingFor:newEncoding. (pref match:fontsEncoding) ifTrue:[ - ^ self + ^ self ]. "/ stupid ... pref = 'ascii*' ifTrue:[ - (fontsEncoding match:'iso8859*') ifTrue:[ - ^ self - ] + (fontsEncoding match:'iso8859*') ifTrue:[ + ^ self + ] ]. filter := [:f | |coding| - (coding := f encoding) notNil - and:[pref match:coding]]. + (coding := f encoding) notNil + and:[pref match:coding]]. defaultFont := TextView defaultFont onDevice:device. (pref match:(defaultFont encoding)) ifFalse:[ - defaultFont := nil. + defaultFont := nil. ]. defaultFont isNil ifTrue:[ - (pref = 'ascii*' - or:[pref = 'iso8859*']) ifTrue:[ - defaultFont := FontDescription family:'courier' face:'medium' style:'roman' size:12 - ] + (pref = 'ascii*' + or:[pref = 'iso8859*']) ifTrue:[ + defaultFont := FontDescription family:'courier' face:'medium' style:'roman' size:12 + ] ]. defaultFont isNil ifTrue:[ - defaultFont := device - listOfAvailableFonts - detect:[:f | filter value:f] - ifNone:nil. - defaultFont isNil ifTrue:[ - - "/ flush list, and refetch font list - "/ (in case someone just changed the font path ...) - - device flushListOfAvailableFonts. - defaultFont := device - listOfAvailableFonts - detect:[:f | filter value:f] - ifNone:nil. - ]. - - defaultFont isNil ifTrue:[ - self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'. - ^ self. - ] + defaultFont := device + listOfAvailableFonts + detect:[:f | filter value:f] + ifNone:nil. + defaultFont isNil ifTrue:[ + + "/ flush list, and refetch font list + "/ (in case someone just changed the font path ...) + + device flushListOfAvailableFonts. + defaultFont := device + listOfAvailableFonts + detect:[:f | filter value:f] + ifNone:nil. + ]. + + defaultFont isNil ifTrue:[ + self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'. + ^ self. + ] ]. msg := 'switch to a %1 encoded font ?'. (ask not or:[self confirm:(resources string:msg with:pref) withCRs]) ifTrue:[ - self withWaitCursorDo:[ - f := FontPanel - fontFromUserInitial:defaultFont - title:(resources string:'font selection') - filter:filter. - f notNil ifTrue:[ - subView font:f - ] - ] + self withWaitCursorDo:[ + f := FontPanel + fontFromUserInitial:defaultFont + title:(resources string:'font selection') + filter:filter. + f notNil ifTrue:[ + subView font:f + ] + ] ] "Created: 26.10.1996 / 12:06:54 / cg" @@ -5913,7 +6149,7 @@ fileName := self getSelectedFileName. fileName notNil ifTrue:[ - self doOpenFile:fileName viaDoubleClick:viaDoubleClick + self doOpenFile:fileName viaDoubleClick:viaDoubleClick ] "Created: / 19.6.1996 / 09:39:07 / cg" @@ -6248,7 +6484,7 @@ commentStrings := self fileCommentStrings. commentStrings notNil ifTrue:[ - subView perform:#commentStrings: with:commentStrings ifNotUnderstood:nil + subView perform:#commentStrings: with:commentStrings ifNotUnderstood:nil ]. "Modified: 7.1.1997 / 20:30:54 / cg" @@ -6345,11 +6581,11 @@ 'info.txt' 'INFO.TXT' ) do:[:f | - |n| - n := currentDirectory construct:f. - (n isReadable and:[n isDirectory not]) ifTrue:[ - ^ f. - ] + |n| + n := currentDirectory construct:f. + (n isReadable and:[n isDirectory not]) ifTrue:[ + ^ f. + ] ]. ^ nil @@ -6362,9 +6598,9 @@ This is wrong here - should be moved into OperatingSystem." ^ self getModeString:modeBits - with:#( 'owner:' $r $w $x - ' group:' $r $w $x - ' others:' $r $w $x ) + with:#( 'owner:' $r $w $x + ' group:' $r $w $x + ' others:' $r $w $x ) ! getModeString:modeBits with:texts @@ -6378,18 +6614,18 @@ #( nil 8r400 8r200 8r100 nil 8r040 8r020 8r010 nil 8r004 8r002 8r001 ) with: texts do:[:bitMask :access | - |ch| - - bitMask isNil ifTrue:[ - modeString := modeString , (resources string:access) - ] ifFalse:[ - (bits bitAnd:bitMask) == 0 ifTrue:[ - ch := $- - ] ifFalse:[ - ch := access - ]. - modeString := modeString copyWith:ch - ] + |ch| + + bitMask isNil ifTrue:[ + modeString := modeString , (resources string:access) + ] ifFalse:[ + (bits bitAnd:bitMask) == 0 ifTrue:[ + ch := $- + ] ifFalse:[ + ch := access + ]. + modeString := modeString copyWith:ch + ] ]. ^ modeString ! @@ -6401,7 +6637,7 @@ info := self getInfoFile. info notNil ifTrue:[ - txt := self readFile:info + txt := self readFile:info ]. self show:txt. ! @@ -6418,15 +6654,15 @@ " unitString := ''. size < (500 * 1024) ifTrue:[ - size < 1024 ifTrue:[ - n := size - ] ifFalse:[ - n := (size * 10 // 1024 / 10.0). - unitString := ' Kb' - ] + size < 1024 ifTrue:[ + n := size + ] ifFalse:[ + n := (size * 10 // 1024 / 10.0). + unitString := ' Kb' + ] ] ifFalse:[ - n := (size * 10 // 1024 // 1024 / 10.0). - unitString := ' Mb' + n := (size * 10 // 1024 // 1024 / 10.0). + unitString := ' Mb' ]. ^ (n printStringLeftPaddedTo:5) , unitString. ! ! @@ -6450,22 +6686,22 @@ |f stream text msg sz| (f := fileName asFilename) isAbsolute ifFalse:[ - f := (currentDirectory construct:fileName) + f := (currentDirectory construct:fileName) ]. stream := f readStream. stream isNil ifTrue:[ - msg := (resources string:'cannot read file ''%1'' !!' with:fileName). - self showAlert:msg with:(FileStream lastErrorString). - ^ nil + msg := (resources string:'cannot read file ''%1'' !!' with:fileName). + self showAlert:msg with:(FileStream lastErrorString). + ^ nil ]. " for very big files, give ObjectMemory a hint, to preallocate more " (sz := stream fileSize) > 1000000 ifTrue:[ - Processor activeProcess withPriority:Processor userBackgroundPriority do:[ - ObjectMemory announceSpaceNeed:(sz + (sz // 5)) "/ add 20% for tab expansion - ]. + Processor activeProcess withPriority:Processor userBackgroundPriority do:[ + ObjectMemory announceSpaceNeed:(sz + (sz // 5)) "/ add 20% for tab expansion + ]. ]. text := self readStream:stream lineDelimiter:aCharacter encoding:encoding. @@ -6497,33 +6733,33 @@ enc := encoding. enc == #iso8859 ifTrue:[ - enc := nil + enc := nil ]. aCharacter == Character cr ifTrue:[ - FileStream lineTooLongErrorSignal handle:[:ex | - |s partialLine| - - s := ex parameter at:1. - partialLine := ex parameter at:2. - ex proceedWith:(partialLine , s upTo:aCharacter) - ] do:[ - [aStream atEnd] whileFalse:[ - line := aStream nextLine withTabsExpanded. - enc notNil ifTrue:[ - line := line decodeFrom:enc - ]. - text add:line - ]. - ]. + FileStream lineTooLongErrorSignal handle:[:ex | + |s partialLine| + + s := ex parameter at:1. + partialLine := ex parameter at:2. + ex proceedWith:(partialLine , s upTo:aCharacter) + ] do:[ + [aStream atEnd] whileFalse:[ + line := aStream nextLine withTabsExpanded. + enc notNil ifTrue:[ + line := line decodeFrom:enc + ]. + text add:line + ]. + ]. ] ifFalse:[ - [aStream atEnd] whileFalse:[ - line := (aStream upTo:aCharacter) withTabsExpanded. - enc notNil ifTrue:[ - line := line decodeFrom:enc - ]. - text add:line - ]. + [aStream atEnd] whileFalse:[ + line := (aStream upTo:aCharacter) withTabsExpanded. + enc notNil ifTrue:[ + line := line decodeFrom:enc + ]. + text add:line + ]. ]. ^ text @@ -6544,7 +6780,7 @@ "show/insert contents of fileName in subView" ^ self - showFile:fileName insert:insert encoding:encoding doubleClick:false + showFile:fileName insert:insert encoding:encoding doubleClick:false "Modified: 19.6.1996 / 09:40:19 / cg" ! @@ -6798,7 +7034,7 @@ tabSpec addDependent:self. tabRulerView notNil ifTrue:[ - tabRulerView tabulatorSpecification:tabSpec. + tabRulerView tabulatorSpecification:tabSpec. ]. "Created: / 17.4.1997 / 02:51:41 / cg" @@ -6905,8 +7141,8 @@ stopImageRenderProcess imageRenderProcess notNil ifTrue:[ - imageRenderProcess terminate. - imageRenderProcess := nil + imageRenderProcess terminate. + imageRenderProcess := nil ]. "Created: 19.4.1997 / 13:51:34 / cg" @@ -6915,8 +7151,8 @@ stopUpdateProcess Processor removeTimedBlock:checkBlock. listUpdateProcess notNil ifTrue:[ - listUpdateProcess terminate. - listUpdateProcess := nil. + listUpdateProcess terminate. + listUpdateProcess := nil. ]. "Created: 19.4.1997 / 13:51:34 / cg" @@ -7062,7 +7298,7 @@ anyImages lineIndex aFileName entry typ f p typeString done endIndex state stopAtEnd nextState img prevFirstLine prevLastLine - numVisible dirSuffix prevWidth| + numVisible dirSuffix prevWidth t| dirSuffix := Filename directorySuffix. dirSuffix size > 0 ifTrue:[ @@ -7228,23 +7464,31 @@ ' ' $r $w $x ). entry colAt:3 put:modeString. - ((info uid) ~~ prevUid) ifTrue:[ - prevUid := (info uid). - nameString := OperatingSystem getUserNameFromID:prevUid. - nameString := nameString contractTo:10. - nameString := nameString , (String new:(10 - nameString size)) + showingTimeAndDate value ifTrue:[ + t := f isSymbolicLink + ifFalse:[f modificationTime] + ifTrue:[f linkInfo modified]. + entry colAt:4 put:t asDate printString. + entry colAt:5 put:t asTime printString. + ] ifFalse:[ + ((info uid) ~~ prevUid) ifTrue:[ + prevUid := (info uid). + nameString := OperatingSystem getUserNameFromID:prevUid. + nameString := nameString contractTo:10. + nameString := nameString , (String new:(10 - nameString size)) + ]. + nameString isNil ifTrue:[nameString := '???']. + entry colAt:4 put:nameString withoutSpaces. + + ((info gid) ~~ prevGid) ifTrue:[ + prevGid := (info gid). + groupString := OperatingSystem getGroupNameFromID:prevGid. + groupString := groupString contractTo:10. + groupString := groupString , (String new:(10 - groupString size)) + ]. + groupString isNil ifTrue:[groupString := '???']. + entry colAt:5 put:groupString withoutSpaces. ]. - nameString isNil ifTrue:[nameString := '???']. - entry colAt:4 put:nameString withoutSpaces. - - ((info gid) ~~ prevGid) ifTrue:[ - prevGid := (info gid). - groupString := OperatingSystem getGroupNameFromID:prevGid. - groupString := groupString contractTo:10. - groupString := groupString , (String new:(10 - groupString size)) - ]. - groupString isNil ifTrue:[groupString := '???']. - entry colAt:5 put:groupString withoutSpaces. (typ == #regular) ifTrue:[ entry colAt:6 put:(self sizePrintString:(info size)). @@ -7402,10 +7646,6 @@ "Modified: / 18.6.1998 / 15:27:35 / cg" ! -hasVisitHistory - ^ self class hasVisitHistory -! - path "return my currentDirectories pathName; sent from the pathField to aquire the pathname when I changed directory" @@ -7422,5 +7662,5 @@ !FileBrowser class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.442 2001-11-19 08:07:03 cg Exp $' + ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.443 2001-11-19 15:14:52 cg Exp $' ! !