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