FBrowser.st
changeset 747 a50e8643c666
parent 729 da2aa1dee58f
child 748 777db65fa111
equal deleted inserted replaced
746:8f7d8caecf22 747:a50e8643c666
   148 
   148 
   149 changeDisplayMode
   149 changeDisplayMode
   150     "toggle from long to short listing (and vice-versa)"
   150     "toggle from long to short listing (and vice-versa)"
   151 
   151 
   152     showLongList := showLongList not.
   152     showLongList := showLongList not.
       
   153     tabSpec := nil.
   153     self updateCurrentDirectory
   154     self updateCurrentDirectory
       
   155 
       
   156     "Modified: 8.10.1996 / 15:58:47 / cg"
   154 !
   157 !
   155 
   158 
   156 changeDotFileVisibility
   159 changeDotFileVisibility
   157     "turn on/off visibility of files whose name starts with '.'"
   160     "turn on/off visibility of files whose name starts with '.'"
   158 
   161 
  1334     "define the tabs for the long list"
  1337     "define the tabs for the long list"
  1335 
  1338 
  1336     tabSpec := TabulatorSpecification new.
  1339     tabSpec := TabulatorSpecification new.
  1337     tabSpec unit:#inch.
  1340     tabSpec unit:#inch.
  1338 "/  tabSpec positions:#(0     2     2.3   4.3    5.3    6.0      6.5).
  1341 "/  tabSpec positions:#(0     2     2.3   4.3    5.3    6.0      6.5).
  1339     tabSpec widths:   #(2     0.3   1.7     1      0.5  0.5      1"any").
  1342     tabSpec widths:   #(2     0.3   2.0     1      0.5  0.5      1"any").
  1340     "                   name  type  mode  owner  group  size     type"
  1343     "                   name  type  mode  owner  group  size     type"
  1341     tabSpec align:    #(#left #left #left #right #right #decimal #left).
  1344     tabSpec align:    #(#left #left #left #right #right #decimal #left).
  1342     tabSpec addDependent:self
  1345     tabSpec addDependent:self
       
  1346 
       
  1347     "Modified: 8.10.1996 / 15:59:28 / cg"
  1343 !
  1348 !
  1344 
  1349 
  1345 doChangeCurrentDirectoryTo:fileName updateHistory:updateHistory 
  1350 doChangeCurrentDirectoryTo:fileName updateHistory:updateHistory 
  1346     "verify argument is name of a readable & executable directory
  1351     "verify argument is name of a readable & executable directory
  1347      and if so, go there"
  1352      and if so, go there"
  2156      that browsers reading short directories will finish first.
  2161      that browsers reading short directories will finish first.
  2157      ST/X users love this behavior ;-)
  2162      ST/X users love this behavior ;-)
  2158     "
  2163     "
  2159 
  2164 
  2160     self withReadCursorDo:[
  2165     self withReadCursorDo:[
  2161 	Processor removeTimedBlock:checkBlock.
  2166         Processor removeTimedBlock:checkBlock.
  2162 
  2167 
  2163 	timeOfLastCheck := AbsoluteTime now.
  2168         timeOfLastCheck := AbsoluteTime now.
  2164 
  2169 
  2165 	files := currentDirectory asOrderedCollection.
  2170         files := currentDirectory asOrderedCollection.
  2166 
  2171 
  2167 	matchPattern := filterField contents.
  2172         matchPattern := filterField contents.
  2168 	(matchPattern notNil and:[
  2173         (matchPattern notNil and:[
  2169 	 matchPattern isEmpty not and:[
  2174          matchPattern isEmpty not and:[
  2170 	 matchPattern ~= '*']]) ifTrue:[
  2175          matchPattern ~= '*']]) ifTrue:[
  2171 	    files := files select:[:aName | 
  2176             files := files select:[:aName | 
  2172 			 ((currentDirectory typeOf:aName) == #directory)
  2177                          ((currentDirectory typeOf:aName) == #directory)
  2173 			 or:[matchPattern match:aName]
  2178                          or:[matchPattern match:aName]
  2174 		     ].
  2179                      ].
  2175 	].
  2180         ].
  2176 	files sort.
  2181         files sort.
  2177 
  2182 
  2178 	files size == 0 ifTrue:[
  2183         files size == 0 ifTrue:[
  2179 	    self information:('directory ', currentDirectory pathName, ' vanished').
  2184             self information:('directory ', currentDirectory pathName, ' vanished').
  2180 	    ^ self
  2185             ^ self
  2181 	].
  2186         ].
  2182 	files := self withoutHiddenFiles:files.
  2187         files := self withoutHiddenFiles:files.
  2183 	fileList := files copy.
  2188         fileList := files copy.
  2184 
  2189 
  2185 	"
  2190         "
  2186 	 this is a time consuming operation (especially, if reading an
  2191          this is a time consuming operation (especially, if reading an
  2187 	 NFS-mounted directory); therefore lower my priority while getting
  2192          NFS-mounted directory); therefore lower my priority while getting
  2188 	 the files info ...
  2193          the files info ...
  2189 	"
  2194         "
  2190 	Processor activeProcess withLowerPriorityDo:[
  2195         Processor activeProcess withLowerPriorityDo:[
  2191 
  2196 
  2192 	    "
  2197             "
  2193 	     first show the names only - this is relatively fast
  2198              first show the names only - this is relatively fast
  2194 	    "
  2199             "
  2195 	    fileListView setList:files expandTabs:false.
  2200             fileListView setList:files expandTabs:false.
  2196 
  2201 
  2197 	    "
  2202             "
  2198 	     then walk over the files, adding more info
  2203              then walk over the files, adding more info
  2199 	     (since we have to stat each file, this may take a while longer
  2204              (since we have to stat each file, this may take a while longer
  2200 	    "
  2205             "
  2201 	    showLongList ifTrue:[
  2206             showLongList ifTrue:[
  2202 		tabSpec isNil ifTrue:[self defineTabulatorsForLongList].
  2207                 tabSpec isNil ifTrue:[self defineTabulatorsForLongList].
  2203 
  2208 
  2204 		text := OrderedCollection new.
  2209                 text := OrderedCollection new.
  2205 		files keysAndValuesDo:[:lineIndex :aFileName |
  2210                 files keysAndValuesDo:[:lineIndex :aFileName |
  2206 		    |entry col typ f p typeString|
  2211                     |entry col typ f p typeString|
  2207 
  2212 
  2208 		    entry := MultiColListEntry new.
  2213                     entry := MultiColListEntry new.
  2209 		    entry tabulatorSpecification:tabSpec.
  2214                     entry tabulatorSpecification:tabSpec.
  2210 
  2215 
  2211 		    "
  2216                     "
  2212 		     if multiple FileBrowsers are reading, let others
  2217                      if multiple FileBrowsers are reading, let others
  2213 		     make some progress too
  2218                      make some progress too
  2214 		    "
  2219                     "
  2215 		    windowGroup notNil ifTrue:[windowGroup processExposeEvents].
  2220                     windowGroup notNil ifTrue:[windowGroup processExposeEvents].
  2216 		    Processor yield.
  2221                     Processor yield.
  2217 		    "
  2222                     "
  2218 		     could be destroyed in the meanwhile ...
  2223                      could be destroyed in the meanwhile ...
  2219 		    "
  2224                     "
  2220 		    realized ifFalse:[^ self].
  2225                     realized ifFalse:[^ self].
  2221 
  2226 
  2222 		    len := aFileName size.
  2227                     len := aFileName size.
  2223 		    (len < 20) ifTrue:[
  2228                     (len < 20) ifTrue:[
  2224 			line := aFileName , (String new:(22 - len))
  2229                         line := aFileName , (String new:(22 - len))
  2225 		    ] ifFalse:[
  2230                     ] ifFalse:[
  2226 			"can happen on BSD only"
  2231                         "can happen on BSD only"
  2227 			line := (aFileName copyTo:20) , '  '
  2232                         line := (aFileName copyTo:20) , '  '
  2228 		    ].
  2233                     ].
  2229 		    entry colAt:1 put:line.
  2234                     entry colAt:1 put:line.
  2230 
  2235 
  2231 		    info := currentDirectory infoOf:aFileName.
  2236                     info := currentDirectory infoOf:aFileName.
  2232 		    info isNil ifTrue:[
  2237                     info isNil ifTrue:[
  2233 			"not accessable - usually a symlink,
  2238                         "not accessable - usually a symlink,
  2234 			 to a nonexisting/nonreadable file
  2239                          to a nonexisting/nonreadable file
  2235 			"
  2240                         "
  2236 			entry colAt:2 put:'?'.
  2241                         entry colAt:2 put:'?'.
  2237 			entry colAt:3 put:'(bad symbolic link ?)'.
  2242                         entry colAt:3 put:'(bad symbolic link ?)'.
  2238 		    ] ifFalse:[
  2243                     ] ifFalse:[
  2239 			typ := (info at:#type).
  2244                         typ := (info at:#type).
  2240 			(typ == #regular) ifFalse:[
  2245                         (typ == #regular) ifFalse:[
  2241 			    entry colAt:2 put:(typ at:1) asString.
  2246                             entry colAt:2 put:(typ at:1) asString.
  2242 			] ifTrue:[
  2247                         ] ifTrue:[
  2243 			    entry colAt:2 put:' '.
  2248                             entry colAt:2 put:' '.
  2244 			].
  2249                         ].
  2245 
  2250                         modeString := self getModeString:(info at:#mode)
  2246 			modeString := self getModeString:(info at:#mode)
  2251                                                     with:#( '' $r $w $x 
  2247 						    with:#( '' $r $w $x 
  2252                                                             '  ' $r $w $x 
  2248 							    '  ' $r $w $x 
  2253                                                             '  ' $r $w $x ).
  2249 							    '  ' $r $w $x ).
  2254                         entry colAt:3 put:modeString.
  2250 			entry colAt:3 put:modeString.
  2255 
  2251 
  2256                         ((info at:#uid) ~~ prevUid) ifTrue:[
  2252 			((info at:#uid) ~~ prevUid) ifTrue:[
  2257                             prevUid := (info at:#uid).
  2253 			    prevUid := (info at:#uid).
  2258                             nameString := OperatingSystem getUserNameFromID:prevUid.
  2254 			    nameString := OperatingSystem getUserNameFromID:prevUid.
  2259                             nameString := nameString , (String new:(10 - nameString size))
  2255 			    nameString := nameString , (String new:(10 - nameString size))
  2260                         ].
  2256 			].
  2261                         entry colAt:4 put:nameString withoutSpaces.
  2257 			entry colAt:4 put:nameString withoutSpaces.
  2262                         ((info at:#gid) ~~ prevGid) ifTrue:[
  2258 			((info at:#gid) ~~ prevGid) ifTrue:[
  2263                             prevGid := (info at:#gid).
  2259 			    prevGid := (info at:#gid).
  2264                             groupString := OperatingSystem getGroupNameFromID:prevGid.
  2260 			    groupString := OperatingSystem getGroupNameFromID:prevGid.
  2265                             groupString := groupString , (String new:(10 - groupString size))
  2261 			    groupString := groupString , (String new:(10 - groupString size))
  2266                         ].
  2262 			].
  2267                         entry colAt:5 put:groupString withoutSpaces.
  2263 			entry colAt:5 put:groupString withoutSpaces.
  2268 
  2264 
  2269                         (typ == #regular) ifTrue:[
  2265 			(typ == #regular) ifTrue:[
  2270                             entry colAt:6 put:(self sizePrintString:(info at:#size)).
  2266 			    entry colAt:6 put:(self sizePrintString:(info at:#size)).
  2271                         ].
  2267 			].
  2272 
  2268 
  2273                         f := currentDirectory asFilename:aFileName.
  2269 			f := currentDirectory asFilename:aFileName.
  2274                         f isSymbolicLink ifTrue:[
  2270 			f isSymbolicLink ifTrue:[
  2275                             p := f linkInfo at:#path.    
  2271 			    p := f linkInfo at:#path.    
  2276                             typeString := 'symbolic link to ' , p
  2272 			    typeString := 'symbolic link to ' , p
  2277                         ] ifFalse:[        
  2273 			] ifFalse:[        
  2278                             (showVeryLongList not or:[typ == #directory]) ifTrue:[
  2274 			    (showVeryLongList not or:[typ == #directory]) ifTrue:[
  2279                                 typeString := typ asString
  2275 				typeString := typ asString
  2280                             ] ifFalse:[
  2276 			    ] ifFalse:[
  2281                                 typeString := f fileType.
  2277 				typeString := f fileType.
  2282                             ].
  2278 			    ].
  2283                         ].
  2279 			].
  2284                         entry colAt:7 put:typeString.
  2280 			entry colAt:7 put:typeString.
  2285                         text add:entry
  2281 			text add:entry
  2286                     ].
  2282 		    ].
  2287                     fileListView at:lineIndex put:entry
  2283 		    fileListView at:lineIndex put:entry
  2288                 ].
  2284 		].
  2289             ] ifFalse:[
  2285 	    ] ifFalse:[
  2290                 files keysAndValuesDo:[:lineIndex :aName |
  2286 		files keysAndValuesDo:[:lineIndex :aName |
  2291                     |entry|
  2287 		    |entry|
  2292 
  2288 
  2293                     "
  2289 		    "
  2294                      if multiple FileBrowsers are reading, let others
  2290 		     if multiple FileBrowsers are reading, let others
  2295                      make some progress too
  2291 		     make some progress too
  2296                     "
  2292 		    "
  2297                     windowGroup notNil ifTrue:[windowGroup processExposeEvents].
  2293 		    windowGroup notNil ifTrue:[windowGroup processExposeEvents].
  2298                     Processor yield.
  2294 		    Processor yield.
  2299                     realized ifFalse:[^ self].
  2295 		    realized ifFalse:[^ self].
  2300 
  2296 
  2301                     ((currentDirectory isDirectory:aName) and:[
  2297 		    ((currentDirectory isDirectory:aName) and:[
  2302                     (aName ~= '..') and:[aName ~= '.']]) ifTrue:[
  2298 		    (aName ~= '..') and:[aName ~= '.']]) ifTrue:[
  2303                         entry := aName , ' ...'
  2299 			entry := aName , ' ...'
  2304                     ] ifFalse:[
  2300 		    ] ifFalse:[
  2305                         entry := aName
  2301 			entry := aName
  2306                     ].
  2302 		    ].
  2307                     fileListView at:lineIndex put:entry
  2303 		    fileListView at:lineIndex put:entry
  2308                 ].
  2304 		].
  2309             ].
  2305 	    ].
  2310         ].
  2306 	].
  2311 
  2307 
  2312         "
  2308 	"
  2313          install a new check after some time
  2309 	 install a new check after some time
  2314         "
  2310 	"
  2315         Processor addTimedBlock:checkBlock afterSeconds:checkDelta
  2311 	Processor addTimedBlock:checkBlock afterSeconds:checkDelta
       
  2312     ]
  2316     ]
  2313 
  2317 
  2314     "Modified: 21.9.1995 / 11:40:23 / claus"
  2318     "Modified: 21.9.1995 / 11:40:23 / claus"
  2315     "Modified: 14.12.1995 / 20:59:09 / cg"
  2319     "Modified: 8.10.1996 / 15:57:55 / cg"
  2316 !
  2320 !
  2317 
  2321 
  2318 validateFontEncodingFor:newEncoding
  2322 validateFontEncodingFor:newEncoding
  2319     "if required, query user if he/she wants to change to another font,
  2323     "if required, query user if he/she wants to change to another font,
  2320      which is able to display text encoded as specified by newEncoding"
  2324      which is able to display text encoded as specified by newEncoding"
  2645 ! !
  2649 ! !
  2646 
  2650 
  2647 !FileBrowser  class methodsFor:'documentation'!
  2651 !FileBrowser  class methodsFor:'documentation'!
  2648 
  2652 
  2649 version
  2653 version
  2650     ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.95 1996-09-13 07:04:01 cg Exp $'
  2654     ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.96 1996-10-08 15:00:44 cg Exp $'
  2651 ! !
  2655 ! !