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