author | Claus Gittinger <cg@exept.de> |
Tue, 04 Dec 2001 14:22:49 +0100 | |
changeset 3567 | f85c170f14e8 |
parent 3549 | 8c924bf310ed |
child 3678 | d180d63dc7ca |
permissions | -rw-r--r-- |
5 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 3 |
All Rights Reserved |
5 | 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 |
" |
|
0 | 12 |
|
3263 | 13 |
"{ Package: 'stx:libview' }" |
14 |
||
0 | 15 |
Dictionary subclass:#ResourcePack |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
16 |
instanceVariableNames:'superPack packsClassName fileReadFailed' |
308
54fa63d274fa
also allow "/ for comment lines
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
17 |
classVariableNames:'Packs' |
54fa63d274fa
also allow "/ for comment lines
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
18 |
poolDictionaries:'' |
3484 | 19 |
category:'Interface-Internationalization' |
0 | 20 |
! |
21 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
22 |
!ResourcePack class methodsFor:'documentation'! |
46 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 27 |
All Rights Reserved |
5 | 28 |
|
46 | 29 |
This software is furnished under a license and may be used |
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
5 | 37 |
|
46 | 38 |
documentation |
39 |
" |
|
1942 | 40 |
This class supports easy customization of smalltalk code (i.e. internationalization |
41 |
and viewStyle adaption). |
|
145 | 42 |
ResourcePacks are class specific, meaning that every subclass of View |
1942 | 43 |
and ApplicationModel has an instance of ResourcePack (instVar called 'resources') |
44 |
which is created when the first instance of the view/app is created, |
|
45 |
and cached in a class-instVar (so the file is only read once). |
|
54 | 46 |
|
50 | 47 |
The resourcePack consists of a mapping from strings to values, which are |
48 |
then used in labels, buttons, menus etc. |
|
49 |
The resourcePack initializes itself from a file found in 'resources/<className>.rs', |
|
50 |
where 'className' is built by the usual abbreviation mechanism (see abbrev-files). |
|
1942 | 51 |
|
50 | 52 |
Conditional mappings are possible, by including lines as: |
3422 | 53 |
#if <expression> |
54 |
#endif |
|
50 | 55 |
in the resourcefile. Example: |
56 |
file 'foo.rs': |
|
3422 | 57 |
#if Language == #de |
58 |
'abort' 'Abbruch' |
|
59 |
#endif |
|
60 |
#if Language == #fr |
|
61 |
'abort' 'canceller' |
|
62 |
#endif |
|
145 | 63 |
|
64 |
the corresponding resource-strings are accessed (from methods within the class) |
|
65 |
using: |
|
3422 | 66 |
resources string:'abort' |
145 | 67 |
|
54 | 68 |
returning the mapped string (i.e. 'Abbruch' if the global Language is set |
3422 | 69 |
to #de).. |
145 | 70 |
|
1942 | 71 |
If no corresponding entry is found in the resources, the key is returned; |
72 |
alternatively, use: |
|
3422 | 73 |
resources string:'foo' default:'bar' |
1942 | 74 |
which returns 'bar', if no resource definition for 'foo' is found. |
75 |
||
54 | 76 |
Translations can also include arguments, such as: |
3422 | 77 |
resources string:'really delete %1' with:fileName |
145 | 78 |
|
79 |
This scheme has the advantage, that you can write your programs using your |
|
80 |
native language strings. Later, when new languages are to be supported, |
|
81 |
simply create a resource file for the class and add translations for |
|
82 |
all those strings. (find the keys by looking at users of resource or senders |
|
1942 | 83 |
of 'string:*'). |
84 |
Notice, that the grammar of different languages may imply a reordering, |
|
85 |
so the above string becomes the german 'wollen Sie %1 wirklich löschen'; |
|
86 |
so using percent-placeholders is much better than simple concatenations of |
|
87 |
arguments to the question. |
|
145 | 88 |
|
89 |
More languages can be added later without any change in the code, |
|
90 |
recompilation or the like. |
|
91 |
Even by people without access to the source code i.e. which only have the |
|
92 |
applications binary. |
|
93 |
||
94 |
Also, unsupported languages' strings are simply left unchanged - if you |
|
95 |
write your application in (say) english, and only plan to use it in english, |
|
96 |
no additional work is required (i.e you dont need a resource file then). |
|
97 |
Strings for unknown languages will come in english |
|
98 |
(which is better than nothing or empty button labels ;-) |
|
99 |
||
100 |
Summary: |
|
3422 | 101 |
in subclasses of View and ApplicationModel, |
102 |
instead of writing: |
|
145 | 103 |
|
3422 | 104 |
... |
105 |
b := Button label:'press me' |
|
106 |
... |
|
145 | 107 |
|
3422 | 108 |
always write: |
612 | 109 |
|
3422 | 110 |
... |
111 |
b := Button label:(resources string:'press me') |
|
112 |
... |
|
145 | 113 |
|
3422 | 114 |
if your class is not a subclass of one of the above, AND you need |
115 |
resource translations, you wont inherit the resources variable |
|
116 |
(which is automatically initialized). |
|
117 |
In this case, you have to ask the ResourcePack class explicitely for |
|
118 |
a corresponding package: |
|
145 | 119 |
|
3422 | 120 |
ResourcePack for:aClassName |
145 | 121 |
|
3422 | 122 |
as an example, see how the Date class gets the national names of |
123 |
week & monthnames. |
|
145 | 124 |
|
612 | 125 |
[author:] |
3422 | 126 |
Claus Gittinger |
145 | 127 |
" |
128 |
! |
|
129 |
||
130 |
examples |
|
131 |
" |
|
132 |
normally, resources are found in files named after their classes sourcefile |
|
133 |
For example, the FileBrowsers resources are found in 'FBrowser.rs'. |
|
134 |
For the examples below, we process resources from a constant string; |
|
3422 | 135 |
this is NOT representative. |
136 |
[exBegin] |
|
137 |
|stream res| |
|
145 | 138 |
|
3422 | 139 |
stream := ReadStream on:' |
145 | 140 |
foo ''the translation for foo'' |
3422 | 141 |
#if Language == #de |
145 | 142 |
bar ''die deutsche uebersetzung von bar'' |
143 |
baz ''baz hat den Wert %1'' |
|
144 |
#endif |
|
3422 | 145 |
#if Language == #fr |
145 | 146 |
bar ''bar en francaise'' |
147 |
baz ''%1, c''''est baz'' |
|
148 |
#endif |
|
149 |
||
150 |
'. |
|
151 |
||
3422 | 152 |
res := ResourcePack new readFromResourceStream:stream in:nil. |
145 | 153 |
|
3422 | 154 |
Transcript showCR:'baz is translated to: ' , (res string:'baz' with:'1234'). |
155 |
Transcript showCR:'bar is translated to: ' , (res string:'bar'). |
|
156 |
Transcript showCR:'foo is translated to: ' , (res string:'foo'). |
|
157 |
Transcript showCR:'fooBar is translated to: ' , (res string:'fooBar'). |
|
158 |
[exEnd] |
|
145 | 159 |
set the Language to french: |
3422 | 160 |
[exBegin] |
161 |
Language := #fr |
|
162 |
[exEnd] |
|
145 | 163 |
and repeat the above. |
620 | 164 |
back to english: |
3422 | 165 |
[exBegin] |
166 |
Language := #en |
|
167 |
[exEnd] |
|
620 | 168 |
back to german: |
3422 | 169 |
[exBegin] |
170 |
Language := #de |
|
171 |
[exEnd] |
|
46 | 172 |
" |
173 |
! ! |
|
5 | 174 |
|
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
175 |
!ResourcePack class methodsFor:'initialization'! |
0 | 176 |
|
72 | 177 |
flushCachedResourcePacks |
24 | 178 |
"forget all cached resources - needed after a style change" |
179 |
||
180 |
Packs := nil. |
|
181 |
self initialize |
|
182 |
||
72 | 183 |
"ResourcePack flushCachedResourcePacks" |
244 | 184 |
! |
185 |
||
186 |
initialize |
|
187 |
Packs isNil ifTrue:[ |
|
188 |
Packs := WeakArray new:30 |
|
189 |
]. |
|
190 |
||
191 |
"ResourcePack initialize" |
|
192 |
! ! |
|
193 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
194 |
!ResourcePack class methodsFor:'instance creation'! |
244 | 195 |
|
196 |
for:aClass |
|
197 |
"get the full resource definitions for aClass (i.e. with super packs). |
|
198 |
Also leave the resulting pack in the cache for faster access next time." |
|
199 |
||
3049
d5f2b3f66e37
load resources from package directory, if present
Claus Gittinger <cg@exept.de>
parents:
3047
diff
changeset
|
200 |
|nm pack superPack pkg prj prjDir baseName path| |
244 | 201 |
|
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
202 |
nm := aClass resourcePackName. |
244 | 203 |
pack := self searchCacheFor:nm. |
204 |
pack notNil ifTrue:[^ pack]. |
|
205 |
||
3049
d5f2b3f66e37
load resources from package directory, if present
Claus Gittinger <cg@exept.de>
parents:
3047
diff
changeset
|
206 |
baseName := (Smalltalk fileNameForClass:nm) , '.rs'. |
3046 | 207 |
|
3049
d5f2b3f66e37
load resources from package directory, if present
Claus Gittinger <cg@exept.de>
parents:
3047
diff
changeset
|
208 |
"/ search in the classes package directory first ... |
d5f2b3f66e37
load resources from package directory, if present
Claus Gittinger <cg@exept.de>
parents:
3047
diff
changeset
|
209 |
prjDir := Smalltalk projectDirectoryForClass:aClass. |
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
210 |
|
2971 | 211 |
(prjDir notNil |
212 |
and:[(prjDir := prjDir asFilename) exists |
|
213 |
and:[(prjDir := prjDir construct:'resources') exists |
|
214 |
and:[(prjDir construct:baseName) exists]]]) ifTrue:[ |
|
3101
38cc69894380
fix to avoid loosing the directory with #includes
Claus Gittinger <cg@exept.de>
parents:
3097
diff
changeset
|
215 |
pack := self fromFile:baseName directory:prjDir pathName. |
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
216 |
] ifFalse:[ |
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
217 |
pack := self fromFile:baseName. |
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
218 |
]. |
244 | 219 |
aClass == Object ifFalse:[ |
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
220 |
pack superPack:(self for:(aClass superclass)). |
244 | 221 |
]. |
222 |
pack packsClassName:nm. |
|
223 |
self addToCache:pack. |
|
224 |
^ pack |
|
225 |
||
226 |
" |
|
3046 | 227 |
ResourcePack for:TextView |
244 | 228 |
ResourcePack for:CodeView |
3046 | 229 |
ResourcePack for:Workspace |
3049
d5f2b3f66e37
load resources from package directory, if present
Claus Gittinger <cg@exept.de>
parents:
3047
diff
changeset
|
230 |
ResourcePack for:View |
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
231 |
ResourcePack for:ErrorLogger |
3101
38cc69894380
fix to avoid loosing the directory with #includes
Claus Gittinger <cg@exept.de>
parents:
3097
diff
changeset
|
232 |
ResourcePack for:NewLauncher |
244 | 233 |
Workspace classResources |
234 |
" |
|
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
235 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
236 |
"Modified: / 29.1.1998 / 22:42:53 / cg" |
244 | 237 |
! |
238 |
||
239 |
fromFile:aFileName |
|
240 |
"get the resource definitions from a file in the default directory. |
|
241 |
Uncached low-level entry." |
|
242 |
||
243 |
^ self fromFile:aFileName directory:'resources' |
|
244 |
||
245 |
" |
|
246 |
ResourcePack fromFile:'SBrowser.rs' |
|
247 |
ResourcePack fromFile:'FBrowser.rs' |
|
248 |
ResourcePack fromFile:'Smalltalk.rs' |
|
249 |
" |
|
250 |
! |
|
251 |
||
252 |
fromFile:aFileName directory:dirName |
|
253 |
"get the resource definitions from a file in a directory. |
|
254 |
Uncached low-level entry." |
|
255 |
||
256 |
|newPack| |
|
257 |
||
258 |
newPack := self new. |
|
259 |
newPack readFromFile:aFileName directory:dirName. |
|
260 |
^ newPack |
|
0 | 261 |
! ! |
262 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
263 |
!ResourcePack class methodsFor:'private'! |
54 | 264 |
|
265 |
addToCache:aPack |
|
266 |
|idx| |
|
0 | 267 |
|
54 | 268 |
idx := Packs identityIndexOf:nil. |
269 |
idx == 0 ifTrue:[ |
|
1078
f7b6f15899ab
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
270 |
idx := Packs identityIndexOf:0 |
f7b6f15899ab
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
271 |
]. |
f7b6f15899ab
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
272 |
idx == 0 ifTrue:[ |
72 | 273 |
" |
274 |
throw away oldest |
|
275 |
" |
|
276 |
idx := Packs size. |
|
277 |
Packs replaceFrom:1 to:idx-1 with:Packs startingAt:2. |
|
54 | 278 |
]. |
279 |
Packs at:idx put:aPack |
|
280 |
! |
|
0 | 281 |
|
54 | 282 |
searchCacheFor:aClassname |
998 | 283 |
|sz "{ Class: SmallInteger }" | |
0 | 284 |
|
24 | 285 |
Packs isNil ifTrue:[ |
72 | 286 |
self initialize. |
287 |
^ nil |
|
0 | 288 |
]. |
54 | 289 |
|
290 |
sz := Packs size. |
|
291 |
1 to:sz do:[:idx | |
|
72 | 292 |
|aPack| |
54 | 293 |
|
72 | 294 |
aPack := Packs at:idx. |
1078
f7b6f15899ab
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
295 |
(aPack notNil |
f7b6f15899ab
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1042
diff
changeset
|
296 |
and:[aPack ~~ 0]) ifTrue:[ |
72 | 297 |
aClassname = aPack packsClassName ifTrue:[ |
298 |
" |
|
299 |
bring to end for LRU |
|
300 |
" |
|
301 |
Packs replaceFrom:idx to:sz-1 with:Packs startingAt:idx+1. |
|
302 |
Packs at:sz put:aPack. |
|
303 |
^ aPack |
|
304 |
] |
|
305 |
] |
|
0 | 306 |
]. |
54 | 307 |
^ nil |
123 | 308 |
|
309 |
" |
|
310 |
ResourcePack searchCacheFor:'TextView' |
|
311 |
" |
|
54 | 312 |
! ! |
313 |
||
0 | 314 |
!ResourcePack methodsFor:'accessing'! |
315 |
||
244 | 316 |
array:anArray |
317 |
"translate a collection of strings" |
|
0 | 318 |
|
244 | 319 |
^ anArray collect:[:r | self at:r default:r] |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
320 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
321 |
" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
322 |
Launcher classResources array:#('file' 'classes') |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
323 |
" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
324 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
325 |
"Modified: / 29.1.1998 / 22:44:22 / cg" |
0 | 326 |
! |
327 |
||
2 | 328 |
at:aKey |
123 | 329 |
"translate a string" |
330 |
||
72 | 331 |
^ self at:aKey ifAbsent:aKey |
0 | 332 |
! |
333 |
||
334 |
at:aKey default:default |
|
123 | 335 |
"translate a string" |
336 |
||
72 | 337 |
^ self at:aKey ifAbsent:default |
0 | 338 |
! |
339 |
||
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
340 |
at:aKey ifAbsent:defaultValue |
123 | 341 |
"translate a string" |
342 |
||
3549
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
343 |
|val alternativeKey| |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
344 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
345 |
aKey notNil ifTrue:[ |
3549
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
346 |
val := super at:aKey ifAbsent:nil. |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
347 |
val notNil ifTrue:[^ val]. |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
348 |
|
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
349 |
"/ try with case-first swapped... |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
350 |
(aKey isString |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
351 |
and:[aKey size > 0 |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
352 |
and:[aKey first isLetter]]) ifTrue:[ |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
353 |
alternativeKey := aKey first isUppercase |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
354 |
ifTrue:[aKey asLowercaseFirst] |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
355 |
ifFalse:[aKey asUppercaseFirst]. |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
356 |
val := super at:alternativeKey ifAbsent:nil. |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
357 |
val notNil ifTrue:[ |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
358 |
aKey first isUppercase |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
359 |
ifTrue:[^val asUppercaseFirst]. |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
360 |
^ val asLowercaseFirst. |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
361 |
]. |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
362 |
]. |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
363 |
|
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
364 |
superPack notNil ifTrue:[ |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
365 |
^ superPack at:aKey ifAbsent:defaultValue. |
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
366 |
]. |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
367 |
]. |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
368 |
^ defaultValue value |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
369 |
|
3549
8c924bf310ed
lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents:
3484
diff
changeset
|
370 |
"Modified: / 16.11.2001 / 12:25:33 / cg" |
2 | 371 |
! |
372 |
||
373 |
name:aKey default:default |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
374 |
"translate a string. |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
375 |
Obsolete - use #string:default:" |
123 | 376 |
|
72 | 377 |
^ self at:aKey ifAbsent:default |
2 | 378 |
! |
379 |
||
0 | 380 |
string:s |
3097 | 381 |
"translate (retrieve) a string - if not present, return s" |
123 | 382 |
|
72 | 383 |
^ self at:s ifAbsent:s |
3097 | 384 |
|
385 |
" |
|
386 |
NewLauncher classResources |
|
387 |
string:'LICENCEFILE' |
|
388 |
" |
|
0 | 389 |
! |
390 |
||
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
391 |
string:s default:defaultString |
3097 | 392 |
"translate (retrieve) a string - if not present, return defaultString" |
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
393 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
394 |
^ self at:s ifAbsent:defaultString |
3097 | 395 |
|
396 |
" |
|
397 |
NewLauncher classResources |
|
398 |
string:'fooBar' default:'Hello world' |
|
399 |
" |
|
400 |
||
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
401 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
402 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
403 |
string:s default:defaultString with:arg |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
404 |
"translate and expand arg" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
405 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
406 |
^ self string:s default:defaultString withArgs:(Array with:arg) |
3097 | 407 |
|
408 |
" |
|
409 |
NewLauncher classResources |
|
410 |
string:'%1 fooBar' default:'Hello %1' with:'foo' |
|
411 |
" |
|
412 |
||
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
413 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
414 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
415 |
string:s default:defaultString with:arg1 with:arg2 |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
416 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
417 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
418 |
^ self string:s default:defaultString withArgs:(Array with:arg1 with:arg2) |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
419 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
420 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
421 |
string:s default:defaultString with:arg1 with:arg2 with:arg3 |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
422 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
423 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
424 |
^ self string:s default:defaultString withArgs:(Array with:arg1 with:arg2 with:arg3) |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
425 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
426 |
"Created: 9.12.1995 / 19:08:50 / cg" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
427 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
428 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
429 |
string:s default:defaultString with:arg1 with:arg2 with:arg3 with:arg4 |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
430 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
431 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
432 |
^ self string:s default:defaultString withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
433 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
434 |
"Created: 9.9.1996 / 18:52:14 / cg" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
435 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
436 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
437 |
string:s default:defaultString withArgs:argArray |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
438 |
"translate and expand args" |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
439 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
440 |
|template| |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
441 |
|
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
442 |
template := self at:s ifAbsent:defaultString. |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
443 |
^ template expandPlaceholdersWith:argArray |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
444 |
! |
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
445 |
|
0 | 446 |
string:s with:arg |
123 | 447 |
"translate and expand arg" |
448 |
||
0 | 449 |
^ self string:s withArgs:(Array with:arg) |
450 |
! |
|
451 |
||
452 |
string:s with:arg1 with:arg2 |
|
123 | 453 |
"translate and expand args" |
454 |
||
0 | 455 |
^ self string:s withArgs:(Array with:arg1 with:arg2) |
456 |
! |
|
457 |
||
292
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
458 |
string:s with:arg1 with:arg2 with:arg3 |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
459 |
"translate and expand args" |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
460 |
|
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
461 |
^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3) |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
462 |
|
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
463 |
"Created: 9.12.1995 / 19:08:50 / cg" |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
464 |
! |
62799b2ab9ae
new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents:
251
diff
changeset
|
465 |
|
1042 | 466 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 |
467 |
"translate and expand args" |
|
468 |
||
469 |
^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
|
470 |
||
471 |
"Created: 9.9.1996 / 18:52:14 / cg" |
|
472 |
! |
|
473 |
||
3184 | 474 |
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
475 |
"translate and expand args" |
|
476 |
||
477 |
^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
|
478 |
||
479 |
! |
|
480 |
||
0 | 481 |
string:s withArgs:argArray |
123 | 482 |
"translate and expand args" |
483 |
||
135 | 484 |
|template| |
0 | 485 |
|
2461
3c212ae910ec
added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
486 |
template := self at:s ifAbsent:s. |
135 | 487 |
^ template expandPlaceholdersWith:argArray |
0 | 488 |
! ! |
489 |
||
3317 | 490 |
!ResourcePack methodsFor:'accessing-internals'! |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
491 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
492 |
name:aKey |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
493 |
"translate a string" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
494 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
495 |
^ self at:aKey ifAbsent:aKey |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
496 |
! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
497 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
498 |
packsClassName |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
499 |
^ packsClassName |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
500 |
! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
501 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
502 |
packsClassName:aString |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
503 |
packsClassName := aString |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
504 |
! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
505 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
506 |
superPack:anotherResourcePack |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
507 |
superPack := anotherResourcePack |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
508 |
|
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
509 |
"Created: / 29.1.1998 / 22:43:09 / cg" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
510 |
! ! |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
511 |
|
0 | 512 |
!ResourcePack methodsFor:'file reading'! |
513 |
||
684 | 514 |
fileReadFailed |
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
515 |
"return true, if the pack does not really contain |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
516 |
valid translations, since the fileRead failed. |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
517 |
However, all inherited translations are still available |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
518 |
through the receiver" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
519 |
|
687 | 520 |
^ fileReadFailed ~~ false |
684 | 521 |
|
2033
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
522 |
"Created: / 14.5.1996 / 10:19:26 / cg" |
dad8f0ee02f4
do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents:
1956
diff
changeset
|
523 |
"Modified: / 29.1.1998 / 22:46:38 / cg" |
684 | 524 |
! |
525 |
||
1894
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
526 |
nonexistingFileRead |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
527 |
"asked to read definitions for a non-existing file. |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
528 |
Here, this is legal and ignored (typically using inherited resources). |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
529 |
However, subclasses (such as styleSheet) may flag it as an error." |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
530 |
|
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
531 |
^ nil |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
532 |
|
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
533 |
"Created: 6.9.1997 / 11:38:53 / cg" |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
534 |
! |
9982e96dff75
better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
535 |
|
2291
eaac1c5f2a61
show fileName if a line has error.
Claus Gittinger <cg@exept.de>
parents:
2153
diff
changeset
|
536 |
processLine:aLine encoding:encoding file:fileName |
145 | 537 |
"process a single valid line (i.e. #ifdef & #include has already been processed)" |
538 |
||
2314 | 539 |
|lineString name stream l rest macroName value |
540 |
conditional hasError| |
|
144 | 541 |
|
145 | 542 |
lineString := aLine withoutSeparators. |
144 | 543 |
name := nil. |
544 |
(lineString at:1) == $' ifTrue:[ |
|
2608 | 545 |
stream := ReadStream on:lineString. |
546 |
stream signalAtEnd:false. |
|
547 |
name := String |
|
548 |
readFrom:stream |
|
549 |
onError:[('ResourcePack [warning]: invalid line <' |
|
550 |
,lineString |
|
551 |
,'> in file:' |
|
552 |
, fileName |
|
553 |
) errorPrintCR. nil]. |
|
158 | 554 |
"/ OLD: l := stream position |
2608 | 555 |
l := stream position + 1. |
144 | 556 |
|
557 |
"/ l := lineString indexOf:$' startingAt:2. |
|
558 |
"/ l ~~ 0 ifTrue:[ |
|
559 |
"/ name := (lineString copyFrom:2 to:l-1). |
|
560 |
"/ l := l + 1 |
|
561 |
"/ ] |
|
562 |
] ifFalse:[ |
|
2608 | 563 |
l := lineString indexOfSeparatorStartingAt:1. |
564 |
l ~~ 0 ifTrue:[ |
|
565 |
name := lineString copyFrom:1 to:l-1. |
|
566 |
] |
|
144 | 567 |
]. |
568 |
name notNil ifTrue:[ |
|
2608 | 569 |
hasError := false. |
2153 | 570 |
|
2608 | 571 |
rest := (lineString copyFrom:l) withoutSeparators. |
572 |
" |
|
573 |
skip <type> if present |
|
574 |
" |
|
575 |
(rest startsWith:$<) ifTrue:[ |
|
576 |
l := lineString indexOf:$> startingAt:l. |
|
577 |
rest := (lineString copyFrom:l+1) withoutSeparators. |
|
578 |
]. |
|
2153 | 579 |
|
2608 | 580 |
conditional := false. |
581 |
(rest startsWith:$?) ifTrue:[ |
|
582 |
rest := (rest copyFrom:2) withoutSeparators. |
|
583 |
conditional := true. |
|
584 |
]. |
|
2153 | 585 |
|
2608 | 586 |
(rest startsWith:$=) ifTrue:[ |
587 |
rest := rest copyFrom:2. |
|
588 |
stream := ReadStream on:rest. |
|
589 |
macroName := stream nextAlphaNumericWord. |
|
590 |
[stream peek == $.] whileTrue:[ |
|
591 |
stream next. |
|
592 |
stream peek notNil ifTrue:[ |
|
593 |
macroName := macroName , '.' , (stream nextAlphaNumericWord) |
|
594 |
] |
|
595 |
]. |
|
596 |
rest := stream upToEnd. |
|
597 |
value := self at:macroName ifAbsent:nil. |
|
598 |
(value isNil) ifTrue:[ |
|
599 |
hasError := true. |
|
3003 | 600 |
('ResourcePack [warning]: bad (nil-valued) macro: ' , macroName) errorPrintCR. |
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
601 |
('ResourcePack [warning]: in line: ' , lineString) errorPrintCR. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
602 |
('ResourcePack [warning]: in file: ' , fileName) errorPrintCR. |
2608 | 603 |
]. |
604 |
value isBlock ifTrue:[ |
|
605 |
value := value value |
|
606 |
]. |
|
607 |
value := Compiler evaluate:('self ' , rest) |
|
608 |
receiver:value |
|
609 |
notifying:nil |
|
610 |
compile:false. |
|
611 |
(value == #Error) ifTrue:[ |
|
612 |
hasError := true. |
|
613 |
('ResourcePack [warning]: error in line: "self ' , rest , '"') errorPrintCR. |
|
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
614 |
('ResourcePack [warning]: in file: ' , fileName) errorPrintCR. |
2608 | 615 |
] |
616 |
] ifFalse:[ |
|
617 |
value := Compiler evaluate:rest compile:false. |
|
618 |
(value == #Error) ifTrue:[ |
|
619 |
hasError := true. |
|
620 |
('ResourcePack [warning]: error in line: "' , rest , '"') errorPrintCR. |
|
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
621 |
('ResourcePack [warning]: in file: ' , fileName) errorPrintCR. |
2608 | 622 |
] ifFalse:[ |
623 |
encoding notNil ifTrue:[ |
|
624 |
value isString ifTrue:[ |
|
625 |
value := value decodeFrom:encoding |
|
626 |
] |
|
627 |
] |
|
628 |
] |
|
629 |
]. |
|
630 |
hasError ifFalse:[ |
|
631 |
(conditional not |
|
632 |
or:[(self includesKey:name) not]) ifTrue:[ |
|
633 |
self at:name put:value. |
|
634 |
] |
|
635 |
] |
|
144 | 636 |
] |
462
423f8426fefc
added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents:
444
diff
changeset
|
637 |
|
2291
eaac1c5f2a61
show fileName if a line has error.
Claus Gittinger <cg@exept.de>
parents:
2153
diff
changeset
|
638 |
"Created: / 30.8.1998 / 12:35:37 / cg" |
2608 | 639 |
"Modified: / 28.4.1999 / 22:23:14 / cg" |
144 | 640 |
! |
641 |
||
244 | 642 |
readFromFile:fileName directory:dirName |
643 |
"read definitions from a file in a directory" |
|
644 |
||
645 |
|inStream ok| |
|
646 |
||
686 | 647 |
fileReadFailed := false. |
244 | 648 |
dirName = 'resources' ifTrue:[ |
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
649 |
inStream := Smalltalk resourceFileStreamFor:fileName |
244 | 650 |
] ifFalse:[ |
3101
38cc69894380
fix to avoid loosing the directory with #includes
Claus Gittinger <cg@exept.de>
parents:
3097
diff
changeset
|
651 |
inStream := Smalltalk |
38cc69894380
fix to avoid loosing the directory with #includes
Claus Gittinger <cg@exept.de>
parents:
3097
diff
changeset
|
652 |
systemFileStreamFor:(dirName |
38cc69894380
fix to avoid loosing the directory with #includes
Claus Gittinger <cg@exept.de>
parents:
3097
diff
changeset
|
653 |
ifNil:[fileName] |
38cc69894380
fix to avoid loosing the directory with #includes
Claus Gittinger <cg@exept.de>
parents:
3097
diff
changeset
|
654 |
ifNotNil:[dirName , '/' , fileName]). |
244 | 655 |
]. |
656 |
inStream isNil ifTrue:[ |
|
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
657 |
" |
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
658 |
an empty pack |
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
659 |
" |
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
660 |
^ self nonexistingFileRead |
244 | 661 |
]. |
2996 | 662 |
|
244 | 663 |
ok := self readFromResourceStream:inStream in:dirName. |
664 |
inStream close. |
|
686 | 665 |
|
244 | 666 |
ok ifFalse:[ |
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
667 |
fileReadFailed := true. |
684 | 668 |
|
2970
928387584c9c
for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents:
2608
diff
changeset
|
669 |
('ResourcePack [warning]: ''' , fileName , ''' contains error(s) - data may be incomplete.') errorPrintCR. |
244 | 670 |
]. |
671 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
672 |
"Modified: 10.1.1997 / 18:05:17 / cg" |
244 | 673 |
! |
674 |
||
72 | 675 |
readFromResourceStream:inStream in:dirName |
145 | 676 |
"read definitions from a stream. THe dirName argument is required to |
210
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
677 |
specify where #include files are searched for. |
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
678 |
Return true, if the style sheet could be read without errors, false otherwise." |
145 | 679 |
|
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
680 |
|lineString l lNo rest value ifLevel skipping first ok encoding pack errorHandler| |
462
423f8426fefc
added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents:
444
diff
changeset
|
681 |
|
423f8426fefc
added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents:
444
diff
changeset
|
682 |
encoding := nil. |
0 | 683 |
|
210
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
684 |
ok := true. |
0 | 685 |
ifLevel := 0. |
686 |
skipping := false. |
|
210
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
687 |
lNo := 0. |
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
688 |
|
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
689 |
errorHandler := [:ex | |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
690 |
|con| |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
691 |
|
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
692 |
('ResourcePack [warning]: ''' , ex errorString , '''') errorPrintCR. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
693 |
('ResourcePack [info]: file: ' , inStream pathName printString , ' line: ' , lNo printString , ': ''' , lineString , '''') errorPrintCR. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
694 |
con := ex suspendedContext. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
695 |
('ResourcePack [info]: in: ' , con fullPrintString) errorPrintCR. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
696 |
con := con sender. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
697 |
('ResourcePack [info]: : ' , con fullPrintString) errorPrintCR. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
698 |
con := con sender. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
699 |
('ResourcePack [info]: : ' , con fullPrintString) errorPrintCR. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
700 |
value := nil. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
701 |
ok := false. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
702 |
]. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
703 |
|
0 | 704 |
[inStream atEnd] whileFalse:[ |
2459
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
705 |
lineString := inStream nextLine. lNo := lNo + 1. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
706 |
[lineString notNil and:[lineString endsWith:$\]] whileTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
707 |
lineString := lineString copyWithoutLast:1. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
708 |
l := inStream nextLine. lNo := lNo + 1. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
709 |
l notNil ifTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
710 |
lineString := lineString , l. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
711 |
]. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
712 |
]. |
177 | 713 |
|
2459
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
714 |
(lineString size > 0) ifTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
715 |
first := lineString at:1. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
716 |
"/ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
717 |
"/ for your convenience: treat ; AND "/ as comment-line |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
718 |
"/ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
719 |
((first == $;) or:[lineString startsWith:'"/']) ifFalse:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
720 |
first == $# ifTrue:[ |
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
721 |
"/ a directive |
2459
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
722 |
lineString := (lineString copyFrom:2) withoutSpaces. |
72 | 723 |
|
2459
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
724 |
(lineString startsWith:'if') ifTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
725 |
skipping ifFalse:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
726 |
rest := lineString copyFrom:3. |
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
727 |
ErrorSignal |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
728 |
handle:errorHandler |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
729 |
do:[ |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
730 |
value := Compiler evaluate:rest compile:false]. |
2459
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
731 |
(value == #Error) ifTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
732 |
('ResourcePack [warning]: error in resource:' , lineString) errorPrintCR. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
733 |
]. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
734 |
(value == false) ifTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
735 |
skipping := true |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
736 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
737 |
]. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
738 |
ifLevel := ifLevel + 1 |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
739 |
] ifFalse:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
740 |
(lineString startsWith:'endif') ifTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
741 |
ifLevel := ifLevel - 1. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
742 |
ifLevel == 0 ifTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
743 |
skipping := false |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
744 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
745 |
] ifFalse:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
746 |
(lineString startsWith:'else') ifTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
747 |
skipping := skipping not |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
748 |
] ifFalse:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
749 |
skipping ifFalse:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
750 |
(lineString startsWith:'include') ifTrue:[ |
3082
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
751 |
(lineString startsWith:'includeResourcesFor') ifTrue:[ |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
752 |
"/ include those resources ... |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
753 |
rest := lineString copyFrom:('includeResourcesFor' size + 1). |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
754 |
value := Compiler evaluate:rest compile:false. |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
755 |
value isBehavior ifTrue:[ |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
756 |
pack := self class for:value. |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
757 |
pack notNil ifTrue:[ |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
758 |
self declareAllFrom:pack. |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
759 |
] |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
760 |
] |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
761 |
] ifFalse:[ |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
762 |
rest := lineString copyFrom:('include' size + 1). |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
763 |
value := Compiler evaluate:rest compile:false. |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
764 |
value isString ifFalse:[ |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
765 |
('ResourcePack [warning]: bad include filename: ' , value printString) errorPrintCR. |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
766 |
('ResourcePack [info]: line ' , lNo printString , ': ''' , lineString , '''') infoPrintCR. |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
767 |
] ifTrue:[ |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
768 |
self readFromFile:value directory:dirName |
0f6435aaa66a
new directive: #includeResourcesFor
Claus Gittinger <cg@exept.de>
parents:
3049
diff
changeset
|
769 |
] |
2459
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
770 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
771 |
] ifFalse:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
772 |
(lineString startsWith:'encoding') ifTrue:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
773 |
rest := lineString copyFrom:9. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
774 |
encoding := rest withoutSeparators asSymbol |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
775 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
776 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
777 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
778 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
779 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
780 |
]. |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
781 |
] ifFalse:[ |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
782 |
skipping ifFalse:[ |
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
783 |
ErrorSignal |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
784 |
handle:errorHandler |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
785 |
do:[ |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
786 |
(lineString at:1) == $!! ifTrue:[ |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
787 |
"/ evaluate the rest |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
788 |
Compiler evaluate:(lineString copyFrom:2) |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
789 |
receiver:nil |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
790 |
notifying:nil |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
791 |
compile:false. |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
792 |
] ifFalse:[ |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
793 |
"/ process as resource |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
794 |
self |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
795 |
processLine:lineString |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
796 |
encoding:encoding |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
797 |
file:(inStream isFileStream |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
798 |
ifTrue:[inStream pathName] |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
799 |
ifFalse:['---']) |
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
800 |
]] |
2459
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
801 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
802 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
803 |
] |
55f57cb8551b
(notNil and:[isEmpty not]) -> (size > 0)
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
804 |
] |
0 | 805 |
]. |
210
0f942dafc85a
gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents:
177
diff
changeset
|
806 |
^ ok |
177 | 807 |
|
2291
eaac1c5f2a61
show fileName if a line has error.
Claus Gittinger <cg@exept.de>
parents:
2153
diff
changeset
|
808 |
"Modified: / 31.8.1995 / 02:33:45 / claus" |
eaac1c5f2a61
show fileName if a line has error.
Claus Gittinger <cg@exept.de>
parents:
2153
diff
changeset
|
809 |
"Modified: / 30.8.1998 / 12:35:24 / cg" |
0 | 810 |
! ! |
811 |
||
1173
86a212598655
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
812 |
!ResourcePack class methodsFor:'documentation'! |
251 | 813 |
|
814 |
version |
|
3567
f85c170f14e8
allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents:
3549
diff
changeset
|
815 |
^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.70 2001-12-04 13:22:49 cg Exp $' |
251 | 816 |
! ! |
0 | 817 |
ResourcePack initialize! |