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