16 showVeryLongList showDotFiles myName killButton compressTabs |
16 showVeryLongList showDotFiles myName killButton compressTabs |
17 lockUpdate previousDirectory currentFileName timeOfFileRead |
17 lockUpdate previousDirectory currentFileName timeOfFileRead |
18 tabSpec commandView commandIndex fileEncoding tabRulerView |
18 tabSpec commandView commandIndex fileEncoding tabRulerView |
19 scrollView icons' |
19 scrollView icons' |
20 classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon |
20 classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon |
21 CommandHistory CommandHistorySize Icons' |
21 CommandHistory CommandHistorySize Icons DefaultCommandPerSuffix' |
22 poolDictionaries:'' |
22 poolDictionaries:'' |
23 category:'Interface-Browsers' |
23 category:'Interface-Browsers' |
24 ! |
24 ! |
25 |
25 |
26 !FileBrowser class methodsFor:'documentation'! |
26 !FileBrowser class methodsFor:'documentation'! |
114 "Modified: 6.4.1997 / 14:57:12 / cg" |
114 "Modified: 6.4.1997 / 14:57:12 / cg" |
115 ! ! |
115 ! ! |
116 |
116 |
117 !FileBrowser class methodsFor:'command history'! |
117 !FileBrowser class methodsFor:'command history'! |
118 |
118 |
119 addToCommandHistory:aCommandString |
119 addToCommandHistory:aCommandString for:aFilename |
|
120 |cmd suffix| |
|
121 |
120 (aCommandString notNil and:[aCommandString notEmpty]) ifTrue:[ |
122 (aCommandString notNil and:[aCommandString notEmpty]) ifTrue:[ |
121 CommandHistory notNil ifTrue:[ |
123 CommandHistory notNil ifTrue:[ |
122 CommandHistory addFirst:aCommandString. |
124 CommandHistory addFirst:aCommandString. |
123 CommandHistory size > CommandHistorySize ifTrue:[ |
125 CommandHistory size > CommandHistorySize ifTrue:[ |
124 CommandHistory removeLast |
126 CommandHistory removeLast |
125 ] |
127 ] |
126 ]. |
128 ]. |
|
129 aFilename notNil ifTrue:[ |
|
130 cmd := aCommandString copyTo:(aCommandString indexOf:Character space ifAbsent:[aCommandString size + 1])-1. |
|
131 DefaultCommandPerSuffix isNil ifTrue:[ |
|
132 DefaultCommandPerSuffix := Dictionary new. |
|
133 ]. |
|
134 suffix := aFilename asFilename suffix. |
|
135 suffix notNil ifTrue:[ |
|
136 DefaultCommandPerSuffix at:suffix put:cmd. |
|
137 ] |
|
138 ] |
127 ] |
139 ] |
128 |
140 |
129 "Created: 14.11.1996 / 14:58:13 / cg" |
141 "Created: 14.11.1996 / 14:58:13 / cg" |
130 ! ! |
142 ! ! |
131 |
143 |
410 |
422 |
411 fileExecute |
423 fileExecute |
412 "if text was modified show a queryBox, |
424 "if text was modified show a queryBox, |
413 otherwise pop up execute box immediately" |
425 otherwise pop up execute box immediately" |
414 |
426 |
415 |action| |
427 |action sel fileName| |
416 |
428 |
417 " |
429 " |
418 this replaces everything by the commands output ... |
430 this replaces everything by the commands output ... |
419 " |
431 " |
420 action := [:command | |
432 action := [:command | |
421 self class addToCommandHistory:command. |
433 self class addToCommandHistory:command for:fileName. |
422 self doExecuteCommand:command replace:true |
434 self doExecuteCommand:command replace:true |
423 ]. |
435 ]. |
424 |
436 |
425 (self askIfModified:'contents has not been saved.\\Modifications will be lost when command is executed.' |
437 (self askIfModified:'contents has not been saved.\\Modifications will be lost when command is executed.' |
426 yesButton:'execute') ifFalse:[^ self]. |
438 yesButton:'execute') ifFalse:[^ self]. |
1490 noLabel:(resources at:noButtonText) |
1507 noLabel:(resources at:noButtonText) |
1491 |
1508 |
1492 "Modified: 21.2.1996 / 01:19:21 / cg" |
1509 "Modified: 21.2.1996 / 01:19:21 / cg" |
1493 ! |
1510 ! |
1494 |
1511 |
1495 askForCommandThenDo:aBlock |
1512 askForCommandFor:fileName thenDo:aBlock |
1496 "setup and launch a querybox to ask for unix command. |
1513 "setup and launch a querybox to ask for unix command. |
1497 Then evaluate aBlock passing the command-string as argument." |
1514 Then evaluate aBlock passing the command-string as argument." |
1498 |
1515 |
1499 |fileName sel box| |
1516 |sel box| |
1500 |
1517 |
1501 box := FilenameEnterBox |
1518 box := FilenameEnterBox |
1502 title:(resources at:'execute unix command:') |
1519 title:(resources at:'execute unix command:') |
1503 okText:(resources at:'execute') |
1520 okText:(resources at:'execute') |
1504 action:aBlock. |
1521 action:aBlock. |
1505 |
1522 |
1506 sel := fileListView selection. |
|
1507 sel size == 1 ifTrue:[ |
|
1508 fileName := fileList at:sel first |
|
1509 ]. |
|
1510 fileName notNil ifTrue:[ |
1523 fileName notNil ifTrue:[ |
1511 self initialCommandFor:fileName into:box. |
1524 self initialCommandFor:fileName into:box. |
1512 ]. |
1525 ]. |
1513 box directory:currentDirectory pathName asFilename. |
1526 box directory:currentDirectory pathName asFilename. |
1514 box showAtPointer |
1527 box showAtPointer. |
|
1528 box destroy. |
1515 |
1529 |
1516 "Modified: 7.9.1995 / 10:31:54 / claus" |
1530 "Modified: 7.9.1995 / 10:31:54 / claus" |
1517 ! |
1531 ! |
1518 |
1532 |
1519 askIfModified:question yesButton:yesButtonText |
1533 askIfModified:question yesButton:yesButtonText |
2258 |
2272 |
2259 "Created: 26.2.1996 / 17:43:08 / cg" |
2273 "Created: 26.2.1996 / 17:43:08 / cg" |
2260 "Modified: 23.1.1997 / 20:39:25 / cg" |
2274 "Modified: 23.1.1997 / 20:39:25 / cg" |
2261 ! |
2275 ! |
2262 |
2276 |
|
2277 initialCommandFor:fileName into:aBox |
|
2278 "set a useful initial command for execute box." |
|
2279 |
|
2280 |lcFilename cmd select| |
|
2281 |
|
2282 "/ XXX should be changed to take stuff from a config file |
|
2283 "/ XXX or from resources. |
|
2284 |
|
2285 ((currentDirectory typeOf:fileName) == #regular) ifTrue:[ |
|
2286 |
|
2287 (currentDirectory isExecutable:fileName) ifTrue:[ |
|
2288 aBox initialText:(fileName , ' <arguments>'). |
|
2289 ^ self |
|
2290 ]. |
|
2291 |
|
2292 lcFilename := fileName asLowercase. |
|
2293 |
|
2294 select := true. |
|
2295 |
|
2296 "some heuristics - my personal preferences ... |
|
2297 (actually this should come from a configfile)" |
|
2298 |
|
2299 (fileName endsWith:'akefile') ifTrue:[ |
|
2300 aBox initialText:'make target' selectFrom:6 to:11. |
|
2301 ^ self |
|
2302 ]. |
|
2303 (lcFilename endsWith:'tar.z') ifTrue:[ |
|
2304 cmd := 'zcat %1 | tar tvf -'. |
|
2305 select := false. |
|
2306 ]. |
|
2307 (fileName endsWith:'.taz') ifTrue:[ |
|
2308 aBox initialText:'zcat %1 | tar tvf -'. |
|
2309 select := false. |
|
2310 ]. |
|
2311 (fileName endsWith:'.tar') ifTrue:[ |
|
2312 cmd := 'tar tvf %1'. |
|
2313 select := 7. |
|
2314 ]. |
|
2315 (fileName endsWith:'.zoo') ifTrue:[ |
|
2316 cmd := 'zoo -list %1'. |
|
2317 select := 9. |
|
2318 ]. |
|
2319 (lcFilename endsWith:'.zip') ifTrue:[ |
|
2320 cmd := 'unzip -l %1'. |
|
2321 select := 8. |
|
2322 ]. |
|
2323 (lcFilename endsWith:'.z') ifTrue:[ |
|
2324 cmd := 'uncompress %1' |
|
2325 ]. |
|
2326 (fileName endsWith:'tar.gz') ifTrue:[ |
|
2327 cmd := ('gunzip < %1 | tar tvf -' ). |
|
2328 select := false. |
|
2329 ]. |
|
2330 (fileName endsWith:'.tgz') ifTrue:[ |
|
2331 cmd := ('gunzip < %1 | tar tvf -' ). |
|
2332 select := false. |
|
2333 ]. |
|
2334 (fileName endsWith:'.gz') ifTrue:[ |
|
2335 cmd := 'gunzip %1'. |
|
2336 ]. |
|
2337 (lcFilename endsWith:'.html') ifTrue:[ |
|
2338 cmd := 'netscape %1' |
|
2339 ]. |
|
2340 (lcFilename endsWith:'.htm') ifTrue:[ |
|
2341 cmd := 'netscape %1' |
|
2342 ]. |
|
2343 (fileName endsWith:'.uue') ifTrue:[ |
|
2344 cmd := 'uudecode %1' |
|
2345 ]. |
|
2346 (fileName endsWith:'.c') ifTrue:[ |
|
2347 cmd := 'cc -c %1'. |
|
2348 select := 5. |
|
2349 ]. |
|
2350 (fileName endsWith:'.cc') ifTrue:[ |
|
2351 cmd := 'g++ -c %1'. |
|
2352 select := 6. |
|
2353 ]. |
|
2354 (fileName endsWith:'.C') ifTrue:[ |
|
2355 cmd := 'g++ -c %1'. |
|
2356 select := 6. |
|
2357 ]. |
|
2358 (fileName endsWith:'.xbm') ifTrue:[ |
|
2359 cmd := 'bitmap %1' |
|
2360 ]. |
|
2361 (lcFilename endsWith:'.ps') ifTrue:[ |
|
2362 cmd := 'ghostview %1' |
|
2363 ]. |
|
2364 ((fileName endsWith:'.1') |
|
2365 or:[fileName endsWith:'.man']) ifTrue:[ |
|
2366 cmd := 'nroff -man %1'. |
|
2367 select := 10. |
|
2368 ]. |
|
2369 |
|
2370 cmd isNil ifTrue:[ |
|
2371 DefaultCommandPerSuffix isNil ifTrue:[ |
|
2372 cmd := '<cmd>' |
|
2373 ] ifFalse:[ |
|
2374 cmd := DefaultCommandPerSuffix |
|
2375 at:(lcFilename asFilename suffix) |
|
2376 ifAbsent:'<cmd>'. |
|
2377 ]. |
|
2378 cmd := cmd , ' %1'. |
|
2379 ]. |
|
2380 |
|
2381 cmd := cmd bindWith:fileName. |
|
2382 select == false ifTrue:[ |
|
2383 aBox initialText:cmd |
|
2384 ] ifFalse:[ |
|
2385 select isInteger ifFalse:[ |
|
2386 select := (cmd indexOf:Character space ifAbsent:[cmd size + 1]) - 1. |
|
2387 ]. |
|
2388 aBox initialText:cmd selectFrom:1 to:select |
|
2389 ] |
|
2390 ] |
|
2391 |
|
2392 "Modified: 4.4.1997 / 12:26:40 / cg" |
|
2393 ! |
|
2394 |
2263 onlyOneSelection |
2395 onlyOneSelection |
2264 "show a warning, that only one file must be selected for |
2396 "show a warning, that only one file must be selected for |
2265 this operation" |
2397 this operation" |
2266 |
2398 |
2267 self warn:'exactly one file must be selected !!' |
2399 self warn:'exactly one file must be selected !!' |
2520 ]. |
2652 ]. |
2521 ^ false |
2653 ^ false |
2522 |
2654 |
2523 "Created: 19.6.1996 / 09:43:50 / cg" |
2655 "Created: 19.6.1996 / 09:43:50 / cg" |
2524 "Modified: 16.4.1997 / 13:56:21 / cg" |
2656 "Modified: 16.4.1997 / 13:56:21 / cg" |
2525 ! |
|
2526 |
|
2527 initialCommandFor:fileName into:aBox |
|
2528 "set a useful initial command for execute box." |
|
2529 |
|
2530 |lcFilename| |
|
2531 |
|
2532 "/ XXX should be changed to take stuff from a config file |
|
2533 "/ XXX or from resources. |
|
2534 |
|
2535 ((currentDirectory typeOf:fileName) == #regular) ifTrue:[ |
|
2536 |
|
2537 (currentDirectory isExecutable:fileName) ifTrue:[ |
|
2538 aBox initialText:(fileName , '<arguments>'). |
|
2539 ^ self |
|
2540 ]. |
|
2541 |
|
2542 lcFilename := fileName asLowercase. |
|
2543 |
|
2544 "some heuristics - my personal preferences ... |
|
2545 (actually this should come from a configfile)" |
|
2546 |
|
2547 (fileName endsWith:'akefile') ifTrue:[ |
|
2548 aBox initialText:'make target' selectFrom:6 to:11. |
|
2549 ^ self |
|
2550 ]. |
|
2551 (lcFilename endsWith:'tar.z') ifTrue:[ |
|
2552 aBox initialText:'zcat ' , fileName , ' | tar tvf -'. |
|
2553 ^ self |
|
2554 ]. |
|
2555 (fileName endsWith:'.taz') ifTrue:[ |
|
2556 aBox initialText:'zcat ' , fileName , ' | tar tvf -'. |
|
2557 ^ self |
|
2558 ]. |
|
2559 (fileName endsWith:'.tar') ifTrue:[ |
|
2560 aBox initialText:'tar tvf ' , fileName selectFrom:1 to:7. |
|
2561 ^ self |
|
2562 ]. |
|
2563 (fileName endsWith:'.zoo') ifTrue:[ |
|
2564 aBox initialText:'zoo -list ' , fileName selectFrom:1 to:9. |
|
2565 ^ self |
|
2566 ]. |
|
2567 (lcFilename endsWith:'.zip') ifTrue:[ |
|
2568 aBox initialText:'unzip -l ' , fileName selectFrom:1 to:8. |
|
2569 ^ self |
|
2570 ]. |
|
2571 (lcFilename endsWith:'.z') ifTrue:[ |
|
2572 aBox initialText:'uncompress ' , fileName selectFrom:1 to:10. |
|
2573 ^ self |
|
2574 ]. |
|
2575 (fileName endsWith:'tar.gz') ifTrue:[ |
|
2576 aBox initialText:('gunzip <' , fileName , ' | tar tvf -' ). |
|
2577 ^ self |
|
2578 ]. |
|
2579 (fileName endsWith:'.tgz') ifTrue:[ |
|
2580 aBox initialText:('gunzip <' , fileName , ' | tar tvf -' ). |
|
2581 ^ self |
|
2582 ]. |
|
2583 (fileName endsWith:'.gz') ifTrue:[ |
|
2584 aBox initialText:('gunzip <' , fileName , ' >' , (fileName copyWithoutLast:3 "copyTo:(fileName size - 3)")). |
|
2585 ^ self |
|
2586 ]. |
|
2587 (lcFilename endsWith:'.html') ifTrue:[ |
|
2588 aBox initialText:'netscape ' , fileName . |
|
2589 ^ self |
|
2590 ]. |
|
2591 (lcFilename endsWith:'.htm') ifTrue:[ |
|
2592 aBox initialText:'netscape ' , fileName . |
|
2593 ^ self |
|
2594 ]. |
|
2595 (fileName endsWith:'.uue') ifTrue:[ |
|
2596 aBox initialText:'uudecode ' , fileName selectFrom:1 to:8. |
|
2597 ^ self |
|
2598 ]. |
|
2599 (fileName endsWith:'.c') ifTrue:[ |
|
2600 aBox initialText:'cc -c ' , fileName selectFrom:1 to:5. |
|
2601 ^ self |
|
2602 ]. |
|
2603 (fileName endsWith:'.cc') ifTrue:[ |
|
2604 aBox initialText:'g++ -c ' , fileName selectFrom:1 to:6. |
|
2605 ^ self |
|
2606 ]. |
|
2607 (fileName endsWith:'.C') ifTrue:[ |
|
2608 aBox initialText:'g++ -c ' , fileName selectFrom:1 to:6. |
|
2609 ^ self |
|
2610 ]. |
|
2611 (fileName endsWith:'.xbm') ifTrue:[ |
|
2612 aBox initialText:'bitmap ' , fileName selectFrom:1 to:6. |
|
2613 ^ self |
|
2614 ]. |
|
2615 (lcFilename endsWith:'.ps') ifTrue:[ |
|
2616 aBox initialText:'ghostview ' , fileName selectFrom:1 to:9. |
|
2617 ^ self |
|
2618 ]. |
|
2619 ((fileName endsWith:'.1') |
|
2620 or:[fileName endsWith:'.man']) ifTrue:[ |
|
2621 aBox initialText:'nroff -man ' , fileName selectFrom:1 to:10. |
|
2622 ^ self |
|
2623 ]. |
|
2624 aBox initialText:'<cmd> ' , fileName selectFrom:1 to:5 |
|
2625 ] |
|
2626 |
|
2627 "Modified: 4.4.1997 / 12:26:40 / cg" |
|
2628 ! |
2657 ! |
2629 |
2658 |
2630 nonBinaryFileAction:aFilename |
2659 nonBinaryFileAction:aFilename |
2631 "for some nonBinary files, if double clicked, we can do some useful |
2660 "for some nonBinary files, if double clicked, we can do some useful |
2632 action ..." |
2661 action ..." |