author | Claus Gittinger <cg@exept.de> |
Thu, 23 Oct 1997 16:42:02 +0200 | |
changeset 1353 | 4d07c1f53b3d |
parent 1351 | aa03062fd25b |
child 1358 | bda6daa1de70 |
permissions | -rw-r--r-- |
36 | 1 |
" |
2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
1317 | 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 |
||
1353 | 13 |
'From Smalltalk/X, Version:3.2.1 on 23-oct-1997 at 2:47:05 pm' ! |
14 |
||
36 | 15 |
StandardSystemView subclass:#FileBrowser |
1010 | 16 |
instanceVariableNames:'labelView filterField fileListView subView currentDirectory |
17 |
fileList checkBlock checkDelta timeOfLastCheck showLongList |
|
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
18 |
showDotFiles myName killButton pauseToggle compressTabs |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
19 |
lockUpdate previousDirectory currentFileName timeOfFileRead |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
20 |
tabSpec commandView commandIndex fileEncoding tabRulerView |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
21 |
scrollView icons listUpdateProcess' |
1010 | 22 |
classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon |
1142
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
23 |
CommandHistory CommandHistorySize Icons DefaultCommandPerSuffix' |
1010 | 24 |
poolDictionaries:'' |
25 |
category:'Interface-Browsers' |
|
36 | 26 |
! |
27 |
||
763
94a8d188b52d
care for the nameSpace Query when loading binary classes
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
28 |
!FileBrowser class methodsFor:'documentation'! |
36 | 29 |
|
30 |
copyright |
|
31 |
" |
|
32 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
1317 | 33 |
All Rights Reserved |
36 | 34 |
|
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
44 |
documentation |
|
45 |
" |
|
46 |
this used to be a very simple demo application, |
|
47 |
but migrated into a quite nice tool, includes all kinds of |
|
48 |
warning and information boxes, background processes for directory- |
|
49 |
reading and internationalized strings. A good example for beginners, |
|
100 | 50 |
on how to do things .... (and maybe how not to do things ;-, since some |
51 |
stuff is historic and was implemented at times when better mechanisms |
|
52 |
were not available) |
|
52 | 53 |
|
36 | 54 |
See additional information in 'doc/misc/fbrowser.doc'. |
45 | 55 |
|
52 | 56 |
WARNING: files edited with FileBrowser will have leading spaces (multiple-8) |
1317 | 57 |
being replaced by tabs. If tabs are to be preserved at other |
58 |
positions (for example, sendmail-config files) they will be |
|
59 |
corrupt after being written. |
|
508 | 60 |
|
61 |
[instance variables]: |
|
62 |
||
1317 | 63 |
checkDelta <Integer> number of seconds of check interval |
64 |
(looks ever so often if shown directory |
|
65 |
has changed). You may make this number |
|
66 |
higher, if your network-times are |
|
67 |
incorrect and thus, the filebrowser |
|
68 |
checks too often. |
|
69 |
||
70 |
compressTabs <Boolean> if true, leading spaces will be |
|
71 |
replaced by tabs when saving text |
|
52 | 72 |
|
73 |
some of the defaults (long/short list etc.) can be set by the resource file; |
|
74 |
see FileBrowser>>initialize for more details.. |
|
508 | 75 |
|
76 |
[author:] |
|
1317 | 77 |
Claus Gittinger |
36 | 78 |
" |
203 | 79 |
! ! |
36 | 80 |
|
763
94a8d188b52d
care for the nameSpace Query when loading binary classes
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
81 |
!FileBrowser class methodsFor:'instance creation'! |
36 | 82 |
|
83 |
openOn:aDirectoryPath |
|
84 |
"start a new FileBrowser in a pathname" |
|
85 |
||
86 |
^ (self new currentDirectory:aDirectoryPath) open |
|
87 |
||
52 | 88 |
" |
89 |
FileBrowser openOn:'aDirectoryPath' |
|
90 |
FileBrowser openOn:'/etc' |
|
91 |
FileBrowser openOn:'..' |
|
92 |
FileBrowser openOn:'.' |
|
93 |
" |
|
93 | 94 |
! |
95 |
||
96 |
openOnFileNamed:aFilename |
|
97 |
"start a new FileBrowser on a file" |
|
98 |
||
99 |
|f browser| |
|
100 |
||
101 |
f := aFilename asFilename. |
|
1124 | 102 |
f isDirectory ifTrue:[ |
1317 | 103 |
^ self openOn:aFilename |
1124 | 104 |
]. |
93 | 105 |
browser := self new. |
106 |
browser currentDirectory:f directoryName. |
|
107 |
browser showFile:f baseName. |
|
108 |
^ browser open |
|
109 |
||
110 |
" |
|
111 |
FileBrowser openOnFileNamed:'Makefile' |
|
112 |
FileBrowser openOnFileNamed:'../Makefile' |
|
113 |
FileBrowser openOnFileNamed:'/tmp/foo' |
|
114 |
" |
|
1124 | 115 |
|
116 |
"Modified: 6.4.1997 / 14:57:12 / cg" |
|
36 | 117 |
! ! |
118 |
||
1145
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
119 |
!FileBrowser class methodsFor:'class initialization'! |
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
120 |
|
1178
f5f4d0c605db
lazy initialization of Icons
Claus Gittinger <cg@exept.de>
parents:
1173
diff
changeset
|
121 |
initializeIcons |
1239
e58e2cb6639a
allow specification of icons from resource file.
Claus Gittinger <cg@exept.de>
parents:
1235
diff
changeset
|
122 |
|resources| |
e58e2cb6639a
allow specification of icons from resource file.
Claus Gittinger <cg@exept.de>
parents:
1235
diff
changeset
|
123 |
|
e58e2cb6639a
allow specification of icons from resource file.
Claus Gittinger <cg@exept.de>
parents:
1235
diff
changeset
|
124 |
resources := self classResources. |
e58e2cb6639a
allow specification of icons from resource file.
Claus Gittinger <cg@exept.de>
parents:
1235
diff
changeset
|
125 |
|
1145
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
126 |
Icons := IdentityDictionary new. |
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
127 |
|
1147 | 128 |
#( |
1329 | 129 |
(#directory 'ICON_DIRECTORY' 'tiny_yellow_dir.xpm' ) |
130 |
(#directoryLocked 'ICON_DIRECTORY_LOCKED' 'tiny_yellow_dir_locked.xpm') |
|
131 |
(#directoryLink 'ICON_DIRECTORY_LINK' 'tiny_yellow_dir_link.xpm' ) |
|
132 |
(#file 'ICON_FILE' 'tiny_file_plain.xpm' ) |
|
133 |
(#fileLink 'ICON_FILE_LINK' 'tiny_file_link.xpm' ) |
|
134 |
(#fileLocked 'ICON_FILE_LOCKED' 'tiny_file_lock.xpm' ) |
|
135 |
(#imageFile 'ICON_IMAGE_FILE' 'tiny_file_pix.xpm' ) |
|
136 |
(#textFile 'ICON_TEXT_FILE' 'tiny_file_text.xpm' ) |
|
137 |
||
1239
e58e2cb6639a
allow specification of icons from resource file.
Claus Gittinger <cg@exept.de>
parents:
1235
diff
changeset
|
138 |
) do:[:entry | |
1329 | 139 |
|key resource defaultName nm| |
140 |
||
141 |
key := entry at:1. |
|
142 |
resource := entry at:2. |
|
143 |
defaultName := entry at:3. |
|
144 |
||
145 |
nm := resources at:resource default:nil. |
|
146 |
nm isNil ifTrue:[ |
|
147 |
nm := 'bitmaps/xpmBitmaps/document_images/' , defaultName |
|
148 |
]. |
|
149 |
Icons at:key put:(Image fromFile:nm). |
|
1147 | 150 |
] |
151 |
||
152 |
" |
|
1178
f5f4d0c605db
lazy initialization of Icons
Claus Gittinger <cg@exept.de>
parents:
1173
diff
changeset
|
153 |
self initializeIcons |
1147 | 154 |
" |
155 |
||
1253 | 156 |
"Modified: 28.7.1997 / 09:19:45 / cg" |
1145
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
157 |
! ! |
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
158 |
|
865
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
159 |
!FileBrowser class methodsFor:'command history'! |
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
160 |
|
1142
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
161 |
addToCommandHistory:aCommandString for:aFilename |
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
162 |
|cmd suffix| |
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
163 |
|
865
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
164 |
(aCommandString notNil and:[aCommandString notEmpty]) ifTrue:[ |
1317 | 165 |
CommandHistory notNil ifTrue:[ |
166 |
CommandHistory addFirst:aCommandString. |
|
167 |
CommandHistory size > CommandHistorySize ifTrue:[ |
|
168 |
CommandHistory removeLast |
|
169 |
] |
|
170 |
]. |
|
171 |
aFilename notNil ifTrue:[ |
|
172 |
cmd := aCommandString copyTo:(aCommandString indexOf:Character space ifAbsent:[aCommandString size + 1])-1. |
|
173 |
DefaultCommandPerSuffix isNil ifTrue:[ |
|
174 |
DefaultCommandPerSuffix := Dictionary new. |
|
175 |
]. |
|
176 |
suffix := aFilename asFilename suffix. |
|
177 |
suffix notNil ifTrue:[ |
|
178 |
DefaultCommandPerSuffix at:suffix put:cmd. |
|
179 |
] |
|
180 |
] |
|
865
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
181 |
] |
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
182 |
|
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
183 |
"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
|
184 |
! ! |
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
185 |
|
763
94a8d188b52d
care for the nameSpace Query when loading binary classes
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
186 |
!FileBrowser class methodsFor:'defaults'! |
73 | 187 |
|
188 |
defaultIcon |
|
1147 | 189 |
"return the file browsers default window icon" |
190 |
||
1287 | 191 |
<resource: #style (#FILEBROWSER_ICON #FILEBROWSER_ICON_FILE)> |
192 |
||
193 |
|nm i res| |
|
1147 | 194 |
|
195 |
(i := DefaultIcon) isNil ifTrue:[ |
|
1317 | 196 |
res := self classResources. |
197 |
i := res at:'FILEBROWSER_ICON' default:nil. |
|
198 |
i isNil ifTrue:[ |
|
199 |
nm := res at:'FILEBROWSER_ICON_FILE' default:'FBrowser.xbm'. |
|
200 |
i := Image fromFile:nm resolution:100. |
|
201 |
i isNil ifTrue:[ |
|
202 |
i := Image fromFile:('bitmaps/' , nm) resolution:100. |
|
203 |
i isNil ifTrue:[ |
|
204 |
i := StandardSystemView defaultIcon |
|
205 |
] |
|
206 |
] |
|
207 |
]. |
|
208 |
i notNil ifTrue:[ |
|
209 |
DefaultIcon := i := i on:Display |
|
210 |
] |
|
1145
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
211 |
]. |
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
212 |
^ i |
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
213 |
|
1147 | 214 |
"Modified: 19.3.1997 / 20:48:34 / ca" |
1287 | 215 |
"Modified: 15.8.1997 / 15:27:19 / cg" |
73 | 216 |
! ! |
217 |
||
1119 | 218 |
!FileBrowser methodsFor:'drag & drop'! |
172 | 219 |
|
1132
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
220 |
canDrop:aCollectionOfDropObjects |
1119 | 221 |
"I accept fileObjects only" |
222 |
||
1132
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
223 |
aCollectionOfDropObjects do:[:aDropObject | |
1317 | 224 |
aDropObject isFileObject ifFalse:[ |
225 |
aDropObject isTextObject ifFalse:[^ false]. |
|
226 |
] |
|
1122
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
227 |
]. |
1132
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
228 |
^ true |
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
229 |
|
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
230 |
"Modified: 11.4.1997 / 12:41:59 / cg" |
1118 | 231 |
! |
232 |
||
1132
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
233 |
drop:aCollectionOfDropObjects at:aPoint |
1122
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
234 |
"handle drops" |
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
235 |
|
1132
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
236 |
aCollectionOfDropObjects do:[:aDropObject | |
1317 | 237 |
self dropSingleObject:aDropObject at:aPoint |
1132
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
238 |
] |
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
239 |
|
bd2eda432e1d
drop arg is always a collection
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
240 |
"Modified: 11.4.1997 / 12:43:36 / cg" |
1122
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
241 |
! |
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
242 |
|
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
243 |
dropSingleObject:someObject at:aPoint |
1119 | 244 |
"handle drops; if its a directory, change to it. |
1124 | 245 |
If its a file, change to its directory and select the file. |
246 |
If its text, paste it into the codeView." |
|
1119 | 247 |
|
1122
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
248 |
|newDir newFile| |
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
249 |
|
1124 | 250 |
someObject isFileObject ifTrue:[ |
1317 | 251 |
someObject isDirectory ifTrue:[ |
252 |
newDir := someObject theObject pathName. |
|
253 |
] ifFalse:[ |
|
254 |
newDir := someObject theObject directoryName. |
|
255 |
newFile := someObject theObject baseName. |
|
256 |
]. |
|
257 |
||
258 |
newDir notNil ifTrue:[ |
|
259 |
newDir ~= currentDirectory pathName ifTrue:[ |
|
260 |
self changeDirectoryTo:newDir. |
|
261 |
] |
|
262 |
]. |
|
263 |
newFile notNil ifTrue:[ |
|
264 |
newFile ~= currentFileName ifTrue:[ |
|
265 |
fileListView selection:(fileList indexOf:newFile). |
|
266 |
self doFileGet:false. |
|
267 |
] |
|
268 |
]. |
|
269 |
^ self |
|
1122
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
270 |
]. |
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
271 |
|
1124 | 272 |
someObject isTextObject ifTrue:[ |
1317 | 273 |
subView paste:someObject theObject. |
274 |
^ self |
|
1118 | 275 |
]. |
1124 | 276 |
|
277 |
"Modified: 6.4.1997 / 14:46:44 / cg" |
|
1119 | 278 |
! ! |
279 |
||
280 |
!FileBrowser methodsFor:'events'! |
|
1118 | 281 |
|
1010 | 282 |
handlesKeyPress:key inView:view |
283 |
"this method is reached via delegation: are we prepared to handle |
|
284 |
a keyPress in some other view ?" |
|
285 |
||
286 |
<resource: #keyboard (#GotoLine #InspectIt #CmdI #Cmdu #DoIt #Delete #BackSpace #Accept)> |
|
287 |
||
288 |
view == fileListView ifTrue:[ |
|
1317 | 289 |
(key == #Delete |
290 |
or:[key == #BackSpace |
|
291 |
or:[key == #Accept |
|
292 |
or:[key == #CmdI |
|
293 |
or:[key == #Cmdu |
|
294 |
or:[key == #InspectIt |
|
295 |
or:[key == #GotoLine |
|
296 |
or:[key == #DoIt]]]]]]]) ifTrue:[^ true]. |
|
1010 | 297 |
]. |
298 |
^ false |
|
299 |
||
300 |
"Created: 28.1.1997 / 14:03:20 / stefan" |
|
301 |
"Modified: 28.1.1997 / 15:03:30 / stefan" |
|
1193
568b858d94ce
show current namespace in menus fileIn item
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
302 |
"Modified: 20.6.1997 / 16:35:01 / cg" |
1010 | 303 |
! |
304 |
||
305 |
keyPress:key x:x y:y view:view |
|
306 |
"this method is reached via delegation from the fileListView" |
|
307 |
||
308 |
<resource: #keyboard (#GotoLine #InspectIt #CmdI #Cmdu #DoIt #Delete #BackSpace #Accept)> |
|
309 |
||
310 |
(key == #Delete or:[key == #BackSpace]) ifTrue:[ |
|
1317 | 311 |
self fileRemove. |
312 |
^ self |
|
1010 | 313 |
]. |
314 |
(key == #Accept) ifTrue:[ |
|
1317 | 315 |
self fileFileIn. |
316 |
^ self |
|
1010 | 317 |
]. |
318 |
(key == #GotoLine) ifTrue:[ |
|
1317 | 319 |
self fileGet. |
320 |
^ self |
|
1010 | 321 |
]. |
322 |
(key == #DoIt) ifTrue:[ |
|
1317 | 323 |
self fileExecute. |
324 |
^ self |
|
1010 | 325 |
]. |
326 |
(key == #InspectIt) ifTrue:[ |
|
1317 | 327 |
self fileGetInfo. |
328 |
^ self |
|
1010 | 329 |
]. |
330 |
(key == #CmdI) ifTrue:[ |
|
1317 | 331 |
self fileGetLongInfo. |
332 |
^ self |
|
1010 | 333 |
]. |
334 |
(key == #Cmdu) ifTrue:[ |
|
1317 | 335 |
self updateCurrentDirectory. |
336 |
^ self |
|
1010 | 337 |
]. |
338 |
fileListView keyPress:key x:x y:y |
|
339 |
||
340 |
"Created: 28.1.1997 / 14:03:56 / stefan" |
|
341 |
"Modified: 28.1.1997 / 15:03:56 / stefan" |
|
1193
568b858d94ce
show current namespace in menus fileIn item
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
342 |
"Modified: 20.6.1997 / 16:35:08 / cg" |
1010 | 343 |
! |
344 |
||
172 | 345 |
mapped |
346 |
super mapped. |
|
347 |
" |
|
348 |
whant to know about changed history |
|
349 |
" |
|
350 |
self updateCurrentDirectory |
|
351 |
! |
|
352 |
||
353 |
visibilityChange:how |
|
354 |
|wasVisible| |
|
355 |
||
356 |
wasVisible := shown. |
|
357 |
super visibilityChange:how. |
|
358 |
(wasVisible not and:[shown]) ifTrue:[ |
|
1317 | 359 |
" |
360 |
start checking again |
|
361 |
" |
|
362 |
Processor removeTimedBlock:checkBlock. |
|
363 |
Processor addTimedBlock:checkBlock afterSeconds:checkDelta. |
|
172 | 364 |
] |
365 |
! ! |
|
366 |
||
367 |
!FileBrowser methodsFor:'fileList user interaction'! |
|
368 |
||
369 |
changeDisplayMode |
|
370 |
"toggle from long to short listing (and vice-versa)" |
|
371 |
||
372 |
showLongList := showLongList not. |
|
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
373 |
self showOrHideTabView. |
172 | 374 |
self updateCurrentDirectory |
747 | 375 |
|
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
376 |
"Modified: 19.4.1997 / 09:50:14 / cg" |
172 | 377 |
! |
378 |
||
379 |
changeDotFileVisibility |
|
380 |
"turn on/off visibility of files whose name starts with '.'" |
|
381 |
||
382 |
showDotFiles := showDotFiles not. |
|
383 |
self updateCurrentDirectory |
|
384 |
! |
|
385 |
||
1327 | 386 |
fileDoubleClick:lineNr |
387 |
"double click on a file - get its contents" |
|
388 |
||
389 |
self fileSelect:lineNr. |
|
390 |
self fileGet:true |
|
391 |
! |
|
392 |
||
386
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
393 |
fileEncoding |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
394 |
"open a dialog to allow change of the files character encoding. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
395 |
Files are converted to internal encoding when read, and converted back |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
396 |
to this encoding when saved. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
397 |
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
|
398 |
the internal encoding (which is iso8859). |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
399 |
Notice: currently, not too many encodings are supported by the system." |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
400 |
|
495
6d6a6b8feb2b
ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
401 |
|dialog list descr encodings encodingNames idx| |
386
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
402 |
|
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
403 |
list := SelectionInList new. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
404 |
|
495
6d6a6b8feb2b
ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
405 |
descr := CharacterArray supportedExternalEncodings. |
6d6a6b8feb2b
ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
406 |
encodings := descr at:2. |
6d6a6b8feb2b
ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
407 |
encodingNames := descr at:1. |
6d6a6b8feb2b
ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
408 |
|
6d6a6b8feb2b
ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents:
488
diff
changeset
|
409 |
list list:encodingNames. |
386
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
410 |
list selectionIndex:(encodings indexOf:fileEncoding ifAbsent:1). |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
411 |
|
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
412 |
dialog := Dialog new. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
413 |
|
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
414 |
dialog addTextLabel:(resources string:'ENCODING_MSG') withCRs. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
415 |
dialog addVerticalSpace. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
416 |
dialog addListBoxOn:list withNumberOfLines:5. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
417 |
|
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
418 |
dialog addAbortButton; addOkButton. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
419 |
dialog open. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
420 |
|
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
421 |
dialog accepted ifTrue:[ |
1317 | 422 |
idx := list selectionIndex. |
423 |
fileEncoding := encodings at:idx. |
|
424 |
subView externalEncoding:fileEncoding. |
|
425 |
||
426 |
self validateFontEncodingFor:fileEncoding ask:true. |
|
386
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
427 |
]. |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
428 |
|
1219 | 429 |
"Modified: 30.6.1997 / 14:41:12 / cg" |
386
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
430 |
! |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
431 |
|
172 | 432 |
fileExecute |
433 |
"if text was modified show a queryBox, |
|
434 |
otherwise pop up execute box immediately" |
|
435 |
||
1142
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
436 |
|action sel fileName| |
172 | 437 |
|
438 |
" |
|
439 |
this replaces everything by the commands output ... |
|
440 |
" |
|
865
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
441 |
action := [:command | |
1317 | 442 |
self class addToCommandHistory:command for:fileName. |
443 |
self doExecuteCommand:command replace:true |
|
444 |
]. |
|
172 | 445 |
|
446 |
(self askIfModified:'contents has not been saved.\\Modifications will be lost when command is executed.' |
|
1317 | 447 |
yesButton:'execute') ifFalse:[^ self]. |
172 | 448 |
|
449 |
"/ " |
|
450 |
"/ this inserts the commands output ... |
|
451 |
"/ " |
|
452 |
"/ action := [:command| self doExecuteCommand:command replace:false]. |
|
453 |
"/ |
|
1142
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
454 |
|
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
455 |
sel := fileListView selection. |
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
456 |
sel size == 1 ifTrue:[ |
1317 | 457 |
fileName := fileList at:sel first |
1142
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
458 |
]. |
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
459 |
self askForCommandFor:fileName thenDo:action |
865
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
460 |
|
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
461 |
"Modified: 14.11.1996 / 14:59:34 / cg" |
172 | 462 |
! |
463 |
||
464 |
fileFileIn |
|
465 |
"fileIn the selected file(s)" |
|
466 |
||
467 |
self fileFileInLazy:false |
|
468 |
! |
|
469 |
||
470 |
fileFileInLazy |
|
471 |
"fileIn the selected file(s). Do a quick load (no compilation)" |
|
472 |
||
473 |
self fileFileInLazy:true |
|
474 |
! |
|
475 |
||
476 |
fileFileInLazy:lazy |
|
477 |
"fileIn the selected file(s)" |
|
478 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
479 |
|aStream path oldPath wasLazy bos| |
172 | 480 |
|
481 |
self selectedFilesDo:[:fileName | |
|
1329 | 482 |
path := currentDirectory filenameFor:fileName. |
483 |
path type == #regular ifTrue:[ |
|
484 |
(ObjectFileLoader notNil |
|
485 |
and:[ObjectFileLoader hasValidBinaryExtension:fileName]) ifTrue:[ |
|
486 |
Object abortSignal catch:[ |
|
487 |
|p| |
|
488 |
||
489 |
"/ |
|
490 |
"/ look if already loaded ... then unload first |
|
491 |
"/ |
|
492 |
p := path pathName. |
|
493 |
(ObjectFileLoader loadedObjectFiles includes:p) ifTrue:[ |
|
494 |
(Dialog confirm:(resources |
|
495 |
string:'%1 is already loaded; load anyway ?' |
|
496 |
with:p)) ifFalse:[ |
|
497 |
^ self |
|
498 |
]. |
|
499 |
Transcript showCR:'unloading old ' , p , ' ...'. |
|
500 |
ObjectFileLoader unloadObjectFile:p. |
|
501 |
]. |
|
502 |
||
503 |
Transcript showCR:'loading ' , p , ' ...'. |
|
504 |
ObjectFileLoader loadObjectFile:p. |
|
505 |
Class addInfoRecord:('fileIn ' , fileName) |
|
506 |
] |
|
507 |
] ifFalse:[ |
|
508 |
(path hasSuffix:'cls') ifTrue:[ |
|
509 |
aStream := path readStream. |
|
510 |
aStream notNil ifTrue:[ |
|
511 |
bos := BinaryObjectStorage onOld:aStream. |
|
512 |
Class nameSpaceQuerySignal |
|
513 |
answer:Smalltalk |
|
514 |
do:[ |
|
515 |
bos next. |
|
516 |
]. |
|
517 |
bos close |
|
518 |
] |
|
519 |
] ifFalse:[ |
|
520 |
((path hasSuffix:'class') |
|
521 |
or:[(path hasSuffix:'cla')]) ifTrue:[ |
|
522 |
JavaClassReader notNil ifTrue:[ |
|
523 |
JavaClassReader loadFile:(path pathName) |
|
524 |
] |
|
525 |
] ifFalse:[ |
|
526 |
aStream := path readStream. |
|
527 |
aStream notNil ifTrue:[ |
|
528 |
[ |
|
529 |
Class withoutUpdatingChangesDo:[ |
|
530 |
oldPath := Smalltalk systemPath. |
|
531 |
Smalltalk systemPath:(oldPath copy addFirst:currentDirectory pathName; yourself). |
|
532 |
wasLazy := Compiler compileLazy:lazy. |
|
533 |
aStream fileIn. |
|
534 |
]. |
|
535 |
Class addInfoRecord:('fileIn ' , fileName) |
|
536 |
] valueNowOrOnUnwindDo:[ |
|
537 |
Compiler compileLazy:wasLazy. |
|
538 |
Smalltalk systemPath:oldPath. |
|
539 |
aStream close |
|
540 |
] |
|
541 |
] |
|
542 |
] |
|
543 |
] |
|
544 |
] |
|
545 |
] |
|
172 | 546 |
] |
547 |
||
1172 | 548 |
"Modified: 29.4.1997 / 21:56:24 / cg" |
1325
3c1609a6bfbf
Fix #fileFileInLazy: (error introduced in prev version).
Stefan Vogel <sv@exept.de>
parents:
1324
diff
changeset
|
549 |
"Modified: 19.9.1997 / 23:42:22 / stefan" |
172 | 550 |
! |
551 |
||
552 |
fileGet |
|
553 |
"get contents of selected file into subView. |
|
554 |
If text was modified show a queryBox, |
|
555 |
otherwise get it immediately" |
|
556 |
||
633
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
557 |
self fileGet:false |
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
558 |
|
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
559 |
"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
|
560 |
! |
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
561 |
|
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
562 |
fileGet:viaDoubleClick |
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
563 |
"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
|
564 |
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
|
565 |
otherwise get it immediately" |
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
566 |
|
172 | 567 |
|fileName msg label| |
568 |
||
1110
9ec4692e9cda
dont decode string, if the encoding is already iso8859
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
569 |
(subView modified not or:[subView contentsWasSaved]) ifTrue:[ |
1329 | 570 |
self doFileGet:viaDoubleClick. |
571 |
^ self |
|
1110
9ec4692e9cda
dont decode string, if the encoding is already iso8859
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
572 |
]. |
172 | 573 |
fileName := self getSelectedFileName. |
574 |
fileName notNil ifTrue:[ |
|
1329 | 575 |
(currentDirectory filenameFor:fileName) isDirectory ifTrue:[ |
576 |
msg := 'contents has not been saved.\\Modifications will be lost when directory is changed.'. |
|
577 |
label := 'change'. |
|
578 |
] ifFalse:[ |
|
579 |
msg := 'contents has not been saved.\\Modifications will be lost when new file is read.'. |
|
580 |
label := 'get'. |
|
581 |
]. |
|
582 |
(self ask:(resources at:msg) yesButton:label) ifTrue:[ |
|
583 |
subView modified:false. |
|
584 |
self doFileGet:viaDoubleClick |
|
585 |
] |
|
172 | 586 |
] |
633
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
587 |
|
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
588 |
"Created: 19.6.1996 / 09:38:35 / cg" |
1162 | 589 |
"Modified: 23.4.1997 / 13:04:11 / cg" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
590 |
"Modified: 18.9.1997 / 16:27:34 / stefan" |
172 | 591 |
! |
592 |
||
593 |
fileGetInfo |
|
594 |
"show short file (stat)-info" |
|
595 |
||
596 |
self fileGetInfo:false |
|
597 |
! |
|
598 |
||
599 |
fileGetInfo:longInfo |
|
600 |
"get info on selected file - show it in a box" |
|
601 |
||
602 |
|string| |
|
603 |
||
604 |
string := self getFileInfoString:longInfo. |
|
605 |
string notNil ifTrue:[ |
|
1317 | 606 |
self information:string |
172 | 607 |
] |
608 |
! |
|
609 |
||
610 |
fileGetLongInfo |
|
611 |
"show long stat (file)-info" |
|
612 |
||
613 |
self fileGetInfo:true |
|
614 |
! |
|
615 |
||
616 |
fileInsert |
|
1162 | 617 |
"insert contents of file at the cursor position" |
172 | 618 |
|
619 |
|fileName| |
|
620 |
||
621 |
fileName := self getSelectedFileName. |
|
622 |
fileName notNil ifTrue:[ |
|
1317 | 623 |
self showFile:fileName insert:true encoding:fileEncoding |
172 | 624 |
] |
386
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
625 |
|
1162 | 626 |
"Modified: 23.4.1997 / 13:06:06 / cg" |
172 | 627 |
! |
628 |
||
629 |
fileListMenu |
|
630 |
"return the menu to show in the fileList" |
|
631 |
||
1235
13610578a5d2
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
632 |
<resource: #programMenu> |
1040 | 633 |
|
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
634 |
|labels shorties selectors m sel ns subLabels subSelectors| |
172 | 635 |
|
636 |
labels := #( |
|
1317 | 637 |
'spawn' |
638 |
'-' |
|
639 |
'get contents' |
|
640 |
'insert contents' |
|
641 |
'show info' |
|
642 |
'show full info' |
|
643 |
). |
|
1193
568b858d94ce
show current namespace in menus fileIn item
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
644 |
|
568b858d94ce
show current namespace in menus fileIn item
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
645 |
((ns := Project current defaultNameSpace) notNil |
568b858d94ce
show current namespace in menus fileIn item
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
646 |
and:[ns ~~ Smalltalk]) ifTrue:[ |
1317 | 647 |
labels := labels copyWith:'fileIn (into ''' , Project current defaultNameSpace name , ''')' |
1193
568b858d94ce
show current namespace in menus fileIn item
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
648 |
] ifFalse:[ |
1317 | 649 |
labels := labels copyWith:'fileIn' |
1193
568b858d94ce
show current namespace in menus fileIn item
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
650 |
]. |
568b858d94ce
show current namespace in menus fileIn item
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
651 |
|
568b858d94ce
show current namespace in menus fileIn item
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
652 |
labels := labels , #( |
1317 | 653 |
'-' |
654 |
'update' |
|
655 |
'-' |
|
656 |
'execute unix command ...' |
|
657 |
'st/x tools' |
|
658 |
'-' |
|
659 |
'remove' |
|
660 |
'rename ...' |
|
661 |
'-' |
|
662 |
'display long list' |
|
663 |
'show all files' |
|
664 |
'encoding ...' |
|
665 |
'-' |
|
666 |
'create directory ...' |
|
667 |
'create file ...' |
|
668 |
). |
|
172 | 669 |
|
670 |
selectors := #( |
|
1317 | 671 |
fileSpawn |
672 |
nil |
|
673 |
fileGet |
|
674 |
fileInsert |
|
675 |
fileGetInfo |
|
676 |
fileGetLongInfo |
|
677 |
fileFileIn |
|
678 |
nil |
|
679 |
updateCurrentDirectory |
|
680 |
nil |
|
681 |
fileExecute |
|
682 |
stxTools |
|
683 |
nil |
|
684 |
fileRemove |
|
685 |
fileRename |
|
686 |
nil |
|
687 |
changeDisplayMode |
|
688 |
changeDotFileVisibility |
|
689 |
fileEncoding |
|
690 |
nil |
|
691 |
newDirectory |
|
692 |
newFile |
|
693 |
). |
|
172 | 694 |
|
1010 | 695 |
shorties := #( |
1317 | 696 |
nil |
697 |
nil |
|
698 |
GotoLine |
|
699 |
nil |
|
700 |
InspectIt |
|
701 |
CmdI |
|
702 |
Cmdf |
|
703 |
nil |
|
704 |
nil |
|
705 |
Cmdu |
|
706 |
nil |
|
707 |
DoIt |
|
708 |
nil |
|
709 |
Delete |
|
710 |
nil |
|
711 |
nil |
|
712 |
nil |
|
713 |
nil |
|
714 |
nil |
|
715 |
nil |
|
716 |
nil |
|
717 |
nil |
|
718 |
). |
|
1010 | 719 |
|
172 | 720 |
m := PopUpMenu |
1317 | 721 |
labels:(resources array:labels) |
722 |
selectors:selectors |
|
723 |
accelerators:shorties |
|
724 |
receiver:self. |
|
172 | 725 |
|
726 |
showDotFiles ifTrue:[ |
|
1317 | 727 |
m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files') |
172 | 728 |
]. |
729 |
showLongList ifTrue:[ |
|
1317 | 730 |
m labelAt:#changeDisplayMode put:(resources string:'display short list') |
172 | 731 |
]. |
732 |
||
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
733 |
subLabels := #( |
1317 | 734 |
'Changes browser' |
735 |
'Editor' |
|
736 |
'HTML reader' |
|
737 |
'Image inspect' |
|
738 |
'show file differences' |
|
739 |
). |
|
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
740 |
|
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
741 |
subSelectors := #( |
1317 | 742 |
openChangesBrowser |
743 |
openEditor |
|
744 |
openHTMLReader |
|
745 |
openImageInspector |
|
746 |
openDiffView |
|
747 |
). |
|
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
748 |
|
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
749 |
JavaInterpreter notNil ifTrue:[ |
1317 | 750 |
subLabels := subLabels , #('Java Applet Viewer'). |
751 |
subSelectors := subSelectors , #(openAppletViewer). |
|
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
752 |
]. |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
753 |
|
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
754 |
m subMenuAt:#stxTools |
1317 | 755 |
put:(PopUpMenu |
756 |
labels:(resources array:subLabels) |
|
757 |
selectors:subSelectors |
|
758 |
receiver:self). |
|
172 | 759 |
|
760 |
((sel := fileListView selection) isNil or:[sel isEmpty]) ifTrue:[ |
|
1317 | 761 |
m disableAll:#(fileGet fileInsert |
762 |
fileGetInfo fileGetLongInfo |
|
763 |
fileFileIn fileFileInLazy |
|
764 |
fileRemove fileRename). |
|
765 |
(m subMenuAt:#stxTools) |
|
766 |
disableAll:#(openChangesBrowser openEditor openHTMLReader openImageInspector) |
|
865
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
767 |
] ifFalse:[ |
1317 | 768 |
fileListView selection size > 1 ifTrue:[ |
769 |
m disableAll:#( fileGet fileInsert fileGetInfo fileGetLongInfo fileRename ) |
|
770 |
] |
|
172 | 771 |
]. |
772 |
||
773 |
^m |
|
252 | 774 |
|
1010 | 775 |
"Modified: 28.1.1997 / 15:04:42 / stefan" |
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
776 |
"Modified: 15.8.1997 / 04:33:26 / cg" |
172 | 777 |
! |
778 |
||
779 |
filePrint |
|
1162 | 780 |
"send a files contents to the printer (not in the menu)" |
781 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
782 |
|fileName path inStream printStream line| |
172 | 783 |
|
294 | 784 |
self withWaitCursorDo:[ |
1329 | 785 |
fileName := self getSelectedFileName. |
786 |
fileName notNil ifTrue:[ |
|
787 |
path := currentDirectory filenameFor:fileName. |
|
788 |
(path type == #regular) ifTrue:[ |
|
789 |
inStream := path readStream. |
|
790 |
inStream isNil ifFalse:[ |
|
791 |
printStream := PrinterStream new. |
|
792 |
printStream notNil ifTrue:[ |
|
793 |
[inStream atEnd] whileFalse:[ |
|
794 |
line := inStream nextLine. |
|
795 |
printStream nextPutLine:line. |
|
796 |
]. |
|
797 |
printStream close |
|
798 |
]. |
|
799 |
inStream close |
|
800 |
] |
|
801 |
] |
|
802 |
]. |
|
803 |
0 "compiler hint" |
|
172 | 804 |
] |
294 | 805 |
|
1162 | 806 |
"Modified: 23.4.1997 / 13:05:40 / cg" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
807 |
"Modified: 18.9.1997 / 16:29:17 / stefan" |
172 | 808 |
! |
809 |
||
810 |
fileRemove |
|
811 |
"remove the selected file(s). |
|
812 |
Query if user really wants to remove the file. |
|
813 |
- should be enhanced, to look for a ~/.trash directory |
|
814 |
and move files there if it exists (without asking in this case)." |
|
815 |
||
816 |
|sel q| |
|
817 |
||
818 |
sel := fileListView selection. |
|
819 |
sel notNil ifTrue:[ |
|
1317 | 820 |
sel size > 1 ifTrue:[ |
821 |
q := resources string:'remove selected files ?' |
|
822 |
] ifFalse:[ |
|
823 |
q := resources string:'remove ''%1'' ?' with:(fileList at:sel first) |
|
824 |
]. |
|
825 |
(self ask:q yesButton:'remove') ifTrue:[self doRemove] |
|
172 | 826 |
] |
827 |
! |
|
828 |
||
829 |
fileRename |
|
830 |
"rename the selected file(s)" |
|
831 |
||
832 |
|queryBox| |
|
833 |
||
834 |
queryBox := FilenameEnterBox new. |
|
835 |
queryBox okText:(resources at:'rename'). |
|
836 |
self selectedFilesDo:[:oldName | |
|
1317 | 837 |
queryBox title:(resources string:'rename ''%1'' to:' with:oldName). |
838 |
queryBox initialText:oldName. |
|
839 |
queryBox action:[:newName | self doRename:oldName to:newName]. |
|
840 |
queryBox showAtPointer |
|
172 | 841 |
] |
842 |
! |
|
843 |
||
844 |
fileSelect:lineNr |
|
845 |
"selected a file - do nothing here" |
|
1162 | 846 |
|
172 | 847 |
^ self |
1162 | 848 |
|
849 |
"Modified: 23.4.1997 / 13:04:55 / cg" |
|
172 | 850 |
! |
851 |
||
852 |
fileSpawn |
|
853 |
"start another FileBrowser on the selected directory or |
|
854 |
on the same directory if none is selected." |
|
855 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
856 |
|any path| |
172 | 857 |
|
858 |
any := false. |
|
859 |
self selectedFilesDo:[:fileName | |
|
1329 | 860 |
path := currentDirectory filenameFor:fileName. |
861 |
path isDirectory ifTrue:[ |
|
862 |
self class openOn:(path pathName). |
|
863 |
any := true |
|
864 |
] |
|
172 | 865 |
]. |
866 |
any ifFalse:[ |
|
1329 | 867 |
self class openOn:currentDirectory pathName |
172 | 868 |
] |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
869 |
|
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
870 |
"Modified: 18.9.1997 / 16:32:39 / stefan" |
172 | 871 |
! |
872 |
||
873 |
newDirectory |
|
874 |
"ask for and create a new directory" |
|
875 |
||
876 |
|queryBox| |
|
877 |
||
878 |
queryBox := FilenameEnterBox |
|
1317 | 879 |
title:(resources at:'create new directory:') withCRs |
880 |
okText:(resources at:'create') |
|
881 |
action:[:newName | self doCreateDirectory:newName]. |
|
172 | 882 |
queryBox showAtPointer |
1162 | 883 |
|
884 |
"Modified: 23.4.1997 / 13:04:27 / cg" |
|
172 | 885 |
! |
886 |
||
887 |
newFile |
|
888 |
"ask for and create a new file" |
|
889 |
||
890 |
|sel queryBox| |
|
891 |
||
892 |
queryBox := FilenameEnterBox |
|
1317 | 893 |
title:(resources at:'create new file:') withCRs |
894 |
okText:(resources at:'create') |
|
895 |
action:[:newName | self doCreateFile:newName]. |
|
172 | 896 |
sel := subView selection. |
897 |
sel notNil ifTrue:[ |
|
1317 | 898 |
queryBox initialText:(sel asString) |
172 | 899 |
]. |
900 |
queryBox showAtPointer |
|
381 | 901 |
|
1162 | 902 |
"Modified: 23.4.1997 / 13:04:38 / cg" |
172 | 903 |
! |
904 |
||
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
905 |
openAppletViewer |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
906 |
|numItems| |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
907 |
|
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
908 |
(numItems := fileListView selection size) > 2 ifTrue:[ |
1329 | 909 |
(self |
910 |
confirm:(resources string:'open for each of the %1 items ?' |
|
911 |
with:numItems)) ifFalse:[^ self]. |
|
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
912 |
]. |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
913 |
|
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
914 |
JavaInterpreter releaseAllJavaResources. |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
915 |
Java markAllClassesUninitialized. |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
916 |
Java initAllStaticFields. |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
917 |
Java initAllClasses. |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
918 |
|
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
919 |
self selectedFilesDo:[:fileName | |
1329 | 920 |
|p path| |
921 |
||
922 |
path := currentDirectory filenameFor:fileName. |
|
923 |
path isDirectory ifFalse:[ |
|
924 |
p := Java |
|
925 |
javaProcessForMainOf:(Java classForName:'sun.applet.AppletViewer') |
|
926 |
argumentString:path pathName. |
|
927 |
p resume. |
|
928 |
] |
|
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
929 |
]. |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
930 |
|
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
931 |
"Modified: 15.8.1997 / 05:03:02 / cg" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
932 |
"Modified: 18.9.1997 / 17:00:59 / stefan" |
1286
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
933 |
! |
2a464093d865
added 'open applet viewer' to ST/X tools menu
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
934 |
|
172 | 935 |
openChangesBrowser |
936 |
"open a change browser on the selected file(s)" |
|
937 |
||
938 |
self openTool:ChangesBrowser |
|
939 |
! |
|
940 |
||
252 | 941 |
openDiffView |
942 |
"open a diff-view" |
|
943 |
||
488
26f8da377672
allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
944 |
|box name1 name2 text1 text2 d err nm here l1| |
252 | 945 |
|
961 | 946 |
name1 := ValueHolder newString. |
252 | 947 |
name2 := self getSelectedFileName asValue. |
948 |
here := currentDirectory pathName. |
|
949 |
||
950 |
box := DialogBox new. |
|
951 |
box addTextLabel:'show difference between:'. |
|
952 |
box addFilenameInputFieldOn:name1 in:here tabable:true. |
|
953 |
box addTextLabel:'and:'. |
|
954 |
box addFilenameInputFieldOn:name2 in:here tabable:true. |
|
955 |
||
956 |
box addAbortButton; addOkButton. |
|
957 |
||
958 |
box showAtPointer. |
|
959 |
||
960 |
box accepted ifTrue:[ |
|
1329 | 961 |
name1 := name1 value. |
962 |
name1 isEmpty ifTrue:[ |
|
963 |
text1 := subView contents. |
|
964 |
name1 := nil. |
|
965 |
l1 := 'browser contents' |
|
966 |
] ifFalse:[ |
|
967 |
name1 := currentDirectory filenameFor:name1. |
|
968 |
name1 isReadable ifFalse:[ |
|
969 |
nm := name1. |
|
970 |
name1 exists ifFalse:[ |
|
971 |
err := '%1 does not exist'. |
|
972 |
] ifTrue:[ |
|
973 |
err := '%1 is not readable' |
|
974 |
]. |
|
975 |
]. |
|
976 |
l1 := name1 pathName |
|
977 |
]. |
|
978 |
||
979 |
name2 := currentDirectory filenameFor:name2 value. |
|
980 |
err isNil ifTrue:[ |
|
981 |
name2 isReadable ifFalse:[ |
|
982 |
nm := name2. |
|
983 |
name2 exists ifFalse:[ |
|
984 |
err := '%1 does not exist'. |
|
985 |
] ifTrue:[ |
|
986 |
err := '%1 is not readable' |
|
987 |
]. |
|
988 |
]. |
|
989 |
]. |
|
990 |
err notNil ifTrue:[ |
|
991 |
self warn:(resources string:err with:nm pathName). |
|
992 |
^ self |
|
993 |
]. |
|
994 |
||
995 |
self withWaitCursorDo:[ |
|
996 |
name1 notNil ifTrue:[ |
|
997 |
text1 := name1 contents. |
|
998 |
]. |
|
999 |
text2 := name2 contents. |
|
1000 |
d := DiffTextView |
|
1001 |
openOn:text1 label:l1 |
|
1002 |
and:text2 label:name2 pathName. |
|
1003 |
d label:'file differences'. |
|
1004 |
] |
|
252 | 1005 |
]. |
1006 |
||
1007 |
"Created: 7.12.1995 / 20:33:58 / cg" |
|
961 | 1008 |
"Modified: 16.1.1997 / 00:51:22 / cg" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1009 |
"Modified: 18.9.1997 / 17:31:46 / stefan" |
267 | 1010 |
! |
1011 |
||
1012 |
openEditor |
|
1013 |
self openTool:EditTextView |
|
1014 |
! |
|
1015 |
||
1016 |
openHTMLReader |
|
556 | 1017 |
self openTool:HTMLDocumentView |
1018 |
||
1019 |
"Modified: 20.5.1996 / 20:30:58 / cg" |
|
267 | 1020 |
! |
1021 |
||
1022 |
openImageInspector |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1023 |
|img path| |
267 | 1024 |
|
1025 |
self selectedFilesDo:[:fileName | |
|
1329 | 1026 |
path := currentDirectory filenameFor:fileName. |
1027 |
path isDirectory ifFalse:[ |
|
1028 |
img := Image fromFile:(path pathName). |
|
1029 |
img notNil ifTrue:[ |
|
1030 |
img inspect |
|
1031 |
] ifFalse:[ |
|
1032 |
self warn:'unknown format: ' , fileName |
|
1033 |
] |
|
1034 |
] |
|
267 | 1035 |
]. |
1036 |
||
1037 |
"Modified: 17.9.1995 / 17:41:24 / claus" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1038 |
"Modified: 18.9.1997 / 17:05:04 / stefan" |
267 | 1039 |
! |
1040 |
||
1041 |
openTool:aToolClass |
|
1042 |
"open a tool on the selected file(s)" |
|
1043 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1044 |
|numItems path| |
865
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
1045 |
|
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
1046 |
(numItems := fileListView selection size) > 2 ifTrue:[ |
1329 | 1047 |
(self |
1048 |
confirm:(resources string:'open for each of the %1 items ?' |
|
1049 |
with:numItems)) ifFalse:[^ self]. |
|
865
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
1050 |
]. |
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
1051 |
|
267 | 1052 |
self selectedFilesDo:[:fileName | |
1329 | 1053 |
path := currentDirectory filenameFor:fileName. |
1054 |
path isDirectory ifFalse:[ |
|
1055 |
aToolClass openOn:(path pathName). |
|
1056 |
] |
|
267 | 1057 |
]. |
865
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
1058 |
|
48395e8ecca9
remember executeCommand actions in history as well.
Claus Gittinger <cg@exept.de>
parents:
851
diff
changeset
|
1059 |
"Modified: 14.11.1996 / 16:01:32 / cg" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1060 |
"Modified: 18.9.1997 / 17:06:18 / stefan" |
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1061 |
! |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1062 |
|
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1063 |
showOrHideTabView |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1064 |
"depending on the showLongList setting, show or hde the tabSpec view" |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1065 |
|
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1066 |
showLongList ifTrue:[ |
1317 | 1067 |
false "self is3D" ifTrue:[ |
1068 |
scrollView topInset:(tabRulerView superView height). |
|
1069 |
tabRulerView superView leftInset:(fileListView originRelativeTo:scrollView) x. |
|
1070 |
] ifFalse:[ |
|
1071 |
scrollView topInset:(tabRulerView height). |
|
1072 |
tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x. |
|
1073 |
]. |
|
1074 |
tabRulerView hiddenTabs:#(1). |
|
1075 |
tabRulerView fixedTabs:#(1). |
|
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1076 |
] ifFalse:[ |
1317 | 1077 |
scrollView topInset:0 |
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1078 |
]. |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1079 |
tabSpec := nil. |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1080 |
|
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1081 |
"Created: 19.4.1997 / 09:50:02 / cg" |
172 | 1082 |
! ! |
1083 |
||
1084 |
!FileBrowser methodsFor:'help '! |
|
1085 |
||
1086 |
helpTextFor:aComponent |
|
1087 |
|s| |
|
1088 |
||
1089 |
aComponent == subView ifTrue:[ |
|
1317 | 1090 |
s := 'HELP_SUBVIEW' |
172 | 1091 |
]. |
1092 |
aComponent == fileListView ifTrue:[ |
|
1317 | 1093 |
s := 'HELP_FILELIST' |
172 | 1094 |
]. |
1095 |
aComponent == filterField ifTrue:[ |
|
1317 | 1096 |
s := 'HELP_FILTER' |
172 | 1097 |
]. |
1098 |
aComponent == labelView ifTrue:[ |
|
1317 | 1099 |
s := 'HELP_PATHFIELD' |
172 | 1100 |
]. |
1101 |
aComponent == commandView ifTrue:[ |
|
1317 | 1102 |
s := 'HELP_COMMANDVIEW' |
172 | 1103 |
]. |
1104 |
s notNil ifTrue:[ |
|
1317 | 1105 |
^ resources string:s |
172 | 1106 |
]. |
1107 |
^ nil |
|
1108 |
! ! |
|
1109 |
||
36 | 1110 |
!FileBrowser methodsFor:'initialization'! |
1111 |
||
172 | 1112 |
currentDirectory:aDirectoryPath |
1113 |
"set the directory to be browsed" |
|
1114 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1115 |
currentDirectory := aDirectoryPath asFilename. |
172 | 1116 |
self changed:#path. |
1327 | 1117 |
|
172 | 1118 |
" |
1119 |
tell my subview (whatever that is) to start its file-dialog |
|
1120 |
(i.e. save-as etc.) in that directory |
|
1121 |
" |
|
1122 |
(subView respondsTo:#directoryForFileDialog:) ifTrue:[ |
|
1329 | 1123 |
subView directoryForFileDialog:currentDirectory |
172 | 1124 |
] |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1125 |
|
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1126 |
"Modified: 16.9.1997 / 14:56:17 / stefan" |
1327 | 1127 |
"Modified: 21.9.1997 / 11:28:49 / cg" |
172 | 1128 |
! |
1129 |
||
1130 |
focusSequence |
|
1131 |
"return the sequence in which ALT-CursorRight steps focus" |
|
1132 |
||
1133 |
|fs| |
|
1134 |
||
1135 |
fs := Array |
|
1317 | 1136 |
with:filterField |
1137 |
with:fileListView |
|
1138 |
with:subView. |
|
172 | 1139 |
|
1140 |
commandView notNil ifTrue:[ |
|
1317 | 1141 |
fs := fs copyWith:commandView |
172 | 1142 |
]. |
1143 |
^fs |
|
1144 |
! |
|
1145 |
||
1146 |
initEvents |
|
1147 |
super initEvents. |
|
1148 |
self enableEvent:#visibilityChange. |
|
1149 |
! |
|
1150 |
||
36 | 1151 |
initialize |
1102 | 1152 |
|frame spacing halfSpacing v topFrame labelFrame filterModel |
1329 | 1153 |
buttonPanel img| |
36 | 1154 |
|
1155 |
super initialize. |
|
1156 |
||
819
b78a26650047
initialize fileEncoding to #iso8859
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1157 |
fileEncoding := #iso8859. "/ native ST/X encoding |
386
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
1158 |
|
52 | 1159 |
"if true, will replace leading spaces by tabs on |
1160 |
file write. If false, they will be written as spaces |
|
1161 |
" |
|
1162 |
compressTabs := resources at:'COMPRESS_TABS' default:true. |
|
1163 |
||
1164 |
" |
|
1165 |
showing long or short by default |
|
1166 |
" |
|
1311 | 1167 |
showLongList := resources at:'LONG_LIST' default:false. |
52 | 1168 |
|
1169 |
" |
|
1170 |
show hidden files or not ? |
|
1171 |
" |
|
1172 |
showDotFiles := resources at:'SHOW_DOT_FILES' default:false. |
|
1173 |
||
1174 |
||
45 | 1175 |
lockUpdate := false. |
1176 |
||
132 | 1177 |
CommandHistory isNil ifTrue:[ |
1341 | 1178 |
CommandHistory := OrderedCollection new. |
1179 |
CommandHistorySize := 50 |
|
132 | 1180 |
]. |
36 | 1181 |
DirectoryHistory isNil ifTrue:[ |
1341 | 1182 |
DirectoryHistory := OrderedCollection new. |
1183 |
DirectoryHistoryWhere := OrderedCollection new. |
|
1184 |
HistorySize := 15. |
|
36 | 1185 |
]. |
132 | 1186 |
commandIndex := 0. |
36 | 1187 |
|
1188 |
myName := (resources string:self class name). |
|
1189 |
self label:myName. |
|
45 | 1190 |
|
93 | 1191 |
labelFrame := View |
1341 | 1192 |
origin:(0.0 @ 0.0) |
1193 |
corner:(1.0 @ (font height * 2)) |
|
1194 |
in:self. |
|
52 | 1195 |
|
105 | 1196 |
styleSheet name = #st80 ifTrue:[ |
1341 | 1197 |
labelFrame level:1 |
45 | 1198 |
]. |
36 | 1199 |
|
1200 |
spacing := ViewSpacing. |
|
1201 |
halfSpacing := spacing // 2. |
|
1202 |
||
1100
d9382b49c62d
Use #pushEvent: for timer handling.
Stefan Vogel <sv@exept.de>
parents:
1091
diff
changeset
|
1203 |
" |
d9382b49c62d
Use #pushEvent: for timer handling.
Stefan Vogel <sv@exept.de>
parents:
1091
diff
changeset
|
1204 |
checkBlock is executed by the Processor every checkDelta seconds. |
d9382b49c62d
Use #pushEvent: for timer handling.
Stefan Vogel <sv@exept.de>
parents:
1091
diff
changeset
|
1205 |
We use #pushEvent: to perform the directory update |
d9382b49c62d
Use #pushEvent: for timer handling.
Stefan Vogel <sv@exept.de>
parents:
1091
diff
changeset
|
1206 |
in our windowgroups process. |
d9382b49c62d
Use #pushEvent: for timer handling.
Stefan Vogel <sv@exept.de>
parents:
1091
diff
changeset
|
1207 |
" |
d9382b49c62d
Use #pushEvent: for timer handling.
Stefan Vogel <sv@exept.de>
parents:
1091
diff
changeset
|
1208 |
checkBlock := [self pushEvent:#checkIfDirectoryHasChanged]. |
45 | 1209 |
checkDelta := resources at:'CHECK_DELTA' default:10. |
36 | 1210 |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1211 |
currentDirectory := Filename currentDirectory. |
36 | 1212 |
|
344
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
1213 |
filterModel := '*' asValue. |
45 | 1214 |
filterField := EditField in:labelFrame. |
1071 | 1215 |
filterField |
1341 | 1216 |
origin:[((width // 4 * 3) + halfSpacing) @ halfSpacing] |
1217 |
corner:(1.0 @ (filterField heightIncludingBorder + halfSpacing + halfSpacing) ). |
|
1071 | 1218 |
filterField rightInset:halfSpacing. |
344
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
1219 |
filterField model:filterModel. |
45 | 1220 |
|
36 | 1221 |
self initializeFilterPattern. |
344
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
1222 |
filterModel onChangeSend:#filterPatternChanged to:self. |
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
1223 |
"/ filterField leaveAction:[:key | fileListView scrollToTop. self updateCurrentDirectory]. |
36 | 1224 |
|
1327 | 1225 |
"/ labelView := Label in:labelFrame. |
1226 |
"/ labelView origin:(halfSpacing @ halfSpacing) |
|
1227 |
"/ extent:[((width // 4 * 3) - spacing - borderWidth) |
|
1228 |
"/ @ |
|
1229 |
"/ (filterField heightIncludingBorder) |
|
1230 |
"/ "(font height + font descent)" |
|
1231 |
"/ ]. |
|
1232 |
"/ labelView adjust:#right. |
|
1233 |
"/ labelView borderWidth:0. |
|
1234 |
"/ labelView model:self; menu:#labelMenu; aspect:#path; labelMessage:#path. |
|
1235 |
"/ labelFrame model:self; menu:#labelMenu. |
|
1236 |
||
1237 |
labelView := FilenameEditField in:labelFrame. |
|
1238 |
labelView |
|
1341 | 1239 |
origin:(halfSpacing @ halfSpacing) |
1240 |
extent:[((width // 4 * 3) - spacing - borderWidth) |
|
1241 |
@ |
|
1242 |
(filterField heightIncludingBorder) |
|
1243 |
"(font height + font descent)" |
|
1244 |
]. |
|
1327 | 1245 |
labelView menu:#labelMenu; aspect:#path; changeMessage:#pathChanged:. |
1246 |
labelView model:self. |
|
1247 |
labelView backgroundColor:(labelFrame viewBackground). |
|
73 | 1248 |
labelFrame model:self; menu:#labelMenu. |
1329 | 1249 |
labelView cursorType:#solidCaret; cursorTypeNoFocus:#none. |
1250 |
labelView level:0. |
|
1251 |
labelView borderWidth:0. |
|
1252 |
||
1253 |
killButton := Button label:(resources string:'kill') in:self. |
|
1254 |
"/ killButton origin:(halfSpacing @ halfSpacing) |
|
1255 |
"/ extent:(killButton width @ filterField height). |
|
1256 |
killButton origin:(halfSpacing @ 1.0). |
|
1257 |
killButton topInset:(killButton height negated). |
|
1258 |
killButton beInvisible. |
|
1259 |
||
1260 |
pauseToggle := Toggle label:(resources string:'pause') in:self. |
|
1261 |
"/ pauseToggle origin:((killButton corner x + 50) @ halfSpacing) |
|
1262 |
"/ extent:(pauseToggle width @ filterField height). |
|
1263 |
pauseToggle origin:((killButton corner x + ViewSpacing + 20) @ 1.0). |
|
1264 |
pauseToggle topInset:(pauseToggle height negated). |
|
1265 |
pauseToggle beInvisible. |
|
36 | 1266 |
|
132 | 1267 |
self initializeCommandViewIn:self. |
1268 |
||
1269 |
"/ frame := VariableVerticalPanel |
|
1270 |
"/ origin:[frame borderWidth negated |
|
1271 |
"/ @ |
|
1272 |
"/ labelFrame height |
|
1273 |
"/ "/ (labelView height + labelView origin y + spacing) |
|
1274 |
"/ ] |
|
1275 |
"/ corner:(1.0 @ 1.0) |
|
1276 |
"/ in:self. |
|
1277 |
||
1278 |
frame := VariableVerticalPanel origin:0.0@0.0 corner:1.0@1.0 in:self. |
|
1279 |
frame topInset:labelFrame height. |
|
1280 |
commandView notNil ifTrue:[ |
|
1341 | 1281 |
frame bottomInset:(commandView height + spacing + spacing) |
132 | 1282 |
]. |
36 | 1283 |
|
1102 | 1284 |
topFrame := View in:frame. |
36 | 1285 |
topFrame origin:(0.0 @ 0.0) corner:(1.0 @ 0.3). |
1286 |
||
1104 | 1287 |
false "self is3D" ifTrue:[ |
1341 | 1288 |
v := View in:topFrame. |
1289 |
v level:-1. |
|
1290 |
tabRulerView := TabSpecRuler in:v. |
|
1291 |
tabRulerView level:1. |
|
1292 |
v origin:(0.0@0.0) corner:(1.0@10). |
|
1293 |
tabRulerView origin:(0.0@0.0) corner:(1.0@1.0). |
|
1104 | 1294 |
] ifFalse:[ |
1341 | 1295 |
tabRulerView := TabSpecRuler in:topFrame. |
1296 |
tabRulerView origin:(0.0@0.0) corner:(1.0@10). |
|
1104 | 1297 |
]. |
1102 | 1298 |
tabRulerView borderWidth:0. |
1299 |
tabRulerView synchronousOperation:true. |
|
1300 |
||
1301 |
scrollView := ScrollableView in:topFrame. |
|
1302 |
scrollView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
1303 |
||
1304 |
fileListView := SelectionInListView new. |
|
1305 |
scrollView scrolledView:fileListView. |
|
36 | 1306 |
fileListView action:[:lineNr | self fileSelect:lineNr]. |
1326 | 1307 |
fileListView doubleClickAction:[:lineNr | self fileDoubleClick:lineNr]. |
36 | 1308 |
fileListView multipleSelectOk:true. |
1010 | 1309 |
fileListView delegate:self. |
98 | 1310 |
fileListView menuHolder:self; menuPerformer:self; menuMessage:#fileListMenu. |
1122
970fc7e88639
support drag out of my list.
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
1311 |
fileListView allowDrag:true. |
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1312 |
fileListView dragObjectConverter:[:obj | |
1341 | 1313 |
|dir nm path idx| |
1314 |
||
1315 |
nm := obj theObject asString. |
|
1316 |
idx := fileListView list indexOf:nm. |
|
1317 |
idx == 0 ifTrue:[ |
|
1318 |
"/ cannot happen ... |
|
1319 |
nil |
|
1320 |
] ifFalse:[ |
|
1321 |
nm := fileList at:idx. |
|
1322 |
dir := currentDirectory pathName asFilename. |
|
1323 |
path := dir constructString:nm. |
|
1324 |
DropObject newFile:path. |
|
1325 |
] |
|
1326 |
]. |
|
1158
ea2cd788ef59
delay tabView origin setting
Claus Gittinger <cg@exept.de>
parents:
1157
diff
changeset
|
1327 |
|
ea2cd788ef59
delay tabView origin setting
Claus Gittinger <cg@exept.de>
parents:
1157
diff
changeset
|
1328 |
"/ sigh - must be delayed - origin is not yet fixe |
ea2cd788ef59
delay tabView origin setting
Claus Gittinger <cg@exept.de>
parents:
1157
diff
changeset
|
1329 |
"/ tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x. |
ea2cd788ef59
delay tabView origin setting
Claus Gittinger <cg@exept.de>
parents:
1157
diff
changeset
|
1330 |
"/ self showOrHideTabView. |
1102 | 1331 |
|
36 | 1332 |
v := self initializeSubViewIn:frame. |
132 | 1333 |
|
36 | 1334 |
v origin:(0.0 @ 0.3) corner:(1.0 @ 1.0). |
1335 |
subView := v scrolledView. |
|
1336 |
(subView respondsTo:#directoryForFileDialog:) ifTrue:[ |
|
1341 | 1337 |
subView directoryForFileDialog:currentDirectory |
36 | 1338 |
]. |
1339 |
||
1329 | 1340 |
"/ buttonPanel := HorizontalPanelView in:self. |
1341 |
"/ buttonPanel horizontalLayout:#leftSpace. |
|
1342 |
"/ buttonPanel verticalSpace:0. |
|
1343 |
"/ "/ buttonPanel verticalLayout:#top. |
|
1344 |
"/ buttonPanel borderWidth:0. |
|
1345 |
"/ |
|
1346 |
"/ buttonPanel |
|
1347 |
"/ origin:(0.5 @ halfSpacing) |
|
1348 |
"/ extent:[((width // 4) - spacing - borderWidth) |
|
1349 |
"/ @ |
|
1350 |
"/ (buttonPanel preferredExtent y max:(labelView height)) |
|
1351 |
"/ ]. |
|
1352 |
"/ "/ buttonPanel level:-1. |
|
1353 |
"/ |
|
1354 |
"/ upButton := Button in:buttonPanel. |
|
1355 |
"/ img := Image fromFile:'bitmaps/xpmBitmaps/document_images/tiny_yellow_dir_up.xpm'. |
|
1356 |
"/ upButton label:(img ? 'up'). |
|
1357 |
"/ upButton action:[self changeToParentDirectory]. |
|
1328 | 1358 |
|
36 | 1359 |
ObjectMemory addDependent:self. |
132 | 1360 |
|
1361 |
"Modified: 6.9.1995 / 20:26:06 / claus" |
|
1329 | 1362 |
"Modified: 16.9.1997 / 14:52:46 / stefan" |
1341 | 1363 |
"Modified: 8.10.1997 / 17:07:27 / cg" |
36 | 1364 |
! |
1365 |
||
132 | 1366 |
initializeCommandViewIn:frame |
1367 |
"set up the command view - can be redefined in subclasses as empty, |
|
1368 |
if no commandView is wanted" |
|
1369 |
||
1370 |
||
1371 |
commandView := EditField origin:0.0@1.0 corner:1.0@1.0 in:frame. |
|
1303 | 1372 |
commandView allInset:ViewSpacing//2. |
132 | 1373 |
commandView topInset:(commandView preferredExtent y negated - ViewSpacing). |
1374 |
||
133 | 1375 |
"/ commandView contents:'** no commands which require input here **'. |
132 | 1376 |
|
142 | 1377 |
commandView entryCompletionBlock:[:contents | |
1329 | 1378 |
|newString| |
1379 |
||
1380 |
newString := Filename |
|
1381 |
filenameCompletionFor:contents |
|
1382 |
directory:currentDirectory |
|
1383 |
directoriesOnly:false |
|
1384 |
filesOnly:false |
|
1385 |
ifMultiple:[:dir | commandView flash.]. |
|
1386 |
commandView contents:newString. |
|
1387 |
commandView cursorToEndOfLine. |
|
132 | 1388 |
]. |
1389 |
commandView leaveAction:[:key | |
|
1329 | 1390 |
|cmd nCmd empty| |
1391 |
||
1392 |
(key == #CursorDown |
|
1393 |
or:[key == #CursorUp]) ifTrue:[ |
|
1394 |
nCmd := CommandHistory size. |
|
1395 |
nCmd == 0 ifTrue:[ |
|
1396 |
empty := true |
|
1397 |
] ifFalse:[ |
|
1398 |
key == #CursorUp ifTrue:[ |
|
1399 |
commandIndex == nCmd ifTrue:[ |
|
1400 |
commandView flash. |
|
1401 |
]. |
|
1402 |
commandIndex := (commandIndex + 1) min:nCmd |
|
1403 |
] ifFalse:[ |
|
1404 |
commandIndex == 1 ifTrue:[ |
|
1405 |
commandView flash. |
|
1406 |
empty := true. |
|
1407 |
]. |
|
1408 |
commandIndex := (commandIndex - 1) max:1. |
|
1409 |
]. |
|
1410 |
]. |
|
1411 |
empty == true ifTrue:[ |
|
1412 |
commandView contents:nil |
|
1413 |
] ifFalse:[ |
|
1414 |
commandView contents:(CommandHistory at:commandIndex). |
|
1415 |
] |
|
1416 |
]. |
|
1417 |
key == #Return ifTrue:[ |
|
1418 |
cmd := commandView contents. |
|
1419 |
||
1420 |
subView insertLine:( |
|
1421 |
Text string:('>> ' , cmd) |
|
1422 |
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
|
1423 |
"/ ColoredListEntry string:('>> ' , cmd) color:Color blue |
1329 | 1424 |
) |
1425 |
before:(subView cursorLine). |
|
1426 |
subView cursorDown:1. |
|
133 | 1427 |
|
1428 |
"/ subView insertStringAtCursor:cmd. |
|
1429 |
"/ subView insertCharAtCursor:(Character cr). |
|
132 | 1430 |
|
1329 | 1431 |
(cmd notNil and:[cmd notEmpty]) ifTrue:[ |
1432 |
self class addToCommandHistory:cmd for:nil. |
|
1433 |
self doExecuteCommand:cmd replace:false. |
|
1434 |
commandView contents:nil. |
|
1435 |
commandIndex := 0 |
|
1436 |
] |
|
1437 |
] |
|
132 | 1438 |
]. |
1439 |
||
133 | 1440 |
"Modified: 7.9.1995 / 15:48:45 / claus" |
1303 | 1441 |
"Modified: 30.8.1997 / 19:22:52 / cg" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1442 |
"Modified: 18.9.1997 / 16:55:01 / stefan" |
132 | 1443 |
! |
1444 |
||
172 | 1445 |
initializeFilterPattern |
1446 |
"set an initial matchpattern - can be redefined in subclasses" |
|
1447 |
||
344
3f881dbee13a
use a model for the filter field
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
1448 |
filterField model value:'*' |
172 | 1449 |
! |
1450 |
||
1451 |
initializeSubViewIn:frame |
|
1452 |
"set up the contents view - can be redefined in subclasses for |
|
1453 |
different view types (SoundFileBrowser/ImageBrowsers etc.)" |
|
1454 |
||
1455 |
^ HVScrollableView for:CodeView miniScrollerH:true miniScrollerV:false in:frame. |
|
1158
ea2cd788ef59
delay tabView origin setting
Claus Gittinger <cg@exept.de>
parents:
1157
diff
changeset
|
1456 |
! |
ea2cd788ef59
delay tabView origin setting
Claus Gittinger <cg@exept.de>
parents:
1157
diff
changeset
|
1457 |
|
1247 | 1458 |
postRealize |
1459 |
super postRealize. |
|
1158
ea2cd788ef59
delay tabView origin setting
Claus Gittinger <cg@exept.de>
parents:
1157
diff
changeset
|
1460 |
self showOrHideTabView. |
ea2cd788ef59
delay tabView origin setting
Claus Gittinger <cg@exept.de>
parents:
1157
diff
changeset
|
1461 |
|
1247 | 1462 |
"Created: 24.7.1997 / 18:13:46 / cg" |
172 | 1463 |
! ! |
1464 |
||
1465 |
!FileBrowser methodsFor:'misc user interaction'! |
|
1466 |
||
1467 |
destroy |
|
1468 |
"destroy view and boxes" |
|
1469 |
||
1470 |
ObjectMemory removeDependent:self. |
|
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1471 |
self stopUpdateProcess. |
172 | 1472 |
checkBlock := nil. |
1473 |
super destroy |
|
1145
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
1474 |
|
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
1475 |
"Modified: 19.4.1997 / 13:51:48 / cg" |
172 | 1476 |
! |
1477 |
||
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1478 |
discardChangesDialog |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1479 |
"ask the user if changes should be discarded, |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1480 |
return true if changes should be discarded, false otherwise" |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1481 |
|
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1482 |
^ self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.' |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1483 |
yesButton:'change' |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1484 |
|
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1485 |
"Created: 2.10.1997 / 14:08:37 / stefan" |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1486 |
! |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1487 |
|
346 | 1488 |
filterPatternChanged |
1489 |
fileListView scrollToTop. |
|
1490 |
self updateCurrentDirectory |
|
1491 |
! |
|
1492 |
||
172 | 1493 |
terminate |
1494 |
"exit FileBrowser" |
|
1495 |
||
1496 |
(self askIfModified:'contents has not been saved.\\Modifications will be lost when FileBrowser is closed.' |
|
1317 | 1497 |
yesButton:'close') ifTrue:[self destroy] |
172 | 1498 |
! |
1499 |
||
1500 |
update:what with:someArgument from:changedObject |
|
1501 |
realized ifFalse:[^ self]. |
|
36 | 1502 |
|
172 | 1503 |
(what == #aboutToExit) ifTrue:[ |
1317 | 1504 |
"system wants to shut down this |
1505 |
- if text was modified, pop up, and ask user and save if requested." |
|
1506 |
||
1507 |
(subView modified and:[subView contentsWasSaved not]) ifTrue:[ |
|
1508 |
self raiseDeiconified. |
|
1509 |
||
1510 |
(self |
|
1511 |
ask:(resources at:'FileBrowser:\\contents has not been saved.\\Save before exiting ?') |
|
1512 |
yesButton:'save' |
|
1513 |
noButton:'don''t save') |
|
1514 |
ifTrue:[ |
|
1515 |
subView acceptAction notNil ifTrue:[ |
|
1516 |
subView accept |
|
1517 |
] ifFalse:[ |
|
1518 |
subView save |
|
1519 |
] |
|
1520 |
] |
|
1521 |
]. |
|
1522 |
^ self |
|
172 | 1523 |
]. |
1524 |
changedObject == tabSpec ifTrue:[ |
|
1317 | 1525 |
fileListView invalidate |
172 | 1526 |
]. |
380 | 1527 |
|
585
be0241bf7268
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
1528 |
"Modified: 29.5.1996 / 16:13:43 / cg" |
172 | 1529 |
! ! |
1530 |
||
1531 |
!FileBrowser methodsFor:'pathField user interaction'! |
|
1532 |
||
1271 | 1533 |
addDirToJavaClassPath |
1534 |
"add the current path to javas classPath |
|
1535 |
(only available with ST/J System" |
|
1536 |
||
1537 |
Java addToClassPath:currentDirectory pathName |
|
1538 |
||
1539 |
"Modified: 14.12.1996 / 15:37:47 / cg" |
|
1540 |
"Created: 1.8.1997 / 21:25:22 / cg" |
|
1541 |
! |
|
1542 |
||
1272 | 1543 |
addDirToJavaSourcePath |
1544 |
"add the current path to javas sourcePath |
|
1545 |
(only available with ST/J System" |
|
1546 |
||
1547 |
Java addToSourcePath:currentDirectory pathName |
|
1548 |
||
1549 |
"Modified: 14.12.1996 / 15:37:47 / cg" |
|
1550 |
"Created: 2.8.1997 / 14:11:19 / cg" |
|
1551 |
! |
|
1552 |
||
172 | 1553 |
changeCurrentDirectory |
1554 |
"if text was modified show a queryBox, |
|
1329 | 1555 |
otherwise ask for & change to that directory" |
172 | 1556 |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1557 |
self discardChangesDialog ifTrue:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1558 |
self queryForDirectoryToChange |
36 | 1559 |
] |
1329 | 1560 |
|
1561 |
"Modified: 21.9.1997 / 23:45:35 / cg" |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1562 |
"Modified: 2.10.1997 / 14:09:02 / stefan" |
36 | 1563 |
! |
1564 |
||
172 | 1565 |
changeDirectoryTo:aDirectoryName |
1566 |
"sent from label menu to change back to a previous directory" |
|
132 | 1567 |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1568 |
self discardChangesDialog ifTrue:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1569 |
self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:false. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1570 |
]. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1571 |
|
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1572 |
"Modified: 2.10.1997 / 14:09:24 / stefan" |
172 | 1573 |
! |
1574 |
||
1329 | 1575 |
changeToDefaultDirectory |
1576 |
"if text was modified show a queryBox, |
|
1577 |
otherwise change immediately to the default directory" |
|
1578 |
||
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1579 |
self discardChangesDialog ifTrue:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1580 |
self doChangeToDefaultDirectory |
1329 | 1581 |
] |
1582 |
||
1583 |
"Modified: 21.9.1997 / 23:45:04 / cg" |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1584 |
"Modified: 2.10.1997 / 14:09:33 / stefan" |
1329 | 1585 |
! |
1586 |
||
172 | 1587 |
changeToHomeDirectory |
1588 |
"if text was modified show a queryBox, |
|
1329 | 1589 |
otherwise change immediately to the home directory" |
132 | 1590 |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1591 |
self discardChangesDialog ifTrue:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1592 |
self doChangeToHomeDirectory |
172 | 1593 |
] |
1329 | 1594 |
|
1595 |
"Modified: 21.9.1997 / 23:45:10 / cg" |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1596 |
"Modified: 2.10.1997 / 14:09:42 / stefan" |
172 | 1597 |
! |
45 | 1598 |
|
172 | 1599 |
changeToParentDirectory |
1600 |
"if text was modified show a queryBox, |
|
1329 | 1601 |
otherwise change immediately to the parent directory" |
45 | 1602 |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1603 |
self discardChangesDialog ifTrue:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1604 |
self doChangeToParentDirectory |
36 | 1605 |
] |
1329 | 1606 |
|
1607 |
"Modified: 21.9.1997 / 23:45:15 / cg" |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1608 |
"Modified: 2.10.1997 / 14:09:55 / stefan" |
98 | 1609 |
! |
1610 |
||
172 | 1611 |
copyPath |
1612 |
"copy current path into cut & paste buffer" |
|
1613 |
||
873 | 1614 |
self setTextSelection:currentDirectory pathName |
1615 |
||
1616 |
"Modified: 14.12.1996 / 15:37:47 / cg" |
|
172 | 1617 |
! |
1618 |
||
1619 |
labelMenu |
|
1040 | 1620 |
"return the popUpMenu for the path label" |
1621 |
||
1235
13610578a5d2
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
1622 |
<resource: #programMenu> |
1040 | 1623 |
|
172 | 1624 |
|labels selectors args menu| |
1625 |
||
1626 |
labels := #( |
|
1317 | 1627 |
'copy path' |
1628 |
'-' |
|
1629 |
'up' |
|
1630 |
'back' |
|
1631 |
'change to home-directory' |
|
1329 | 1632 |
'change to default-directory' |
1317 | 1633 |
'change directory ...' |
1634 |
). |
|
98 | 1635 |
|
172 | 1636 |
selectors := #( |
1317 | 1637 |
copyPath |
1638 |
nil |
|
1639 |
changeToParentDirectory |
|
1640 |
changeToPreviousDirectory |
|
1641 |
changeToHomeDirectory |
|
1329 | 1642 |
changeToDefaultDirectory |
1317 | 1643 |
changeCurrentDirectory |
1644 |
). |
|
123 | 1645 |
|
1271 | 1646 |
JavaClassReader notNil ifTrue:[ |
1317 | 1647 |
labels := labels , #('-' 'add to JavaClassPath' 'add to JavaSourcePath' 'remove from JavaClassPath' 'remove from JavaSourcePath'). |
1648 |
selectors := selectors , #(nil #addDirToJavaClassPath #addDirToJavaSourcePath #removeDirFromJavaClassPath #removeDirFromJavaSourcePath). |
|
1271 | 1649 |
]. |
1650 |
||
172 | 1651 |
args := Array new:(labels size). |
126 | 1652 |
|
172 | 1653 |
DirectoryHistory size > 0 ifTrue:[ |
1317 | 1654 |
labels := labels copyWith:'-'. |
1655 |
selectors := selectors copyWith:nil. |
|
1656 |
args := args copyWith:nil. |
|
1657 |
||
1658 |
DirectoryHistory do:[:dirName | |
|
1659 |
labels := labels copyWith:dirName. |
|
1660 |
selectors := selectors copyWith:#changeDirectoryTo:. |
|
1661 |
args := args copyWith:dirName |
|
1662 |
] |
|
123 | 1663 |
]. |
172 | 1664 |
|
1665 |
menu := PopUpMenu |
|
1317 | 1666 |
labels:(resources array:labels) |
1667 |
selectors:selectors |
|
1668 |
args:args |
|
1669 |
receiver:self. |
|
172 | 1670 |
|
1671 |
previousDirectory isNil ifTrue:[ |
|
1317 | 1672 |
menu disable:#changeToPreviousDirectory. |
132 | 1673 |
]. |
172 | 1674 |
^menu. |
1040 | 1675 |
|
1329 | 1676 |
"Modified: 21.9.1997 / 23:46:36 / cg" |
172 | 1677 |
! |
1678 |
||
1327 | 1679 |
pathChanged:newPath |
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1680 |
"change directory to newPath. If newPath is a filename, change |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1681 |
to its directory and get get the file." |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1682 |
|
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1683 |
|f name idx| |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1684 |
|
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1685 |
self discardChangesDialog ifTrue:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1686 |
f := newPath asFilename. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1687 |
(f isDirectory) ifTrue:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1688 |
self changeDirectoryTo:newPath |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1689 |
] ifFalse:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1690 |
self changeDirectoryTo:(f directoryName). |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1691 |
self changed:#path. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1692 |
name := f baseName. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1693 |
idx := fileList indexOf:name. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1694 |
fileListView selection:idx. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1695 |
self fileSelect:name. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1696 |
self fileGet:true. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1697 |
]. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1698 |
] ifFalse:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1699 |
self changed:#path. |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1700 |
]. |
1327 | 1701 |
|
1702 |
"Created: 21.9.1997 / 10:43:12 / cg" |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1703 |
"Modified: 7.10.1997 / 14:10:39 / stefan" |
1327 | 1704 |
! |
1705 |
||
172 | 1706 |
queryForDirectoryToChange |
1707 |
"query for new directory" |
|
123 | 1708 |
|
1168
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
1709 |
|queryBox dirName| |
98 | 1710 |
|
172 | 1711 |
queryBox := FilenameEnterBox |
1317 | 1712 |
title:(resources at:'change directory to:') withCRs |
1713 |
okText:(resources at:'change') |
|
1714 |
action:[:newName | dirName := newName]. |
|
172 | 1715 |
"/ queryBox initialText:''. |
1168
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
1716 |
queryBox showAtPointer. |
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
1717 |
queryBox destroy. |
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
1718 |
self doChangeCurrentDirectoryTo:dirName updateHistory:true. |
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
1719 |
|
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
1720 |
"Modified: 28.4.1997 / 19:50:52 / cg" |
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
1721 |
"Modified: 28.4.1997 / 22:30:40 / dq" |
1271 | 1722 |
! |
1723 |
||
1724 |
removeDirFromJavaClassPath |
|
1725 |
"remove the current path from javas classPath |
|
1726 |
(only available with ST/J System" |
|
1727 |
||
1728 |
Java removeFromClassPath:currentDirectory pathName |
|
1729 |
||
1730 |
"Modified: 14.12.1996 / 15:37:47 / cg" |
|
1731 |
"Created: 1.8.1997 / 21:25:36 / cg" |
|
1272 | 1732 |
! |
1733 |
||
1734 |
removeDirFromJavaSourcePath |
|
1735 |
"remove the current path from javas sourcePath |
|
1736 |
(only available with ST/J System" |
|
1737 |
||
1738 |
Java removeFromSourcePath:currentDirectory pathName |
|
1739 |
||
1740 |
"Modified: 14.12.1996 / 15:37:47 / cg" |
|
1741 |
"Created: 2.8.1997 / 14:11:41 / cg" |
|
36 | 1742 |
! ! |
1743 |
||
1744 |
!FileBrowser methodsFor:'private'! |
|
1745 |
||
172 | 1746 |
ask:question yesButton:yesButtonText |
1747 |
"common method to ask a yes/no question; return true or false" |
|
36 | 1748 |
|
172 | 1749 |
^ self ask:question yesButton:yesButtonText noButton:'cancel' |
1750 |
! |
|
93 | 1751 |
|
172 | 1752 |
ask:question yesButton:yesButtonText noButton:noButtonText |
36 | 1753 |
"common method to ask a yes/no question" |
1754 |
||
380 | 1755 |
^ Dialog |
1317 | 1756 |
confirm:question withCRs |
1757 |
yesLabel:(resources at:yesButtonText) |
|
1758 |
noLabel:(resources at:noButtonText) |
|
37 | 1759 |
|
380 | 1760 |
"Modified: 21.2.1996 / 01:19:21 / cg" |
36 | 1761 |
! |
1762 |
||
1142
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
1763 |
askForCommandFor:fileName thenDo:aBlock |
172 | 1764 |
"setup and launch a querybox to ask for unix command. |
1765 |
Then evaluate aBlock passing the command-string as argument." |
|
93 | 1766 |
|
1170 | 1767 |
|box| |
93 | 1768 |
|
172 | 1769 |
box := FilenameEnterBox |
1329 | 1770 |
title:(resources at:'execute unix command:') |
1771 |
okText:(resources at:'execute') |
|
1772 |
action:aBlock. |
|
79 | 1773 |
|
172 | 1774 |
fileName notNil ifTrue:[ |
1329 | 1775 |
self initialCommandFor:fileName into:box. |
172 | 1776 |
]. |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1777 |
box directory:currentDirectory. |
1142
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
1778 |
box showAtPointer. |
9066d7d02a3a
remember last executed command per suffix; offer this as default.
Claus Gittinger <cg@exept.de>
parents:
1141
diff
changeset
|
1779 |
box destroy. |
36 | 1780 |
|
172 | 1781 |
"Modified: 7.9.1995 / 10:31:54 / claus" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1782 |
"Modified: 16.9.1997 / 15:35:10 / stefan" |
36 | 1783 |
! |
1784 |
||
98 | 1785 |
askIfModified:question yesButton:yesButtonText |
1786 |
"tell user, that code has been modified - let her confirm" |
|
1787 |
||
1788 |
(subView modified not or:[subView contentsWasSaved]) ifTrue:[ |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1789 |
^ true |
98 | 1790 |
]. |
1340 | 1791 |
(self ask:(resources string:question) yesButton:yesButtonText) ifTrue:[ |
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1792 |
"/ reset modified flag so question is asked only once |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1793 |
subView modified:false. |
1340 | 1794 |
^ true |
1795 |
]. |
|
1796 |
^ false |
|
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1797 |
|
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
1798 |
"Modified: 2.10.1997 / 14:23:47 / stefan" |
98 | 1799 |
! |
1800 |
||
1162 | 1801 |
getSelectedFileName |
1802 |
"returns the currently selected file; shows an error if |
|
1803 |
multiple files are selected" |
|
1804 |
||
1805 |
|sel| |
|
1806 |
||
1807 |
sel := fileListView selection. |
|
1808 |
(sel size > 1) ifTrue:[ |
|
1317 | 1809 |
self onlyOneSelection |
1162 | 1810 |
] ifFalse:[ |
1317 | 1811 |
sel notNil ifTrue:[ |
1812 |
^ fileList at:sel first |
|
1813 |
] |
|
1162 | 1814 |
]. |
1815 |
^ nil |
|
1816 |
! |
|
1817 |
||
1818 |
onlyOneSelection |
|
1819 |
"show a warning, that only one file must be selected for |
|
1820 |
this operation" |
|
1821 |
||
1822 |
self warn:'exactly one file must be selected !!' |
|
1823 |
! |
|
1824 |
||
1825 |
selectedFilesDo:aBlock |
|
1826 |
"evaluate aBlock on all selected files; |
|
1827 |
show a wait cursor while doing this" |
|
1828 |
||
1829 |
|sel| |
|
1830 |
||
1831 |
sel := fileListView selection. |
|
1832 |
sel notNil ifTrue:[ |
|
1317 | 1833 |
self withWaitCursorDo:[ |
1834 |
sel do:[:aSelectionIndex | |
|
1835 |
aBlock value:(fileList at:aSelectionIndex ) |
|
1836 |
] |
|
1837 |
] |
|
1162 | 1838 |
] |
1839 |
||
1840 |
! |
|
1841 |
||
1842 |
show:something |
|
1843 |
"show something in subview and undef acceptAction" |
|
1844 |
||
1845 |
subView contents:something. |
|
1846 |
subView acceptAction:nil. |
|
1847 |
subView modified:false. |
|
1848 |
currentFileName := nil |
|
1849 |
! |
|
1850 |
||
1851 |
showAlert:aString with:anErrorString |
|
1852 |
"show an alertbox, displaying the last Unix-error" |
|
1853 |
||
1854 |
|msg| |
|
1855 |
||
1856 |
anErrorString isNil ifTrue:[ |
|
1317 | 1857 |
msg := aString |
1162 | 1858 |
] ifFalse:[ |
1317 | 1859 |
msg := aString , '\\(' , anErrorString , ')' |
1162 | 1860 |
]. |
1861 |
self warn:msg withCRs |
|
1862 |
! |
|
1863 |
||
1864 |
withoutHiddenFiles:aCollection |
|
1865 |
"remove hidden files (i.e. those that start with '.') from |
|
1866 |
the list in aCollection" |
|
1867 |
||
1868 |
|newCollection| |
|
1869 |
||
1870 |
newCollection := aCollection species new. |
|
1871 |
aCollection do:[:fname | |
|
1317 | 1872 |
|ignore| |
1873 |
||
1874 |
ignore := false. |
|
1875 |
||
1876 |
((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[ |
|
1877 |
showDotFiles ifFalse:[ |
|
1878 |
ignore := true |
|
1879 |
] |
|
1880 |
]. |
|
1881 |
ignore ifFalse:[ |
|
1882 |
newCollection add:fname |
|
1883 |
] |
|
1162 | 1884 |
]. |
1885 |
^ newCollection |
|
1886 |
||
1887 |
"Modified: 21.2.1996 / 01:33:18 / cg" |
|
1888 |
! ! |
|
1889 |
||
1890 |
!FileBrowser methodsFor:'private - actions & command execution'! |
|
1891 |
||
1892 |
binaryFileAction:aFilename |
|
1893 |
"for some binary files, if double clicked, we can do some useful |
|
1894 |
action ..." |
|
1895 |
||
1330 | 1896 |
(currentDirectory construct:aFilename) isExecutableProgram ifTrue:[ |
1329 | 1897 |
(OperatingSystem executeCommand:'cd ', currentDirectory pathName, '; ',aFilename) |
1898 |
ifTrue:[^true]. |
|
1162 | 1899 |
]. |
1900 |
^ self imageAction:aFilename |
|
1901 |
||
1902 |
"Modified: 19.6.1996 / 09:44:07 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
1903 |
"Modified: 18.9.1997 / 17:18:04 / stefan" |
1162 | 1904 |
! |
1905 |
||
1906 |
doExecuteCommand:command replace:replace |
|
1907 |
"execute a unix command inserting the output of the command. |
|
1908 |
If replace is true, all text is replaced by the commands output; |
|
1909 |
otherwise, its inserted as selected text at the cursor position." |
|
1910 |
||
1334
59536e6bb08d
Fix #doExecuteCommand:replace: to not hang in pipeStream>>atEnd:
Stefan Vogel <sv@exept.de>
parents:
1332
diff
changeset
|
1911 |
|stream noData line lnr myProcess myPriority startLine startCol stopSignal |
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1912 |
pauseSignal access stillReplacing pauseHolder lowerFrameView commandLine| |
1162 | 1913 |
|
1914 |
access := Semaphore forMutualExclusion name:'accessLock'. |
|
1915 |
stopSignal := Signal new. |
|
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1916 |
pauseSignal := Signal new. |
1162 | 1917 |
|
1918 |
" |
|
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1919 |
The following is tricky: |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1920 |
the pauseToggle & killButton will |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1921 |
be handled by their own windowGroup process. |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1922 |
This means, that they respond to events even though |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1923 |
I myself am reading the commands output. |
1162 | 1924 |
" |
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1925 |
|
1329 | 1926 |
commandView beInvisible. |
1927 |
||
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1928 |
" |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1929 |
must take kill & pauseButtons out of my group |
1162 | 1930 |
" |
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1931 |
killButton windowGroup:nil. |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1932 |
pauseToggle windowGroup:nil. |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1933 |
|
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1934 |
" |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1935 |
bring them to front, and turn hidden-mode off |
1162 | 1936 |
" |
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1937 |
killButton raise; beVisible. |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1938 |
pauseToggle raise; beVisible. |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1939 |
|
1162 | 1940 |
" |
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1941 |
kill will make me raise the stopSignal when pressed |
1162 | 1942 |
" |
1943 |
killButton |
|
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
1944 |
action:[ |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
1945 |
stream notNil ifTrue:[ |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
1946 |
access critical:[ |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
1947 |
myProcess interruptWith:[stopSignal raise]. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
1948 |
] |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
1949 |
] |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
1950 |
]. |
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1951 |
|
1162 | 1952 |
" |
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1953 |
pause makes me stop reading the commands output |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1954 |
" |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1955 |
pauseHolder := false asValue. |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1956 |
pauseToggle model:pauseHolder. |
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1957 |
pauseToggle pressAction:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1958 |
stream notNil ifTrue:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1959 |
access critical:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1960 |
myProcess interruptWith:[pauseSignal raise]. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1961 |
] |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1962 |
] |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1963 |
]. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1964 |
|
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1965 |
|
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1966 |
" |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1967 |
start kill button under its own windowgroup |
1162 | 1968 |
" |
1969 |
killButton openAutonomous. |
|
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1970 |
killButton windowGroup process processGroupId:(Processor activeProcess id). |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1971 |
|
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1972 |
" |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1973 |
and add the pauseToggle to its windowGroup |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1974 |
" |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1975 |
pauseToggle windowGroup:(killButton windowGroup). |
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1976 |
|
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1977 |
|
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
1978 |
lowerFrameView := subView superView. |
1162 | 1979 |
|
1980 |
" |
|
1981 |
go fork a pipe and read it |
|
1982 |
" |
|
1983 |
self label:(myName , ': executing ' , (command copyTo:(20 min:command size)) , ' ...'). |
|
1984 |
[ |
|
1985 |
self withWaitCursorDo:[ |
|
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
1986 |
stopSignal catch:[ |
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1987 |
pauseSignal handle:[:ex| |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1988 |
|noPauseSema| |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1989 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1990 |
"/ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1991 |
"/ allow interaction with |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1992 |
"/ the codeView via the other windowGroup |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1993 |
"/ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1994 |
lowerFrameView windowGroup:(killButton windowGroup). |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1995 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1996 |
"/ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1997 |
"/ wait for pause to be turned off |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1998 |
"/ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
1999 |
noPauseSema := Semaphore new. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2000 |
pauseHolder onChangeSend:#signal to:noPauseSema. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2001 |
noPauseSema wait. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2002 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2003 |
"/ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2004 |
"/ no interaction with the codeView ... |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2005 |
"/ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2006 |
lowerFrameView windowGroup:(self windowGroup). |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2007 |
ex proceed. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2008 |
] do:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2009 |
startLine := subView cursorLine. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2010 |
startCol := subView cursorCol. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2011 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2012 |
" |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2013 |
this can be a time consuming operation; therefore lower my priority |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2014 |
" |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2015 |
myProcess := Processor activeProcess. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2016 |
myPriority := myProcess priority. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2017 |
myProcess priority:(Processor userBackgroundPriority). |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2018 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2019 |
stream := PipeStream |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2020 |
readingFrom:command |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2021 |
errorDisposition:#inline |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2022 |
inDirectory:currentDirectory. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2023 |
stream notNil ifTrue:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2024 |
[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2025 |
|codeView lines noPauseSema| |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2026 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2027 |
stream buffered:true. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2028 |
codeView := subView. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2029 |
codeView unselect. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2030 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2031 |
replace ifTrue:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2032 |
codeView list:nil. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2033 |
lnr := 1. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2034 |
]. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2035 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2036 |
stillReplacing := replace. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2037 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2038 |
[stream readWait. stream atEnd] whileFalse:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2039 |
" |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2040 |
data available; read up to 100 lines |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2041 |
and insert as a single junk. This speeds up |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2042 |
display of long output (less line-scrolling). |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2043 |
" |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2044 |
lines := OrderedCollection new:100. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2045 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2046 |
[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2047 |
line := stream nextLine. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2048 |
line notNil ifTrue:[lines add:line]. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2049 |
] doWhile:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2050 |
stream canReadWithoutBlocking |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2051 |
and:[stream atEnd not |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2052 |
and:[lines size < 100]] |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2053 |
]. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2054 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2055 |
" |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2056 |
need this critical section; otherwise, |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2057 |
we could get the signal while waiting for |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2058 |
an expose event ... |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2059 |
" |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2060 |
access critical:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2061 |
lines size > 0 ifTrue:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2062 |
stillReplacing ifTrue:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2063 |
lines do:[:line | |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2064 |
codeView at:lnr put:line withTabsExpanded. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2065 |
codeView cursorToBottom; cursorDown:1. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2066 |
lnr := lnr + 1. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2067 |
lnr > codeView list size ifTrue:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2068 |
stillReplacing := false |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2069 |
] |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2070 |
]. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2071 |
] ifFalse:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2072 |
codeView insertLines:lines before:codeView cursorLine. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2073 |
codeView cursorDown:lines size. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2074 |
] |
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2075 |
]. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2076 |
]. |
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2077 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2078 |
" |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2079 |
give others running at same prio a chance too |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2080 |
(especially other FileBrowsers doing the same) |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2081 |
" |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2082 |
Processor yield |
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2083 |
]. |
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2084 |
] valueNowOrOnUnwindDo:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2085 |
stream shutDown "close". stream := nil. |
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2086 |
]. |
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2087 |
|
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2088 |
"/ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2089 |
"/ the command could have changed the directory |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2090 |
"/ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2091 |
self updateCurrentDirectoryIfChanged |
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2092 |
]. |
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2093 |
replace ifTrue:[ |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2094 |
subView modified:false. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2095 |
]. |
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2096 |
] |
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2097 |
] |
1162 | 2098 |
] |
2099 |
] valueNowOrOnUnwindDo:[ |
|
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2100 |
|wg| |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2101 |
|
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2102 |
self label:myName; iconLabel:myName. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2103 |
myProcess notNil ifTrue:[myProcess priority:myPriority]. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2104 |
|
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2105 |
" |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2106 |
hide the button, and make sure it will stay |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2107 |
hidden when we are realized again |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2108 |
" |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2109 |
killButton beInvisible. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2110 |
pauseToggle beInvisible. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2111 |
|
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2112 |
commandView beVisible. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2113 |
|
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2114 |
" |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2115 |
remove the killButton from its group |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2116 |
(otherwise, it will be destroyed when we shut down the group) |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2117 |
" |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2118 |
wg := killButton windowGroup. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2119 |
killButton windowGroup:nil. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2120 |
pauseToggle windowGroup:nil. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2121 |
|
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2122 |
" |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2123 |
shut down the kill buttons windowgroup |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2124 |
" |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2125 |
wg notNil ifTrue:[ |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2126 |
wg process terminate. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2127 |
]. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2128 |
" |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2129 |
clear its action (actually not needed, but |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2130 |
releases reference to thisContext earlier) |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2131 |
" |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2132 |
killButton action:nil. |
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2133 |
pauseToggle pressAction:nil. |
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2134 |
"/ |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2135 |
"/ allow interaction with the codeView |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2136 |
"/ (bring it back into my group) |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2137 |
"/ |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2138 |
lowerFrameView windowGroup:(self windowGroup). |
1162 | 2139 |
]. |
2140 |
||
2141 |
currentFileName isNil ifTrue:[ |
|
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2142 |
subView modified:false. |
1162 | 2143 |
]. |
2144 |
||
2145 |
subView size > 10000 ifTrue:[ |
|
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2146 |
self warn:'text quite large now - please cut off some lines' |
1162 | 2147 |
] |
2148 |
||
2149 |
"Modified: 21.9.1995 / 11:18:46 / claus" |
|
1298
4ce2a9cd693a
allow command-output reading to be paused.
Claus Gittinger <cg@exept.de>
parents:
1287
diff
changeset
|
2150 |
"Modified: 20.8.1997 / 19:09:09 / cg" |
1335
4f8ee6e1d8e1
Use signal instead polling for pauseButton in #doExecuteCommand:replace:.
Stefan Vogel <sv@exept.de>
parents:
1334
diff
changeset
|
2151 |
"Modified: 25.9.1997 / 15:09:41 / stefan" |
1162 | 2152 |
! |
2153 |
||
2154 |
imageAction:aFilename |
|
2155 |
"for some image files, if double clicked, we can do some useful |
|
2156 |
action ..." |
|
2157 |
||
2158 |
|img| |
|
2159 |
||
2160 |
(Image isImageFileSuffix:(aFilename asFilename suffix)) |
|
2161 |
ifTrue:[ |
|
1329 | 2162 |
img := Image fromFile:(currentDirectory construct:aFilename). |
2163 |
img notNil ifTrue:[ |
|
2164 |
img inspect. |
|
2165 |
^ true |
|
2166 |
] |
|
1162 | 2167 |
]. |
2168 |
^ false |
|
2169 |
||
2170 |
"Created: 19.6.1996 / 09:43:50 / cg" |
|
2171 |
"Modified: 18.4.1997 / 14:56:04 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2172 |
"Modified: 18.9.1997 / 16:35:48 / stefan" |
1162 | 2173 |
! |
2174 |
||
2175 |
initialCommandFor:fileName into:aBox |
|
2176 |
"set a useful initial command for execute box." |
|
2177 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2178 |
|cmd select path suffix| |
1162 | 2179 |
|
2180 |
"/ XXX should be changed to take stuff from a config file |
|
2181 |
"/ XXX or from resources. |
|
2182 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2183 |
path := currentDirectory filenameFor:fileName. |
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2184 |
(path type == #regular) ifTrue:[ |
1332 | 2185 |
path isExecutableProgram ifTrue:[ |
2186 |
aBox initialText:(fileName , ' <arguments>'). |
|
2187 |
^ self |
|
2188 |
]. |
|
2189 |
||
2190 |
select := true. |
|
2191 |
||
2192 |
"some heuristics - my personal preferences ... |
|
2193 |
(actually this should come from a configfile)" |
|
2194 |
||
2195 |
(fileName endsWith:'akefile') ifTrue:[ |
|
2196 |
aBox initialText:'make target' selectFrom:6 to:11. |
|
2197 |
^ self |
|
2198 |
]. |
|
2199 |
||
2200 |
suffix := path suffix. |
|
2201 |
(suffix = 'C') ifTrue:[ |
|
2202 |
cmd := 'g++ -c %1'. |
|
2203 |
select := 6. |
|
2204 |
] ifFalse:[ |
|
2205 |
suffix := suffix asLowercase. |
|
2206 |
(suffix = 'taz') ifTrue:[ |
|
2207 |
aBox initialText:'zcat %1 | tar tvf -'. |
|
2208 |
select := false. |
|
2209 |
]. |
|
2210 |
(suffix = 'tar') ifTrue:[ |
|
2211 |
cmd := 'tar tvf %1'. |
|
2212 |
select := 7. |
|
2213 |
]. |
|
2214 |
(suffix = 'zoo') ifTrue:[ |
|
2215 |
cmd := 'zoo -list %1'. |
|
2216 |
select := 9. |
|
2217 |
]. |
|
2218 |
(suffix = 'zip') ifTrue:[ |
|
2219 |
cmd := 'unzip -l %1'. |
|
2220 |
select := 8. |
|
2221 |
]. |
|
2222 |
(suffix = 'z') ifTrue:[ |
|
2223 |
(fileName endsWith:'tar.z') ifTrue:[ |
|
2224 |
cmd := 'zcat %1 | tar tvf -'. |
|
2225 |
select := false. |
|
2226 |
] ifFalse:[ |
|
2227 |
cmd := 'uncompress %1' |
|
2228 |
]. |
|
2229 |
]. |
|
2230 |
(suffix = 'gz') ifTrue:[ |
|
2231 |
(fileName endsWith:'tar.gz') ifTrue:[ |
|
2232 |
cmd := ('gunzip < %1 | tar tvf -' ). |
|
2233 |
select := false. |
|
2234 |
] ifFalse:[ |
|
2235 |
cmd := 'gunzip %1'. |
|
2236 |
]. |
|
2237 |
]. |
|
2238 |
(suffix = 'tgz') ifTrue:[ |
|
2239 |
cmd := ('gunzip < %1 | tar tvf -' ). |
|
2240 |
select := false. |
|
2241 |
]. |
|
2242 |
(suffix = 'html') ifTrue:[ |
|
2243 |
cmd := 'netscape %1' |
|
2244 |
]. |
|
2245 |
(suffix = 'htm') ifTrue:[ |
|
2246 |
cmd := 'netscape %1' |
|
2247 |
]. |
|
2248 |
(suffix = 'uue') ifTrue:[ |
|
2249 |
cmd := 'uudecode %1' |
|
2250 |
]. |
|
2251 |
(suffix = 'c') ifTrue:[ |
|
2252 |
cmd := 'cc -c %1'. |
|
2253 |
select := 5. |
|
2254 |
]. |
|
2255 |
(suffix = 'cc') ifTrue:[ |
|
2256 |
cmd := 'g++ -c %1'. |
|
2257 |
select := 6. |
|
2258 |
]. |
|
2259 |
(suffix = 'xbm') ifTrue:[ |
|
2260 |
cmd := 'bitmap %1' |
|
2261 |
]. |
|
2262 |
(suffix = 'ps') ifTrue:[ |
|
2263 |
cmd := 'ghostview %1' |
|
2264 |
]. |
|
2265 |
((suffix = '1') or:[suffix = 'man']) ifTrue:[ |
|
2266 |
cmd := 'nroff -man %1'. |
|
2267 |
select := 10. |
|
2268 |
]. |
|
2269 |
]. |
|
2270 |
||
2271 |
cmd isNil ifTrue:[ |
|
2272 |
DefaultCommandPerSuffix isNil ifTrue:[ |
|
2273 |
cmd := '<cmd>' |
|
2274 |
] ifFalse:[ |
|
2275 |
cmd := DefaultCommandPerSuffix |
|
2276 |
at:suffix |
|
2277 |
ifAbsent:'<cmd>'. |
|
2278 |
]. |
|
2279 |
cmd := cmd , ' %1'. |
|
2280 |
]. |
|
2281 |
||
2282 |
cmd := cmd bindWith:fileName. |
|
2283 |
select == false ifTrue:[ |
|
2284 |
aBox initialText:cmd |
|
2285 |
] ifFalse:[ |
|
2286 |
select isInteger ifFalse:[ |
|
2287 |
select := (cmd indexOf:Character space ifAbsent:[cmd size + 1]) - 1. |
|
2288 |
]. |
|
2289 |
aBox initialText:cmd selectFrom:1 to:select |
|
2290 |
] |
|
1162 | 2291 |
] |
2292 |
||
1272 | 2293 |
"Modified: 3.8.1997 / 16:55:26 / cg" |
1332 | 2294 |
"Modified: 24.9.1997 / 16:34:52 / stefan" |
1162 | 2295 |
! |
2296 |
||
2297 |
nonBinaryFileAction:aFilename |
|
2298 |
"for some nonBinary files, if double clicked, we can do some useful |
|
2299 |
action ..." |
|
2300 |
||
2301 |
|fullPath lcName| |
|
2302 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2303 |
fullPath := currentDirectory filenameFor:aFilename. |
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2304 |
((fullPath hasSuffix:'htm') or:[fullPath hasSuffix:'html']) ifTrue:[ |
1329 | 2305 |
HTMLDocumentView openOn:fullPath pathName. |
2306 |
^ true |
|
1162 | 2307 |
]. |
2308 |
||
2309 |
OperatingSystem isUNIXlike ifTrue:[ |
|
1329 | 2310 |
(#('.man' '.1' '.2' '.3') findFirst:[:suff | fullPath hasSuffix:suff]) ~~ 0 |
2311 |
ifTrue:[ |
|
2312 |
HTMLDocumentView openFullOnText:(HTMLDocGenerator manPageForFile:fullPath pathName). |
|
2313 |
^ true |
|
2314 |
] |
|
1162 | 2315 |
]. |
2316 |
^ self imageAction:aFilename |
|
2317 |
||
2318 |
"Created: 19.6.1996 / 09:36:38 / cg" |
|
2319 |
"Modified: 4.4.1997 / 10:49:00 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2320 |
"Modified: 18.9.1997 / 16:58:40 / stefan" |
1162 | 2321 |
! ! |
2322 |
||
2323 |
!FileBrowser methodsFor:'private - directory stuff'! |
|
2324 |
||
172 | 2325 |
changeToPreviousDirectory |
2326 |
"if text was modified show a queryBox, |
|
2327 |
otherwise change immediately to previous directory." |
|
93 | 2328 |
|
172 | 2329 |
previousDirectory isNil ifTrue:[^ self]. |
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
2330 |
self discardChangesDialog ifTrue:[ |
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
2331 |
self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false |
172 | 2332 |
] |
1339
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
2333 |
|
4b712d8c1738
Allow regular filenames to be entered in pathField.
Stefan Vogel <sv@exept.de>
parents:
1336
diff
changeset
|
2334 |
"Modified: 2.10.1997 / 14:13:40 / stefan" |
36 | 2335 |
! |
2336 |
||
98 | 2337 |
checkIfDirectoryHasChanged |
2338 |
"every checkDelta secs, check if directoy has changed and update the list if so. |
|
2339 |
Also, we check if the file shown has been touched in the meanwhile (for example, |
|
2340 |
from another browser) and say 'outdated' in the label if so. |
|
2341 |
This avoids confusion if the same file is being edited by two browsers. (or other editors). |
|
2342 |
If the text shown in the codeView has been edited, 'modified' is shown. |
|
2343 |
" |
|
2344 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2345 |
|oldSelection nOld newState msg newLabel t| |
98 | 2346 |
|
2347 |
shown ifTrue:[ |
|
1329 | 2348 |
currentDirectory notNil ifTrue:[ |
2349 |
lockUpdate ifTrue:[ |
|
2350 |
Processor removeTimedBlock:checkBlock. |
|
2351 |
Processor addTimedBlock:checkBlock afterSeconds:checkDelta. |
|
2352 |
^ self |
|
2353 |
]. |
|
2354 |
||
2355 |
subView modified ifTrue:[ |
|
2356 |
newState := ' (modified)' |
|
2357 |
]. |
|
2358 |
||
2359 |
(currentDirectory isReadable) ifTrue:[ |
|
2360 |
Processor removeTimedBlock:checkBlock. |
|
2361 |
||
2362 |
t := currentDirectory modificationTime. |
|
2363 |
(t notNil and:[t > timeOfLastCheck]) ifTrue:[ |
|
2364 |
nOld := fileListView numberOfSelections. |
|
2365 |
oldSelection := fileListView selectionValue. |
|
2366 |
self updateCurrentDirectory. |
|
2367 |
nOld ~~ 0 ifTrue:[ |
|
2368 |
nOld > 1 ifTrue:[ |
|
2369 |
oldSelection do:[:element | |
|
2370 |
fileListView addElementToSelection:element |
|
2371 |
] |
|
2372 |
] ifFalse:[ |
|
2373 |
fileListView selectElementWithoutScroll:oldSelection |
|
2374 |
] |
|
2375 |
]. |
|
2376 |
] ifFalse:[ |
|
2377 |
Processor addTimedBlock:checkBlock afterSeconds:checkDelta |
|
2378 |
]. |
|
2379 |
||
2380 |
currentFileName notNil ifTrue:[ |
|
2381 |
|f| |
|
2382 |
f := currentDirectory construct:currentFileName. |
|
2383 |
f exists ifFalse:[ |
|
2384 |
newState := ' (removed)'. |
|
2385 |
] ifTrue:[ |
|
2386 |
f modificationTime > timeOfFileRead ifTrue:[ |
|
2387 |
newState := ' (outdated)'. |
|
2388 |
subView modified ifTrue:[ |
|
2389 |
newState := ' (modified & outdated)' |
|
2390 |
] |
|
2391 |
]. |
|
2392 |
]. |
|
2393 |
]. |
|
2394 |
] ifFalse:[ |
|
2395 |
" |
|
2396 |
if the directory has been deleted, or is not readable ... |
|
2397 |
" |
|
2398 |
(currentDirectory exists) ifFalse:[ |
|
2399 |
msg := 'FileBrowser:\\directory %1 is gone ?!!?' |
|
2400 |
] ifTrue:[ |
|
2401 |
msg := 'FileBrowser:\\directory %1 is no longer readable ?!!?' |
|
2402 |
]. |
|
2403 |
self warn:(resources string:msg with:here) withCRs. |
|
2404 |
||
2405 |
fileListView contents:nil. |
|
2406 |
newLabel := myName , ': directory is gone !!'. |
|
2407 |
"/ Processor addTimedBlock:checkBlock afterSeconds:checkDelta |
|
2408 |
]. |
|
2409 |
||
2410 |
newState notNil ifTrue:[ |
|
2411 |
newLabel := myName. |
|
2412 |
currentFileName notNil ifTrue:[ |
|
2413 |
newLabel := newLabel , ': ' , currentFileName |
|
2414 |
]. |
|
2415 |
newLabel := newLabel , newState. |
|
2416 |
]. |
|
2417 |
newLabel notNil ifTrue:[ |
|
2418 |
self label:newLabel. |
|
2419 |
] |
|
2420 |
] |
|
98 | 2421 |
] |
1168
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
2422 |
|
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
2423 |
"Modified: 28.4.1997 / 19:40:34 / cg" |
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
2424 |
"Modified: 28.4.1997 / 22:31:02 / dq" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2425 |
"Modified: 16.9.1997 / 15:17:15 / stefan" |
98 | 2426 |
! |
2427 |
||
172 | 2428 |
doChangeCurrentDirectoryTo:fileName updateHistory:updateHistory |
2429 |
"verify argument is name of a readable & executable directory |
|
2430 |
and if so, go there" |
|
2431 |
||
1317 | 2432 |
|msg path idx f| |
172 | 2433 |
|
2434 |
self label:myName; iconLabel:myName. |
|
2435 |
fileName notNil ifTrue:[ |
|
1329 | 2436 |
f := (currentDirectory filenameFor:fileName) asAbsoluteFilename. |
2437 |
(f isDirectory) ifTrue:[ |
|
2438 |
(f isReadable) ifTrue:[ |
|
2439 |
(f isExecutable) ifTrue:[ |
|
2440 |
path := currentDirectory pathName. |
|
2441 |
previousDirectory := path. |
|
2442 |
||
2443 |
" |
|
2444 |
remember where we are positioned in the fileList |
|
2445 |
(in case we want to return) |
|
2446 |
" |
|
2447 |
idx := DirectoryHistory indexOf:path. |
|
2448 |
idx ~~ 0 ifTrue:[ |
|
2449 |
DirectoryHistoryWhere at:idx put:fileListView firstLineShown |
|
2450 |
]. |
|
2451 |
||
2452 |
updateHistory ifTrue:[ |
|
2453 |
|pos| |
|
2454 |
||
2455 |
(DirectoryHistory includes:path) ifFalse:[ |
|
2456 |
DirectoryHistory size >= HistorySize ifTrue:[ |
|
2457 |
DirectoryHistory removeLast. |
|
2458 |
DirectoryHistoryWhere removeLast |
|
2459 |
] |
|
2460 |
] ifTrue:[ |
|
2461 |
"already been there before; move the entry to |
|
2462 |
the beginning, so it will fall out later." |
|
2463 |
||
2464 |
idx := DirectoryHistory indexOf:path. |
|
2465 |
DirectoryHistory removeIndex:idx. |
|
2466 |
pos := DirectoryHistoryWhere at:idx. |
|
2467 |
DirectoryHistoryWhere removeIndex:idx. |
|
2468 |
]. |
|
2469 |
DirectoryHistory addFirst:path. |
|
2470 |
DirectoryHistoryWhere addFirst:pos. |
|
2471 |
]. |
|
2472 |
||
2473 |
self setCurrentDirectory:(f pathName). |
|
2474 |
||
2475 |
"/ fetch the new path. |
|
2476 |
path := currentDirectory pathName. |
|
2477 |
||
2478 |
" |
|
2479 |
if we have already been there, look for the |
|
2480 |
position offset, and scroll the fileList |
|
2481 |
" |
|
2482 |
idx := DirectoryHistory indexOf:path. |
|
2483 |
idx ~~ 0 ifTrue:[ |
|
2484 |
|pos| |
|
2485 |
||
2486 |
pos := DirectoryHistoryWhere at:idx. |
|
2487 |
pos notNil ifTrue:[ |
|
2488 |
fileListView scrollToLine:pos. |
|
2489 |
] |
|
2490 |
]. |
|
2491 |
||
2492 |
"/ updateHistory ifTrue:[ |
|
2493 |
"/ |pos| |
|
2494 |
"/ |
|
2495 |
"/ (DirectoryHistory includes:path) ifFalse:[ |
|
2496 |
"/ DirectoryHistory size >= HistorySize ifTrue:[ |
|
2497 |
"/ DirectoryHistory removeLast. |
|
2498 |
"/ DirectoryHistoryWhere removeLast |
|
2499 |
"/ ] |
|
2500 |
"/ ] ifTrue:[ |
|
2501 |
"/ "already been there before; move the entry to |
|
2502 |
"/ the beginning, so it will fall out later." |
|
2503 |
"/ |
|
2504 |
"/ idx := DirectoryHistory indexOf:path. |
|
2505 |
"/ DirectoryHistory removeIndex:idx. |
|
2506 |
"/ pos := DirectoryHistoryWhere at:idx. |
|
2507 |
"/ DirectoryHistoryWhere removeIndex:idx. |
|
2508 |
"/ ]. |
|
2509 |
"/ DirectoryHistory addFirst:path. |
|
2510 |
"/ DirectoryHistoryWhere addFirst:pos. |
|
2511 |
"/ ]. |
|
2512 |
||
2513 |
^ self |
|
2514 |
]. |
|
2515 |
msg := 'cannot change directory to ''%1'' !!' |
|
2516 |
] ifFalse:[ |
|
2517 |
msg := 'cannot read directory ''%1'' !!' |
|
2518 |
] |
|
2519 |
] ifFalse:[ |
|
2520 |
OperatingSystem platformName == #vms ifTrue:[ |
|
2521 |
"/ cannot tell if it exists or is simply invisible ... |
|
2522 |
msg := '''%1'' is not a directory or unreadable !!' |
|
2523 |
] ifFalse:[ |
|
2524 |
msg := '''%1'' is not a directory !!' |
|
2525 |
] |
|
2526 |
]. |
|
2527 |
self showAlert:(resources string:msg with:fileName) with:nil |
|
172 | 2528 |
] |
1166
0029f77ccea7
when updating the directoryList,
Claus Gittinger <cg@exept.de>
parents:
1162
diff
changeset
|
2529 |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2530 |
"Modified: 18.9.1997 / 18:22:30 / stefan" |
1329 | 2531 |
"Modified: 21.9.1997 / 23:43:22 / cg" |
2532 |
! |
|
2533 |
||
2534 |
doChangeToDefaultDirectory |
|
2535 |
"go to parent directory" |
|
2536 |
||
2537 |
self doChangeCurrentDirectoryTo:(Filename currentDirectory pathName) updateHistory:true |
|
2538 |
||
2539 |
"Created: 21.9.1997 / 23:45:59 / cg" |
|
172 | 2540 |
! |
2541 |
||
2542 |
doChangeToHomeDirectory |
|
2543 |
"go to home directory" |
|
2544 |
||
2545 |
self doChangeCurrentDirectoryTo:(OperatingSystem getHomeDirectory) updateHistory:true |
|
2546 |
! |
|
2547 |
||
2548 |
doChangeToParentDirectory |
|
1317 | 2549 |
"go to parent directory" |
36 | 2550 |
|
172 | 2551 |
self doChangeCurrentDirectoryTo:'..' updateHistory:true |
2552 |
! |
|
2553 |
||
2554 |
doCreateDirectory:newName |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2555 |
|f| |
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2556 |
|
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2557 |
f := currentDirectory filenameFor:newName. |
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2558 |
f exists ifTrue:[ |
1329 | 2559 |
self warn:'%1 already exists.' with:newName. |
2560 |
^ self |
|
172 | 2561 |
]. |
2562 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2563 |
f makeDirectory ifTrue:[ |
1329 | 2564 |
self updateCurrentDirectoryIfChanged |
172 | 2565 |
] ifFalse:[ |
1329 | 2566 |
self showAlert:(resources string:'cannot create directory ''%1'' !!' with:newName) |
2567 |
with:(OperatingSystem lastErrorString) |
|
172 | 2568 |
] |
1157
667a57034e40
only update if the directory did change (after execute command)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
2569 |
|
667a57034e40
only update if the directory did change (after execute command)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
2570 |
"Modified: 19.4.1997 / 15:30:32 / cg" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2571 |
"Modified: 18.9.1997 / 17:21:25 / stefan" |
172 | 2572 |
! |
2573 |
||
1162 | 2574 |
setCurrentDirectory:aPathName |
2575 |
"setup for another directory" |
|
2576 |
||
2577 |
|newDirectory| |
|
2578 |
||
2579 |
aPathName isEmpty ifTrue:[^ self]. |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2580 |
newDirectory := currentDirectory filenameFor:aPathName. |
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2581 |
newDirectory isDirectory ifTrue:[ |
1329 | 2582 |
self currentDirectory:newDirectory. |
2583 |
currentFileName notNil ifTrue:[ |
|
2584 |
fileListView contents:nil. |
|
2585 |
currentFileName := nil. |
|
2586 |
] ifFalse:[ |
|
2587 |
fileListView setSelection:nil. |
|
2588 |
fileListView scrollToTop. |
|
2589 |
]. |
|
2590 |
self updateCurrentDirectory. |
|
2591 |
self showInfo. |
|
172 | 2592 |
] |
294 | 2593 |
|
1162 | 2594 |
"Modified: 21.9.1995 / 11:22:45 / claus" |
2595 |
"Modified: 25.5.1996 / 12:27:01 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2596 |
"Modified: 18.9.1997 / 17:08:07 / stefan" |
912
dae70963b64c
define language specific commentStrings
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
2597 |
! |
dae70963b64c
define language specific commentStrings
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
2598 |
|
1162 | 2599 |
updateCurrentDirectoryIfChanged |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2600 |
(currentDirectory modificationTime > timeOfLastCheck) ifTrue:[ |
1329 | 2601 |
self updateCurrentDirectory |
1162 | 2602 |
] |
2603 |
||
2604 |
"Modified: 19.4.1997 / 15:30:03 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2605 |
"Modified: 16.9.1997 / 15:35:52 / stefan" |
1162 | 2606 |
! ! |
2607 |
||
2608 |
!FileBrowser methodsFor:'private - encoding'! |
|
172 | 2609 |
|
395 | 2610 |
guessEncodingFrom:aBuffer |
988 | 2611 |
"look for a string |
1317 | 2612 |
encoding #name |
988 | 2613 |
or: |
1317 | 2614 |
encoding: name |
1209 | 2615 |
within the given buffer |
2616 |
(which is usually the first few bytes of a textFile). |
|
2617 |
If thats not found, use heuristics (in CharacterArray) to guess." |
|
988 | 2618 |
|
395 | 2619 |
|n "{Class: SmallInteger }" |
1209 | 2620 |
binary idx s w enc| |
395 | 2621 |
|
2622 |
binary := false. |
|
2623 |
n := aBuffer size. |
|
2624 |
||
1223 | 2625 |
(idx := aBuffer findString:'charset=') ~~ 0 ifTrue:[ |
1317 | 2626 |
s := ReadStream on:aBuffer. |
2627 |
s position:idx + 8. |
|
2628 |
s skipSeparators. |
|
2629 |
w := s upToSeparator. |
|
2630 |
w notNil ifTrue:[ |
|
2631 |
(idx := w indexOf:$") ~~ 0 ifTrue:[ |
|
2632 |
w := w copyTo:idx-1 |
|
2633 |
]. |
|
2634 |
^ w asSymbol |
|
2635 |
]. |
|
1223 | 2636 |
]. |
807 | 2637 |
(idx := aBuffer findString:'encoding') ~~ 0 ifTrue:[ |
1317 | 2638 |
s := ReadStream on:aBuffer. |
2639 |
s position:idx + 8. |
|
2640 |
s skipSeparators. |
|
2641 |
s peek == $: ifTrue:[ |
|
2642 |
s next. |
|
2643 |
s skipSeparators. |
|
2644 |
]. |
|
2645 |
||
2646 |
s peek == $# ifTrue:[ |
|
2647 |
s next. |
|
2648 |
s skipSeparators. |
|
2649 |
]. |
|
2650 |
w := s upToSeparator. |
|
2651 |
w notNil ifTrue:[ |
|
2652 |
^ w asSymbol |
|
2653 |
]. |
|
807 | 2654 |
]. |
2655 |
||
395 | 2656 |
1 to:n do:[:i | |
1317 | 2657 |
(aBuffer at:i) isPrintable ifFalse:[binary := true]. |
395 | 2658 |
]. |
807 | 2659 |
|
395 | 2660 |
binary ifTrue:[ |
1317 | 2661 |
"/ look for JIS7 / EUC encoding |
2662 |
||
2663 |
enc := CharacterArray guessEncodingFrom:aBuffer. |
|
2664 |
enc notNil ifTrue:[ |
|
2665 |
^ enc |
|
2666 |
]. |
|
2667 |
||
2668 |
"/ if the encoding has been set to any non iso setting, |
|
2669 |
"/ assume its what we defined ... |
|
2670 |
||
2671 |
(('iso*' match:fileEncoding) or:['ascii*' match:fileEncoding]) ifTrue:[ |
|
2672 |
^ #binary |
|
2673 |
]. |
|
2674 |
^ fileEncoding ? #binary |
|
395 | 2675 |
]. |
2676 |
^ #ascii |
|
2677 |
||
2678 |
"Created: 26.2.1996 / 17:43:08 / cg" |
|
1223 | 2679 |
"Modified: 1.7.1997 / 00:00:27 / cg" |
1214
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2680 |
! |
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2681 |
|
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2682 |
preferredFontEncodingFor:fileEncoding |
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2683 |
"given a file encoding, return corresponding preferred fontEncoding |
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2684 |
match pattern" |
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2685 |
|
1223 | 2686 |
|fe| |
2687 |
||
2688 |
fe := MIMETypes fontForCharset:fileEncoding. |
|
2689 |
fe notNil ifTrue:[^ fe]. |
|
1221 | 2690 |
^ 'iso8859*' |
1214
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2691 |
|
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2692 |
"Created: 28.6.1997 / 20:47:35 / cg" |
1223 | 2693 |
"Modified: 1.7.1997 / 00:04:56 / cg" |
395 | 2694 |
! |
2695 |
||
1140 | 2696 |
validateFontEncodingFor:newEncoding ask:ask |
2697 |
"if required, query user if he/she wants to change to another font, |
|
2698 |
which is able to display text encoded as specified by newEncoding" |
|
2699 |
||
1214
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2700 |
|fontsEncoding msg filter f defaultFont pref| |
1140 | 2701 |
|
2702 |
fontsEncoding := subView font encoding. |
|
2703 |
||
1221 | 2704 |
pref := self preferredFontEncodingFor:newEncoding. |
2705 |
||
2706 |
(pref match:fontsEncoding) ifTrue:[ |
|
1317 | 2707 |
^ self |
1140 | 2708 |
]. |
1221 | 2709 |
"/ stupid ... |
2710 |
pref = 'ascii*' ifTrue:[ |
|
1317 | 2711 |
(fontsEncoding match:'iso8859*') ifTrue:[ |
2712 |
^ self |
|
2713 |
] |
|
1140 | 2714 |
]. |
2715 |
||
1221 | 2716 |
filter := [:f | |coding| |
1317 | 2717 |
(coding := f encoding) notNil |
2718 |
and:[pref match:coding]]. |
|
1221 | 2719 |
|
2720 |
defaultFont := TextView defaultFont onDevice:device. |
|
2721 |
(pref match:(defaultFont encoding)) ifFalse:[ |
|
1317 | 2722 |
defaultFont := nil. |
1140 | 2723 |
]. |
2724 |
||
1221 | 2725 |
defaultFont isNil ifTrue:[ |
1317 | 2726 |
(pref = 'ascii*' |
2727 |
or:[pref = 'iso8859*']) ifTrue:[ |
|
2728 |
defaultFont := FontDescription family:'courier' face:'medium' style:'roman' size:12 |
|
2729 |
] |
|
1221 | 2730 |
]. |
2731 |
||
2732 |
defaultFont isNil ifTrue:[ |
|
1317 | 2733 |
defaultFont := device |
2734 |
listOfAvailableFonts |
|
2735 |
detect:[:f | filter value:f] |
|
2736 |
ifNone:nil. |
|
2737 |
defaultFont isNil ifTrue:[ |
|
2738 |
||
2739 |
"/ flush list, and refetch font list |
|
2740 |
"/ (in case someone just changed the font path ...) |
|
2741 |
||
2742 |
device flushListOfAvailableFonts. |
|
2743 |
defaultFont := device |
|
2744 |
listOfAvailableFonts |
|
2745 |
detect:[:f | filter value:f] |
|
2746 |
ifNone:nil. |
|
2747 |
]. |
|
2748 |
||
2749 |
defaultFont isNil ifTrue:[ |
|
2750 |
self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'. |
|
2751 |
^ self. |
|
2752 |
] |
|
1221 | 2753 |
]. |
2754 |
||
2755 |
msg := 'switch to a %1 encoded font ?'. |
|
2756 |
(ask not or:[self confirm:(resources string:msg with:pref) withCRs]) |
|
2757 |
ifTrue:[ |
|
1317 | 2758 |
self withWaitCursorDo:[ |
2759 |
f := FontPanel |
|
2760 |
fontFromUserInitial:defaultFont |
|
2761 |
title:(resources string:'font selection') |
|
2762 |
filter:filter. |
|
2763 |
f notNil ifTrue:[ |
|
2764 |
subView font:f |
|
2765 |
] |
|
2766 |
] |
|
1140 | 2767 |
] |
2768 |
||
2769 |
"Created: 26.10.1996 / 12:06:54 / cg" |
|
1221 | 2770 |
"Modified: 30.6.1997 / 17:46:46 / cg" |
1162 | 2771 |
! ! |
2772 |
||
2773 |
!FileBrowser methodsFor:'private - file stuff'! |
|
2774 |
||
2775 |
doCreateFile:newName |
|
2776 |
"create an empty file" |
|
2777 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2778 |
|aStream f| |
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2779 |
|
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2780 |
f := currentDirectory filenameFor:newName. |
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2781 |
f exists ifTrue:[ |
1329 | 2782 |
(self |
2783 |
ask:(resources string:'%1 already exists\\truncate ?' with:newName) |
|
2784 |
yesButton:'truncate' |
|
2785 |
) ifFalse:[^ self]. |
|
1162 | 2786 |
]. |
2787 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2788 |
FileStream openErrorSignal handle:[:ex| |
1329 | 2789 |
^ self showAlert:(resources string:'cannot create file ''%1'' !!' with:newName) |
2790 |
with:(FileStream lastErrorString) |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2791 |
] do:[ |
1329 | 2792 |
aStream := f newReadWriteStream. |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2793 |
]. |
1162 | 2794 |
aStream notNil ifTrue:[ |
1329 | 2795 |
aStream close. |
2796 |
self updateCurrentDirectoryIfChanged |
|
1162 | 2797 |
] ifFalse:[ |
1329 | 2798 |
self showAlert:(resources string:'cannot create file ''%1'' !!' with:newName) |
2799 |
with:(FileStream lastErrorString) |
|
1162 | 2800 |
] |
2801 |
||
2802 |
"Modified: 23.4.1997 / 13:19:12 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2803 |
"Modified: 18.9.1997 / 17:21:45 / stefan" |
1140 | 2804 |
! |
2805 |
||
1162 | 2806 |
doFileGet:viaDoubleClick |
2807 |
"get selected file - show contents in subView. |
|
2808 |
This is invoked either by the 'get file' menu item, or via double click. |
|
2809 |
When invoked via the menu (viaDoubleClick argument is false), |
|
2810 |
the automatic file action is not performed - instead, the file is always |
|
2811 |
shown in the codeView (if possible). |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2812 |
This distinction was done to allow xpm or xbm files (which have an automatic |
1162 | 2813 |
action) to be edited." |
2814 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2815 |
|fileName iconLbl winLbl f| |
1162 | 2816 |
|
2817 |
self withReadCursorDo:[ |
|
1329 | 2818 |
fileName := self getSelectedFileName. |
2819 |
fileName notNil ifTrue:[ |
|
2820 |
f := currentDirectory construct:fileName. |
|
2821 |
f isDirectory ifTrue:[ |
|
2822 |
self doChangeCurrentDirectoryTo:fileName updateHistory:true. |
|
2823 |
winLbl := myName. |
|
2824 |
iconLbl := myName |
|
2825 |
] ifFalse:[ |
|
2826 |
f exists ifFalse:[ |
|
2827 |
self warn:(resources string:'oops, ''%1'' is gone or unreadable.' with:fileName). |
|
2828 |
^ self |
|
2829 |
]. |
|
2830 |
timeOfFileRead := f modificationTime. |
|
2831 |
self showFile:fileName insert:false encoding:fileEncoding doubleClick:viaDoubleClick. |
|
2832 |
currentFileName := fileName. |
|
2833 |
||
2834 |
self fileTypeSpecificActions. |
|
2835 |
||
2836 |
subView acceptAction:[:theCode | |
|
2837 |
self withCursor:(Cursor write) do:[ |
|
2838 |
self writeFile:fileName text:theCode encoding:fileEncoding. |
|
2839 |
timeOfFileRead := f modificationTime. |
|
2840 |
self label:myName , ': ' , currentFileName |
|
2841 |
] |
|
2842 |
]. |
|
2843 |
||
2844 |
winLbl := myName , ': ' , fileName. |
|
2845 |
f isWritable ifFalse:[ |
|
2846 |
winLbl := winLbl , ' (readonly)' |
|
2847 |
]. |
|
2848 |
iconLbl := fileName |
|
2849 |
]. |
|
2850 |
self label:winLbl. |
|
2851 |
self iconLabel:iconLbl. |
|
2852 |
] |
|
1162 | 2853 |
] |
2854 |
||
2855 |
"Created: 19.6.1996 / 09:39:07 / cg" |
|
2856 |
"Modified: 23.4.1997 / 13:19:01 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2857 |
"Modified: 18.9.1997 / 17:35:31 / stefan" |
1162 | 2858 |
! |
2859 |
||
2860 |
doRemove |
|
2861 |
"remove the selected file(s) - no questions asked" |
|
2862 |
||
1330 | 2863 |
|ok msg idx needUpdate toRemove updateRunning f| |
1162 | 2864 |
|
2865 |
updateRunning := listUpdateProcess notNil. |
|
2866 |
self stopUpdateProcess. |
|
2867 |
toRemove := OrderedCollection new. |
|
2868 |
||
2869 |
"/ |
|
2870 |
"/ did the directory change in the meanwhile ? |
|
2871 |
"/ |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2872 |
needUpdate := (currentDirectory modificationTime > timeOfLastCheck). |
1162 | 2873 |
|
2874 |
lockUpdate := true. |
|
2875 |
[ |
|
1329 | 2876 |
self selectedFilesDo:[:fileName | |
1330 | 2877 |
|contents| |
2878 |
||
1329 | 2879 |
f := currentDirectory construct:fileName. |
2880 |
OperatingSystem accessDeniedErrorSignal handle:[:ex| |
|
2881 |
"was not able to remove it" |
|
2882 |
msg := (resources string:'cannot remove ''%1'' !!' with:fileName). |
|
2883 |
self showAlert:msg with:(OperatingSystem lastErrorString) |
|
2884 |
] do:[ |
|
2885 |
f isDirectory ifTrue:[ |
|
1330 | 2886 |
contents := f directoryContents. |
2887 |
contents isEmpty ifTrue:[ |
|
1329 | 2888 |
f remove |
2889 |
] ifFalse:[ |
|
2890 |
(self |
|
2891 |
ask:(resources string:'directory ''%1'' is not empty\remove anyway ?' with:fileName) |
|
2892 |
yesButton:'remove') |
|
2893 |
ifFalse:[ |
|
2894 |
^ self |
|
2895 |
]. |
|
2896 |
f recursiveRemove |
|
2897 |
]. |
|
2898 |
] ifFalse:[ |
|
2899 |
f remove. |
|
2900 |
]. |
|
1162 | 2901 |
" |
1329 | 2902 |
self show:nil |
1162 | 2903 |
" |
1329 | 2904 |
idx := fileList indexOf:fileName. |
2905 |
idx ~~ 0 ifTrue:[ |
|
2906 |
toRemove add:idx. |
|
2907 |
] |
|
2908 |
]. |
|
2909 |
]. |
|
1162 | 2910 |
] valueNowOrOnUnwindDo:[ |
1329 | 2911 |
lockUpdate := false. |
2912 |
fileListView setSelection:nil. |
|
2913 |
||
2914 |
"/ |
|
2915 |
"/ remove reverse - otherwise indices are wrong |
|
2916 |
"/ |
|
2917 |
toRemove sort. |
|
2918 |
toRemove reverseDo:[:idx | |
|
2919 |
fileList removeIndex:idx. |
|
2920 |
fileListView removeIndex:idx. |
|
2921 |
]. |
|
2922 |
||
2923 |
updateRunning ifTrue:[ |
|
2924 |
self updateCurrentDirectory |
|
2925 |
] ifFalse:[ |
|
2926 |
" |
|
2927 |
install a new check after some time |
|
2928 |
" |
|
2929 |
needUpdate ifFalse:[timeOfLastCheck := AbsoluteTime now]. |
|
2930 |
Processor addTimedBlock:checkBlock afterSeconds:checkDelta |
|
2931 |
] |
|
1162 | 2932 |
] |
2933 |
||
2934 |
"Modified: 19.4.1997 / 14:03:55 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2935 |
"Modified: 18.9.1997 / 18:26:18 / stefan" |
1162 | 2936 |
! |
2937 |
||
2938 |
doRename:oldName to:newName |
|
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2939 |
"rename a file (or directory)" |
1162 | 2940 |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2941 |
|old new| |
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
2942 |
|
1162 | 2943 |
(oldName notNil and:[newName notNil]) ifTrue:[ |
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2944 |
(oldName isBlank or:[newName isBlank]) ifFalse:[ |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2945 |
old := currentDirectory filenameFor:oldName. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2946 |
new := currentDirectory filenameFor:newName. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2947 |
OperatingSystem errorSignal handle:[:ex| |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2948 |
self showAlert:(resources string:'cannot rename file ''%1'' to %2 !!' |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2949 |
with:oldName with:newName) |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2950 |
with:(OperatingSystem lastErrorString) |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2951 |
] do:[ |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2952 |
old renameTo:new. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2953 |
]. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2954 |
self updateCurrentDirectoryIfChanged. |
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2955 |
] |
1162 | 2956 |
] |
2957 |
||
2958 |
"Modified: 23.4.1997 / 13:19:37 / cg" |
|
1331
73e712c85588
Handle errors when renaming files.
Stefan Vogel <sv@exept.de>
parents:
1330
diff
changeset
|
2959 |
"Modified: 24.9.1997 / 09:20:00 / stefan" |
1162 | 2960 |
! ! |
2961 |
||
2962 |
!FileBrowser methodsFor:'private - file type & info'! |
|
2963 |
||
2964 |
fileCommentStrings |
|
2965 |
"return a useful comment definition; based upon the fileName for now" |
|
2966 |
||
2967 |
"/ for now, |
|
2968 |
"/ define comment strings, by heuristics; |
|
2969 |
"/ (should look for some mode= or similar string |
|
2970 |
"/ found in the file itself - like emacs does it) |
|
2971 |
||
2972 |
(currentFileName = 'Make.proto' |
|
2973 |
or:[currentFileName = 'Makefile' |
|
2974 |
or:[currentFileName = 'makefile']]) ifTrue:[ |
|
1317 | 2975 |
^ #('#' (nil nil)). |
1162 | 2976 |
]. |
2977 |
((currentFileName endsWith:'.c') |
|
2978 |
or:[(currentFileName endsWith:'.C')]) ifTrue:[ |
|
1317 | 2979 |
^ #(nil ('/*' '*/')). |
1162 | 2980 |
]. |
2981 |
((currentFileName endsWith:'.cc') |
|
2982 |
or:[(currentFileName endsWith:'.CC')]) ifTrue:[ |
|
1317 | 2983 |
^ #('//' ('/*' '*/')). |
1162 | 2984 |
]. |
2985 |
(currentFileName endsWith:'.java') ifTrue:[ |
|
1317 | 2986 |
^ #('//' (nil nil)). |
1162 | 2987 |
]. |
2988 |
||
2989 |
"/ smalltalk comments |
|
2990 |
||
2991 |
^ #('"/' ('"' '"')). |
|
2992 |
||
2993 |
"Created: 7.1.1997 / 20:30:00 / cg" |
|
2994 |
"Modified: 23.4.1997 / 13:11:49 / cg" |
|
2995 |
! |
|
2996 |
||
2997 |
fileTypeSpecificActions |
|
2998 |
"any special fileTypeSpecific actions are done here, |
|
2999 |
when a new file is selected" |
|
3000 |
||
3001 |
|commentStrings| |
|
3002 |
||
3003 |
commentStrings := self fileCommentStrings. |
|
3004 |
commentStrings notNil ifTrue:[ |
|
1317 | 3005 |
subView |
3006 |
commentStrings:#('#' (nil nil)). |
|
1162 | 3007 |
]. |
3008 |
||
3009 |
"Modified: 7.1.1997 / 20:30:54 / cg" |
|
3010 |
! |
|
3011 |
||
3012 |
getFileInfoString:longInfo |
|
3013 |
"get stat info on selected file - return a string which can be |
|
3014 |
shown in a box" |
|
3015 |
||
3016 |
|fileName f fullPath text info fileOutput type modeBits modeString s ts| |
|
3017 |
||
3018 |
fileName := self getSelectedFileName. |
|
3019 |
fileName isNil ifTrue:[^ nil]. |
|
3020 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3021 |
f := currentDirectory construct:fileName. |
1162 | 3022 |
info := f info. |
3023 |
||
3024 |
info isNil ifTrue:[ |
|
1329 | 3025 |
self showAlert:(resources string:'cannot get info of ''%1'' !!' with:fileName) |
3026 |
with:(OperatingSystem lastErrorString). |
|
3027 |
^ nil |
|
1162 | 3028 |
]. |
3029 |
||
3030 |
text := StringCollection new. |
|
3031 |
f isSymbolicLink ifTrue:[ |
|
1329 | 3032 |
text add:(resources string:'symbolic link to: %1' with:(f linkInfo path)) |
1162 | 3033 |
]. |
3034 |
||
3035 |
type := info type. |
|
3036 |
(longInfo and:[type == #regular]) ifTrue:[ |
|
1329 | 3037 |
fullPath := currentDirectory pathName asFilename constructString:fileName. |
3038 |
fileOutput := fullPath asFilename fileType. |
|
1162 | 3039 |
]. |
3040 |
||
3041 |
s := (resources at:'type: '). |
|
3042 |
fileOutput isNil ifTrue:[ |
|
1329 | 3043 |
s := s , type asString |
1162 | 3044 |
] ifFalse:[ |
1329 | 3045 |
s := s , 'regular (' , fileOutput , ')' |
1162 | 3046 |
]. |
3047 |
text add:s. |
|
3048 |
text add:(resources string:'size: %1' with:(info size) printString). |
|
3049 |
||
3050 |
modeBits := info mode. |
|
3051 |
modeString := self getModeString:modeBits. |
|
3052 |
longInfo ifTrue:[ |
|
1329 | 3053 |
text add:(resources string:'access: %1 (%2)' |
3054 |
with:modeString |
|
3055 |
with:(modeBits printStringRadix:8)) |
|
1162 | 3056 |
] ifFalse:[ |
1329 | 3057 |
text add:(resources string:'access: %1' with:modeString) |
1162 | 3058 |
]. |
3059 |
text add:(resources string:'owner: %1' |
|
1329 | 3060 |
with:(OperatingSystem getUserNameFromID:(info uid))). |
1162 | 3061 |
longInfo ifTrue:[ |
1329 | 3062 |
text add:(resources string:'group: %1' |
3063 |
with:(OperatingSystem getGroupNameFromID:(info gid))). |
|
3064 |
||
3065 |
ts := info accessed. |
|
3066 |
text add:(resources string:'last access: %1 %2' |
|
3067 |
with:(ts asTime printString) |
|
3068 |
with:(ts asDate printString)). |
|
3069 |
||
3070 |
ts := info modified. |
|
3071 |
text add:(resources string:'last modification: %1 %2' |
|
3072 |
with:(ts asTime printString) |
|
3073 |
with:(ts asDate printString)). |
|
1162 | 3074 |
]. |
3075 |
^ text asString |
|
3076 |
||
3077 |
"Modified: 8.9.1995 / 11:59:28 / claus" |
|
3078 |
"Modified: 1.11.1996 / 20:47:52 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3079 |
"Modified: 18.9.1997 / 16:34:31 / stefan" |
1162 | 3080 |
! |
3081 |
||
3082 |
getInfoFile |
|
3083 |
"get filename of a description-file (.dir.info, README etc.); |
|
3084 |
This file is automatically shown when a directory is enterred. |
|
3085 |
You can add more names below if you like." |
|
3086 |
||
3087 |
#( |
|
3088 |
'.dir.info' |
|
3089 |
'README' |
|
3090 |
'ReadMe' |
|
3091 |
'Readme' |
|
3092 |
'readme' |
|
3093 |
'read.me' |
|
3094 |
'Read.me' |
|
3095 |
'READ.ME' |
|
1272 | 3096 |
'README.TXT' |
3097 |
'readme.txt' |
|
3098 |
'Readme.txt' |
|
1307 | 3099 |
'Info.txt' |
3100 |
'info.txt' |
|
3101 |
'INFO.TXT' |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3102 |
) do:[:f | |
1329 | 3103 |
|n| |
3104 |
n := currentDirectory construct:f. |
|
3105 |
(n isReadable and:[n isDirectory not]) ifTrue:[ |
|
3106 |
^ f. |
|
3107 |
] |
|
1140 | 3108 |
]. |
1162 | 3109 |
^ nil |
3110 |
||
1272 | 3111 |
"Modified: 3.8.1997 / 16:50:33 / cg" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3112 |
"Modified: 16.9.1997 / 15:26:53 / stefan" |
1162 | 3113 |
! |
3114 |
||
3115 |
getModeString:modeBits |
|
3116 |
"convert file-mode bits into a more user-friendly string. |
|
3117 |
This is wrong here - should be moved into OperatingSystem." |
|
3118 |
||
3119 |
^ self getModeString:modeBits |
|
1317 | 3120 |
with:#( 'owner:' $r $w $x |
3121 |
' group:' $r $w $x |
|
3122 |
' others:' $r $w $x ) |
|
1140 | 3123 |
! |
3124 |
||
1162 | 3125 |
getModeString:modeBits with:texts |
3126 |
"convert file-mode bits into a more user-friendly string. |
|
3127 |
This is wrong here - should be moved into OperatingSystem." |
|
3128 |
||
3129 |
|bits modeString| |
|
3130 |
||
3131 |
bits := modeBits bitAnd:8r777. |
|
3132 |
modeString := ''. |
|
3133 |
||
3134 |
#( nil 8r400 8r200 8r100 nil 8r040 8r020 8r010 nil 8r004 8r002 8r001 ) |
|
3135 |
with: texts do:[:bitMask :access | |
|
1317 | 3136 |
|ch| |
3137 |
||
3138 |
bitMask isNil ifTrue:[ |
|
3139 |
modeString := modeString , (resources string:access) |
|
3140 |
] ifFalse:[ |
|
3141 |
(bits bitAnd:bitMask) == 0 ifTrue:[ |
|
3142 |
ch := $- |
|
3143 |
] ifFalse:[ |
|
3144 |
ch := access |
|
3145 |
]. |
|
3146 |
modeString := modeString copyWith:ch |
|
3147 |
] |
|
633
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
3148 |
]. |
1162 | 3149 |
^ modeString |
3150 |
! |
|
3151 |
||
3152 |
showInfo |
|
3153 |
"show directory info when dir has changed" |
|
3154 |
||
3155 |
|info txt| |
|
3156 |
||
3157 |
info := self getInfoFile. |
|
3158 |
info notNil ifTrue:[ |
|
1317 | 3159 |
txt := self readFile:info |
1162 | 3160 |
]. |
3161 |
self show:txt. |
|
3162 |
! |
|
3163 |
||
3164 |
sizePrintString:size |
|
3165 |
"helper for update-directory to return a string with a files size. |
|
3166 |
This one gives the size in byte, Kb or Mb depending on size. |
|
3167 |
If you dont like this, just uncomment the first statement below." |
|
3168 |
||
3169 |
|unitString n| |
|
3170 |
||
3171 |
" |
|
3172 |
^ size printString. |
|
3173 |
" |
|
3174 |
unitString := ''. |
|
3175 |
size < (500 * 1024) ifTrue:[ |
|
1317 | 3176 |
size < 1024 ifTrue:[ |
3177 |
n := size |
|
3178 |
] ifFalse:[ |
|
3179 |
n := (size * 10 // 1024 / 10.0). |
|
3180 |
unitString := ' Kb' |
|
3181 |
] |
|
1162 | 3182 |
] ifFalse:[ |
1317 | 3183 |
n := (size * 10 // 1024 // 1024 / 10.0). |
3184 |
unitString := ' Mb' |
|
1162 | 3185 |
]. |
3186 |
^ (n printStringLeftPaddedTo:5) , unitString. |
|
3187 |
! ! |
|
3188 |
||
3189 |
!FileBrowser methodsFor:'private - file-I/O'! |
|
3190 |
||
3191 |
readFile:fileName |
|
3192 |
"read in the file, answer its contents as StringCollection" |
|
3193 |
||
3194 |
^ self readFile:fileName lineDelimiter:Character cr encoding:nil |
|
3195 |
||
3196 |
"Modified: 22.2.1996 / 14:57:08 / cg" |
|
3197 |
! |
|
3198 |
||
3199 |
readFile:fileName lineDelimiter:aCharacter encoding:encoding |
|
3200 |
"read in the file, return its contents as StringCollection. |
|
3201 |
The files lines are delimited by aCharacter. |
|
3202 |
If encoding is nonNil, the file is assumed to be coded according to |
|
3203 |
that symbol, and #decodeString: should be able to convert it." |
|
3204 |
||
3205 |
|stream text msg sz| |
|
3206 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3207 |
stream := (currentDirectory construct:fileName) readStream. |
1162 | 3208 |
stream isNil ifTrue:[ |
1329 | 3209 |
msg := (resources string:'cannot read file ''%1'' !!' with:fileName). |
3210 |
self showAlert:msg with:(FileStream lastErrorString). |
|
3211 |
^ nil |
|
1162 | 3212 |
]. |
3213 |
||
3214 |
" |
|
3215 |
for very big files, give ObjectMemory a hint, to preallocate more |
|
3216 |
" |
|
1311 | 3217 |
(sz := stream fileSize) > 1000000 ifTrue:[ |
1329 | 3218 |
Processor activeProcess withPriority:Processor userBackgroundPriority do:[ |
3219 |
ObjectMemory announceSpaceNeed:(sz + (sz // 5)) "/ add 20% for tab expansion |
|
3220 |
]. |
|
1162 | 3221 |
]. |
3222 |
||
3223 |
text := self readStream:stream lineDelimiter:aCharacter encoding:encoding. |
|
3224 |
stream close. |
|
3225 |
^ text |
|
3226 |
||
3227 |
"Created: 22.2.1996 / 14:56:48 / cg" |
|
3228 |
"Modified: 8.10.1996 / 21:01:57 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3229 |
"Modified: 18.9.1997 / 17:06:54 / stefan" |
1162 | 3230 |
! |
3231 |
||
3232 |
readStream:aStream |
|
3233 |
"read in from aStream, answer its contents as StringCollection" |
|
3234 |
||
3235 |
^ self readStream:aStream lineDelimiter:Character cr encoding:nil |
|
3236 |
||
3237 |
"Modified: 22.2.1996 / 14:58:40 / cg" |
|
633
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
3238 |
! |
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
3239 |
|
1162 | 3240 |
readStream:aStream lineDelimiter:aCharacter encoding:encoding |
3241 |
"read from aStream, answer its contents as StringCollection. |
|
3242 |
The files lines are delimited by aCharacter. |
|
3243 |
If encoding is nonNil, the file is assumed to be coded according to |
|
3244 |
that symbol, and #decodeString: should be able to convert it." |
|
3245 |
||
3246 |
|text line enc| |
|
3247 |
||
3248 |
text := StringCollection new. |
|
3249 |
||
3250 |
enc := encoding. |
|
3251 |
enc == #iso8859 ifTrue:[ |
|
1317 | 3252 |
enc := nil |
1162 | 3253 |
]. |
3254 |
||
3255 |
aCharacter == Character cr ifTrue:[ |
|
1317 | 3256 |
[aStream atEnd] whileFalse:[ |
3257 |
line := aStream nextLine withTabsExpanded. |
|
3258 |
enc notNil ifTrue:[ |
|
3259 |
line := line decodeFrom:enc |
|
3260 |
]. |
|
3261 |
text add:line |
|
3262 |
]. |
|
1162 | 3263 |
] ifFalse:[ |
1317 | 3264 |
[aStream atEnd] whileFalse:[ |
3265 |
line := (aStream upTo:aCharacter) withTabsExpanded. |
|
3266 |
enc notNil ifTrue:[ |
|
3267 |
line := line decodeFrom:enc |
|
3268 |
]. |
|
3269 |
text add:line |
|
3270 |
]. |
|
633
4630175ed31e
double click on .htm / .html files open a viewer;
Claus Gittinger <cg@exept.de>
parents:
585
diff
changeset
|
3271 |
]. |
1162 | 3272 |
^ text |
3273 |
||
3274 |
"Created: 22.2.1996 / 14:58:25 / cg" |
|
3275 |
"Modified: 2.4.1997 / 21:31:36 / cg" |
|
3276 |
! |
|
3277 |
||
3278 |
showFile:fileName |
|
3279 |
"show contents of fileName in subView" |
|
3280 |
||
3281 |
self showFile:fileName insert:false encoding:fileEncoding |
|
3282 |
||
3283 |
"Modified: 22.2.1996 / 14:47:10 / cg" |
|
3284 |
! |
|
3285 |
||
3286 |
showFile:fileName insert:insert encoding:encoding |
|
3287 |
"show/insert contents of fileName in subView" |
|
3288 |
||
3289 |
^ self |
|
1317 | 3290 |
showFile:fileName insert:insert encoding:encoding doubleClick:false |
1162 | 3291 |
|
3292 |
"Modified: 19.6.1996 / 09:40:19 / cg" |
|
3293 |
! |
|
3294 |
||
3295 |
showFile:fileName insert:insert encoding:encoding doubleClick:viaDoubleClick |
|
3296 |
"show/insert contents of fileName in subView" |
|
3297 |
||
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3298 |
|path buffer s n i ok convert text msg eol guess action enc |
1214
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
3299 |
fontsEncoding pref failWarning| |
1162 | 3300 |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3301 |
path := currentDirectory filenameFor:fileName. |
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3302 |
(path type == #regular) ifFalse:[ |
1329 | 3303 |
"asked for a non-file - ignore it ..." |
3304 |
path exists ifFalse:[ |
|
3305 |
msg := '''%1'' does not exist !!'. |
|
3306 |
] ifTrue:[ |
|
3307 |
msg := '''%1'' is not a regular file !!'. |
|
3308 |
]. |
|
3309 |
self warn:(resources string:msg with:fileName). |
|
3310 |
^ self |
|
1162 | 3311 |
]. |
3312 |
||
3313 |
"/ |
|
3314 |
"/ check if file is a text file |
|
3315 |
"/ |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3316 |
s := path readStream. |
1162 | 3317 |
s isNil ifTrue:[ |
1329 | 3318 |
self showAlert:(resources string:'cannot read file ''%1'' !!' with:fileName) |
3319 |
with:(FileStream lastErrorString). |
|
3320 |
^ nil |
|
1162 | 3321 |
]. |
3322 |
||
1222
f2952fc3ced9
look at more when guessing the encoding
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3323 |
buffer := String new:4096. |
f2952fc3ced9
look at more when guessing the encoding
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3324 |
n := s nextBytes:4096 into:buffer. |
1162 | 3325 |
s close. |
3326 |
||
3327 |
enc := encoding. |
|
3328 |
ok := true. |
|
3329 |
guess := self guessEncodingFrom:buffer. |
|
3330 |
||
3331 |
guess == #binary ifTrue:[ |
|
1329 | 3332 |
ok := false. |
3333 |
viaDoubleClick ifTrue:[ |
|
3334 |
(self binaryFileAction:fileName) ifTrue:[^ self]. |
|
3335 |
]. |
|
3336 |
(self confirm:(resources string:'''%1'' seems to be a binary file - show anyway ?' with:fileName)) |
|
3337 |
ifFalse:[^ self] |
|
1162 | 3338 |
] ifFalse:[ |
1329 | 3339 |
viaDoubleClick ifTrue:[ |
3340 |
(self nonBinaryFileAction:fileName) ifTrue:[^ self]. |
|
3341 |
]. |
|
3342 |
||
3343 |
fontsEncoding := subView font encoding. |
|
3344 |
pref := self preferredFontEncodingFor:guess. |
|
3345 |
||
3346 |
ok := pref match:fontsEncoding. |
|
3347 |
ok ifFalse:[ |
|
3348 |
pref = 'iso8859*' ifTrue:[ |
|
3349 |
ok := 'ascii*' match:fontsEncoding |
|
3350 |
] |
|
3351 |
]. |
|
3352 |
ok ifTrue:[ |
|
3353 |
fileEncoding := guess. |
|
3354 |
enc := guess. |
|
3355 |
] ifFalse:[ |
|
3356 |
action := Dialog choose:(resources string:'''%1'' seems to require a %2 font.' with:fileName with:pref) |
|
3357 |
labels:(resources array:#('cancel' 'show' 'change font')) |
|
3358 |
values:#(nil #show #encoding) |
|
3359 |
default:#encoding. |
|
3360 |
action isNil ifTrue:[^ self]. |
|
3361 |
action == #encoding ifTrue:[ |
|
3362 |
fileEncoding := guess asSymbol. |
|
3363 |
subView externalEncoding:fileEncoding. |
|
3364 |
self validateFontEncodingFor:fileEncoding ask:false. |
|
3365 |
] ifFalse:[ |
|
3366 |
self information:(resources string:'Individual characters may be invisible/wrong in this font.') |
|
3367 |
]. |
|
3368 |
enc := fileEncoding. |
|
3369 |
]. |
|
1162 | 3370 |
]. |
3371 |
||
3372 |
convert := false. |
|
1329 | 3373 |
"/ ok ifTrue:[ |
3374 |
"/ "/ |
|
3375 |
"/ "/ check if line delimiter is a cr |
|
3376 |
"/ "/ |
|
3377 |
"/ i := buffer indexOf:Character cr. |
|
3378 |
"/ i == 0 ifTrue:[ |
|
3379 |
"/ "/ |
|
3380 |
"/ "/ no newline found - try cr |
|
3381 |
"/ "/ |
|
3382 |
"/ i := buffer indexOf:(Character value:13). |
|
3383 |
"/ i ~~ 0 ifTrue:[ |
|
3384 |
"/ convert := self confirm:(resources string:'''%1'' seems to have CR as line delimiter - convert to NL ?' with:fileName). |
|
3385 |
"/ ] |
|
3386 |
"/ ] |
|
3387 |
"/ ]. |
|
1162 | 3388 |
|
3389 |
insert ifFalse:[ |
|
1329 | 3390 |
"/ release old text first |
3391 |
"/ - we might need the memory in case of huge files |
|
3392 |
"/ (helps if you have a 4Mb file in the view, |
|
3393 |
"/ and click on another biggy) |
|
3394 |
||
3395 |
subView contents:nil. |
|
1162 | 3396 |
]. |
3397 |
||
3398 |
convert ifTrue:[ |
|
1329 | 3399 |
eol := Character value:13 |
1162 | 3400 |
] ifFalse:[ |
1329 | 3401 |
eol := Character cr |
1162 | 3402 |
]. |
1212 | 3403 |
|
1214
02d5bbd925dd
allow decoding errors to be ignored
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
3404 |
failWarning := false. |
1212 | 3405 |
CharacterArray decodingFailedSignal handle:[:ex | |
1329 | 3406 |
|errStr| |
3407 |
||
3408 |
failWarning ifFalse:[ |
|
3409 |
errStr := resources string:ex errorString. |
|
3410 |
(self confirm:(resources |
|
3411 |
string:'An error occurred while decoding:\%1\\The file has either a different encoding or is corrupted.\\Continue ?' |
|
3412 |
with:errStr) withCRs) |
|
3413 |
ifFalse:[ |
|
3414 |
^ self |
|
3415 |
]. |
|
3416 |
failWarning := true. |
|
3417 |
]. |
|
3418 |
ex proceed. |
|
1212 | 3419 |
] do:[ |
1329 | 3420 |
text := self readFile:fileName lineDelimiter:eol encoding:enc. |
1212 | 3421 |
]. |
1162 | 3422 |
|
3423 |
insert ifFalse:[ |
|
1329 | 3424 |
self show:text |
1162 | 3425 |
] ifTrue:[ |
1329 | 3426 |
subView insertSelectedStringAtCursor:text asString |
1162 | 3427 |
]. |
3428 |
||
3429 |
"Created: 19.6.1996 / 09:39:52 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3430 |
"Modified: 18.9.1997 / 17:10:20 / stefan" |
1329 | 3431 |
"Modified: 22.9.1997 / 10:02:38 / cg" |
1162 | 3432 |
! |
3433 |
||
3434 |
writeFile:fileName text:someText encoding:encoding |
|
1353 | 3435 |
|stream errReason msg startNr nLines string| |
3436 |
||
3437 |
errReason := ''. |
|
3438 |
FileStream streamErrorSignal handle:[:ex | |
|
3439 |
errReason := ex errorString. |
|
3440 |
ex return. |
|
3441 |
] do:[ |
|
3442 |
stream := (currentDirectory filenameFor:fileName) writeStream. |
|
3443 |
]. |
|
1162 | 3444 |
stream isNil ifTrue:[ |
1353 | 3445 |
msg := (resources string:'cannot write file ''%1'' !!' with:fileName). |
3446 |
self showAlert:msg with:errReason. |
|
3447 |
^ self. |
|
3448 |
]. |
|
3449 |
||
3450 |
someText isString ifTrue:[ |
|
3451 |
stream nextPutAll:someText. |
|
1162 | 3452 |
] ifFalse:[ |
1353 | 3453 |
"/ |
3454 |
"/ on some systems, writing linewise is very slow (via NFS) |
|
3455 |
"/ therefore we convert to a string and write it in chunks. |
|
3456 |
"/ To avoid creating huge strings, we do it in blocks of 1000 lines. |
|
3457 |
"/ |
|
3458 |
startNr := 1. |
|
3459 |
nLines := someText size. |
|
3460 |
[startNr <= nLines] whileTrue:[ |
|
3461 |
string := someText asStringWithCRsFrom:startNr |
|
3462 |
to:((startNr + 1000) min:nLines) |
|
3463 |
compressTabs:compressTabs. |
|
3464 |
encoding notNil ifTrue:[ |
|
3465 |
string := string encodeInto:encoding |
|
3466 |
]. |
|
3467 |
stream nextPutAll:string. |
|
3468 |
startNr := startNr + 1000 + 1. |
|
3469 |
]. |
|
3470 |
]. |
|
3471 |
||
3472 |
stream close. |
|
3473 |
subView modified:false |
|
1162 | 3474 |
|
3475 |
"Created: 22.2.1996 / 15:03:10 / cg" |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3476 |
"Modified: 18.9.1997 / 17:12:44 / stefan" |
1353 | 3477 |
"Modified: 22.10.1997 / 12:34:38 / cg" |
1140 | 3478 |
! ! |
3479 |
||
3480 |
!FileBrowser methodsFor:'private - presentation'! |
|
3481 |
||
3482 |
defineTabulatorsForLongList |
|
3483 |
"define the tabs for the long list" |
|
3484 |
||
3485 |
tabSpec := TabulatorSpecification new. |
|
3486 |
tabSpec unit:#inch. |
|
3487 |
"/ tabSpec positions:#(0 0.25 2.3 4.3 5.3 6.0 6.5). |
|
3488 |
tabSpec widths: #(0.25 2 2.0 1 0.5 0.5 1"any"). |
|
3489 |
" icon name mode owner group size type" |
|
3490 |
tabSpec align: #(#left #left #left #right #right #decimal #left). |
|
3491 |
tabSpec addDependent:self. |
|
3492 |
||
3493 |
tabRulerView tabulatorSpecification:tabSpec. |
|
3494 |
||
3495 |
"Modified: 17.4.1997 / 02:56:07 / cg" |
|
172 | 3496 |
! |
3497 |
||
1140 | 3498 |
defineTabulatorsForShortList |
3499 |
"define the tabs for the short list" |
|
3500 |
||
3501 |
tabSpec := TabulatorSpecification new. |
|
3502 |
tabSpec unit:#inch. |
|
3503 |
"/ tabSpec positions:#(0 0.25 ). |
|
3504 |
tabSpec widths: #(0.25 2 ). |
|
3505 |
" icon name" |
|
3506 |
tabSpec align: #(#left #left). |
|
3507 |
tabSpec addDependent:self. |
|
3508 |
||
3509 |
tabRulerView tabulatorSpecification:tabSpec. |
|
3510 |
||
3511 |
"Created: 17.4.1997 / 02:51:41 / cg" |
|
3512 |
"Modified: 17.4.1997 / 02:55:17 / cg" |
|
3513 |
! |
|
3514 |
||
3515 |
iconForFile:aFilenameString |
|
1147 | 3516 |
"given a fileName, return an appropriate icon" |
3517 |
||
1253 | 3518 |
|f icn key key2 suff mime| |
1140 | 3519 |
|
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3520 |
f := currentDirectory construct:aFilenameString. |
1140 | 3521 |
f isDirectory ifTrue:[ |
1329 | 3522 |
f isSymbolicLink ifTrue:[ |
3523 |
key := #directoryLink |
|
3524 |
] ifFalse:[ |
|
3525 |
key := #directory. |
|
3526 |
(f isReadable not or:[f isExecutable not]) ifTrue:[ |
|
3527 |
key := #directoryLocked |
|
3528 |
]. |
|
3529 |
] |
|
1147 | 3530 |
] ifFalse:[ |
1329 | 3531 |
f isSymbolicLink ifTrue:[ |
3532 |
f isReadable not ifTrue:[ |
|
3533 |
key := #fileLocked |
|
3534 |
] ifFalse:[ |
|
3535 |
key := #fileLink |
|
3536 |
] |
|
3537 |
] ifFalse:[ |
|
3538 |
key := key2 := #file. |
|
3539 |
(f isReadable not) ifTrue:[ |
|
3540 |
key := #fileLocked |
|
3541 |
] ifFalse:[ |
|
3542 |
suff := f suffix. |
|
3543 |
mime := MIMETypes mimeTypeForSuffix:suff. |
|
3544 |
mime notNil ifTrue:[ |
|
3545 |
(mime startsWith:'image/') ifTrue:[ |
|
3546 |
key := #imageFile |
|
3547 |
] ifFalse:[ |
|
3548 |
(mime startsWith:'text/') ifTrue:[ |
|
3549 |
key := #textFile |
|
3550 |
] |
|
3551 |
] |
|
3552 |
]. |
|
3553 |
]. |
|
3554 |
]. |
|
1140 | 3555 |
]. |
1141 | 3556 |
|
3557 |
icons isNil ifTrue:[ |
|
1329 | 3558 |
icons := IdentityDictionary new |
1141 | 3559 |
]. |
1147 | 3560 |
|
1239
e58e2cb6639a
allow specification of icons from resource file.
Claus Gittinger <cg@exept.de>
parents:
1235
diff
changeset
|
3561 |
icn := icons at:key ifAbsent:nil. |
e58e2cb6639a
allow specification of icons from resource file.
Claus Gittinger <cg@exept.de>
parents:
1235
diff
changeset
|
3562 |
icn isNil ifTrue:[ |
1329 | 3563 |
Icons isNil ifTrue:[ |
3564 |
self class initializeIcons |
|
3565 |
]. |
|
3566 |
icn := Icons at:key ifAbsent:nil. |
|
3567 |
icn notNil ifTrue:[ |
|
3568 |
icn := icn on:device. |
|
3569 |
icons at:key put:icn. |
|
3570 |
] |
|
1141 | 3571 |
]. |
1253 | 3572 |
icn isNil ifTrue:[ |
1329 | 3573 |
key2 notNil ifTrue:[ |
3574 |
icn := icons at:key2 ifAbsent:nil. |
|
3575 |
icn isNil ifTrue:[ |
|
3576 |
icn := Icons at:key2 ifAbsent:nil. |
|
3577 |
icn notNil ifTrue:[ |
|
3578 |
icn := icn on:device. |
|
3579 |
icons at:key2 put:icn. |
|
3580 |
] |
|
3581 |
] |
|
3582 |
] |
|
1253 | 3583 |
]. |
1239
e58e2cb6639a
allow specification of icons from resource file.
Claus Gittinger <cg@exept.de>
parents:
1235
diff
changeset
|
3584 |
^ icn |
1141 | 3585 |
|
1253 | 3586 |
"Modified: 28.7.1997 / 09:19:11 / cg" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3587 |
"Modified: 18.9.1997 / 16:35:28 / stefan" |
36 | 3588 |
! |
3589 |
||
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
3590 |
stopUpdateProcess |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
3591 |
Processor removeTimedBlock:checkBlock. |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
3592 |
listUpdateProcess notNil ifTrue:[ |
1317 | 3593 |
listUpdateProcess terminate. |
3594 |
listUpdateProcess := nil. |
|
1156
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
3595 |
]. |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
3596 |
|
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
3597 |
"Created: 19.4.1997 / 13:51:34 / cg" |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
3598 |
! |
f3df28086973
dont do a full update when removing files
Claus Gittinger <cg@exept.de>
parents:
1154
diff
changeset
|
3599 |
|
36 | 3600 |
updateCurrentDirectory |
3601 |
"update listView with directory contents" |
|
3602 |
||
49 | 3603 |
"the code below may look somewhat complex - |
3604 |
it reads the directory first for the names, |
|
1151
194b10bad6da
great asynchronous list update;
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
3605 |
then (in followup sweeps over the files) gets the |
194b10bad6da
great asynchronous list update;
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
3606 |
files type, info and icon in a forked subprocess. |
1145
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
3607 |
This makes the Filebrowsers list update faster, since the fileInfo |
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
3608 |
(i.e. stat-calls) may take long - especially on NFS-mounted directories. |
49 | 3609 |
The file reading is done at lower priority, to let user continue |
3610 |
his work in other views. However, to be fair to other fileBrowser, |
|
3611 |
which may also read directories at low prio, give up the processor |
|
1145
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
3612 |
after every entry. This shares the cpu among all fileBrowsers; |
0464625bbdbb
read directory in a subprocess.
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
3613 |
Therefore, browsers which read short directories will finish first. |
49 | 3614 |
ST/X users love this behavior ;-) |
3615 |
" |
|
3616 |
||
294 | 3617 |
self withReadCursorDo:[ |
1329 | 3618 |
|files matchPattern list passDone f| |
3619 |
||
3620 |
self stopUpdateProcess. |
|
3621 |
||
3622 |
timeOfLastCheck := AbsoluteTime now. |
|
3623 |
||
3624 |
files := currentDirectory asFilename fullDirectoryContents. |
|
3625 |
||
3626 |
"/ (files includes:(Filename parentDirectoryName)) ifTrue:[ |
|
3627 |
"/ upButton enable. |
|
3628 |
"/ ] ifFalse:[ |
|
3629 |
"/ upButton disable. |
|
3630 |
"/ ]. |
|
3631 |
||
3632 |
"/ show files which are either directories |
|
3633 |
"/ or match the current pattern |
|
3634 |
||
3635 |
matchPattern := filterField contents. |
|
3636 |
(matchPattern notNil and:[ |
|
3637 |
matchPattern isEmpty not and:[ |
|
3638 |
matchPattern ~= '*']]) ifTrue:[ |
|
3639 |
files := files select:[:aName | |
|
3640 |
((currentDirectory construct:aName) isDirectory) |
|
3641 |
or:[matchPattern compoundMatch:aName] |
|
3642 |
]. |
|
3643 |
]. |
|
3644 |
||
3645 |
files sort. |
|
3646 |
||
3647 |
files size == 0 ifTrue:[ |
|
3648 |
self information:('directory ', currentDirectory pathName, ' vanished'). |
|
3649 |
^ self |
|
3650 |
]. |
|
3651 |
files := self withoutHiddenFiles:files. |
|
3652 |
fileList := files copy. |
|
3653 |
||
3654 |
tabSpec isNil ifTrue:[ |
|
3655 |
showLongList ifTrue:[ |
|
3656 |
self defineTabulatorsForLongList |
|
3657 |
] ifFalse:[ |
|
3658 |
self defineTabulatorsForShortList |
|
3659 |
]. |
|
3660 |
]. |
|
3661 |
||
3662 |
"/ |
|
3663 |
"/ first show all the names - this can be done fast ... |
|
3664 |
"/ |
|
3665 |
list := files collect:[:fileName | |
|
3666 |
|entry| |
|
3667 |
||
3668 |
entry := MultiColListEntry new. |
|
3669 |
entry tabulatorSpecification:tabSpec. |
|
3670 |
entry colAt:1 put:nil. |
|
3671 |
entry colAt:2 put:fileName. |
|
3672 |
]. |
|
3673 |
||
3674 |
fileListView setList:list expandTabs:false. |
|
3675 |
passDone := Array new:list size withAll:0. |
|
3676 |
||
3677 |
" |
|
3678 |
this is a time consuming operation (especially, if reading an |
|
3679 |
NFS-mounted directory); therefore, start a low prio process, |
|
3680 |
which fills in the remaining fields in the fileList ... |
|
3681 |
" |
|
3682 |
||
3683 |
listUpdateProcess := [ |
|
3684 |
|prevUid prevGid fileNameString nameString groupString |
|
3685 |
modeString info line len |
|
3686 |
anyImages lineIndex aFileName |
|
3687 |
entry typ f p typeString done endIndex |
|
3688 |
state stopAtEnd nextState img prevFirstLine prevLastLine |
|
1336 | 3689 |
numVisible dirSuffix thisIsVMS| |
1329 | 3690 |
|
3691 |
dirSuffix := Filename directorySuffix. |
|
3692 |
dirSuffix size > 0 ifTrue:[ |
|
1336 | 3693 |
dirSuffix := '.' , dirSuffix asLowercase. |
3694 |
thisIsVMS := OperatingSystem platformName == #vms. |
|
1329 | 3695 |
]. |
3696 |
||
3697 |
"/ |
|
3698 |
"/ then walk over the files, adding more info |
|
3699 |
"/ (since we have to stat each file, this may take a while longer) |
|
3700 |
"/ Visible items are always filled first. |
|
3701 |
||
3702 |
"/ |
|
3703 |
"/ the state machine |
|
3704 |
"/ |
|
3705 |
nextState := IdentityDictionary new. |
|
3706 |
showLongList ifTrue:[ |
|
3707 |
nextState add:(#visibleIcons -> #visibleAttributes). |
|
3708 |
nextState add:(#visibleAttributes -> #visibleTypes). |
|
3709 |
nextState add:(#visibleTypes -> #visibleImages). |
|
3710 |
nextState add:(#visibleImages -> #nextPageIcons). |
|
3711 |
||
3712 |
nextState add:(#nextPageIcons -> #nextPageAttributes). |
|
3713 |
nextState add:(#nextPageAttributes -> #nextPageTypes). |
|
3714 |
nextState add:(#nextPageTypes -> #nextPageImages). |
|
3715 |
nextState add:(#nextPageImages -> #previousPageIcons). |
|
3716 |
||
3717 |
nextState add:(#previousPageIcons -> #previousPageAttributes). |
|
3718 |
nextState add:(#previousPageAttributes -> #previousPageTypes). |
|
3719 |
nextState add:(#previousPageTypes -> #previousPageImages). |
|
3720 |
nextState add:(#previousPageImages -> #remainingIcons). |
|
3721 |
||
3722 |
nextState add:(#remainingIcons -> #remainingAttributes). |
|
3723 |
nextState add:(#remainingAttributes -> #remainingTypes). |
|
3724 |
nextState add:(#remainingTypes -> #remainingImages). |
|
3725 |
nextState add:(#remainingImages -> nil). |
|
3726 |
] ifFalse:[ |
|
3727 |
nextState add:(#visibleIcons -> #nextPageIcons). |
|
3728 |
nextState add:(#nextPageIcons -> #previousPageIcons). |
|
3729 |
nextState add:(#previousPageIcons -> #remainingIcons). |
|
3730 |
nextState add:(#remainingIcons -> nil). |
|
3731 |
]. |
|
3732 |
||
3733 |
anyImages := false. |
|
3734 |
||
3735 |
lineIndex := prevFirstLine := fileListView firstLineShown. |
|
3736 |
endIndex := prevLastLine := fileListView lastLineShown. |
|
3737 |
endIndex := endIndex min:(files size). |
|
3738 |
state := #visibleIcons. |
|
3739 |
||
3740 |
done := false. |
|
3741 |
[done] whileFalse:[ |
|
3742 |
"/ |
|
3743 |
"/ if multiple FileBrowsers are reading, let others |
|
3744 |
"/ make some progress too |
|
3745 |
"/ |
|
3746 |
Processor yield. |
|
3747 |
||
3748 |
"/ |
|
3749 |
"/ could be destroyed in the meanwhile ... |
|
3750 |
"/ |
|
3751 |
realized ifFalse:[ |
|
3752 |
listUpdateProcess := nil. |
|
3753 |
Processor activeProcess terminate |
|
3754 |
]. |
|
3755 |
||
3756 |
((prevFirstLine ~~ fileListView firstLineShown) |
|
3757 |
or:[prevLastLine ~~ fileListView lastLineShown]) ifTrue:[ |
|
3758 |
"/ start all over again |
|
3759 |
lineIndex := prevFirstLine := fileListView firstLineShown. |
|
3760 |
endIndex := prevLastLine := fileListView lastLineShown. |
|
3761 |
endIndex := endIndex min:(files size). |
|
3762 |
state := #visibleIcons. |
|
3763 |
]. |
|
3764 |
||
3765 |
(lineIndex between:1 and:(files size)) ifTrue:[ |
|
3766 |
||
3767 |
"/ |
|
3768 |
"/ expand the next entry ... |
|
3769 |
"/ |
|
3770 |
aFileName := files at:lineIndex. |
|
3771 |
entry := fileListView at:lineIndex. |
|
3772 |
f := currentDirectory construct:aFileName. |
|
3773 |
||
3774 |
(state endsWith:'Icons') ifTrue:[ |
|
3775 |
"/ |
|
3776 |
"/ pass 1 - icons |
|
3777 |
"/ |
|
3778 |
(passDone at:lineIndex) < 1 ifTrue:[ |
|
3779 |
(f isDirectory |
|
3780 |
and:[(aFileName ~= '..') and:[aFileName ~= '.']] |
|
3781 |
) ifTrue:[ |
|
3782 |
||
3783 |
"/ the following suffix cutOff is not really required, |
|
3784 |
"/ but makes the list look better on VMS ... |
|
1336 | 3785 |
fileNameString := aFileName. |
3786 |
dirSuffix notNil ifTrue:[ |
|
3787 |
(aFileName asLowercase endsWith:dirSuffix) ifTrue:[ |
|
3788 |
fileNameString := aFileName copyWithoutLast:(dirSuffix size). |
|
3789 |
] |
|
1329 | 3790 |
]. |
3791 |
fileNameString := fileNameString , ' ...' |
|
3792 |
] ifFalse:[ |
|
1336 | 3793 |
fileNameString := aFileName. |
1351 | 3794 |
thisIsVMS == true ifTrue:[ |
1336 | 3795 |
(aFileName endsWith:'.') ifTrue:[ |
3796 |
aFileName ~= '..' ifTrue:[ |
|
3797 |
fileNameString := aFileName copyWithoutLast:1 |
|
3798 |
] |
|
3799 |
] |
|
3800 |
] |
|
1329 | 3801 |
]. |
3802 |
||
3803 |
showLongList ifTrue:[ |
|
3804 |
len := fileNameString size. |
|
3805 |
(len > 20) ifTrue:[ |
|
3806 |
fileNameString := (fileNameString contractTo:20) |
|
3807 |
]. |
|
3808 |
]. |
|
3809 |
||
3810 |
entry colAt:1 put:(self iconForFile:aFileName). |
|
3811 |
entry colAt:2 put:fileNameString. |
|
3812 |
||
3813 |
fileListView at:lineIndex put:entry. |
|
3814 |
||
3815 |
anyImages ifFalse:[ |
|
3816 |
(Image isImageFileSuffix:(aFileName asFilename suffix)) |
|
3817 |
ifTrue:[ |
|
3818 |
anyImages := true |
|
3819 |
] |
|
3820 |
]. |
|
3821 |
passDone at:lineIndex put:1 |
|
3822 |
] |
|
3823 |
]. |
|
3824 |
||
3825 |
(state endsWith:'Attributes') ifTrue:[ |
|
3826 |
"/ |
|
3827 |
"/ pass 2 - everything except fileType (which takes very long) |
|
3828 |
"/ |
|
3829 |
(passDone at:lineIndex) < 2 ifTrue:[ |
|
3830 |
info := f info. |
|
3831 |
info isNil ifTrue:[ |
|
3832 |
"not accessable - usually a symlink, |
|
3833 |
to a nonexisting/nonreadable file |
|
3834 |
" |
|
3835 |
f isSymbolicLink ifTrue:[ |
|
3836 |
p := f linkInfo path. |
|
3837 |
typeString := 'broken symbolic link to ' , p |
|
3838 |
] ifFalse:[ |
|
3839 |
typeString := 'unknown' |
|
3840 |
]. |
|
3841 |
] ifFalse:[ |
|
3842 |
typ := (info type). |
|
3843 |
||
3844 |
modeString := self getModeString:(info at:#mode) |
|
3845 |
with:#( '' $r $w $x |
|
3846 |
' ' $r $w $x |
|
3847 |
' ' $r $w $x ). |
|
3848 |
entry colAt:3 put:modeString. |
|
3849 |
||
3850 |
((info uid) ~~ prevUid) ifTrue:[ |
|
3851 |
prevUid := (info uid). |
|
3852 |
nameString := OperatingSystem getUserNameFromID:prevUid. |
|
3853 |
nameString := nameString contractTo:10. |
|
3854 |
nameString := nameString , (String new:(10 - nameString size)) |
|
3855 |
]. |
|
3856 |
nameString isNil ifTrue:[nameString := '???']. |
|
3857 |
entry colAt:4 put:nameString withoutSpaces. |
|
3858 |
||
3859 |
((info gid) ~~ prevGid) ifTrue:[ |
|
3860 |
prevGid := (info gid). |
|
3861 |
groupString := OperatingSystem getGroupNameFromID:prevGid. |
|
3862 |
groupString := groupString contractTo:10. |
|
3863 |
groupString := groupString , (String new:(10 - groupString size)) |
|
3864 |
]. |
|
3865 |
groupString isNil ifTrue:[groupString := '???']. |
|
3866 |
entry colAt:5 put:groupString withoutSpaces. |
|
3867 |
||
3868 |
(typ == #regular) ifTrue:[ |
|
3869 |
entry colAt:6 put:(self sizePrintString:(info size)). |
|
3870 |
]. |
|
3871 |
||
3872 |
f isSymbolicLink ifTrue:[ |
|
3873 |
p := f linkInfo path. |
|
3874 |
typeString := 'symbolic link to ' , p |
|
3875 |
] ifFalse:[ |
|
3876 |
typeString := typ asString |
|
3877 |
]. |
|
3878 |
]. |
|
3879 |
entry colAt:7 put:typeString. |
|
3880 |
||
3881 |
fileListView at:lineIndex put:entry. |
|
3882 |
passDone at:lineIndex put:2. |
|
3883 |
]. |
|
3884 |
]. |
|
3885 |
||
3886 |
(state endsWith:'Types') ifTrue:[ |
|
3887 |
"/ |
|
3888 |
"/ pass 3: add fileType |
|
3889 |
"/ |
|
3890 |
(passDone at:lineIndex) < 3 ifTrue:[ |
|
3891 |
info := f info. |
|
3892 |
info notNil ifTrue:[ |
|
3893 |
f isSymbolicLink ifFalse:[ |
|
3894 |
(Image isImageFileSuffix:(f suffix)) ifFalse:[ |
|
3895 |
typeString := f fileType. |
|
3896 |
||
3897 |
entry colAt:7 put:typeString. |
|
3898 |
fileListView at:lineIndex put:entry |
|
3899 |
]. |
|
3900 |
]. |
|
3901 |
]. |
|
3902 |
||
3903 |
passDone at:lineIndex put:3 |
|
3904 |
]. |
|
3905 |
]. |
|
3906 |
||
3907 |
(state endsWith:'Images') ifTrue:[ |
|
3908 |
"/ |
|
3909 |
"/ pass 4: read images |
|
3910 |
"/ |
|
3911 |
(passDone at:lineIndex) < 4 ifTrue:[ |
|
3912 |
(Image isImageFileSuffix:(f suffix)) ifTrue:[ |
|
3913 |
f isDirectory ifFalse:[ |
|
3914 |
img := Image fromFile:(f pathName). |
|
3915 |
img notNil ifTrue:[ |
|
3916 |
img := img magnifiedTo:16@16. |
|
3917 |
img := img on:self device. |
|
3918 |
entry colAt:7 put:img. |
|
3919 |
fileListView at:lineIndex put:entry |
|
3920 |
] |
|
3921 |
] |
|
3922 |
]. |
|
3923 |
passDone at:lineIndex put:4 |
|
3924 |
]. |
|
3925 |
]. |
|
3926 |
]. |
|
3927 |
||
3928 |
"/ |
|
3929 |
"/ advance to the next line |
|
3930 |
"/ |
|
3931 |
lineIndex := lineIndex + 1. |
|
3932 |
lineIndex > endIndex ifTrue:[ |
|
3933 |
"/ finished this round ... |
|
3934 |
"/ see what we are going for ... |
|
3935 |
numVisible := (fileListView lastLineShown - fileListView firstLineShown + 1). |
|
3936 |
||
3937 |
state := nextState at:state ifAbsent:nil. |
|
3938 |
||
3939 |
state isNil ifTrue:[ |
|
3940 |
done := true |
|
3941 |
] ifFalse:[ |
|
3942 |
(state startsWith:'visible') ifTrue:[ |
|
3943 |
lineIndex := fileListView firstLineShown. |
|
3944 |
endIndex := fileListView lastLineShown. |
|
3945 |
endIndex := endIndex min:(files size). |
|
3946 |
] ifFalse:[ |
|
3947 |
(state startsWith:'nextPage') ifTrue:[ |
|
3948 |
lineIndex := fileListView lastLineShown + 1. |
|
3949 |
endIndex := lineIndex + numVisible. |
|
3950 |
endIndex := endIndex min:(files size). |
|
3951 |
lineIndex := lineIndex min:(files size). |
|
3952 |
] ifFalse:[ |
|
3953 |
(state startsWith:'previousPage') ifTrue:[ |
|
3954 |
endIndex := fileListView firstLineShown - 1. |
|
3955 |
lineIndex := endIndex - numVisible. |
|
3956 |
lineIndex := lineIndex max:1. |
|
3957 |
endIndex := endIndex min:(files size). |
|
3958 |
endIndex := endIndex max:1. |
|
3959 |
] ifFalse:[ |
|
3960 |
"/ remaining |
|
3961 |
lineIndex := 1. |
|
3962 |
endIndex := files size. |
|
3963 |
] |
|
3964 |
] |
|
3965 |
] |
|
3966 |
] |
|
3967 |
] |
|
3968 |
]. |
|
3969 |
||
3970 |
listUpdateProcess := nil. |
|
3971 |
||
3972 |
] forkAt:(Processor activePriority - 1). |
|
3973 |
||
3974 |
" |
|
3975 |
install a new check after some time |
|
3976 |
" |
|
3977 |
Processor addTimedBlock:checkBlock afterSeconds:checkDelta |
|
36 | 3978 |
] |
142 | 3979 |
|
3980 |
"Modified: 21.9.1995 / 11:40:23 / claus" |
|
1168
b157f3712548
care for nil returns from userName/groupName * time queries
Claus Gittinger <cg@exept.de>
parents:
1166
diff
changeset
|
3981 |
"Modified: 28.4.1997 / 22:30:30 / dq" |
1324
9f016fbbae01
Use Filename instead of obsolete FileDirectory
Stefan Vogel <sv@exept.de>
parents:
1320
diff
changeset
|
3982 |
"Modified: 18.9.1997 / 18:28:30 / stefan" |
1329 | 3983 |
"Modified: 22.9.1997 / 09:25:33 / cg" |
386
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
3984 |
! ! |
3fd24d9116b3
added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents:
381
diff
changeset
|
3985 |
|
172 | 3986 |
!FileBrowser methodsFor:'queries'! |
73 | 3987 |
|
172 | 3988 |
path |
3989 |
"return my currentDirectories pathName; |
|
1329 | 3990 |
sent from the pathField to aquire the pathname when I changed directory" |
3991 |
||
3992 |
"/ somewhat tricky: first ask it for the full pathName, |
|
3993 |
"/ then convert it to a directory name |
|
3994 |
"/ (which only makes a difference on VMS) |
|
3995 |
||
3996 |
^ currentDirectory asFilename pathName asFilename osNameForDirectory |
|
49 | 3997 |
! ! |
3998 |
||
763
94a8d188b52d
care for the nameSpace Query when loading binary classes
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
3999 |
!FileBrowser class methodsFor:'documentation'! |
203 | 4000 |
|
4001 |
version |
|
1353 | 4002 |
^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.207 1997-10-23 14:42:02 cg Exp $' |
381 | 4003 |
! ! |