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