author | Claus Gittinger <cg@exept.de> |
Fri, 09 Feb 1996 00:26:59 +0100 | |
changeset 355 | 55f1bac567eb |
parent 346 | 9ee1f936b7ea |
child 380 | ec0cfd2b3200 |
permissions | -rw-r--r-- |
36 | 1 |
" |
2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
45 | 3 |
All Rights Reserved |
36 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
StandardSystemView subclass:#FileBrowser |
|
280
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
14 |
instanceVariableNames:'labelView filterField fileListView subView currentDirectory |
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
15 |
fileList checkBlock checkDelta timeOfLastCheck showLongList |
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
16 |
showVeryLongList showDotFiles myName killButton compressTabs |
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
17 |
lockUpdate previousDirectory currentFileName timeOfFileRead |
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
18 |
tabSpec commandView commandIndex' |
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
19 |
classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon |
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
20 |
CommandHistory CommandHistorySize' |
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
21 |
poolDictionaries:'' |
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
22 |
category:'Interface-Browsers' |
36 | 23 |
! |
24 |
||
25 |
!FileBrowser class methodsFor:'documentation'! |
|
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
45 | 30 |
All Rights Reserved |
36 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
this used to be a very simple demo application, |
|
44 |
but migrated into a quite nice tool, includes all kinds of |
|
45 |
warning and information boxes, background processes for directory- |
|
46 |
reading and internationalized strings. A good example for beginners, |
|
100 | 47 |
on how to do things .... (and maybe how not to do things ;-, since some |
48 |
stuff is historic and was implemented at times when better mechanisms |
|
49 |
were not available) |
|
52 | 50 |
|
36 | 51 |
See additional information in 'doc/misc/fbrowser.doc'. |
45 | 52 |
|
52 | 53 |
WARNING: files edited with FileBrowser will have leading spaces (multiple-8) |
54 |
being replaced by tabs. If tabs are to be preserved at other |
|
55 |
positions (for example, sendmail-config files) they will be |
|
56 |
corrupt after being written. |
|
57 |
||
303
1d94813f1977
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
294
diff
changeset
|
58 |
instancevariables of interest: |
45 | 59 |
|
60 |
checkDelta <Integer> number of seconds of check interval |
|
61 |
(looks ever so often if shown directory |
|
62 |
has changed). You may make this number |
|
63 |
higher, if your network-times are |
|
64 |
incorrect and thus, the filebrowser |
|
65 |
checks too often. |
|
66 |
||
67 |
compressTabs <Boolean> if true, leading spaces will be |
|
68 |
replaced by tabs when saving text |
|
52 | 69 |
|
70 |
some of the defaults (long/short list etc.) can be set by the resource file; |
|
71 |
see FileBrowser>>initialize for more details.. |
|
36 | 72 |
" |
203 | 73 |
! ! |
36 | 74 |
|
75 |
!FileBrowser class methodsFor:'instance creation'! |
|
76 |
||
77 |
openOn:aDirectoryPath |
|
78 |
"start a new FileBrowser in a pathname" |
|
79 |
||
80 |
^ (self new currentDirectory:aDirectoryPath) open |
|
81 |
||
52 | 82 |
" |
83 |
FileBrowser openOn:'aDirectoryPath' |
|
84 |
FileBrowser openOn:'/etc' |
|
85 |
FileBrowser openOn:'..' |
|
86 |
FileBrowser openOn:'.' |
|
87 |
" |
|
93 | 88 |
! |
89 |
||
90 |
openOnFileNamed:aFilename |
|
91 |
"start a new FileBrowser on a file" |
|
92 |
||
93 |
|f browser| |
|
94 |
||
95 |
f := aFilename asFilename. |
|
96 |
browser := self new. |
|
97 |
browser currentDirectory:f directoryName. |
|
98 |
browser showFile:f baseName. |
|
99 |
^ browser open |
|
100 |
||
101 |
" |
|
102 |
FileBrowser openOnFileNamed:'Makefile' |
|
103 |
FileBrowser openOnFileNamed:'../Makefile' |
|
104 |
FileBrowser openOnFileNamed:'/tmp/foo' |
|
105 |
" |
|
36 | 106 |
! ! |
107 |
||
73 | 108 |
!FileBrowser class methodsFor:'defaults'! |
109 |
||
110 |
defaultIcon |
|
111 |
DefaultIcon isNil ifTrue:[ |
|
112 |
DefaultIcon := Form |
|
113 |
fromFile:(ClassResources at:'ICON_FILE' |
|
114 |
default:'FBrowser.xbm') |
|
115 |
resolution:100. |
|
116 |
]. |
|
117 |
^ DefaultIcon |
|
118 |
! ! |
|
119 |
||
172 | 120 |
!FileBrowser methodsFor:'events'! |
121 |
||
122 |
mapped |
|
123 |
super mapped. |
|
124 |
" |
|
125 |
whant to know about changed history |
|
126 |
" |
|
127 |
self updateCurrentDirectory |
|
128 |
! |
|
129 |
||
130 |
visibilityChange:how |
|
131 |
|wasVisible| |
|
132 |
||
133 |
wasVisible := shown. |
|
134 |
super visibilityChange:how. |
|
135 |
(wasVisible not and:[shown]) ifTrue:[ |
|
136 |
" |
|
137 |
start checking again |
|
138 |
" |
|
139 |
Processor removeTimedBlock:checkBlock. |
|
140 |
Processor addTimedBlock:checkBlock afterSeconds:checkDelta. |
|
141 |
] |
|
142 |
! ! |
|
143 |
||
144 |
!FileBrowser methodsFor:'fileList user interaction'! |
|
145 |
||
146 |
changeDisplayMode |
|
147 |
"toggle from long to short listing (and vice-versa)" |
|
148 |
||
149 |
showLongList := showLongList not. |
|
150 |
self updateCurrentDirectory |
|
151 |
! |
|
152 |
||
153 |
changeDotFileVisibility |
|
154 |
"turn on/off visibility of files whose name starts with '.'" |
|
155 |
||
156 |
showDotFiles := showDotFiles not. |
|
157 |
self updateCurrentDirectory |
|
158 |
! |
|
159 |
||
160 |
fileExecute |
|
161 |
"if text was modified show a queryBox, |
|
162 |
otherwise pop up execute box immediately" |
|
163 |
||
164 |
|action| |
|
165 |
||
166 |
" |
|
167 |
this replaces everything by the commands output ... |
|
168 |
" |
|
169 |
action := [:command| self doExecuteCommand:command replace:true]. |
|
170 |
||
171 |
(self askIfModified:'contents has not been saved.\\Modifications will be lost when command is executed.' |
|
172 |
yesButton:'execute') ifFalse:[^ self]. |
|
173 |
||
174 |
"/ " |
|
175 |
"/ this inserts the commands output ... |
|
176 |
"/ " |
|
177 |
"/ action := [:command| self doExecuteCommand:command replace:false]. |
|
178 |
"/ |
|
179 |
self askForCommandThenDo:action |
|
180 |
! |
|
181 |
||
182 |
fileFileIn |
|
183 |
"fileIn the selected file(s)" |
|
184 |
||
185 |
self fileFileInLazy:false |
|
186 |
! |
|
187 |
||
188 |
fileFileInLazy |
|
189 |
"fileIn the selected file(s). Do a quick load (no compilation)" |
|
190 |
||
191 |
self fileFileInLazy:true |
|
192 |
! |
|
193 |
||
194 |
fileFileInLazy:lazy |
|
195 |
"fileIn the selected file(s)" |
|
196 |
||
333 | 197 |
|aStream here oldPath wasLazy bos| |
172 | 198 |
|
199 |
self selectedFilesDo:[:fileName | |
|
235 | 200 |
((currentDirectory typeOf:fileName) == #regular) ifTrue:[ |
201 |
here := currentDirectory pathName. |
|
172 | 202 |
|
235 | 203 |
((fileName endsWith:'.o') |
204 |
or:[(fileName endsWith:'.so') |
|
205 |
or:[fileName endsWith:'.obj']]) ifTrue:[ |
|
206 |
Object abortSignal catch:[ |
|
207 |
|p| |
|
172 | 208 |
|
235 | 209 |
p := (here , '/' ,fileName). |
210 |
"/ |
|
211 |
"/ look if already loaded ... then unload first |
|
212 |
"/ |
|
213 |
(ObjectFileLoader loadedObjectFiles includes:p) ifTrue:[ |
|
214 |
(Dialog confirm:(resources |
|
215 |
string:'%1 is already loaded; load anyway ?' |
|
216 |
with:p)) ifFalse:[ |
|
217 |
^ self |
|
218 |
]. |
|
219 |
Transcript showCr:'unloading old ' , p , ' ...'. |
|
220 |
ObjectFileLoader unloadObjectFile:p. |
|
221 |
]. |
|
172 | 222 |
|
235 | 223 |
Transcript showCr:'loading ' , p , ' ...'. |
224 |
ObjectFileLoader loadObjectFile:p. |
|
225 |
Class addInfoRecord:('fileIn ' , fileName) |
|
226 |
] |
|
227 |
] ifFalse:[ |
|
333 | 228 |
(fileName endsWith:'.cls') ifTrue:[ |
229 |
aStream := FileStream readonlyFileNamed:fileName in:currentDirectory. |
|
230 |
aStream notNil ifTrue:[ |
|
231 |
bos := BinaryObjectStorage onOld:aStream. |
|
232 |
bos next. |
|
233 |
bos close |
|
234 |
] |
|
235 |
] ifFalse:[ |
|
236 |
aStream := FileStream readonlyFileNamed:fileName in:currentDirectory. |
|
237 |
aStream notNil ifTrue:[ |
|
238 |
[ |
|
239 |
Class withoutUpdatingChangesDo:[ |
|
240 |
oldPath := Smalltalk systemPath. |
|
241 |
Smalltalk systemPath:(oldPath copy addFirst:here; yourself). |
|
242 |
wasLazy := Compiler compileLazy:lazy. |
|
243 |
aStream fileIn. |
|
244 |
]. |
|
245 |
Class addInfoRecord:('fileIn ' , fileName) |
|
246 |
] valueNowOrOnUnwindDo:[ |
|
247 |
Compiler compileLazy:wasLazy. |
|
248 |
Smalltalk systemPath:oldPath. |
|
249 |
aStream close |
|
250 |
] |
|
235 | 251 |
] |
252 |
] |
|
253 |
] |
|
254 |
] |
|
172 | 255 |
] |
256 |
||
257 |
"Modified: 15.11.1995 / 12:49:57 / cg" |
|
258 |
! |
|
259 |
||
260 |
fileGet |
|
261 |
"get contents of selected file into subView. |
|
262 |
If text was modified show a queryBox, |
|
263 |
otherwise get it immediately" |
|
264 |
||
265 |
|fileName msg label| |
|
266 |
||
267 |
(subView modified not or:[subView contentsWasSaved]) ifTrue:[^ self doFileGet]. |
|
268 |
fileName := self getSelectedFileName. |
|
269 |
fileName notNil ifTrue:[ |
|
270 |
(currentDirectory isDirectory:fileName) ifTrue:[ |
|
271 |
msg := 'contents has not been saved.\\Modifications will be lost when directory is changed.'. |
|
272 |
label := 'change'. |
|
273 |
] ifFalse:[ |
|
274 |
msg := 'contents has not been saved.\\Modifications will be lost when new file is read.'. |
|
275 |
label := 'get'. |
|
276 |
]. |
|
277 |
(self ask:(resources at:msg) yesButton:label) ifTrue:[ |
|
278 |
self doFileGet |
|
279 |
] |
|
280 |
] |
|
281 |
! |
|
282 |
||
283 |
fileGetInfo |
|
284 |
"show short file (stat)-info" |
|
285 |
||
286 |
self fileGetInfo:false |
|
287 |
! |
|
288 |
||
289 |
fileGetInfo:longInfo |
|
290 |
"get info on selected file - show it in a box" |
|
291 |
||
292 |
|string| |
|
293 |
||
294 |
string := self getFileInfoString:longInfo. |
|
295 |
string notNil ifTrue:[ |
|
296 |
self information:string |
|
297 |
] |
|
298 |
! |
|
299 |
||
300 |
fileGetLongInfo |
|
301 |
"show long stat (file)-info" |
|
302 |
||
303 |
self fileGetInfo:true |
|
304 |
! |
|
305 |
||
306 |
fileInsert |
|
307 |
"insert contents of file at cursor" |
|
308 |
||
309 |
|fileName| |
|
310 |
||
311 |
fileName := self getSelectedFileName. |
|
312 |
fileName notNil ifTrue:[ |
|
313 |
self showFile:fileName insert:true |
|
314 |
] |
|
315 |
! |
|
316 |
||
317 |
fileListMenu |
|
318 |
"return the menu to show in the fileList" |
|
319 |
||
320 |
|labels selectors m sel| |
|
321 |
||
322 |
labels := #( |
|
333 | 323 |
'spawn' |
324 |
'-' |
|
325 |
'get contents' |
|
326 |
'insert contents' |
|
327 |
'show info' |
|
328 |
'show full info' |
|
329 |
'fileIn' |
|
330 |
'quick fileIn (lazy)' |
|
331 |
'-' |
|
332 |
'update' |
|
333 |
'-' |
|
334 |
'execute unix command ...' |
|
335 |
'st/x tools' |
|
336 |
'-' |
|
337 |
'remove' |
|
338 |
'rename ...' |
|
339 |
'-' |
|
340 |
'display long list' |
|
341 |
'show all files' |
|
342 |
'-' |
|
343 |
'create directory ...' |
|
344 |
'create file ...' |
|
345 |
). |
|
172 | 346 |
|
347 |
selectors := #( |
|
333 | 348 |
fileSpawn |
349 |
nil |
|
350 |
fileGet |
|
351 |
fileInsert |
|
352 |
fileGetInfo |
|
353 |
fileGetLongInfo |
|
354 |
fileFileIn |
|
355 |
fileFileInLazy |
|
356 |
nil |
|
357 |
updateCurrentDirectory |
|
358 |
nil |
|
359 |
fileExecute |
|
360 |
stxTools |
|
361 |
nil |
|
362 |
fileRemove |
|
363 |
fileRename |
|
364 |
nil |
|
365 |
changeDisplayMode |
|
366 |
changeDotFileVisibility |
|
367 |
nil |
|
368 |
newDirectory |
|
369 |
newFile |
|
370 |
). |
|
172 | 371 |
|
372 |
m := PopUpMenu |
|
333 | 373 |
labels:(resources array:labels) |
374 |
selectors:selectors |
|
375 |
receiver:self. |
|
172 | 376 |
|
377 |
showDotFiles ifTrue:[ |
|
333 | 378 |
m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files') |
172 | 379 |
]. |
380 |
showLongList ifTrue:[ |
|
333 | 381 |
m labelAt:#changeDisplayMode put:(resources string:'display short list') |
172 | 382 |
]. |
383 |
||
384 |
m subMenuAt:#stxTools |
|
333 | 385 |
put:(PopUpMenu |
386 |
labels:(resources array: |
|
387 |
#( |
|
388 |
'Changes browser' |
|
389 |
'Editor' |
|
390 |
'HTML reader' |
|
391 |
'Image inspect' |
|
392 |
'show file differences' |
|
393 |
)) |
|
394 |
selectors:#( |
|
395 |
openChangesBrowser |
|
396 |
openEditor |
|
397 |
openHTMLReader |
|
398 |
openImageInspector |
|
399 |
openDiffView |
|
400 |
) |
|
401 |
receiver:self). |
|
172 | 402 |
|
403 |
((sel := fileListView selection) isNil or:[sel isEmpty]) ifTrue:[ |
|
333 | 404 |
m disableAll:#(fileGet fileInsert |
405 |
fileGetInfo fileGetLongInfo |
|
406 |
fileFileIn fileFileInLazy |
|
407 |
fileRemove fileRename). |
|
408 |
(m subMenuAt:#stxTools) |
|
409 |
disableAll:#(openChangesBrowser openEditor openHTMLReader openImageInspector) |
|
172 | 410 |
]. |
411 |
||
412 |
^m |
|
252 | 413 |
|
280
4775fe6326a0
submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents:
267
diff
changeset
|
414 |
"Modified: 12.12.1995 / 16:59:19 / cg" |
172 | 415 |
! |
416 |
||
417 |
filePrint |
|
418 |
|fileName inStream printStream line| |
|
419 |
||
294 | 420 |
self withWaitCursorDo:[ |
333 | 421 |
fileName := self getSelectedFileName. |
422 |
fileName notNil ifTrue:[ |
|
423 |
((currentDirectory typeOf:fileName) == #regular) ifTrue:[ |
|
424 |
inStream := FileStream readonlyFileNamed:fileName |
|
425 |
in:currentDirectory. |
|
426 |
inStream isNil ifFalse:[ |
|
427 |
printStream := PrinterStream new. |
|
428 |
printStream notNil ifTrue:[ |
|
429 |
[inStream atEnd] whileFalse:[ |
|
430 |
line := inStream nextLine. |
|
431 |
printStream nextPutAll:line. |
|
432 |
printStream cr |
|
433 |
]. |
|
434 |
printStream close |
|
435 |
]. |
|
436 |
inStream close |
|
437 |
] |
|
438 |
] |
|
439 |
]. |
|
440 |
0 "compiler hint" |
|
172 | 441 |
] |
294 | 442 |
|
443 |
"Modified: 14.12.1995 / 20:59:24 / cg" |
|
172 | 444 |
! |
445 |
||
446 |
fileRemove |
|
447 |
"remove the selected file(s). |
|
448 |
Query if user really wants to remove the file. |
|
449 |
- should be enhanced, to look for a ~/.trash directory |
|
450 |
and move files there if it exists (without asking in this case)." |
|
451 |
||
452 |
|sel q| |
|
453 |
||
454 |
sel := fileListView selection. |
|
455 |
sel notNil ifTrue:[ |
|
456 |
sel size > 1 ifTrue:[ |
|
457 |
q := resources string:'remove selected files ?' |
|
458 |
] ifFalse:[ |
|
459 |
q := resources string:'remove ''%1'' ?' with:(fileList at:sel first) |
|
460 |
]. |
|
461 |
(self ask:q yesButton:'remove') ifTrue:[self doRemove] |
|
462 |
] |
|
463 |
! |
|
464 |
||
465 |
fileRename |
|
466 |
"rename the selected file(s)" |
|
467 |
||
468 |
|queryBox| |
|
469 |
||
470 |
queryBox := FilenameEnterBox new. |
|
471 |
queryBox okText:(resources at:'rename'). |
|
472 |
self selectedFilesDo:[:oldName | |
|
473 |
queryBox title:(resources string:'rename ''%1'' to:' with:oldName). |
|
474 |
queryBox initialText:oldName. |
|
475 |
queryBox action:[:newName | self doRename:oldName to:newName]. |
|
476 |
queryBox showAtPointer |
|
477 |
] |
|
478 |
! |
|
479 |
||
480 |
fileSelect:lineNr |
|
481 |
"selected a file - do nothing here" |
|
482 |
^ self |
|
483 |
! |
|
484 |
||
485 |
fileSpawn |
|
486 |
"start another FileBrowser on the selected directory or |
|
487 |
on the same directory if none is selected." |
|
488 |
||
489 |
|any| |
|
490 |
||
491 |
any := false. |
|
492 |
self selectedFilesDo:[:fileName | |
|
493 |
(currentDirectory isDirectory:fileName) ifTrue:[ |
|
494 |
self class openOn:(currentDirectory pathName , '/' , fileName). |
|
495 |
any := true |
|
496 |
] |
|
497 |
]. |
|
498 |
any ifFalse:[ |
|
499 |
self class openOn:currentDirectory pathName |
|
500 |
] |
|
501 |
! |
|
502 |
||
503 |
newDirectory |
|
504 |
"ask for and create a new directory" |
|
505 |
||
506 |
|queryBox| |
|
507 |
||
508 |
queryBox := FilenameEnterBox |
|
509 |
title:(resources at:'create new directory:') withCRs |
|
510 |
okText:(resources at:'create') |
|
511 |
action:[:newName | self doCreateDirectory:newName]. |
|
512 |
"/ queryBox initialText:''. |
|
513 |
queryBox showAtPointer |
|
514 |
! |
|
515 |
||
516 |
newFile |
|
517 |
"ask for and create a new file" |
|
518 |
||
519 |
|sel queryBox| |
|
520 |
||
521 |
queryBox := FilenameEnterBox |
|
522 |
title:(resources at:'create new file:') withCRs |
|
523 |
okText:(resources at:'create') |
|
524 |
action:[:newName | self doCreateFile:newName]. |
|
525 |
sel := subView selection. |
|
526 |
sel notNil ifTrue:[ |
|
527 |
queryBox initialText:(sel asString) |
|
528 |
] ifFalse:[ |
|
529 |
"/ queryBox initialText:'' |
|
530 |
]. |
|
531 |
queryBox showAtPointer |
|
532 |
! |
|
533 |
||
534 |
openChangesBrowser |
|
535 |
"open a change browser on the selected file(s)" |
|
536 |
||
537 |
self openTool:ChangesBrowser |
|
538 |
! |
|
539 |
||
252 | 540 |
openDiffView |
541 |
"open a diff-view" |
|
542 |
||
543 |
|box name1 name2 text1 text2 d err nm here| |
|
544 |
||
545 |
name1 := '' asValue. |
|
546 |
name2 := self getSelectedFileName asValue. |
|
547 |
here := currentDirectory pathName. |
|
548 |
||
549 |
box := DialogBox new. |
|
550 |
box addTextLabel:'show difference between:'. |
|
551 |
box addFilenameInputFieldOn:name1 in:here tabable:true. |
|
552 |
box addTextLabel:'and:'. |
|
553 |
box addFilenameInputFieldOn:name2 in:here tabable:true. |
|
554 |
||
555 |
box addAbortButton; addOkButton. |
|
556 |
||
557 |
box showAtPointer. |
|
558 |
||
559 |
box accepted ifTrue:[ |
|
560 |
(name1 := name1 value asFilename) isAbsolute ifFalse:[ |
|
561 |
name1 := here asFilename construct:name1 |
|
562 |
]. |
|
563 |
(name2 := name2 value asFilename) isAbsolute ifFalse:[ |
|
564 |
name2 := here asFilename construct:name2 |
|
565 |
]. |
|
566 |
name1 isReadable ifFalse:[ |
|
567 |
nm := name1. |
|
568 |
name1 exists ifFalse:[ |
|
569 |
err := '%1 does not exist'. |
|
570 |
] ifTrue:[ |
|
571 |
err := '%1 is not readable' |
|
572 |
]. |
|
573 |
]. |
|
574 |
err isNil ifTrue:[ |
|
575 |
name2 isReadable ifFalse:[ |
|
576 |
nm := name2. |
|
577 |
name2 exists ifFalse:[ |
|
578 |
err := '%1 does not exist'. |
|
579 |
] ifTrue:[ |
|
580 |
err := '%1 is not readable' |
|
581 |
]. |
|
582 |
]. |
|
583 |
]. |
|
584 |
err notNil ifTrue:[ |
|
585 |
self warn:(resources string:err with:nm pathName). |
|
586 |
^ self |
|
587 |
]. |
|
588 |
self withWaitCursorDo:[ |
|
589 |
text1 := name1 contentsOfEntireFile. |
|
590 |
text2 := name2 contentsOfEntireFile. |
|
591 |
d := DiffTextView |
|
592 |
openOn:text1 label:name1 pathName |
|
593 |
and:text2 label:name2 pathName. |
|
594 |
d label:'file differences'. |
|
595 |
] |
|
596 |
]. |
|
597 |
||
598 |
"Created: 7.12.1995 / 20:33:58 / cg" |
|
267 | 599 |
! |
600 |
||
601 |
openEditor |
|
602 |
self openTool:EditTextView |
|
603 |
! |
|
604 |
||
605 |
openHTMLReader |
|
606 |
self openTool:XtHTML |
|
607 |
! |
|
608 |
||
609 |
openImageInspector |
|
610 |
|img| |
|
611 |
||
612 |
self selectedFilesDo:[:fileName | |
|
613 |
(currentDirectory isDirectory:fileName) ifFalse:[ |
|
614 |
img := Image fromFile:(currentDirectory pathName , '/' , fileName). |
|
615 |
img notNil ifTrue:[ |
|
616 |
img inspect |
|
617 |
] ifFalse:[ |
|
618 |
self warn:'unknown format: ' , fileName |
|
619 |
] |
|
620 |
] |
|
621 |
]. |
|
622 |
||
623 |
"Modified: 17.9.1995 / 17:41:24 / claus" |
|
624 |
! |
|
625 |
||
626 |
openTool:aToolClass |
|
627 |
"open a tool on the selected file(s)" |
|
628 |
||
629 |
self selectedFilesDo:[:fileName | |
|
630 |
(currentDirectory isDirectory:fileName) ifFalse:[ |
|
631 |
aToolClass openOn:(currentDirectory pathName , '/' , fileName). |
|
632 |
] |
|
633 |
]. |
|
172 | 634 |
! ! |
635 |
||
636 |
!FileBrowser methodsFor:'help '! |
|
637 |
||
638 |
helpTextFor:aComponent |
|
639 |
|s| |
|
640 |
||
641 |
aComponent == subView ifTrue:[ |
|
642 |
s := 'HELP_SUBVIEW' |
|
643 |
]. |
|
644 |
aComponent == fileListView ifTrue:[ |
|
645 |
s := 'HELP_FILELIST' |
|
646 |
]. |
|
647 |
aComponent == filterField ifTrue:[ |
|
648 |
s := 'HELP_FILTER' |
|
649 |
]. |
|
650 |
aComponent == labelView ifTrue:[ |
|
651 |
s := 'HELP_PATHFIELD' |
|
652 |
]. |
|
653 |
aComponent == commandView ifTrue:[ |
|
654 |
s := 'HELP_COMMANDVIEW' |
|
655 |
]. |
|
656 |
s notNil ifTrue:[ |
|
657 |
^ resources string:s |
|
658 |
]. |
|
659 |
^ nil |
|
660 |
! ! |
|
661 |
||
36 | 662 |
!FileBrowser methodsFor:'initialization'! |
663 |
||
172 | 664 |
currentDirectory:aDirectoryPath |
665 |
"set the directory to be browsed" |
|
666 |
||
667 |
currentDirectory := FileDirectory directoryNamed:aDirectoryPath. |
|
668 |
self changed:#path. |
|
669 |
" |
|
670 |
tell my subview (whatever that is) to start its file-dialog |
|
671 |
(i.e. save-as etc.) in that directory |
|
672 |
" |
|
673 |
(subView respondsTo:#directoryForFileDialog:) ifTrue:[ |
|
674 |
subView directoryForFileDialog:currentDirectory |
|
675 |
] |
|
676 |
! |
|
677 |
||
678 |
focusSequence |
|
679 |
"return the sequence in which ALT-CursorRight steps focus" |
|
680 |
||
681 |
|fs| |
|
682 |
||
683 |
fs := Array |
|
684 |
with:filterField |
|
685 |
with:fileListView |
|
686 |
with:subView. |
|
687 |
||
688 |
commandView notNil ifTrue:[ |
|
689 |
fs := fs copyWith:commandView |
|
690 |
]. |
|
691 |
^fs |
|
692 |
! |
|
693 |
||
694 |
initEvents |
|
695 |
super initEvents. |
|
696 |
self enableEvent:#visibilityChange. |
|
697 |
! |
|
698 |
||
36 | 699 |
initialize |
344
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
700 |
|frame spacing halfSpacing v topFrame labelFrame filterModel| |
36 | 701 |
|
702 |
super initialize. |
|
703 |
||
52 | 704 |
"if true, will replace leading spaces by tabs on |
705 |
file write. If false, they will be written as spaces |
|
706 |
" |
|
707 |
compressTabs := resources at:'COMPRESS_TABS' default:true. |
|
708 |
||
709 |
" |
|
710 |
showing long or short by default |
|
711 |
" |
|
712 |
showLongList := resources at:'LONG_LIST' default:false. |
|
713 |
||
714 |
" |
|
715 |
show type of contents (somwehat slow) or not ? |
|
716 |
" |
|
717 |
showVeryLongList := resources at:'VERYLONG_LIST' default:true. |
|
718 |
||
719 |
" |
|
720 |
show hidden files or not ? |
|
721 |
" |
|
722 |
showDotFiles := resources at:'SHOW_DOT_FILES' default:false. |
|
723 |
||
724 |
||
45 | 725 |
lockUpdate := false. |
726 |
||
132 | 727 |
CommandHistory isNil ifTrue:[ |
333 | 728 |
CommandHistory := OrderedCollection new. |
729 |
CommandHistorySize := 50 |
|
132 | 730 |
]. |
36 | 731 |
DirectoryHistory isNil ifTrue:[ |
333 | 732 |
DirectoryHistory := OrderedCollection new. |
733 |
DirectoryHistoryWhere := OrderedCollection new. |
|
734 |
HistorySize := 15. |
|
36 | 735 |
]. |
132 | 736 |
commandIndex := 0. |
36 | 737 |
|
738 |
myName := (resources string:self class name). |
|
739 |
self label:myName. |
|
45 | 740 |
|
93 | 741 |
labelFrame := View |
333 | 742 |
origin:(0.0 @ 0.0) |
743 |
corner:(1.0 @ (font height * 2)) |
|
744 |
in:self. |
|
52 | 745 |
|
105 | 746 |
styleSheet name = #st80 ifTrue:[ |
333 | 747 |
labelFrame level:1 |
45 | 748 |
]. |
36 | 749 |
|
750 |
spacing := ViewSpacing. |
|
751 |
halfSpacing := spacing // 2. |
|
752 |
||
753 |
checkBlock := [self checkIfDirectoryHasChanged]. |
|
45 | 754 |
checkDelta := resources at:'CHECK_DELTA' default:10. |
36 | 755 |
|
756 |
currentDirectory := FileDirectory directoryNamed:'.'. |
|
757 |
||
344
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
758 |
filterModel := '*' asValue. |
45 | 759 |
filterField := EditField in:labelFrame. |
36 | 760 |
filterField origin:[((width // 4 * 3) + halfSpacing) @ halfSpacing] |
333 | 761 |
corner:(1.0 @ filterField heightIncludingBorder). |
45 | 762 |
filterField rightInset:ViewSpacing-halfSpacing. |
344
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
763 |
filterField model:filterModel. |
45 | 764 |
|
36 | 765 |
self initializeFilterPattern. |
344
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
766 |
filterModel onChangeSend:#filterPatternChanged to:self. |
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
767 |
"/ filterField leaveAction:[:key | fileListView scrollToTop. self updateCurrentDirectory]. |
36 | 768 |
|
45 | 769 |
labelView := Label in:labelFrame. |
36 | 770 |
labelView origin:(halfSpacing @ halfSpacing) |
333 | 771 |
extent:[((width // 4 * 3) - spacing - borderWidth) |
772 |
@ |
|
773 |
(filterField heightIncludingBorder) |
|
774 |
"(font height + font descent)" |
|
775 |
]. |
|
36 | 776 |
labelView adjust:#right. |
777 |
labelView borderWidth:0. |
|
93 | 778 |
labelView model:self; menu:#labelMenu; aspect:#path; labelMessage:#path. |
73 | 779 |
labelFrame model:self; menu:#labelMenu. |
36 | 780 |
|
781 |
killButton := Button label:(resources string:'kill') in:self. |
|
782 |
killButton origin:(halfSpacing @ halfSpacing) |
|
333 | 783 |
extent:(killButton width @ filterField height). |
331 | 784 |
killButton beInvisible. |
36 | 785 |
|
132 | 786 |
self initializeCommandViewIn:self. |
787 |
||
788 |
"/ frame := VariableVerticalPanel |
|
789 |
"/ origin:[frame borderWidth negated |
|
790 |
"/ @ |
|
791 |
"/ labelFrame height |
|
792 |
"/ "/ (labelView height + labelView origin y + spacing) |
|
793 |
"/ ] |
|
794 |
"/ corner:(1.0 @ 1.0) |
|
795 |
"/ in:self. |
|
796 |
||
797 |
frame := VariableVerticalPanel origin:0.0@0.0 corner:1.0@1.0 in:self. |
|
798 |
frame topInset:labelFrame height. |
|
799 |
commandView notNil ifTrue:[ |
|
333 | 800 |
frame bottomInset:(commandView height + spacing + spacing) |
132 | 801 |
]. |
36 | 802 |
|
803 |
topFrame := ScrollableView for:SelectionInListView in:frame. |
|
804 |
topFrame origin:(0.0 @ 0.0) corner:(1.0 @ 0.3). |
|
805 |
||
806 |
fileListView := topFrame scrolledView. |
|
807 |
fileListView action:[:lineNr | self fileSelect:lineNr]. |
|
808 |
fileListView doubleClickAction:[:lineNr | self fileSelect:lineNr. |
|
333 | 809 |
self fileGet]. |
36 | 810 |
fileListView multipleSelectOk:true. |
98 | 811 |
fileListView menuHolder:self; menuPerformer:self; menuMessage:#fileListMenu. |
36 | 812 |
|
813 |
v := self initializeSubViewIn:frame. |
|
132 | 814 |
|
36 | 815 |
v origin:(0.0 @ 0.3) corner:(1.0 @ 1.0). |
816 |
subView := v scrolledView. |
|
817 |
(subView respondsTo:#directoryForFileDialog:) ifTrue:[ |
|
333 | 818 |
subView directoryForFileDialog:currentDirectory |
36 | 819 |
]. |
820 |
||
821 |
ObjectMemory addDependent:self. |
|
132 | 822 |
|
823 |
"Modified: 6.9.1995 / 20:26:06 / claus" |
|
331 | 824 |
"Modified: 17.1.1996 / 11:45:56 / cg" |
36 | 825 |
! |
826 |
||
132 | 827 |
initializeCommandViewIn:frame |
828 |
"set up the command view - can be redefined in subclasses as empty, |
|
829 |
if no commandView is wanted" |
|
830 |
||
831 |
||
832 |
commandView := EditField origin:0.0@1.0 corner:1.0@1.0 in:frame. |
|
833 |
commandView topInset:(commandView preferredExtent y negated - ViewSpacing). |
|
834 |
commandView bottomInset:ViewSpacing. |
|
835 |
commandView horizontalInset:ViewSpacing. |
|
836 |
||
133 | 837 |
"/ commandView contents:'** no commands which require input here **'. |
132 | 838 |
|
142 | 839 |
commandView entryCompletionBlock:[:contents | |
840 |
|newString| |
|
841 |
||
842 |
newString := Filename |
|
843 |
filenameCompletionFor:contents |
|
844 |
directory:currentDirectory pathName asFilename |
|
845 |
directoriesOnly:false |
|
846 |
filesOnly:false |
|
847 |
ifMultiple:[:dir | commandView flash.]. |
|
848 |
commandView contents:newString. |
|
849 |
commandView cursorToEndOfLine. |
|
132 | 850 |
]. |
851 |
commandView leaveAction:[:key | |
|
852 |
|cmd nCmd empty| |
|
853 |
||
854 |
(key == #CursorDown |
|
855 |
or:[key == #CursorUp]) ifTrue:[ |
|
133 | 856 |
nCmd := CommandHistory size. |
857 |
nCmd == 0 ifTrue:[ |
|
858 |
empty := true |
|
859 |
] ifFalse:[ |
|
860 |
key == #CursorUp ifTrue:[ |
|
861 |
commandIndex == nCmd ifTrue:[ |
|
862 |
commandView flash. |
|
863 |
]. |
|
864 |
commandIndex := (commandIndex + 1) min:nCmd |
|
865 |
] ifFalse:[ |
|
866 |
commandIndex == 1 ifTrue:[ |
|
867 |
commandView flash. |
|
868 |
empty := true. |
|
869 |
]. |
|
870 |
commandIndex := (commandIndex - 1) max:1. |
|
871 |
]. |
|
872 |
]. |
|
873 |
empty == true ifTrue:[ |
|
874 |
commandView contents:nil |
|
875 |
] ifFalse:[ |
|
876 |
commandView contents:(CommandHistory at:commandIndex). |
|
877 |
] |
|
132 | 878 |
]. |
879 |
key == #Return ifTrue:[ |
|
880 |
cmd := commandView contents. |
|
881 |
||
133 | 882 |
subView insertLine:(ColoredListEntry string:('>> ' , cmd) color:Color blue) |
883 |
before:(subView cursorLine). |
|
884 |
subView cursorDown. |
|
885 |
||
886 |
"/ subView insertStringAtCursor:cmd. |
|
887 |
"/ subView insertCharAtCursor:(Character cr). |
|
132 | 888 |
|
889 |
(cmd notNil and:[cmd notEmpty]) ifTrue:[ |
|
890 |
CommandHistory notNil ifTrue:[ |
|
891 |
CommandHistory addFirst:cmd. |
|
892 |
CommandHistory size > CommandHistorySize ifTrue:[ |
|
893 |
CommandHistory removeLast |
|
894 |
] |
|
895 |
]. |
|
896 |
self doExecuteCommand:cmd replace:false. |
|
897 |
commandView contents:nil. |
|
898 |
commandIndex := 0 |
|
899 |
] |
|
900 |
] |
|
901 |
]. |
|
902 |
||
133 | 903 |
"Modified: 7.9.1995 / 15:48:45 / claus" |
132 | 904 |
! |
905 |
||
172 | 906 |
initializeFilterPattern |
907 |
"set an initial matchpattern - can be redefined in subclasses" |
|
908 |
||
344
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
909 |
filterField model value:'*' |
172 | 910 |
! |
911 |
||
912 |
initializeSubViewIn:frame |
|
913 |
"set up the contents view - can be redefined in subclasses for |
|
914 |
different view types (SoundFileBrowser/ImageBrowsers etc.)" |
|
915 |
||
916 |
^ HVScrollableView for:CodeView miniScrollerH:true miniScrollerV:false in:frame. |
|
917 |
! ! |
|
918 |
||
919 |
!FileBrowser methodsFor:'misc user interaction'! |
|
920 |
||
921 |
destroy |
|
922 |
"destroy view and boxes" |
|
923 |
||
924 |
ObjectMemory removeDependent:self. |
|
925 |
Processor removeTimedBlock:checkBlock. |
|
926 |
checkBlock := nil. |
|
927 |
super destroy |
|
928 |
! |
|
929 |
||
346 | 930 |
filterPatternChanged |
931 |
fileListView scrollToTop. |
|
932 |
self updateCurrentDirectory |
|
933 |
! |
|
934 |
||
172 | 935 |
terminate |
936 |
"exit FileBrowser" |
|
937 |
||
938 |
(self askIfModified:'contents has not been saved.\\Modifications will be lost when FileBrowser is closed.' |
|
939 |
yesButton:'close') ifTrue:[self destroy] |
|
940 |
! |
|
941 |
||
942 |
update:what with:someArgument from:changedObject |
|
943 |
realized ifFalse:[^ self]. |
|
36 | 944 |
|
172 | 945 |
(what == #aboutToExit) ifTrue:[ |
946 |
"system wants to shut down this |
|
947 |
- if text was modified, pop up, and ask user and save if requested." |
|
948 |
||
949 |
(subView modified and:[subView contentsWasSaved not]) ifTrue:[ |
|
950 |
self raiseDeiconified. |
|
951 |
||
952 |
self ask:(resources at:'FileBrowser:\\contents has not been saved.\\Save before exiting ?') withCRs |
|
953 |
yesButton:'save' |
|
954 |
noButton:'don''t save' |
|
955 |
action:[ |
|
956 |
subView acceptAction notNil ifTrue:[ |
|
957 |
subView accept |
|
958 |
] ifFalse:[ |
|
959 |
subView save |
|
960 |
] |
|
961 |
] |
|
962 |
]. |
|
963 |
^ self |
|
964 |
]. |
|
965 |
changedObject == tabSpec ifTrue:[ |
|
966 |
fileListView redraw |
|
967 |
]. |
|
968 |
! ! |
|
969 |
||
970 |
!FileBrowser methodsFor:'pathField user interaction'! |
|
971 |
||
972 |
changeCurrentDirectory |
|
973 |
"if text was modified show a queryBox, |
|
974 |
otherwise change immediately to directory" |
|
975 |
||
976 |
(self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.' |
|
977 |
yesButton:'change') ifTrue:[ |
|
978 |
self queryForDirectoryToChange |
|
36 | 979 |
] |
980 |
! |
|
981 |
||
172 | 982 |
changeDirectoryTo:aDirectoryName |
983 |
"sent from label menu to change back to a previous directory" |
|
132 | 984 |
|
172 | 985 |
self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:false |
986 |
! |
|
987 |
||
988 |
changeToHomeDirectory |
|
989 |
"if text was modified show a queryBox, |
|
990 |
otherwise change immediately to directory" |
|
132 | 991 |
|
172 | 992 |
(self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.' |
993 |
yesButton:'change') ifTrue:[ |
|
994 |
self doChangeToHomeDirectory |
|
995 |
] |
|
996 |
! |
|
45 | 997 |
|
172 | 998 |
changeToParentDirectory |
999 |
"if text was modified show a queryBox, |
|
1000 |
otherwise change immediately to directory" |
|
45 | 1001 |
|
172 | 1002 |
(self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.' |
1003 |
yesButton:'change') ifTrue:[ |
|
1004 |
self doChangeToParentDirectory |
|
36 | 1005 |
] |
98 | 1006 |
! |
1007 |
||
172 | 1008 |
copyPath |
1009 |
"copy current path into cut & paste buffer" |
|
1010 |
||
1011 |
Smalltalk at:#CopyBuffer put:currentDirectory pathName |
|
1012 |
! |
|
1013 |
||
1014 |
labelMenu |
|
1015 |
|labels selectors args menu| |
|
1016 |
||
1017 |
labels := #( |
|
1018 |
'copy path' |
|
1019 |
'-' |
|
1020 |
'up' |
|
1021 |
'back' |
|
1022 |
'change to home-directory' |
|
1023 |
'change directory ...' |
|
1024 |
). |
|
98 | 1025 |
|
172 | 1026 |
selectors := #( |
1027 |
copyPath |
|
1028 |
nil |
|
1029 |
changeToParentDirectory |
|
1030 |
changeToPreviousDirectory |
|
1031 |
changeToHomeDirectory |
|
1032 |
changeCurrentDirectory |
|
1033 |
). |
|
123 | 1034 |
|
172 | 1035 |
args := Array new:(labels size). |
126 | 1036 |
|
172 | 1037 |
DirectoryHistory size > 0 ifTrue:[ |
1038 |
labels := labels copyWith:'-'. |
|
1039 |
selectors := selectors copyWith:nil. |
|
1040 |
args := args copyWith:nil. |
|
1041 |
||
1042 |
DirectoryHistory do:[:dirName | |
|
1043 |
labels := labels copyWith:dirName. |
|
1044 |
selectors := selectors copyWith:#changeDirectoryTo:. |
|
1045 |
args := args copyWith:dirName |
|
1046 |
] |
|
123 | 1047 |
]. |
172 | 1048 |
|
1049 |
menu := PopUpMenu |
|
1050 |
labels:(resources array:labels) |
|
1051 |
selectors:selectors |
|
1052 |
args:args |
|
1053 |
receiver:self. |
|
1054 |
||
1055 |
previousDirectory isNil ifTrue:[ |
|
1056 |
menu disable:#changeToPreviousDirectory. |
|
132 | 1057 |
]. |
172 | 1058 |
^menu. |
1059 |
! |
|
1060 |
||
1061 |
queryForDirectoryToChange |
|
1062 |
"query for new directory" |
|
123 | 1063 |
|
172 | 1064 |
|queryBox| |
98 | 1065 |
|
172 | 1066 |
queryBox := FilenameEnterBox |
1067 |
title:(resources at:'change directory to:') withCRs |
|
1068 |
okText:(resources at:'change') |
|
1069 |
action:[:newName | self doChangeCurrentDirectoryTo:newName updateHistory:true]. |
|
1070 |
"/ queryBox initialText:''. |
|
1071 |
queryBox showAtPointer |
|
36 | 1072 |
! ! |
1073 |
||
1074 |
!FileBrowser methodsFor:'private'! |
|
1075 |
||
172 | 1076 |
ask:question yesButton:yesButtonText |
1077 |
"common method to ask a yes/no question; return true or false" |
|
36 | 1078 |
|
172 | 1079 |
^ self ask:question yesButton:yesButtonText noButton:'cancel' |
1080 |
! |
|
93 | 1081 |
|
172 | 1082 |
ask:question yesButton:yesButtonText noButton:noButtonText |
1083 |
"common method to ask a yes/no question; return true or false" |
|
1084 |
||
1085 |
self |
|
1086 |
ask:question |
|
1087 |
yesButton:yesButtonText |
|
1088 |
noButton:noButtonText |
|
1089 |
action:[^ true]. |
|
1090 |
^ false |
|
36 | 1091 |
! |
1092 |
||
1093 |
ask:question yesButton:yesButtonText noButton:noButtonText action:aBlock |
|
1094 |
"common method to ask a yes/no question" |
|
1095 |
||
37 | 1096 |
|yesNoBox| |
1097 |
||
49 | 1098 |
yesNoBox := YesNoBox |
1099 |
title:question withCRs |
|
1100 |
yesText:(resources at:yesButtonText) |
|
1101 |
noText:(resources at:noButtonText). |
|
36 | 1102 |
yesNoBox okAction:aBlock. |
1103 |
yesNoBox showAtPointer |
|
1104 |
! |
|
1105 |
||
172 | 1106 |
askForCommandThenDo:aBlock |
1107 |
"setup and launch a querybox to ask for unix command. |
|
1108 |
Then evaluate aBlock passing the command-string as argument." |
|
93 | 1109 |
|
172 | 1110 |
|fileName sel box| |
93 | 1111 |
|
172 | 1112 |
box := FilenameEnterBox |
1113 |
title:(resources at:'execute unix command:') |
|
1114 |
okText:(resources at:'execute') |
|
1115 |
action:aBlock. |
|
79 | 1116 |
|
172 | 1117 |
sel := fileListView selection. |
1118 |
sel size == 1 ifTrue:[ |
|
1119 |
fileName := fileList at:sel first |
|
1120 |
]. |
|
1121 |
fileName notNil ifTrue:[ |
|
1122 |
self initialCommandFor:fileName into:box. |
|
1123 |
]. |
|
1124 |
box directory:currentDirectory pathName asFilename. |
|
1125 |
box showAtPointer |
|
36 | 1126 |
|
172 | 1127 |
"Modified: 7.9.1995 / 10:31:54 / claus" |
36 | 1128 |
! |
1129 |
||
98 | 1130 |
askIfModified:question yesButton:yesButtonText |
1131 |
"tell user, that code has been modified - let her confirm" |
|
1132 |
||
1133 |
(subView modified not or:[subView contentsWasSaved]) ifTrue:[ |
|
1134 |
^ true |
|
1135 |
]. |
|
1136 |
^ self |
|
1137 |
ask:(resources string:question) |
|
1138 |
yesButton:yesButtonText |
|
1139 |
! |
|
1140 |
||
172 | 1141 |
binaryFileAction:aFilename |
1142 |
"for some binary files, if double clicked, we can do some useful |
|
1143 |
action ..." |
|
1144 |
||
1145 |
|isImage img| |
|
36 | 1146 |
|
172 | 1147 |
(currentDirectory pathName , '/' , aFilename) asFilename isExecutable ifTrue:[ |
1148 |
(OperatingSystem executeCommand:'cd ',currentDirectory pathName, '; ',aFilename) |
|
1149 |
ifTrue:[^true]. |
|
1150 |
]. |
|
1151 |
isImage := false. |
|
1152 |
(aFilename endsWith:'.gif') ifTrue:[isImage := true]. |
|
1153 |
(aFilename endsWith:'.tiff') ifTrue:[isImage := true]. |
|
1154 |
(aFilename endsWith:'.pnm') ifTrue:[isImage := true]. |
|
1155 |
(aFilename endsWith:'.xbm') ifTrue:[isImage := true]. |
|
1156 |
isImage ifTrue:[ |
|
1157 |
img := Image fromFile:(currentDirectory pathName , '/' , aFilename). |
|
1158 |
img notNil ifTrue:[ |
|
1159 |
img inspect. |
|
1160 |
^ true |
|
120 | 1161 |
] |
36 | 1162 |
]. |
172 | 1163 |
^ false |
1164 |
||
1165 |
"Created: 14.9.1995 / 10:23:10 / claus" |
|
36 | 1166 |
! |
1167 |
||
172 | 1168 |
changeToPreviousDirectory |
1169 |
"if text was modified show a queryBox, |
|
1170 |
otherwise change immediately to previous directory." |
|
93 | 1171 |
|
172 | 1172 |
previousDirectory isNil ifTrue:[^ self]. |
1173 |
(self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.' |
|
1174 |
yesButton:'change') ifTrue:[ |
|
1175 |
self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false |
|
1176 |
] |
|
36 | 1177 |
! |
1178 |
||
98 | 1179 |
checkIfDirectoryHasChanged |
1180 |
"every checkDelta secs, check if directoy has changed and update the list if so. |
|
1181 |
Also, we check if the file shown has been touched in the meanwhile (for example, |
|
1182 |
from another browser) and say 'outdated' in the label if so. |
|
1183 |
This avoids confusion if the same file is being edited by two browsers. (or other editors). |
|
1184 |
If the text shown in the codeView has been edited, 'modified' is shown. |
|
1185 |
" |
|
1186 |
||
1187 |
|oldSelection nOld here newState msg newLabel| |
|
1188 |
||
1189 |
shown ifTrue:[ |
|
1190 |
currentDirectory notNil ifTrue:[ |
|
1191 |
lockUpdate ifTrue:[ |
|
1192 |
Processor removeTimedBlock:checkBlock. |
|
1193 |
Processor addTimedBlock:checkBlock afterSeconds:checkDelta. |
|
1194 |
^ self |
|
1195 |
]. |
|
1196 |
||
1197 |
subView modified ifTrue:[ |
|
1198 |
newState := ' (modified)' |
|
1199 |
]. |
|
1200 |
||
1201 |
here := currentDirectory pathName. |
|
1202 |
(OperatingSystem isReadable:here) ifTrue:[ |
|
1203 |
Processor removeTimedBlock:checkBlock. |
|
1204 |
||
1205 |
(currentDirectory timeOfLastChange > timeOfLastCheck) ifTrue:[ |
|
1206 |
nOld := fileListView numberOfSelections. |
|
1207 |
oldSelection := fileListView selectionValue. |
|
1208 |
self updateCurrentDirectory. |
|
1209 |
nOld ~~ 0 ifTrue:[ |
|
1210 |
nOld > 1 ifTrue:[ |
|
1211 |
oldSelection do:[:element | |
|
1212 |
fileListView addElementToSelection:element |
|
1213 |
] |
|
1214 |
] ifFalse:[ |
|
1215 |
fileListView selectElementWithoutScroll:oldSelection |
|
1216 |
] |
|
1217 |
]. |
|
1218 |
] ifFalse:[ |
|
1219 |
Processor addTimedBlock:checkBlock afterSeconds:checkDelta |
|
1220 |
]. |
|
1221 |
||
1222 |
currentFileName notNil ifTrue:[ |
|
1223 |
(currentDirectory exists:currentFileName) ifFalse:[ |
|
1224 |
newState := ' (removed)'. |
|
1225 |
] ifTrue:[ |
|
1226 |
(currentDirectory timeOfLastChange:currentFileName) > timeOfFileRead ifTrue:[ |
|
1227 |
newState := ' (outdated)'. |
|
1228 |
subView modified ifTrue:[ |
|
1229 |
newState := ' (modified & outdated)' |
|
1230 |
] |
|
1231 |
]. |
|
1232 |
]. |
|
1233 |
]. |
|
1234 |
||
1235 |
] ifFalse:[ |
|
1236 |
" |
|
1237 |
if the directory has been deleted, or is not readable ... |
|
1238 |
" |
|
1239 |
(OperatingSystem isValidPath:here) ifFalse:[ |
|
1240 |
msg := 'FileBrowser:\\directory %1 is gone ?!!?' |
|
1241 |
] ifTrue:[ |
|
1242 |
msg := 'FileBrowser:\\directory %1 is no longer readable ?!!?' |
|
1243 |
]. |
|
1244 |
self warn:(resources string:msg with:here) withCRs. |
|
1245 |
||
1246 |
fileListView contents:nil. |
|
1247 |
newLabel := myName , ': directory is gone !!'. |
|
1248 |
"/ Processor addTimedBlock:checkBlock afterSeconds:checkDelta |
|
1249 |
]. |
|
1250 |
||
1251 |
newState notNil ifTrue:[ |
|
1252 |
newLabel := myName. |
|
1253 |
currentFileName notNil ifTrue:[ |
|
1254 |
newLabel := newLabel , ': ' , currentFileName |
|
1255 |
]. |
|
1256 |
newLabel := newLabel , newState. |
|
1257 |
]. |
|
1258 |
newLabel notNil ifTrue:[ |
|
1259 |
self label:newLabel. |
|
1260 |
] |
|
1261 |
] |
|
1262 |
] |
|
1263 |
! |
|
1264 |
||
172 | 1265 |
defineTabulatorsForLongList |
1266 |
"define the tabs for the long list" |
|
1267 |
||
1268 |
tabSpec := TabulatorSpecification new. |
|
1269 |
tabSpec unit:#inch. |
|
1270 |
"/ tabSpec positions:#(0 2 2.3 4.3 5.3 6.0 6.5). |
|
1271 |
tabSpec widths: #(2 0.3 1.7 1 0.5 0.5 1"any"). |
|
1272 |
" name type mode owner group size type" |
|
1273 |
tabSpec align: #(#left #left #left #right #right #decimal #left). |
|
1274 |
tabSpec addDependent:self |
|
1275 |
! |
|
1276 |
||
1277 |
doChangeCurrentDirectoryTo:fileName updateHistory:updateHistory |
|
1278 |
"verify argument is name of a readable & executable directory |
|
1279 |
and if so, go there" |
|
1280 |
||
1281 |
|msg path idx| |
|
1282 |
||
1283 |
self label:myName; iconLabel:myName. |
|
1284 |
fileName notNil ifTrue:[ |
|
1285 |
(currentDirectory isDirectory:fileName) ifTrue:[ |
|
1286 |
(currentDirectory isReadable:fileName) ifTrue:[ |
|
1287 |
(currentDirectory isExecutable:fileName) ifTrue:[ |
|
1288 |
||
1289 |
path := currentDirectory pathName. |
|
1290 |
previousDirectory := path. |
|
1291 |
||
1292 |
" |
|
1293 |
remember where we are in the fileList |
|
1294 |
(in case we want to return) |
|
1295 |
" |
|
1296 |
idx := DirectoryHistory indexOf:path. |
|
1297 |
idx ~~ 0 ifTrue:[ |
|
1298 |
DirectoryHistoryWhere at:idx put:fileListView firstLineShown |
|
1299 |
]. |
|
1300 |
||
1301 |
self setCurrentDirectory:fileName. |
|
1302 |
||
1303 |
path := currentDirectory pathName. |
|
1304 |
||
1305 |
" |
|
1306 |
if we have already been there, look for the |
|
1307 |
position offset, and scroll the fileList |
|
1308 |
" |
|
1309 |
idx := DirectoryHistory indexOf:path. |
|
1310 |
idx ~~ 0 ifTrue:[ |
|
1311 |
|pos| |
|
1312 |
||
1313 |
pos := DirectoryHistoryWhere at:idx. |
|
1314 |
pos notNil ifTrue:[ |
|
1315 |
fileListView scrollToLine:pos |
|
1316 |
] |
|
1317 |
]. |
|
1318 |
||
1319 |
updateHistory ifTrue:[ |
|
1320 |
|pos| |
|
1321 |
||
1322 |
(DirectoryHistory includes:path) ifFalse:[ |
|
1323 |
DirectoryHistory size >= HistorySize ifTrue:[ |
|
1324 |
DirectoryHistory removeLast. |
|
1325 |
DirectoryHistoryWhere removeLast |
|
1326 |
] |
|
1327 |
] ifTrue:[ |
|
1328 |
"already been there before; move the entry to |
|
1329 |
the beginning, so it will fall out later." |
|
1330 |
||
1331 |
idx := DirectoryHistory indexOf:path. |
|
1332 |
DirectoryHistory removeIndex:idx. |
|
1333 |
pos := DirectoryHistoryWhere at:idx. |
|
1334 |
DirectoryHistoryWhere removeIndex:idx. |
|
1335 |
]. |
|
1336 |
DirectoryHistory addFirst:path. |
|
1337 |
DirectoryHistoryWhere addFirst:pos. |
|
1338 |
]. |
|
1339 |
||
1340 |
^ self |
|
1341 |
]. |
|
1342 |
msg := 'cannot change directory to ''%1'' !!' |
|
1343 |
] ifFalse:[ |
|
1344 |
msg := 'cannot read directory ''%1'' !!' |
|
1345 |
] |
|
1346 |
] ifFalse:[ |
|
1347 |
msg := '''%1'' is not a directory !!' |
|
1348 |
]. |
|
1349 |
self showAlert:(resources string:msg with:fileName) with:nil |
|
1350 |
] |
|
1351 |
! |
|
1352 |
||
1353 |
doChangeToHomeDirectory |
|
1354 |
"go to home directory" |
|
1355 |
||
1356 |
self doChangeCurrentDirectoryTo:(OperatingSystem getHomeDirectory) updateHistory:true |
|
1357 |
! |
|
1358 |
||
1359 |
doChangeToParentDirectory |
|
1360 |
"go to home directory" |
|
36 | 1361 |
|
172 | 1362 |
self doChangeCurrentDirectoryTo:'..' updateHistory:true |
1363 |
! |
|
1364 |
||
1365 |
doCreateDirectory:newName |
|
1366 |
(currentDirectory includes:newName) ifTrue:[ |
|
1367 |
self warn:'%1 already exists.' with:newName. |
|
1368 |
^ self |
|
1369 |
]. |
|
1370 |
||
1371 |
(currentDirectory createDirectory:newName) ifTrue:[ |
|
1372 |
self updateCurrentDirectory |
|
1373 |
] ifFalse:[ |
|
1374 |
self showAlert:(resources string:'cannot create directory ''%1'' !!' with:newName) |
|
1375 |
with:(OperatingSystem lastErrorString) |
|
1376 |
] |
|
1377 |
! |
|
1378 |
||
1379 |
doCreateFile:newName |
|
1380 |
|aStream| |
|
1381 |
||
1382 |
(currentDirectory includes:newName) ifTrue:[ |
|
1383 |
(self |
|
1384 |
ask:(resources string:'%1 already exists\\truncate ?' with:newName) |
|
1385 |
yesButton:'truncate' |
|
1386 |
noButton:'cancel' |
|
1387 |
) ifFalse:[^ self]. |
|
1388 |
]. |
|
1389 |
||
1390 |
aStream := FileStream newFileNamed:newName in:currentDirectory. |
|
1391 |
aStream notNil ifTrue:[ |
|
1392 |
aStream close. |
|
1393 |
self updateCurrentDirectory |
|
1394 |
] ifFalse:[ |
|
1395 |
self showAlert:(resources string:'cannot create file ''%1'' !!' with:newName) |
|
1396 |
with:(FileStream lastErrorString) |
|
1397 |
] |
|
1398 |
! |
|
1399 |
||
1400 |
doExecuteCommand:command replace:replace |
|
1401 |
"execute a unix command inserting the output of the command. |
|
1402 |
If replace is true, all text is replaced by the commands output; |
|
1403 |
otherwise, its inserted as selected text at the cursor position." |
|
1404 |
||
1405 |
|stream line lnr myProcess myPriority startLine startCol stopSignal |
|
1406 |
access| |
|
1407 |
||
1408 |
access := Semaphore forMutualExclusion. |
|
1409 |
stopSignal := Signal new. |
|
1410 |
||
1411 |
" |
|
1412 |
must take killButton out of my group |
|
1413 |
" |
|
1414 |
windowGroup removeView:killButton. |
|
1415 |
" |
|
1416 |
bring it to front, and turn hidden-mode off |
|
1417 |
" |
|
1418 |
killButton raise. |
|
331 | 1419 |
killButton beVisible. |
172 | 1420 |
" |
1421 |
it will make me raise stopSignal when pressed |
|
1422 |
" |
|
1423 |
killButton |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1424 |
action:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1425 |
stream notNil ifTrue:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1426 |
access critical:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1427 |
myProcess interruptWith:[stopSignal raise]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1428 |
] |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1429 |
] |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1430 |
]. |
172 | 1431 |
" |
1432 |
start it up under its own windowgroup |
|
1433 |
" |
|
1434 |
killButton openAutonomous. |
|
1435 |
||
1436 |
" |
|
1437 |
go fork a pipe and read it |
|
1438 |
" |
|
1439 |
self label:(myName , ': executing ' , (command copyTo:(20 min:command size)) , ' ...'). |
|
1440 |
[ |
|
1441 |
self withWaitCursorDo:[ |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1442 |
stopSignal catch:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1443 |
startLine := subView cursorLine. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1444 |
startCol := subView cursorCol. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1445 |
|
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1446 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1447 |
this can be a time consuming operation; therefore lower my priority |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1448 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1449 |
myProcess := Processor activeProcess. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1450 |
myPriority := myProcess priority. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1451 |
myProcess priority:(Processor userBackgroundPriority). |
172 | 1452 |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1453 |
stream := PipeStream readingFrom:('cd ' |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1454 |
, currentDirectory pathName |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1455 |
, '; ' |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1456 |
, command |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1457 |
, ' 2>&1' ). |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1458 |
stream notNil ifTrue:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1459 |
[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1460 |
|codeView lines| |
36 | 1461 |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1462 |
codeView := subView. |
172 | 1463 |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1464 |
replace ifTrue:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1465 |
codeView list:nil. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1466 |
lnr := 1. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1467 |
]. |
172 | 1468 |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1469 |
[stream atEnd] whileFalse:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1470 |
(stream readWaitWithTimeoutMs:50) ifFalse:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1471 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1472 |
data available |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1473 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1474 |
lines := OrderedCollection new:50. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1475 |
line := stream nextLine. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1476 |
line notNil ifTrue:[lines add:line]. |
172 | 1477 |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1478 |
[stream atEnd not |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1479 |
and:[stream canReadWithoutBlocking |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1480 |
and:[lines size < 50]]] whileTrue:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1481 |
line := stream nextLine. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1482 |
line notNil ifTrue:[lines add:line]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1483 |
]. |
172 | 1484 |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1485 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1486 |
need this critical section; otherwise, |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1487 |
we could get the signal while waiting for |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1488 |
an expose event ... |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1489 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1490 |
access critical:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1491 |
lines size > 0 ifTrue:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1492 |
replace ifTrue:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1493 |
lines do:[:line | |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1494 |
codeView at:lnr put:line withTabsExpanded. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1495 |
codeView cursorToBottom; cursorDown. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1496 |
lnr := lnr + 1. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1497 |
]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1498 |
] ifFalse:[ |
172 | 1499 |
codeView insertLines:lines before:codeView cursorLine. |
1500 |
codeView cursorDown:lines size. |
|
1501 |
"/ lines do:[:line | |
|
1502 |
"/ codeView insertLine:line withTabsExpanded before:codeView cursorLine. |
|
1503 |
"/ codeView cursorDown. |
|
1504 |
"/ ] |
|
1505 |
"/ codeView insertStringAtCursor:line. |
|
1506 |
"/ codeView insertCharAtCursor:(Character cr). |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1507 |
] |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1508 |
]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1509 |
]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1510 |
]. |
172 | 1511 |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1512 |
shown ifTrue:[windowGroup processExposeEvents]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1513 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1514 |
give others running at same prio a chance too |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1515 |
(especially other FileBrowsers doing the same) |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1516 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1517 |
Processor yield |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1518 |
]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1519 |
] valueNowOrOnUnwindDo:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1520 |
stream shutDown "close". stream := nil. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1521 |
]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1522 |
self updateCurrentDirectory |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1523 |
]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1524 |
replace ifTrue:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1525 |
subView modified:false. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1526 |
]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1527 |
] |
172 | 1528 |
] |
1529 |
] valueNowOrOnUnwindDo:[ |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1530 |
|wg| |
172 | 1531 |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1532 |
self label:myName; iconLabel:myName. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1533 |
myProcess notNil ifTrue:[myProcess priority:myPriority]. |
172 | 1534 |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1535 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1536 |
remove the killButton from its group |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1537 |
(otherwise, it will be destroyed when we shut down the group) |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1538 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1539 |
wg := killButton windowGroup. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1540 |
killButton windowGroup:nil. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1541 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1542 |
shut down the windowgroup |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1543 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1544 |
wg notNil ifTrue:[ |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1545 |
wg process terminate. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1546 |
]. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1547 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1548 |
hide the button, and make sure it will stay |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1549 |
hidden when we are realized again |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1550 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1551 |
killButton beInvisible. |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1552 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1553 |
clear its action (actually not needed, but |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1554 |
releases reference to thisContext earlier) |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1555 |
" |
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1556 |
killButton action:nil. |
36 | 1557 |
]. |
172 | 1558 |
|
1559 |
currentFileName isNil ifTrue:[ |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1560 |
subView modified:false. |
172 | 1561 |
]. |
1562 |
||
1563 |
subView size > 10000 ifTrue:[ |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1564 |
self warn:'text quite large now - please cut off some lines' |
172 | 1565 |
] |
1566 |
||
1567 |
"Modified: 21.9.1995 / 11:18:46 / claus" |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
1568 |
"Modified: 9.2.1996 / 00:26:07 / cg" |
172 | 1569 |
! |
1570 |
||
1571 |
doFileGet |
|
1572 |
"get selected file - show contents in subView" |
|
1573 |
||
1574 |
|fileName| |
|
1575 |
||
294 | 1576 |
self withReadCursorDo:[ |
333 | 1577 |
fileName := self getSelectedFileName. |
1578 |
fileName notNil ifTrue:[ |
|
1579 |
(currentDirectory isDirectory:fileName) ifTrue:[ |
|
1580 |
self doChangeCurrentDirectoryTo:fileName updateHistory:true. |
|
1581 |
self label:myName. |
|
1582 |
self iconLabel:myName |
|
1583 |
] ifFalse:[ |
|
1584 |
(currentDirectory exists:fileName) ifFalse:[ |
|
1585 |
self warn:(resources string:'oops, ''%1'' is gone' with:fileName). |
|
1586 |
^ self |
|
1587 |
]. |
|
1588 |
timeOfFileRead := currentDirectory timeOfLastChange:fileName. |
|
1589 |
self showFile:fileName insert:false. |
|
1590 |
currentFileName := fileName. |
|
172 | 1591 |
|
333 | 1592 |
subView acceptAction:[:theCode | |
1593 |
self withCursor:(Cursor write) do:[ |
|
1594 |
self writeFile:fileName text:theCode. |
|
1595 |
timeOfFileRead := currentDirectory timeOfLastChange:fileName. |
|
1596 |
self label:myName , ': ' , currentFileName |
|
1597 |
] |
|
1598 |
]. |
|
172 | 1599 |
|
333 | 1600 |
(currentDirectory isWritable:fileName) ifFalse:[ |
1601 |
self label:(myName , ': ' , fileName , ' (readonly)') |
|
1602 |
] ifTrue:[ |
|
1603 |
self label:(myName , ': ' , fileName) |
|
1604 |
]. |
|
1605 |
self iconLabel:fileName |
|
1606 |
] |
|
1607 |
] |
|
172 | 1608 |
] |
294 | 1609 |
|
310 | 1610 |
"Modified: 17.12.1995 / 15:42:16 / cg" |
172 | 1611 |
! |
1612 |
||
1613 |
doRemove |
|
1614 |
"remove the selected file(s) - no questions asked" |
|
1615 |
||
1616 |
|ok msg dir| |
|
1617 |
||
1618 |
lockUpdate := true. |
|
1619 |
[ |
|
1620 |
self selectedFilesDo:[:fileName | |
|
1621 |
ok := false. |
|
1622 |
(currentDirectory isDirectory:fileName) ifTrue:[ |
|
1623 |
dir := FileDirectory directoryNamed:fileName in:currentDirectory. |
|
1624 |
dir isEmpty ifFalse:[ |
|
1625 |
(self ask:(resources string:'directory ''%1'' is not empty\remove anyway ?' with:fileName) |
|
1626 |
yesButton:'remove') ifTrue:[ |
|
1627 |
ok := currentDirectory removeDirectory:fileName |
|
1628 |
] |
|
1629 |
] ifTrue:[ |
|
1630 |
ok := currentDirectory removeDirectory:fileName |
|
1631 |
]. |
|
1632 |
] ifFalse:[ |
|
1633 |
ok := currentDirectory remove:fileName. |
|
1634 |
]. |
|
1635 |
ok ifFalse:[ |
|
1636 |
"was not able to remove it" |
|
1637 |
msg := (resources string:'cannot remove ''%1'' !!' with:fileName). |
|
1638 |
self showAlert:msg with:(OperatingSystem lastErrorString) |
|
1639 |
] ifTrue:[ |
|
1640 |
" |
|
1641 |
self show:nil |
|
1642 |
" |
|
1643 |
] |
|
1644 |
]. |
|
1645 |
] valueNowOrOnUnwindDo:[ |
|
1646 |
lockUpdate := false. |
|
1647 |
fileListView deselect. |
|
1648 |
self updateCurrentDirectory. |
|
1649 |
] |
|
1650 |
! |
|
1651 |
||
1652 |
doRename:oldName to:newName |
|
1653 |
(oldName notNil and:[newName notNil]) ifTrue:[ |
|
1654 |
(oldName isBlank or:[newName isBlank]) ifFalse:[ |
|
1655 |
currentDirectory renameFile:oldName newName:newName. |
|
1656 |
self updateCurrentDirectory. |
|
1657 |
] |
|
1658 |
] |
|
36 | 1659 |
! |
1660 |
||
1661 |
getFileInfoString:longInfo |
|
1662 |
"get stat info on selected file - return a string which can be |
|
1663 |
shown in a box" |
|
1664 |
||
133 | 1665 |
|fileName f fullPath text info fileOutput type modeBits modeString s ts| |
36 | 1666 |
|
1667 |
fileName := self getSelectedFileName. |
|
1668 |
fileName isNil ifTrue:[^ nil]. |
|
1669 |
||
133 | 1670 |
f := currentDirectory pathName asFilename construct:fileName. |
1671 |
info := f info. |
|
1672 |
||
1673 |
"/ info := currentDirectory infoOf:fileName. |
|
36 | 1674 |
info isNil ifTrue:[ |
45 | 1675 |
self showAlert:(resources string:'cannot get info of ''%1'' !!' with:fileName) |
1676 |
with:(OperatingSystem lastErrorString). |
|
1677 |
^ nil |
|
36 | 1678 |
]. |
1679 |
||
59 | 1680 |
text := StringCollection new. |
133 | 1681 |
f isSymbolicLink ifTrue:[ |
1682 |
text add:(resources string:'symbolic link to: %1' with:(f linkInfo at:#path)) |
|
1683 |
]. |
|
1684 |
||
36 | 1685 |
type := info at:#type. |
1686 |
(longInfo and:[type == #regular]) ifTrue:[ |
|
45 | 1687 |
fullPath := currentDirectory pathName , '/' , fileName. |
49 | 1688 |
fileOutput := fullPath asFilename fileType. |
36 | 1689 |
]. |
1690 |
||
1691 |
s := (resources at:'type: '). |
|
1692 |
fileOutput isNil ifTrue:[ |
|
45 | 1693 |
s := s , type asString |
36 | 1694 |
] ifFalse:[ |
45 | 1695 |
s := s , 'regular (' , fileOutput , ')' |
36 | 1696 |
]. |
1697 |
text add:s. |
|
133 | 1698 |
text add:(resources string:'size: %1' with:(info at:#size) printString). |
36 | 1699 |
|
1700 |
modeBits := (info at:#mode). |
|
1701 |
modeString := self getModeString:modeBits. |
|
1702 |
longInfo ifTrue:[ |
|
133 | 1703 |
text add:(resources string:'access: %1 (%2)' |
1704 |
with:modeString |
|
1705 |
with:(modeBits printStringRadix:8)) |
|
36 | 1706 |
] ifFalse:[ |
133 | 1707 |
text add:(resources string:'access: %1' with:modeString) |
36 | 1708 |
]. |
133 | 1709 |
text add:(resources string:'owner: %1' |
1710 |
with:(OperatingSystem getUserNameFromID:(info at:#uid))). |
|
36 | 1711 |
longInfo ifTrue:[ |
133 | 1712 |
text add:(resources string:'group: %1' |
1713 |
with:(OperatingSystem getGroupNameFromID:(info at:#gid))). |
|
36 | 1714 |
|
133 | 1715 |
ts := info at:#accessed. |
1716 |
text add:(resources string:'last access: %1 %2' |
|
1717 |
with:(ts asTime printString) |
|
1718 |
with:(ts asDate printString)). |
|
1719 |
||
1720 |
ts := info at:#modified. |
|
1721 |
text add:(resources string:'last modification: %1 %2' |
|
1722 |
with:(ts asTime printString) |
|
1723 |
with:(ts asDate printString)). |
|
36 | 1724 |
]. |
1725 |
^ text asString |
|
133 | 1726 |
|
1727 |
"Modified: 8.9.1995 / 11:59:28 / claus" |
|
36 | 1728 |
! |
1729 |
||
172 | 1730 |
getInfoFile |
1731 |
"get filename of a description-file (.dir.info, README etc.); |
|
1732 |
This file is automatically shown when a directory is enterred. |
|
1733 |
You can add more names below if you like." |
|
1734 |
||
1735 |
#( '.dir.info' |
|
1736 |
'README' |
|
1737 |
'ReadMe' |
|
1738 |
'Readme' |
|
1739 |
'readme' |
|
1740 |
) do:[:f | |
|
1741 |
(currentDirectory isReadable:f) ifTrue:[ |
|
1742 |
(currentDirectory isDirectory:f) ifFalse:[^ f]. |
|
1743 |
] |
|
1744 |
]. |
|
1745 |
^ nil |
|
1746 |
! |
|
1747 |
||
1748 |
getModeString:modeBits |
|
1749 |
"convert file-mode bits into a more user-friendly string. |
|
1750 |
This is wrong here - should be moved into OperatingSystem." |
|
1751 |
||
1752 |
^ self getModeString:modeBits |
|
1753 |
with:#( 'owner:' $r $w $x |
|
1754 |
' group:' $r $w $x |
|
1755 |
' others:' $r $w $x ) |
|
1756 |
! |
|
1757 |
||
37 | 1758 |
getModeString:modeBits with:texts |
36 | 1759 |
"convert file-mode bits into a more user-friendly string. |
1760 |
This is wrong here - should be moved into OperatingSystem." |
|
1761 |
||
1762 |
|bits modeString| |
|
1763 |
||
1764 |
bits := modeBits bitAnd:8r777. |
|
1765 |
modeString := ''. |
|
1766 |
||
1767 |
#( nil 8r400 8r200 8r100 nil 8r040 8r020 8r010 nil 8r004 8r002 8r001 ) |
|
37 | 1768 |
with: texts do:[:bitMask :access | |
116 | 1769 |
|ch| |
1770 |
||
45 | 1771 |
bitMask isNil ifTrue:[ |
1772 |
modeString := modeString , (resources string:access) |
|
1773 |
] ifFalse:[ |
|
1774 |
(bits bitAnd:bitMask) == 0 ifTrue:[ |
|
116 | 1775 |
ch := $- |
45 | 1776 |
] ifFalse:[ |
116 | 1777 |
ch := access |
1778 |
]. |
|
1779 |
modeString := modeString copyWith:ch |
|
45 | 1780 |
] |
36 | 1781 |
]. |
1782 |
^ modeString |
|
1783 |
! |
|
1784 |
||
172 | 1785 |
getSelectedFileName |
1786 |
"returns the currently selected file; shows an error if |
|
1787 |
multiple files are selected" |
|
1788 |
||
1789 |
|sel| |
|
1790 |
||
1791 |
sel := fileListView selection. |
|
1792 |
(sel size > 1) ifTrue:[ |
|
1793 |
self onlyOneSelection |
|
1794 |
] ifFalse:[ |
|
1795 |
sel notNil ifTrue:[ |
|
1796 |
^ fileList at:sel first |
|
1797 |
] |
|
1798 |
]. |
|
1799 |
^ nil |
|
1800 |
! |
|
1801 |
||
1802 |
initialCommandFor:fileName into:aBox |
|
1803 |
"set a useful initial command for execute box. |
|
1804 |
||
1805 |
XXX should be changed to take stuff from a config file |
|
1806 |
XXX or from resources." |
|
1807 |
||
1808 |
((currentDirectory typeOf:fileName) == #regular) ifTrue:[ |
|
1809 |
||
1810 |
(currentDirectory isExecutable:fileName) ifTrue:[ |
|
1811 |
aBox initialText:(fileName , '<arguments>'). |
|
1812 |
^ self |
|
1813 |
]. |
|
1814 |
||
1815 |
"some heuristics - my personal preferences ... |
|
1816 |
(actually this should come from a configfile)" |
|
1817 |
||
1818 |
(fileName endsWith:'akefile') ifTrue:[ |
|
1819 |
aBox initialText:'make target' selectFrom:6 to:11. |
|
1820 |
^ self |
|
1821 |
]. |
|
1822 |
(fileName endsWith:'.tar.Z') ifTrue:[ |
|
1823 |
aBox initialText:'zcat ' , fileName , ' | tar tvf -'. |
|
1824 |
^ self |
|
1825 |
]. |
|
1826 |
(fileName endsWith:'.taz') ifTrue:[ |
|
1827 |
aBox initialText:'zcat ' , fileName , ' | tar tvf -'. |
|
1828 |
^ self |
|
1829 |
]. |
|
1830 |
(fileName endsWith:'.tar') ifTrue:[ |
|
1831 |
aBox initialText:'tar tvf ' , fileName selectFrom:1 to:7. |
|
1832 |
^ self |
|
1833 |
]. |
|
1834 |
(fileName endsWith:'.zoo') ifTrue:[ |
|
1835 |
aBox initialText:'zoo -list ' , fileName selectFrom:1 to:9. |
|
1836 |
^ self |
|
1837 |
]. |
|
1838 |
(fileName endsWith:'.zip') ifTrue:[ |
|
1839 |
aBox initialText:'unzip -l ' , fileName selectFrom:1 to:8. |
|
1840 |
^ self |
|
1841 |
]. |
|
1842 |
(fileName endsWith:'.Z') ifTrue:[ |
|
1843 |
aBox initialText:'uncompress ' , fileName selectFrom:1 to:10. |
|
1844 |
^ self |
|
1845 |
]. |
|
1846 |
(fileName endsWith:'tar.gz') ifTrue:[ |
|
1847 |
aBox initialText:('gunzip <' , fileName , ' | tar tvf -' ). |
|
1848 |
^ self |
|
1849 |
]. |
|
1850 |
(fileName endsWith:'.gz') ifTrue:[ |
|
1851 |
aBox initialText:('gunzip <' , fileName , ' >' , (fileName copyWithoutLast:3 "copyTo:(fileName size - 3)")). |
|
1852 |
^ self |
|
1853 |
]. |
|
1854 |
(fileName endsWith:'.html') ifTrue:[ |
|
1855 |
aBox initialText:'chimera ' , fileName . |
|
1856 |
^ self |
|
1857 |
]. |
|
1858 |
(fileName endsWith:'.uue') ifTrue:[ |
|
1859 |
aBox initialText:'uudecode ' , fileName selectFrom:1 to:8. |
|
1860 |
^ self |
|
1861 |
]. |
|
1862 |
(fileName endsWith:'.c') ifTrue:[ |
|
1863 |
aBox initialText:'cc -c ' , fileName selectFrom:1 to:5. |
|
1864 |
^ self |
|
1865 |
]. |
|
1866 |
(fileName endsWith:'.cc') ifTrue:[ |
|
1867 |
aBox initialText:'g++ -c ' , fileName selectFrom:1 to:6. |
|
1868 |
^ self |
|
1869 |
]. |
|
1870 |
(fileName endsWith:'.C') ifTrue:[ |
|
1871 |
aBox initialText:'g++ -c ' , fileName selectFrom:1 to:6. |
|
1872 |
^ self |
|
1873 |
]. |
|
1874 |
(fileName endsWith:'.xbm') ifTrue:[ |
|
1875 |
aBox initialText:'bitmap ' , fileName selectFrom:1 to:6. |
|
1876 |
^ self |
|
1877 |
]. |
|
1878 |
((fileName endsWith:'.ps') or:[fileName endsWith:'.PS']) ifTrue:[ |
|
1879 |
aBox initialText:'ghostview ' , fileName selectFrom:1 to:9. |
|
1880 |
^ self |
|
1881 |
]. |
|
1882 |
((fileName endsWith:'.1') |
|
1883 |
or:[fileName endsWith:'.man']) ifTrue:[ |
|
1884 |
aBox initialText:'nroff -man ' , fileName selectFrom:1 to:10. |
|
1885 |
^ self |
|
1886 |
]. |
|
1887 |
aBox initialText:'<cmd> ' , fileName selectFrom:1 to:5 |
|
1888 |
] |
|
1889 |
! |
|
1890 |
||
1891 |
onlyOneSelection |
|
1892 |
"show a warning, that only one file must be selected for |
|
1893 |
this operation" |
|
1894 |
||
1895 |
self warn:'exactly one file must be selected !!' |
|
1896 |
! |
|
1897 |
||
1898 |
readFile:fileName |
|
1899 |
"read in the file, answer its contents as StringCollection" |
|
1900 |
||
1901 |
^ self readFile:fileName lineDelimiter:Character cr |
|
1902 |
! |
|
1903 |
||
1904 |
readFile:fileName lineDelimiter:aCharacter |
|
1905 |
"read in the file, answer its contents as StringCollection. |
|
1906 |
The files lines are delimited by aCharacter." |
|
1907 |
||
1908 |
|stream text msg sz| |
|
1909 |
||
1910 |
stream := FileStream readonlyFileNamed:fileName in:currentDirectory. |
|
1911 |
stream isNil ifTrue:[ |
|
1912 |
msg := (resources string:'cannot read file ''%1'' !!' with:fileName). |
|
1913 |
self showAlert:msg with:(FileStream lastErrorString). |
|
1914 |
^ nil |
|
1915 |
]. |
|
1916 |
||
1917 |
" |
|
1918 |
for very big files, give ObjectMemory a hint, to preallocate more |
|
1919 |
" |
|
1920 |
(sz := stream size) > 1000000 ifTrue:[ |
|
1921 |
Processor activeProcess withLowerPriorityDo:[ |
|
1922 |
ObjectMemory announceSpaceNeed:(sz + (sz // 5)) "/ add 20% for tab expansion |
|
1923 |
]. |
|
1924 |
]. |
|
1925 |
||
1926 |
text := self readStream:stream lineDelimiter:aCharacter. |
|
1927 |
stream close. |
|
1928 |
^ text |
|
1929 |
! |
|
1930 |
||
1931 |
readStream:aStream |
|
1932 |
"read in from aStream, answer its contents as StringCollection" |
|
1933 |
||
1934 |
^ self readStream:aStream lineDelimiter:Character cr |
|
1935 |
! |
|
1936 |
||
1937 |
readStream:aStream lineDelimiter:aCharacter |
|
1938 |
"read from aStream, answer its contents as StringCollection. |
|
1939 |
The files lines are delimited by aCharacter." |
|
1940 |
||
1941 |
|text line| |
|
37 | 1942 |
|
172 | 1943 |
text := StringCollection new. |
1944 |
aCharacter == Character cr ifTrue:[ |
|
1945 |
[aStream atEnd] whileFalse:[ |
|
1946 |
line := aStream nextLine withTabsExpanded. |
|
1947 |
text add:line |
|
1948 |
]. |
|
1949 |
] ifFalse:[ |
|
1950 |
[aStream atEnd] whileFalse:[ |
|
1951 |
line := (aStream upTo:aCharacter) withTabsExpanded. |
|
1952 |
text add:line |
|
1953 |
]. |
|
1954 |
]. |
|
1955 |
^ text |
|
1956 |
||
1957 |
"Created: 10.9.1995 / 21:54:12 / claus" |
|
1958 |
! |
|
1959 |
||
1960 |
selectedFilesDo:aBlock |
|
1961 |
"evaluate aBlock on all selected files; |
|
1962 |
show a wait cursor while doing this" |
|
1963 |
||
1964 |
|sel| |
|
1965 |
||
1966 |
sel := fileListView selection. |
|
1967 |
sel notNil ifTrue:[ |
|
1968 |
self withWaitCursorDo:[ |
|
1969 |
sel do:[:aSelectionIndex | |
|
1970 |
aBlock value:(fileList at:aSelectionIndex ) |
|
1971 |
] |
|
1972 |
] |
|
1973 |
] |
|
1974 |
||
1975 |
! |
|
1976 |
||
1977 |
setCurrentDirectory:aPathName |
|
1978 |
"setup for another directory" |
|
1979 |
||
1980 |
|newDirectory| |
|
1981 |
||
1982 |
aPathName isEmpty ifTrue:[^ self]. |
|
1983 |
(currentDirectory isDirectory:aPathName) ifTrue:[ |
|
1984 |
newDirectory := FileDirectory directoryNamed:aPathName in:currentDirectory. |
|
1985 |
newDirectory notNil ifTrue:[ |
|
1986 |
self currentDirectory:newDirectory pathName. |
|
1987 |
currentFileName notNil ifTrue:[ |
|
1988 |
fileListView contents:nil. |
|
1989 |
currentFileName := nil. |
|
1990 |
] ifFalse:[ |
|
1991 |
fileListView selection:nil. |
|
1992 |
fileListView scrollToTop. |
|
1993 |
]. |
|
1994 |
self updateCurrentDirectory. |
|
1995 |
self showInfo. |
|
1996 |
] |
|
1997 |
] |
|
1998 |
||
1999 |
"Modified: 21.9.1995 / 11:22:45 / claus" |
|
2000 |
! |
|
2001 |
||
2002 |
show:something |
|
2003 |
"show something in subview and undef acceptAction" |
|
2004 |
||
2005 |
subView contents:something. |
|
2006 |
subView acceptAction:nil. |
|
2007 |
subView modified:false. |
|
2008 |
currentFileName := nil |
|
2009 |
! |
|
2010 |
||
2011 |
showAlert:aString with:anErrorString |
|
2012 |
"show an alertbox, displaying the last Unix-error" |
|
2013 |
||
2014 |
|msg| |
|
2015 |
||
2016 |
anErrorString isNil ifTrue:[ |
|
2017 |
msg := aString |
|
2018 |
] ifFalse:[ |
|
2019 |
msg := aString , '\\(' , anErrorString , ')' |
|
2020 |
]. |
|
2021 |
self warn:msg withCRs |
|
2022 |
! |
|
2023 |
||
2024 |
showFile:fileName |
|
2025 |
"show contents of fileName in subView" |
|
2026 |
||
2027 |
self showFile:fileName insert:false |
|
2028 |
! |
|
2029 |
||
2030 |
showFile:fileName insert:insert |
|
2031 |
"show/insert contents of fileName in subView" |
|
2032 |
||
2033 |
|buffer s n i ok convert text msg| |
|
2034 |
||
2035 |
((currentDirectory typeOf:fileName) == #regular) ifFalse:[ |
|
333 | 2036 |
"asked for a non-file - ignore it ..." |
2037 |
(currentDirectory exists:fileName) ifFalse:[ |
|
2038 |
msg := '''%1'' does not exist !!'. |
|
2039 |
] ifTrue:[ |
|
2040 |
msg := '''%1'' is not a regular file !!'. |
|
2041 |
]. |
|
2042 |
self warn:(resources string:msg with:fileName). |
|
2043 |
^ self |
|
172 | 2044 |
]. |
2045 |
" |
|
2046 |
check if file is a text file |
|
2047 |
" |
|
2048 |
s := FileStream readonlyFileNamed:fileName in:currentDirectory. |
|
2049 |
s isNil ifTrue:[ |
|
333 | 2050 |
self showAlert:(resources string:'cannot read file ''%1'' !!' with:fileName) |
2051 |
with:(FileStream lastErrorString). |
|
2052 |
^ nil |
|
172 | 2053 |
]. |
2054 |
||
2055 |
buffer := String new:300. |
|
2056 |
n := s nextBytes:300 into:buffer. |
|
2057 |
s close. |
|
2058 |
||
2059 |
ok := true. |
|
2060 |
1 to:n do:[:i | |
|
333 | 2061 |
(buffer at:i) isPrintable ifFalse:[ok := false]. |
172 | 2062 |
]. |
2063 |
ok ifFalse:[ |
|
333 | 2064 |
(self binaryFileAction:fileName) ifTrue:[^ self]. |
2065 |
(self confirm:(resources string:'''%1'' seems to be a binary file - show anyway ?' with:fileName)) |
|
2066 |
ifFalse:[^ self] |
|
172 | 2067 |
]. |
2068 |
||
2069 |
convert := false. |
|
2070 |
ok ifTrue:[ |
|
333 | 2071 |
" |
2072 |
check if line delimiter is a cr |
|
2073 |
" |
|
2074 |
i := buffer indexOf:Character cr. |
|
2075 |
i == 0 ifTrue:[ |
|
2076 |
" |
|
2077 |
no newline found - try cr |
|
2078 |
" |
|
2079 |
i := buffer indexOf:(Character value:13). |
|
2080 |
i ~~ 0 ifTrue:[ |
|
2081 |
convert := self confirm:(resources string:'''%1'' seems to have CR as line delimiter - convert to NL ?' with:fileName). |
|
2082 |
] |
|
2083 |
] |
|
172 | 2084 |
]. |
2085 |
||
2086 |
insert ifFalse:[ |
|
333 | 2087 |
"release old text first - we might need the memory in case of huge files |
2088 |
(helps if you have a 4Mb file in the view, and click on another biggy)" |
|
2089 |
subView contents:nil. |
|
172 | 2090 |
]. |
2091 |
||
2092 |
convert ifTrue:[ |
|
333 | 2093 |
text := self readFile:fileName lineDelimiter:(Character value:13) |
172 | 2094 |
] ifFalse:[ |
333 | 2095 |
text := self readFile:fileName. |
172 | 2096 |
]. |
2097 |
insert ifFalse:[ |
|
333 | 2098 |
self show:text |
172 | 2099 |
] ifTrue:[ |
333 | 2100 |
subView insertSelectedStringAtCursor:text asString |
172 | 2101 |
]. |
288 | 2102 |
|
2103 |
"Modified: 13.12.1995 / 16:25:35 / cg" |
|
172 | 2104 |
! |
2105 |
||
2106 |
showInfo |
|
2107 |
"show directory info when dir has changed" |
|
2108 |
||
2109 |
|info txt| |
|
2110 |
||
2111 |
info := self getInfoFile. |
|
2112 |
info notNil ifTrue:[ |
|
2113 |
txt := self readFile:info |
|
2114 |
]. |
|
2115 |
self show:txt. |
|
37 | 2116 |
! |
2117 |
||
36 | 2118 |
sizePrintString:size |
2119 |
"helper for update-directory to return a string with a files size. |
|
2120 |
This one gives the size in byte, Kb or Mb depending on size. |
|
2121 |
If you dont like this, just uncomment the first statement below." |
|
2122 |
||
93 | 2123 |
|unitString n| |
36 | 2124 |
|
2125 |
" |
|
2126 |
^ size printString. |
|
2127 |
" |
|
2128 |
unitString := ''. |
|
2129 |
size < (500 * 1024) ifTrue:[ |
|
93 | 2130 |
size < 1024 ifTrue:[ |
2131 |
n := size |
|
45 | 2132 |
] ifFalse:[ |
93 | 2133 |
n := (size * 10 // 1024 / 10.0). |
45 | 2134 |
unitString := ' Kb' |
2135 |
] |
|
36 | 2136 |
] ifFalse:[ |
93 | 2137 |
n := (size * 10 // 1024 // 1024 / 10.0). |
45 | 2138 |
unitString := ' Mb' |
36 | 2139 |
]. |
93 | 2140 |
^ (n printStringLeftPaddedTo:5) , unitString. |
36 | 2141 |
! |
2142 |
||
2143 |
updateCurrentDirectory |
|
2144 |
"update listView with directory contents" |
|
2145 |
||
142 | 2146 |
|files text len line info modeString |
53 | 2147 |
prevUid prevGid nameString groupString matchPattern| |
36 | 2148 |
|
49 | 2149 |
"the code below may look somewhat complex - |
2150 |
it reads the directory first for the names, |
|
2151 |
then (in a second sweep over the files) gets the |
|
2152 |
files type and info. This makes the Filebrowsers |
|
2153 |
list update seem faster, since the fileInfo (i.e. stat-calls) |
|
2154 |
may take long - especially on NFS-mounted directories. |
|
2155 |
The file reading is done at lower priority, to let user continue |
|
2156 |
his work in other views. However, to be fair to other fileBrowser, |
|
2157 |
which may also read directories at low prio, give up the processor |
|
2158 |
after every entry. This shares the cpu among all fileBrowsers, so |
|
2159 |
that browsers reading short directories will finish first. |
|
2160 |
ST/X users love this behavior ;-) |
|
2161 |
" |
|
2162 |
||
294 | 2163 |
self withReadCursorDo:[ |
333 | 2164 |
Processor removeTimedBlock:checkBlock. |
36 | 2165 |
|
333 | 2166 |
timeOfLastCheck := AbsoluteTime now. |
45 | 2167 |
|
333 | 2168 |
files := currentDirectory asOrderedCollection. |
36 | 2169 |
|
333 | 2170 |
matchPattern := filterField contents. |
2171 |
(matchPattern notNil and:[ |
|
2172 |
matchPattern isEmpty not and:[ |
|
2173 |
matchPattern ~= '*']]) ifTrue:[ |
|
2174 |
files := files select:[:aName | |
|
2175 |
((currentDirectory typeOf:aName) == #directory) |
|
2176 |
or:[matchPattern match:aName] |
|
2177 |
]. |
|
2178 |
]. |
|
2179 |
files sort. |
|
36 | 2180 |
|
333 | 2181 |
files size == 0 ifTrue:[ |
2182 |
self information:('directory ', currentDirectory pathName, ' vanished'). |
|
2183 |
^ self |
|
2184 |
]. |
|
2185 |
files := self withoutHiddenFiles:files. |
|
2186 |
fileList := files copy. |
|
45 | 2187 |
|
333 | 2188 |
" |
2189 |
this is a time consuming operation (especially, if reading an |
|
2190 |
NFS-mounted directory); therefore lower my priority while getting |
|
2191 |
the files info ... |
|
2192 |
" |
|
2193 |
Processor activeProcess withLowerPriorityDo:[ |
|
49 | 2194 |
|
333 | 2195 |
" |
2196 |
first show the names only - this is relatively fast |
|
2197 |
" |
|
2198 |
fileListView setList:files expandTabs:false. |
|
37 | 2199 |
|
333 | 2200 |
" |
2201 |
then walk over the files, adding more info |
|
2202 |
(since we have to stat each file, this may take a while longer |
|
2203 |
" |
|
2204 |
showLongList ifTrue:[ |
|
2205 |
tabSpec isNil ifTrue:[self defineTabulatorsForLongList]. |
|
37 | 2206 |
|
333 | 2207 |
text := OrderedCollection new. |
2208 |
files keysAndValuesDo:[:lineIndex :aFileName | |
|
2209 |
|entry col typ f p typeString| |
|
37 | 2210 |
|
333 | 2211 |
entry := MultiColListEntry new. |
2212 |
entry tabulatorSpecification:tabSpec. |
|
37 | 2213 |
|
333 | 2214 |
" |
2215 |
if multiple FileBrowsers are reading, let others |
|
2216 |
make some progress too |
|
2217 |
" |
|
2218 |
windowGroup notNil ifTrue:[windowGroup processExposeEvents]. |
|
2219 |
Processor yield. |
|
2220 |
" |
|
2221 |
could be destroyed in the meanwhile ... |
|
2222 |
" |
|
2223 |
realized ifFalse:[^ self]. |
|
36 | 2224 |
|
333 | 2225 |
len := aFileName size. |
2226 |
(len < 20) ifTrue:[ |
|
2227 |
line := aFileName , (String new:(22 - len)) |
|
2228 |
] ifFalse:[ |
|
2229 |
"can happen on BSD only" |
|
2230 |
line := (aFileName copyTo:20) , ' ' |
|
2231 |
]. |
|
2232 |
entry colAt:1 put:line. |
|
37 | 2233 |
|
333 | 2234 |
info := currentDirectory infoOf:aFileName. |
2235 |
info isNil ifTrue:[ |
|
2236 |
"not accessable - usually a symlink, |
|
2237 |
to a nonexisting/nonreadable file |
|
2238 |
" |
|
2239 |
entry colAt:2 put:'?'. |
|
2240 |
entry colAt:3 put:'(bad symbolic link ?)'. |
|
2241 |
] ifFalse:[ |
|
2242 |
typ := (info at:#type). |
|
2243 |
(typ == #regular) ifFalse:[ |
|
2244 |
entry colAt:2 put:(typ at:1) asString. |
|
2245 |
] ifTrue:[ |
|
2246 |
entry colAt:2 put:' '. |
|
2247 |
]. |
|
36 | 2248 |
|
333 | 2249 |
modeString := self getModeString:(info at:#mode) |
2250 |
with:#( '' $r $w $x |
|
2251 |
' ' $r $w $x |
|
2252 |
' ' $r $w $x ). |
|
2253 |
entry colAt:3 put:modeString. |
|
36 | 2254 |
|
333 | 2255 |
((info at:#uid) ~~ prevUid) ifTrue:[ |
2256 |
prevUid := (info at:#uid). |
|
2257 |
nameString := OperatingSystem getUserNameFromID:prevUid. |
|
2258 |
nameString := nameString , (String new:(10 - nameString size)) |
|
2259 |
]. |
|
2260 |
entry colAt:4 put:nameString withoutSpaces. |
|
2261 |
((info at:#gid) ~~ prevGid) ifTrue:[ |
|
2262 |
prevGid := (info at:#gid). |
|
2263 |
groupString := OperatingSystem getGroupNameFromID:prevGid. |
|
2264 |
groupString := groupString , (String new:(10 - groupString size)) |
|
2265 |
]. |
|
2266 |
entry colAt:5 put:groupString withoutSpaces. |
|
36 | 2267 |
|
333 | 2268 |
(typ == #regular) ifTrue:[ |
2269 |
entry colAt:6 put:(self sizePrintString:(info at:#size)). |
|
2270 |
]. |
|
49 | 2271 |
|
333 | 2272 |
f := currentDirectory asFilename:aFileName. |
2273 |
f isSymbolicLink ifTrue:[ |
|
2274 |
p := f linkInfo at:#path. |
|
2275 |
typeString := 'symbolic link to ' , p |
|
2276 |
] ifFalse:[ |
|
2277 |
(showVeryLongList not or:[typ == #directory]) ifTrue:[ |
|
2278 |
typeString := typ asString |
|
2279 |
] ifFalse:[ |
|
2280 |
typeString := f fileType. |
|
2281 |
]. |
|
2282 |
]. |
|
2283 |
entry colAt:7 put:typeString. |
|
2284 |
text add:entry |
|
2285 |
]. |
|
2286 |
fileListView at:lineIndex put:entry |
|
2287 |
]. |
|
2288 |
] ifFalse:[ |
|
2289 |
files keysAndValuesDo:[:lineIndex :aName | |
|
2290 |
|entry| |
|
49 | 2291 |
|
333 | 2292 |
" |
2293 |
if multiple FileBrowsers are reading, let others |
|
2294 |
make some progress too |
|
2295 |
" |
|
2296 |
windowGroup notNil ifTrue:[windowGroup processExposeEvents]. |
|
2297 |
Processor yield. |
|
2298 |
realized ifFalse:[^ self]. |
|
49 | 2299 |
|
333 | 2300 |
((currentDirectory isDirectory:aName) and:[ |
2301 |
(aName ~= '..') and:[aName ~= '.']]) ifTrue:[ |
|
2302 |
entry := aName , ' ...' |
|
2303 |
] ifFalse:[ |
|
2304 |
entry := aName |
|
2305 |
]. |
|
2306 |
fileListView at:lineIndex put:entry |
|
2307 |
]. |
|
2308 |
]. |
|
2309 |
]. |
|
36 | 2310 |
|
333 | 2311 |
" |
2312 |
install a new check after some time |
|
2313 |
" |
|
2314 |
Processor addTimedBlock:checkBlock afterSeconds:checkDelta |
|
36 | 2315 |
] |
142 | 2316 |
|
2317 |
"Modified: 21.9.1995 / 11:40:23 / claus" |
|
294 | 2318 |
"Modified: 14.12.1995 / 20:59:09 / cg" |
36 | 2319 |
! |
2320 |
||
172 | 2321 |
withoutHiddenFiles:aCollection |
2322 |
"remove hidden files (i.e. those that start with '.') from |
|
2323 |
the list in aCollection" |
|
36 | 2324 |
|
172 | 2325 |
|newCollection| |
52 | 2326 |
|
172 | 2327 |
newCollection := aCollection species new. |
2328 |
aCollection do:[:fname | |
|
2329 |
((fname startsWith:'.') and:[(fname = '..') not]) ifTrue:[ |
|
2330 |
showDotFiles ifTrue:[ |
|
2331 |
newCollection add:fname |
|
45 | 2332 |
] |
2333 |
] ifFalse:[ |
|
172 | 2334 |
newCollection add:fname |
45 | 2335 |
] |
36 | 2336 |
]. |
172 | 2337 |
^ newCollection |
36 | 2338 |
! |
2339 |
||
2340 |
writeFile:fileName text:someText |
|
2341 |
|stream msg startNr nLines string| |
|
2342 |
||
310 | 2343 |
stream := FileStream newFileNamed:fileName in:currentDirectory. |
2344 |
stream isNil ifTrue:[ |
|
333 | 2345 |
msg := (resources string:'cannot write file ''%1'' !!' with:fileName). |
2346 |
self showAlert:msg with:(FileStream lastErrorString) |
|
310 | 2347 |
] ifFalse:[ |
333 | 2348 |
someText isString ifTrue:[ |
2349 |
stream nextPutAll:someText. |
|
2350 |
] ifFalse:[ |
|
2351 |
" |
|
2352 |
on some systems, writing linewise is very slow (via NFS) |
|
2353 |
therefore we convert to a string and write it in chunks |
|
2354 |
to avoid creating huge strings, we do it in blocks of 1000 lines |
|
2355 |
" |
|
2356 |
startNr := 1. |
|
2357 |
nLines := someText size. |
|
2358 |
[startNr <= nLines] whileTrue:[ |
|
2359 |
string := someText asStringWithCRsFrom:startNr |
|
2360 |
to:((startNr + 1000) min:nLines) |
|
2361 |
compressTabs:compressTabs. |
|
2362 |
stream nextPutAll:string. |
|
2363 |
startNr := startNr + 1000 + 1. |
|
2364 |
]. |
|
36 | 2365 |
"/ someText do:[:line | |
2366 |
"/ line notNil ifTrue:[ |
|
2367 |
"/ stream nextPutAll:line. |
|
2368 |
"/ ]. |
|
2369 |
"/ stream cr. |
|
2370 |
"/ ] |
|
333 | 2371 |
]. |
2372 |
stream close. |
|
2373 |
subView modified:false |
|
36 | 2374 |
] |
310 | 2375 |
|
2376 |
"Modified: 17.12.1995 / 15:42:48 / cg" |
|
36 | 2377 |
! ! |
2378 |
||
172 | 2379 |
!FileBrowser methodsFor:'queries'! |
73 | 2380 |
|
172 | 2381 |
path |
2382 |
"return my currentDirectories pathName; |
|
2383 |
sent from the pathField label to aquire pathname when I changed directory" |
|
49 | 2384 |
|
172 | 2385 |
^ currentDirectory pathName |
49 | 2386 |
! ! |
2387 |
||
203 | 2388 |
!FileBrowser class methodsFor:'documentation'! |
2389 |
||
2390 |
version |
|
355
55f1bac567eb
command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
2391 |
^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.70 1996-02-08 23:26:59 cg Exp $'! ! |