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