ResourcePack.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Jul 2015 13:24:48 +0200
changeset 6887 b10262d21ed1
parent 6799 ee648b604f67
child 6909 e3e7a1e51bc7
permissions -rw-r--r--
linked index chain in WeakArray
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6799
ee648b604f67 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6767
diff changeset
     1
"{ Encoding: utf8 }"
ee648b604f67 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6767
diff changeset
     2
5
claus
parents: 2
diff changeset
     3
"
claus
parents: 2
diff changeset
     4
 COPYRIGHT (c) 1993 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
     5
	      All Rights Reserved
5
claus
parents: 2
diff changeset
     6
claus
parents: 2
diff changeset
     7
 This software is furnished under a license and may be used
claus
parents: 2
diff changeset
     8
 only in accordance with the terms of that license and with the
claus
parents: 2
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
claus
parents: 2
diff changeset
    10
 be provided or otherwise made available to, or used by, any
claus
parents: 2
diff changeset
    11
 other person.  No title to or ownership of the software is
claus
parents: 2
diff changeset
    12
 hereby transferred.
claus
parents: 2
diff changeset
    13
"
3263
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 3184
diff changeset
    14
"{ Package: 'stx:libview' }"
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 3184
diff changeset
    15
6767
9a77194dae66 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6661
diff changeset
    16
"{ NameSpace: Smalltalk }"
9a77194dae66 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6661
diff changeset
    17
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    18
Dictionary subclass:#ResourcePack
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
    19
	instanceVariableNames:'packsClassName packsFileName fileReadFailed superPack projectPack'
5826
c4ed474970c1 forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents: 5781
diff changeset
    20
	classVariableNames:'Packs FailedToLoadPacks DebugModifications'
308
54fa63d274fa also allow "/ for comment lines
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    21
	poolDictionaries:''
3484
d21aad9e7db9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3422
diff changeset
    22
	category:'Interface-Internationalization'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    23
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    24
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
    25
!ResourcePack class methodsFor:'documentation'!
46
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    26
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    27
copyright
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    28
"
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    29
 COPYRIGHT (c) 1993 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    30
	      All Rights Reserved
5
claus
parents: 2
diff changeset
    31
46
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    32
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    33
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    35
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    36
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    37
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    38
"
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    39
!
5
claus
parents: 2
diff changeset
    40
46
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    41
documentation
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
    42
"
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    43
    This class supports easy customization of smalltalk code (i.e. internationalization
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    44
    and viewStyle adaption).
145
claus
parents: 144
diff changeset
    45
    ResourcePacks are class specific, meaning that every subclass of View
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    46
    and ApplicationModel has an instance of ResourcePack (instVar called 'resources')
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    47
    which is created when the first instance of the view/app is created,
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    48
    and cached in a class-instVar (so the file is only read once).
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
    49
50
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    50
    The resourcePack consists of a mapping from strings to values, which are
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    51
    then used in labels, buttons, menus etc.
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    52
    The resourcePack initializes itself from a file found in 'resources/<className>.rs',
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    53
    where 'className' is built by the usual abbreviation mechanism (see abbrev-files).
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    54
50
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    55
    Conditional mappings are possible, by including lines as:
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    56
	#if <expression>
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    57
	#endif
50
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    58
    in the resourcefile. Example:
2faa1f522096 *** empty log message ***
claus
parents: 46
diff changeset
    59
    file 'foo.rs':
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    60
	#if Language == #de
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    61
	'abort' 'Abbruch'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    62
	#endif
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    63
	#if Language == #fr
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    64
	'abort' 'canceller'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    65
	#endif
145
claus
parents: 144
diff changeset
    66
claus
parents: 144
diff changeset
    67
    the corresponding resource-strings are accessed (from methods within the class)
claus
parents: 144
diff changeset
    68
    using:
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    69
	resources string:'abort'
145
claus
parents: 144
diff changeset
    70
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
    71
    returning the mapped string (i.e. 'Abbruch' if the global Language is set
3422
f00c788fa81f Comment only
Stefan Vogel <sv@exept.de>
parents: 3407
diff changeset
    72
    to #de)..
145
claus
parents: 144
diff changeset
    73
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    74
    If no corresponding entry is found in the resources, the key is returned;
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    75
    alternatively, use:
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    76
	resources string:'foo' default:'bar'
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    77
    which returns 'bar', if no resource definition for 'foo' is found.
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    78
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
    79
    Translations can also include arguments, such as:
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    80
	resources string:'really delete %1' with:fileName
145
claus
parents: 144
diff changeset
    81
claus
parents: 144
diff changeset
    82
    This scheme has the advantage, that you can write your programs using your
claus
parents: 144
diff changeset
    83
    native language strings. Later, when new languages are to be supported,
claus
parents: 144
diff changeset
    84
    simply create a resource file for the class and add translations for
claus
parents: 144
diff changeset
    85
    all those strings. (find the keys by looking at users of resource or senders
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    86
    of 'string:*').
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    87
    Notice, that the grammar of different languages may imply a reordering,
6799
ee648b604f67 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6767
diff changeset
    88
    so the above string becomes the german 'wollen Sie %1 wirklich löschen';
1942
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    89
    so using percent-placeholders is much better than simple concatenations of
1dd0aedfed03 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1936
diff changeset
    90
    arguments to the question.
145
claus
parents: 144
diff changeset
    91
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    92
    More languages can be added later without any change in the code, or recompilation
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    93
    or the like. Even by people without access to the source code (i.e. which only have the
5653
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
    94
    applications binary).
145
claus
parents: 144
diff changeset
    95
claus
parents: 144
diff changeset
    96
    Also, unsupported languages' strings are simply left unchanged - if you
claus
parents: 144
diff changeset
    97
    write your application in (say) english, and only plan to use it in english,
5653
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
    98
    no additional work is required (i.e you don't even need a resource file then).
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
    99
    Strings for unknown languages will come in english
145
claus
parents: 144
diff changeset
   100
    (which is better than nothing or empty button labels ;-)
claus
parents: 144
diff changeset
   101
5653
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   102
    Notice, that you can also translate engish to english, by providing an en.rs file.
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   103
    This is sometimes useful to fix typing errors or bad syntax in the english,
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   104
    as sometimes made by the programmer, without a need to recompile or to also adjust other
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   105
    language translations.
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   106
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   107
    Finally, this scheme is also compatible to a pure enum-key based translation mechanism,
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   108
    as typically used in the C-world.
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   109
    Simple use keys as argument, and provide translations for all languages (incl. english).
5653
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   110
    For example:
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   111
	Button label:(resources string:#BTN_FOO_LABEL)
5653
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   112
0e2dd1102337 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 5652
diff changeset
   113
145
claus
parents: 144
diff changeset
   114
    Summary:
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   115
	in subclasses of View and ApplicationModel, instead of writing:
145
claus
parents: 144
diff changeset
   116
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   117
		...
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   118
		b := Button label:'press me'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   119
		...
145
claus
parents: 144
diff changeset
   120
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   121
	always write:
612
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   122
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   123
		...
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   124
		b := Button label:(resources string:'press me')
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   125
		...
145
claus
parents: 144
diff changeset
   126
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   127
	if your class is not a subclass of one of the above, AND you need
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   128
	resource translations, you won't inherit the resources variable
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   129
	(which is automatically initialized).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   130
	In this case, you have to ask the ResourcePack class explicitely for
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   131
	a corresponding package:
5483
f9d6b4bb9e85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5466
diff changeset
   132
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   133
		ResourcePack for:aClassName
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   134
	or (even better):
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   135
		ResourcePack forPackage:aPackageID
145
claus
parents: 144
diff changeset
   136
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   137
	as an example, see how the Date class gets the national names of
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   138
	week & monthnames.
145
claus
parents: 144
diff changeset
   139
5483
f9d6b4bb9e85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5466
diff changeset
   140
    Debugging:
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   141
	in the past, it happened that strings as returned by me were modified by someone else
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   142
	(replaceAll:with:) and then lead to invalid presentation in the future.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   143
	To detect any bad guy which writes into one of my returned strings, set the DebugModifications
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   144
	classVar to true. Then I will return ImmutableStrings which trap on writes.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   145
612
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   146
    [author:]
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   147
	Claus Gittinger
145
claus
parents: 144
diff changeset
   148
"
claus
parents: 144
diff changeset
   149
!
claus
parents: 144
diff changeset
   150
claus
parents: 144
diff changeset
   151
examples
claus
parents: 144
diff changeset
   152
"
claus
parents: 144
diff changeset
   153
    normally, resources are found in files named after their classes sourcefile
claus
parents: 144
diff changeset
   154
    For example, the FileBrowsers resources are found in 'FBrowser.rs'.
claus
parents: 144
diff changeset
   155
    For the examples below, we process resources from a constant string;
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   156
	this is NOT representative.
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   157
									[exBegin]
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   158
	|stream res|
145
claus
parents: 144
diff changeset
   159
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   160
	stream := ReadStream on:'
145
claus
parents: 144
diff changeset
   161
foo  ''the translation for foo''
3422
f00c788fa81f Comment only
Stefan Vogel <sv@exept.de>
parents: 3407
diff changeset
   162
#if Language == #de
145
claus
parents: 144
diff changeset
   163
bar  ''die deutsche uebersetzung von bar''
claus
parents: 144
diff changeset
   164
baz  ''baz hat den Wert %1''
claus
parents: 144
diff changeset
   165
#endif
3422
f00c788fa81f Comment only
Stefan Vogel <sv@exept.de>
parents: 3407
diff changeset
   166
#if Language == #fr
145
claus
parents: 144
diff changeset
   167
bar  ''bar en francaise''
claus
parents: 144
diff changeset
   168
baz  ''%1, c''''est baz''
claus
parents: 144
diff changeset
   169
#endif
claus
parents: 144
diff changeset
   170
claus
parents: 144
diff changeset
   171
'.
claus
parents: 144
diff changeset
   172
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   173
	res := ResourcePack new readFromResourceStream:stream in:nil.
145
claus
parents: 144
diff changeset
   174
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   175
	Transcript showCR:'baz is translated to: ' , (res string:'baz' with:'1234').
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   176
	Transcript showCR:'bar is translated to: ' , (res string:'bar').
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   177
	Transcript showCR:'foo is translated to: ' , (res string:'foo').
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   178
	Transcript showCR:'fooBar is translated to: ' , (res string:'fooBar').
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   179
									[exEnd]
145
claus
parents: 144
diff changeset
   180
    set the Language to french:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   181
									[exBegin]
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   182
	Language := #fr
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   183
									[exEnd]
145
claus
parents: 144
diff changeset
   184
    and repeat the above.
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   185
    back to english:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   186
									[exBegin]
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   187
	Language := #en
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   188
									[exEnd]
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   189
    back to german:
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   190
									[exBegin]
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   191
	Language := #de
3762
968432b99c48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3701
diff changeset
   192
									[exEnd]
46
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
   193
"
7b331e9012fd *** empty log message ***
claus
parents: 24
diff changeset
   194
! !
5
claus
parents: 2
diff changeset
   195
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   196
!ResourcePack class methodsFor:'initialization'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   197
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   198
flushCachedResourcePacks
24
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   199
    "forget all cached resources - needed after a style change"
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   200
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   201
    Packs := nil.
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   202
    self initialize
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   203
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   204
    "
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   205
     ResourcePack flushCachedResourcePacks
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   206
    "
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   207
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   208
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   209
initialize
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   210
    Packs isNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   211
	Packs := WeakArray new:100.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   212
	FailedToLoadPacks := Set new.
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   213
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   214
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   215
    "
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   216
     ResourcePack initialize
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   217
    "
4623
81241ac5d815 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4619
diff changeset
   218
5826
c4ed474970c1 forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents: 5781
diff changeset
   219
    "Modified: / 28-09-2011 / 15:53:21 / cg"
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   220
! !
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   221
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   222
!ResourcePack class methodsFor:'instance creation'!
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   223
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   224
for:aClass
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   225
    "get the full resource definitions for aClass (i.e. with super packs).
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   226
     Also leave the resulting pack in the cache for faster access next time."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   227
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   228
    ^ self for:aClass cached:false
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   229
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   230
    "
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   231
     ResourcePack for:TextView
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   232
     ResourcePack for:CodeView
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   233
     ResourcePack for:Workspace
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   234
     ResourcePack for:View
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   235
     ResourcePack for:ErrorLogger
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   236
     ResourcePack for:NewLauncher
6799
ee648b604f67 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6767
diff changeset
   237
     ResourcePack for:SmallSense::SettingsAppl
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   238
     Workspace classResources
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   239
    "
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   240
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   241
    "Modified: / 18-09-2006 / 19:02:57 / cg"
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   242
!
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   243
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   244
for:aClass cached:cached
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   245
    "get the full resource definitions for aClass (i.e. with super packs).
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   246
     Also leave the resulting pack in the cache for faster access next time."
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   247
3980
443283639aed resourceDirectory asked from class
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
   248
    |nm pack rsrcDir baseName|
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   249
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   250
    nm := aClass resourcePackName.
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   251
    cached ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   252
	pack := self searchCacheFor:nm.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   253
	pack notNil ifTrue:[^ pack].
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   254
    ].
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   255
3049
d5f2b3f66e37 load resources from package directory, if present
Claus Gittinger <cg@exept.de>
parents: 3047
diff changeset
   256
    baseName := (Smalltalk fileNameForClass:nm) , '.rs'.
3980
443283639aed resourceDirectory asked from class
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
   257
    rsrcDir := aClass resourceDirectory.
2970
928387584c9c for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents: 2608
diff changeset
   258
4148
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   259
"/ CHECK this
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   260
"/    (rsrcDir notNil and:[rsrcDir suffix = 'rs']) ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   261
"/        baseName := (Smalltalk fileNameForClass: rsrcDir tail asFilename withoutSuffix pathName),'.rs'.
4148
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   262
"/        rsrcDir := rsrcDir head asFilename.
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   263
"/    ].
0a9c11fc8844 *** empty log message ***
werner
parents: 4094
diff changeset
   264
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   265
    rsrcDir notNil ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   266
	pack := self new.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   267
	rsrcDir exists ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   268
	    (rsrcDir construct:baseName) exists ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   269
		pack := self fromFile:baseName directory:(rsrcDir name) cached:true.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   270
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   271
	]
2970
928387584c9c for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents: 2608
diff changeset
   272
    ] ifFalse:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   273
	pack := self fromFile:baseName directory:'resources' cached:true.
2970
928387584c9c for non-base system classes (i.e. package not stx:),
Claus Gittinger <cg@exept.de>
parents: 2608
diff changeset
   274
    ].
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   275
    aClass superclass notNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   276
	pack superPack:(self for:(aClass superclass)).
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   277
    ].
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   278
    pack packsClassOrFileName:nm.
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   279
    cached ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   280
	self addToCache:pack.
4030
34cdc7a25687 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4028
diff changeset
   281
    ].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   282
    pack projectPack:(self forPackage:(aClass resourcePackage) cached:true).
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   283
    ^ pack
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   284
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   285
    "
4656
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
   286
     ResourcePack forPackage:'bosch:dapasx' cached:true
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
   287
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   288
     ResourcePack for:TextView
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   289
     ResourcePack for:CodeView
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   290
     ResourcePack for:Workspace
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   291
     ResourcePack for:View
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   292
     ResourcePack for:ErrorLogger
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   293
     ResourcePack for:NewLauncher
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   294
     Workspace classResources
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   295
    "
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   296
5642
494cea2296dc comment/format in: #for:cached:
Claus Gittinger <cg@exept.de>
parents: 5603
diff changeset
   297
    "Modified: / 01-11-2010 / 09:09:43 / cg"
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   298
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   299
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   300
forPackage:package
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   301
    "get the full resource definitions given a package id (such as stx:libbasic').
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   302
     Also leave the resulting pack in the cache for faster access next time."
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   303
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   304
    ^ self forPackage:package cached:true
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   305
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   306
    "
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   307
     ResourcePack forPackage:'stx:libbasic'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   308
     ResourcePack forPackage:'stx:libtool'
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   309
    "
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   310
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   311
    "Modified: / 18-09-2006 / 18:45:31 / cg"
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   312
!
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   313
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   314
forPackage:package cached:cached
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   315
    "get the full resource definitions given a package id (such as stx:libbasic').
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   316
     Also optionally leave the resulting pack in the cache for faster access next time."
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   317
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   318
    ^ self forPackage:package resourceFileName:'resources.rs' cached:cached
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   319
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   320
    "
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   321
     ResourcePack forPackage:'stx:libbasic' cached:false
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   322
    "
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   323
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   324
    "Modified: / 19-10-2006 / 23:18:28 / cg"
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   325
!
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   326
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   327
forPackage:package resourceFileName:resourceFileName cached:cached
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   328
    "get the full resource definitions given a package id (such as stx:libbasic').
5826
c4ed474970c1 forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents: 5781
diff changeset
   329
     Also optionally leave the resulting pack in the cache for faster access next time.
c4ed474970c1 forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents: 5781
diff changeset
   330
     Remember failed packs, to avoid retrying reading the file again and again"
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   331
4428
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   332
    |fullName pack rsrcDir file|
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   333
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   334
    fullName := package , '/resources/',resourceFileName.
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   335
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   336
    cached ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   337
	pack := self searchCacheFor:fullName.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   338
	pack notNil ifTrue:[^ pack].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   339
	(FailedToLoadPacks includes:fullName) ifTrue:[^ nil].
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   340
    ].
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   341
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   342
    rsrcDir := Smalltalk projectDirectoryForPackage:package.
4428
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   343
    rsrcDir isNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   344
	file := Smalltalk getResourceFileName:resourceFileName forPackage:package.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   345
	file isNil ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   346
	    FailedToLoadPacks add:fullName.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   347
	    ^ nil
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   348
	].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   349
	rsrcDir := file asFilename directory.
4428
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   350
    ] ifFalse:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   351
	rsrcDir := rsrcDir asFilename construct:'resources'.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   352
	rsrcDir exists ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   353
	    FailedToLoadPacks add:fullName.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   354
	    ^ nil
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   355
	].
4428
599139d322df resource file search
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
   356
    ].
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   357
4673
e469f094c7e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
   358
    pack := self fromFile:resourceFileName directory:rsrcDir cached:cached.
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   359
    pack packsClassOrFileName:fullName.
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   360
    ^ pack
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   361
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   362
    "
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   363
     ResourcePack forPackage:'stx:libbasic' resourceFileName:'resources.rs' cached:false
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   364
    "
4656
e7746815918b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4643
diff changeset
   365
5826
c4ed474970c1 forPackage:resourceFileName:cached:
Claus Gittinger <cg@exept.de>
parents: 5781
diff changeset
   366
    "Modified: / 28-09-2011 / 15:55:30 / cg"
4078
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   367
!
467a07009140 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   368
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   369
fromFile:aFileName
4611
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   370
    "get the resource definitions from a file in the default directory."
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   371
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   372
    ^ self fromFile:aFileName directory:'resources'
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   373
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   374
    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   375
     ResourcePack fromFile:'SBrowser.rs'
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   376
     ResourcePack fromFile:'FBrowser.rs'
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   377
     ResourcePack fromFile:'Smalltalk.rs'
3678
d180d63dc7ca #fromFile: - accept a Filename
Stefan Vogel <sv@exept.de>
parents: 3567
diff changeset
   378
     ResourcePack fromFile:'Smalltalk.rs' asFilename
3983
5c4422ca05c8 encoding: allow symbol
Claus Gittinger <cg@exept.de>
parents: 3980
diff changeset
   379
     ResourcePack fromFile:'../../libtool/resources/AboutBox_ru.rs' asFilename
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   380
    "
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   381
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   382
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   383
fromFile:aFileName directory:dirName
4611
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   384
    "get the resource definitions from a file in a directory."
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   385
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   386
    ^ self fromFile:aFileName directory:dirName cached:false
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   387
!
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   388
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   389
fromFile:aFileName directory:dirName cached:cached
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   390
    "get the resource definitions from a file in a directory.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   391
     Uncached low-level entry."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   392
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   393
    |newPack|
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   394
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   395
    newPack := self new.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   396
    newPack readFromFile:aFileName directory:dirName.
4611
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   397
    cached ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   398
	self addToCache:newPack.
4611
1be2168a79a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   399
    ].
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   400
    ^ newPack
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   401
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   402
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   403
!ResourcePack class methodsFor:'private'!
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   404
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   405
addToCache:aPack
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   406
    |idx|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   407
4084
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   408
    Packs isNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   409
	self initialize.
4084
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   410
    ].
09fce0933fe3 lazy init packs
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   411
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   412
    idx := Packs identityIndexOf:nil.
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   413
    idx == 0 ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   414
	idx := Packs findFirst:[:slot | slot class == SmallInteger].
1078
f7b6f15899ab changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents: 1042
diff changeset
   415
    ].
f7b6f15899ab changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents: 1042
diff changeset
   416
    idx == 0 ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   417
	"
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   418
	 throw away oldest
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   419
	"
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   420
	idx := Packs size.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   421
	Packs replaceFrom:1 to:idx-1 with:Packs startingAt:2.
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   422
    ].
5357
8057d6e1da5f changed:
Claus Gittinger <cg@exept.de>
parents: 5189
diff changeset
   423
    aPack at:'__language__' put:(UserPreferences current language,'_',UserPreferences current languageTerritory).
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   424
    Packs at:idx put:aPack.
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   425
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   426
    "Modified: / 18-09-2006 / 19:12:12 / cg"
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   427
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   428
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
   429
searchCacheFor:aClassOrFileName
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   430
    |sz "{ Class: SmallInteger }" lang|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   431
24
e810b1be068b *** empty log message ***
claus
parents: 12
diff changeset
   432
    Packs isNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   433
	self initialize.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   434
	^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   435
    ].
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   436
5357
8057d6e1da5f changed:
Claus Gittinger <cg@exept.de>
parents: 5189
diff changeset
   437
    lang := (UserPreferences current language,'_',UserPreferences current languageTerritory).
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   438
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   439
    sz := Packs size.
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   440
    1 to:sz do:[:idx |
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   441
	|aPack|
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   442
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   443
	aPack := Packs at:idx.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   444
	(aPack notNil and:[aPack class ~~ SmallInteger]) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   445
	    (aPack at:'__language__' ifAbsent:nil) = lang ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   446
		aClassOrFileName = aPack packsClassOrFileName ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   447
		    "
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   448
		     bring to front for LRU
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   449
		    "
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   450
		    idx ~~ 1 ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   451
			Packs replaceFrom:2 to:idx with:Packs startingAt:1.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   452
			Packs at:1 put:aPack.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   453
		    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   454
		    ^ aPack
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   455
		]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   456
	    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   457
	]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   458
    ].
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   459
    ^ nil
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   460
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   461
    "
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   462
     ResourcePack searchCacheFor:'TextView'
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   463
    "
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   464
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
   465
    "Modified: / 18-09-2006 / 19:13:13 / cg"
54
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   466
! !
29a6b2f8e042 *** empty log message ***
claus
parents: 50
diff changeset
   467
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   468
!ResourcePack class methodsFor:'utilities'!
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   469
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   470
extractEncodingFromLine:lineString
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   471
    |rest encoding|
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   472
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   473
    (lineString startsWith:'encoding') ifFalse:[^ nil].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   474
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   475
    rest := lineString copyFrom:9.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   476
    rest := rest withoutSeparators.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   477
    (rest startsWith:'#') ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   478
	rest := rest copyFrom:2.
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   479
    ].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   480
    (rest startsWith:'''') ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   481
	rest := rest copyFrom:2.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   482
	(rest endsWith:'''') ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   483
	    rest := rest copyButLast:1.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   484
	].
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   485
    ].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   486
    encoding := rest asSymbol.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   487
    ^ encoding.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   488
!
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   489
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   490
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   491
    "process a single valid line (i.e. #ifdef & #include has already been processed)"
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   492
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   493
    self
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   494
	processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   495
	keepUselessTranslations:false.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   496
!
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   497
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   498
processResourceLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError for:aResourcePack keepUselessTranslations:keepUselessTranslations
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   499
    "process a single valid line (i.e. #ifdef & #include has already been processed)"
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   500
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   501
    |name lineStream idx rest macroName value
4670
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   502
     conditional hasError decoder oldValue ignoreTranslation indirect|
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   503
6250
fdcf0119816e class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6219
diff changeset
   504
    "/ Transcript showCR:lineString.
4531
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   505
    encodingSymbolOrEncoder notNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   506
	encodingSymbolOrEncoder isSymbol ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   507
	    decoder := CharacterEncoder encoderFor:encodingSymbolOrEncoder ifAbsent:nil.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   508
	    decoder isNil ifTrue:[ decoder := CharacterEncoder nullEncoderInstance ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   509
	] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   510
	    decoder := encodingSymbolOrEncoder
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   511
	].
4531
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   512
    ].
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   513
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   514
    decoder notNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   515
	lineStream := (decoder decodeString:lineString) readStream.
4531
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   516
    ] ifFalse:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   517
	lineStream := lineString readStream.
4531
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   518
    ].
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   519
    lineStream signalAtEnd:false.
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   520
    lineStream skipSeparators.
5080
1974c938a923 Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 5070
diff changeset
   521
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   522
    lineStream peek == $# ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   523
	name := Array
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   524
		    readFrom:lineStream
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   525
		    onError:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   526
				printError value:('invalid line <' , lineString , '>').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   527
				nil
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   528
			    ].
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   529
    ] ifFalse:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   530
	lineStream peek == $' ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   531
	    name := String
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   532
			readSmalltalkStringFrom:lineStream
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   533
			onError:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   534
				    printError value:('invalid line <' , lineString , '>').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   535
				    nil
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   536
				].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   537
	] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   538
	    name := lineStream upToSeparator.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   539
	].
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   540
    ].
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   541
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   542
    name isNil ifTrue:[^ self ].
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   543
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   544
    ignoreTranslation := false.
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   545
    hasError := false.
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   546
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   547
    lineStream skipSeparators.
6113
798f118104a7 class: ResourcePack
Stefan Vogel <sv@exept.de>
parents: 6051
diff changeset
   548
    idx := lineStream position + 1 + 1.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   549
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   550
    lineStream peek == $< ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   551
	"
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   552
	 skip <type> if present
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   553
	"
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   554
	lineStream skipThrough:$>.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   555
	lineStream skipSeparators.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   556
	idx := lineStream position + 2.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   557
    ].
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   558
4670
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   559
    conditional := indirect := false.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   560
    lineStream peek == $? ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   561
	conditional := true.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   562
	lineStream next.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   563
	lineStream skipSeparators.
4670
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   564
    ].
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   565
d4053f688cdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4656
diff changeset
   566
    lineStream peek == $@ ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   567
	indirect := true.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   568
	lineStream next.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   569
	lineStream skipSeparators.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   570
    ].
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   571
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   572
    lineStream peek == $= ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   573
	lineStream next.
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   574
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   575
	macroName := lineStream nextAlphaNumericWord.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   576
	[lineStream peek == $.] whileTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   577
	    lineStream next.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   578
	    lineStream peek notNil ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   579
		macroName := macroName , '.' , (lineStream nextAlphaNumericWord)
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   580
	    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   581
	].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   582
	rest := lineStream upToEnd.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   583
	value := aResourcePack at:macroName ifAbsent:nil.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   584
	(value isNil) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   585
	    hasError := true.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   586
	    printError value:('bad (nil-valued) macro: ' , macroName).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   587
	].
4678
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   588
"/        value isBlock ifTrue:[
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   589
"/            value := value value
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   590
"/        ].
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   591
	rest isBlank ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   592
	    value := Compiler evaluate:('self ' , rest)
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   593
			      receiver:value
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   594
			      notifying:nil
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   595
			      compile:false.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   596
	    (value == #Error) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   597
		hasError := true.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   598
		printError value:('error in: "self ' , rest , '"').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   599
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   600
	    "/ 'self ' print. rest print. ' -> ' print. value printCR.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   601
	]
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   602
    ] ifFalse:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   603
	lineStream peek == $' ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   604
	    value := String
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   605
			readSmalltalkStringFrom:lineStream
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   606
			onError:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   607
				    printError value:('invalid line <' , lineString , '>').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   608
				    nil
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   609
				].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   610
	    "/ ' -> ' print. value printCR.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   611
	] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   612
	    rest := lineStream upToEnd.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   613
	    [
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   614
		value := Compiler evaluate:rest compile:"true" false.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   615
	    ] on:Error do:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   616
		printError value:('invalid line <' , rest , '>').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   617
		"/ value := rest
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   618
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   619
	    "/ rest print. ' -> ' print. value printCR.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   620
	].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   621
	(value == #Error) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   622
	    hasError := true.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   623
	    printError value:('error in: "' , rest , '"').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   624
	] ifFalse:[
4531
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   625
"/            value isString ifTrue:[
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   626
"/                decoder notNil ifTrue:[
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   627
"/                    value := decoder decodeString:value
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   628
"/                ]
a20b7a06ecdb keys are utf-coded, too
Claus Gittinger <cg@exept.de>
parents: 4510
diff changeset
   629
"/            ]
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   630
	]
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   631
    ].
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   632
5430
128e9b37fd8a comment/format in: #processResourceLine:encoding:file:printErrorWith:for:
sr
parents: 5370
diff changeset
   633
    "/ Transcript show:name; show:' -> '; showCR:value.
128e9b37fd8a comment/format in: #processResourceLine:encoding:file:printErrorWith:for:
sr
parents: 5370
diff changeset
   634
4510
abac7c3f3672 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4509
diff changeset
   635
    hasError ifFalse:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   636
	(conditional not
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   637
	or:[(aResourcePack includesKey:name) not]) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   638
	    name = value ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   639
		keepUselessTranslations ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   640
		    printError value:('useless resource: "' , name , '"').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   641
		    ignoreTranslation := true
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   642
		].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   643
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   644
	    ignoreTranslation ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   645
		oldValue := aResourcePack at:name ifAbsent:nil.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   646
		oldValue notNil ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   647
		    oldValue ~= value ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   648
			printError value:('conflicting resource: "' , name , '"').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   649
			printError value:('oldValue: ' , oldValue printString).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   650
			printError value:('newValue: ' , value printString).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   651
		    ] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   652
			printError value:('duplicate resource: "' , name , '"').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   653
		    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   654
		].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   655
		indirect ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   656
		    value := aResourcePack string:value.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   657
		].
5431
02cd0985796a *** empty log message ***
sr
parents: 5430
diff changeset
   658
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   659
		DebugModifications == true ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   660
		    "/ for debugging only !! (not all primitive code is ready for immutableStrings)
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   661
		    value class == String ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   662
			value := value asImmutableString.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   663
		    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   664
		].
5431
02cd0985796a *** empty log message ***
sr
parents: 5430
diff changeset
   665
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   666
		aResourcePack at:name put:value.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   667
	    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   668
	]
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   669
    ]
4534
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
   670
6250
fdcf0119816e class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6219
diff changeset
   671
    "Modified: / 06-02-2014 / 15:33:03 / cg"
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   672
!
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   673
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   674
resourceFileEntryFor:keyString to:nationalString
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   675
    "generate a line for a translation file, which defines a translation
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   676
     from keyString to nationalString.
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   677
     Naivly, this could be a simple line containing the two storeStrings
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   678
     separated by a space. However, it is better to first cut of any leading
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   679
     and trailing spaces and special characters, such as ':*.,' etc."
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   680
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   681
    ^ (self resourceFileStringFor:keyString),' ',(self resourceFileStringFor:nationalString)
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   682
!
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   683
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   684
resourceFileStringFor:aString
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   685
    "generate a key or value entry for a translation file, for aString.
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   686
     Naivly, this could be a simple the storeString.
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   687
     However, it is better to first cut of any leading
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   688
     and trailing spaces and special characters, sch as ':*.,' etc."
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   689
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   690
    ^ (self shortenedKeyFor:aString) storeString
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   691
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   692
    "
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   693
     self resourceFileStringFor:'  foo:   '
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   694
     self resourceFileStringFor:'  foo bar:   '
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   695
    "
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   696
!
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   697
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   698
shortenedKeyFor:aKey
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   699
    "if
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   700
	  aKey is '(...)', then return '...'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   701
	  if aKey is '[...]', then return '...'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   702
	  if aKey is '{...}', then return '...'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   703
	  if aKey starts or ends with any of '\:=.,?!! ', then return aKey without it
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   704
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   705
     This means, that only a single translation is required to provide local translations for
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   706
     things like
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   707
	'search'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   708
	'search:'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   709
	'search...'
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   710
    "
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   711
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   712
    |idx idx1 idx2 first last keySize|
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   713
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   714
    first := aKey first.
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   715
    last := aKey last.
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   716
    keySize := aKey size.
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   717
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   718
    ((first == $( and:[last == $) ])
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   719
    or:[ (first == $[ and:[last == $] ])
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   720
    or:[ (first == ${ and:[last == $} ]) ]]) ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   721
	^ self shortenedKeyFor:(aKey copyFrom:2 to:keySize-1).
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   722
    ].
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   723
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   724
    idx1 := aKey findFirst:[:ch | ch isSeparator not].
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   725
    idx2 := aKey findLast:[:ch | ch isSeparator not] ifNone:keySize.
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   726
    (idx1 > 1 or:[idx2 < keySize]) ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   727
	^ self shortenedKeyFor:(aKey copyFrom:idx1 to:idx2)
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   728
    ].
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   729
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   730
    idx1 := aKey findFirst:[:ch | ('*:=.?!!,-><\' includes:ch) not].
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   731
    idx2 := aKey findLast:[:ch | ('*:=.?!!,-><\' includes:ch) not] ifNone:keySize.
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   732
    (idx1 > 1 or:[idx2 < keySize]) ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   733
	^ self shortenedKeyFor:(aKey copyFrom:idx1 to:idx2)
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   734
    ].
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   735
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   736
    "/ change duplicated &'s to single
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   737
    (idx := aKey indexOf:$&) ~~ 0 ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   738
	(aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   739
	    ^ self shortenedKeyFor:(aKey copyTo:idx-1),(aKey copyFrom:idx+1).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   740
	].
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   741
    ].
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   742
    ^ aKey.
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   743
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   744
    "
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   745
     'abcde' findFirst:[:ch | 'bcd' includes:ch]
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   746
     'abcde' indexOfAny:'bcd'
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   747
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   748
     self shortenedKeyFor:'abc'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   749
     self shortenedKeyFor:'   abc    '
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   750
     self shortenedKeyFor:'(abc)'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   751
     self shortenedKeyFor:'abc...'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   752
     self shortenedKeyFor:'(abc...)'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   753
     self shortenedKeyFor:'abc:*'
6661
2f05e09f8a31 class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6650
diff changeset
   754
    "
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   755
! !
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
   756
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   757
!ResourcePack methodsFor:'accessing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
   758
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   759
array:anArray
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   760
    "translate a collection of strings"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   761
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   762
    ^ anArray collect:[:r | self at:r default:r]
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   763
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   764
    "
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   765
     Launcher classResources array:#('file' 'classes')
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   766
    "
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   767
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   768
    "Modified: / 29.1.1998 / 22:44:22 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   769
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   770
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   771
at:aKey
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   772
    "translate a string"
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   773
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   774
    ^ self at:aKey ifAbsent:aKey
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   775
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   776
48194c26a46c Initial revision
claus
parents:
diff changeset
   777
at:aKey default:default
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   778
    "translate a string"
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   779
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   780
    ^ self at:aKey ifAbsent:default
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   781
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   782
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   783
at:aKey ifAbsent:defaultValue
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   784
    "translate a string; search here, in my projects pack and in my superpack(s)"
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   785
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   786
    |val pack projectPack alreadySearched|
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   787
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   788
    aKey isNil ifTrue:[ ^ defaultValue value ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   789
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   790
    val := self localAt:aKey.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   791
    val notNil ifTrue:[^ val].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   792
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   793
    (projectPack := self projectPack) notNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   794
	val := projectPack localAt:aKey.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   795
	val notNil ifTrue:[^ val].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   796
    ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   797
    alreadySearched := Set new.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   798
    projectPack notNil ifTrue:[ alreadySearched add:projectPack ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   799
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   800
    pack := self superPack.
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   801
    [ pack notNil ] whileTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   802
	val := pack localAt:aKey.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   803
	val notNil ifTrue:[^ val].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   804
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   805
	(projectPack := pack projectPack) notNil ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   806
	    (alreadySearched includes:projectPack) ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   807
		val := projectPack localAt:aKey.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   808
		val notNil ifTrue:[^ val].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   809
		alreadySearched add:projectPack.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   810
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   811
	].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   812
	pack := pack superPack
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   813
    ].
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   814
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   815
    alreadySearched copy do:[:projectPack |
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   816
	|p|
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   817
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   818
	p := projectPack superPack.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   819
	[p notNil and:[(alreadySearched includes:p) not]] whileTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   820
	    val := p localAt:aKey.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   821
	    val notNil ifTrue:[^ val].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   822
	    alreadySearched add:p.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   823
	    p := p superPack.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   824
	].
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   825
    ].
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   826
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   827
    ^ defaultValue value
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   828
4618
d07d2f6445b6 search algorithm changed.
Claus Gittinger <cg@exept.de>
parents: 4617
diff changeset
   829
    "Modified: / 18-09-2006 / 18:50:52 / cg"
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   830
!
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   831
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   832
localAt:aKey
4035
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   833
    "translate a string.
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   834
     Some special 'intelligence' has been added:
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   835
	if no value for aKey is found,
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   836
	  lookup aKey with first character caseChanged and change the results first characters case.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   837
	  or aKey is '(...)', then lookup ... wrap () around the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   838
	  or aKey is '[...]', then lookup ... wrap [] around the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   839
	  or aKey is '{...}', then lookup ... wrap {} around the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   840
	  or aKey starts with a '\', then lookup aKey without '\' and prepend '\' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   841
	  or aKey ends with a '\', then lookup aKey without '\' and append '\' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   842
	  or aKey ends with a ':', then lookup aKey without ':' and append ':' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   843
	  or aKey ends with a '=', then lookup aKey without '=' and append '=' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   844
	  or aKey ends with a '.', then lookup aKey without '.' and append '.' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   845
	  or aKey ends with a ',', then lookup aKey without ',' and append ',' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   846
	  or aKey ends with a '?', then lookup aKey without '?' and append '?' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   847
	  or aKey ends with a '!!', then lookup aKey without '!!' and append '!!' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   848
	  or aKey ends with a ' ', then lookup aKey without ' ' and append ' ' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   849
	  or aKey ends with a ' ...', then lookup aKey without ' ...' and append '...' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   850
	  or aKey ends with a '...', then lookup aKey without '...' and append '...' to the result.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   851
	  or aKey includes '&', then lookup aKey without '&'.
4035
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   852
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   853
     This means, that only a single translation is required to provide local translations for
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   854
     things like
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   855
	'search'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   856
	'search:'
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   857
	'search...'
4035
a785efbbc5c9 comment
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   858
    "
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   859
5573
e97353eff54d changed: #localAt:
Stefan Vogel <sv@exept.de>
parents: 5483
diff changeset
   860
    |val alternativeKey usedKey idx first last|
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   861
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   862
    val := super at:aKey ifAbsent:nil.
4678
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   863
    val notNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   864
	^ val value
4678
0d83cc874dc3 block value handling changed
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   865
    ].
3549
8c924bf310ed lower case first <-> upper case first
Claus Gittinger <cg@exept.de>
parents: 3484
diff changeset
   866
4848
18a6274df5d1 changed #localAt:
Stefan Vogel <sv@exept.de>
parents: 4844
diff changeset
   867
    (aKey isString and:[aKey notEmpty]) ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   868
	first := aKey first.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   869
	last := aKey last.
5573
e97353eff54d changed: #localAt:
Stefan Vogel <sv@exept.de>
parents: 5483
diff changeset
   870
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   871
	"/ try with case-first swapped...
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   872
	first isLetter ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   873
	    alternativeKey := first isUppercase
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   874
				ifTrue:[aKey asLowercaseFirst]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   875
				ifFalse:[aKey asUppercaseFirst].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   876
	    val := super at:alternativeKey ifAbsent:nil.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   877
	    val notNil ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   878
		first isUppercase ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   879
		    ^ val asUppercaseFirst
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   880
		].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   881
		^ val asLowercaseFirst.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   882
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   883
	].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   884
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   885
	((first == $( and:[last == $) ])
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   886
	or:[ (first == $[ and:[last == $] ])
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   887
	or:[ (first == ${ and:[last == $} ]) ]]) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   888
	    usedKey := aKey copyFrom:2 to:aKey size-1.
5593
c7691bd8ebf4 changed: #localAt:
sr
parents: 5573
diff changeset
   889
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   890
	    val := self localAt:usedKey.        "/ recursion
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   891
	    val notNil ifTrue:[^ first asString,val,last asString].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   892
	].
5593
c7691bd8ebf4 changed: #localAt:
sr
parents: 5573
diff changeset
   893
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   894
	last == $. ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   895
	    (aKey endsWith:' ...') ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   896
		usedKey := aKey copyButLast:4.
5573
e97353eff54d changed: #localAt:
Stefan Vogel <sv@exept.de>
parents: 5483
diff changeset
   897
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   898
		val := self localAt:usedKey.        "/ recursion
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   899
		val notNil ifTrue:[^ val , ' ...'].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   900
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   901
	    (aKey endsWith:'...') ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   902
		usedKey := aKey copyButLast:3.
5573
e97353eff54d changed: #localAt:
Stefan Vogel <sv@exept.de>
parents: 5483
diff changeset
   903
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   904
		val := self localAt:usedKey.        "/ recursion
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   905
		val notNil ifTrue:[^ val , '...'].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   906
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   907
	].
5573
e97353eff54d changed: #localAt:
Stefan Vogel <sv@exept.de>
parents: 5483
diff changeset
   908
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   909
	first isSeparator ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   910
	    usedKey := aKey withoutLeadingSeparators.
4634
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   911
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   912
	    val := self localAt:usedKey.        "/ recursion
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   913
	    val notNil ifTrue:[^ (aKey copyTo:(aKey size - usedKey size)), val]. "/ prepend the stripped separators
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   914
	].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   915
	last isSeparator ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   916
	    usedKey := aKey withoutTrailingSeparators.
4634
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   917
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   918
	    val := self localAt:usedKey.        "/ recursion
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   919
	    val notNil ifTrue:[^ val, (aKey copyFrom:usedKey size + 1)].      "/ append the stripped separators
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   920
	].
4634
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   921
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   922
	('*:=.?!!,-><\' includes:last) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   923
	    aKey size >= 2 ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   924
		usedKey := aKey copyButLast:1.
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   925
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   926
		val := self localAt:usedKey.        "/ recursion
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   927
		val notNil ifTrue:[^ val copyWith:last].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   928
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   929
	].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   930
	('*:=.?!!-><\' includes:first) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   931
	    aKey size >= 2 ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   932
		usedKey := aKey copyFrom:2.
4634
d57ba003bba4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
   933
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   934
		val := self localAt:usedKey.        "/ recursion
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   935
		val notNil ifTrue:[^ first asString , val].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   936
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   937
	].
4028
Claus Gittinger <cg@exept.de>
parents: 4019
diff changeset
   938
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   939
	(first == $( and:[last == $)]) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   940
	    usedKey := aKey copyFrom:2 to:(aKey size - 1).
4028
Claus Gittinger <cg@exept.de>
parents: 4019
diff changeset
   941
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   942
	    val := self localAt:usedKey.        "/ recursion
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   943
	    val notNil ifTrue:[^ '(' , val , ')'].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   944
	].
4017
b0bbac385c4f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3986
diff changeset
   945
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   946
	(idx := aKey indexOf:$&) ~~ 0 ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   947
	    (aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   948
		usedKey := (aKey copyTo:idx-1) , (aKey copyFrom:idx+1).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   949
		val := self localAt:usedKey.    "/ recursion
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   950
		val notNil ifTrue:[^ val].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   951
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   952
	].
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
   953
    ].
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   954
    ^ nil.
4580
48c0580f3b9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4534
diff changeset
   955
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
   956
    "Created: / 18-09-2006 / 17:33:27 / cg"
4796
c17e24be80c1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4678
diff changeset
   957
    "Modified: / 21-08-2007 / 21:18:12 / cg"
5593
c7691bd8ebf4 changed: #localAt:
sr
parents: 5573
diff changeset
   958
    "Modified: / 05-08-2010 / 16:52:32 / sr"
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   959
!
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   960
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   961
name:aKey default:default
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   962
    "translate a string.
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   963
     Obsolete - use #string:default:"
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   964
4844
38faa6eaaf26 comment
Stefan Vogel <sv@exept.de>
parents: 4835
diff changeset
   965
    <resource: #obsolete>
38faa6eaaf26 comment
Stefan Vogel <sv@exept.de>
parents: 4835
diff changeset
   966
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   967
    ^ self at:aKey ifAbsent:default
2
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   968
!
b35336ab0de3 *** empty log message ***
claus
parents: 0
diff changeset
   969
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   970
string:s
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   971
    "translate (retrieve) a string - if not present, return s"
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
   972
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   973
    ^ self at:s ifAbsent:s
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   974
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   975
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   976
     NewLauncher classResources
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   977
	string:'LICENCEFILE'
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   978
    "
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   979
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   980
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   981
string:s default:defaultString
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   982
    "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
   983
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   984
    ^ self at:s ifAbsent:defaultString
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   985
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   986
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   987
     NewLauncher classResources
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
   988
	string:'fooBar' default:'Hello world'
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   989
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   990
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   991
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   992
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   993
string:s default:defaultString with:arg
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   994
    "translate and expand arg"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   995
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
   996
    ^ self string:s default:defaultString withArgs:(Array with:arg)
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   997
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   998
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
   999
     NewLauncher classResources
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1000
	string:'%1 fooBar' default:'Hello %1' with:'foo'
3097
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
  1001
    "
b2cca70d5d55 examples
Claus Gittinger <cg@exept.de>
parents: 3082
diff changeset
  1002
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1003
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1004
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1005
string:s default:defaultString with:arg1 with:arg2
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1006
    "translate and expand args"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1007
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1008
    ^ 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
  1009
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1010
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1011
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
  1012
    "translate and expand args"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1013
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1014
    ^ 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
  1015
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1016
    "Created: 9.12.1995 / 19:08:50 / cg"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1017
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1018
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1019
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
  1020
    "translate and expand args"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1021
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1022
    ^ 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
  1023
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1024
    "Created: 9.9.1996 / 18:52:14 / cg"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1025
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1026
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1027
string:s default:defaultString withArgs:argArray
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1028
    "translate and expand args"
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1029
5070
e0b85fdde61b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5069
diff changeset
  1030
    |template|
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1031
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1032
    template := self at:s ifAbsent:defaultString.
5070
e0b85fdde61b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5069
diff changeset
  1033
    ^ template expandPlaceholdersWith:argArray.
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1034
!
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1035
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1036
string:s with:arg
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
  1037
    "translate and expand arg"
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
  1038
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1039
    ^ self string:s withArgs:(Array with:arg)
48194c26a46c Initial revision
claus
parents:
diff changeset
  1040
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1041
48194c26a46c Initial revision
claus
parents:
diff changeset
  1042
string:s with:arg1 with:arg2
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
  1043
    "translate and expand args"
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
  1044
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1045
    ^ self string:s withArgs:(Array with:arg1 with:arg2)
48194c26a46c Initial revision
claus
parents:
diff changeset
  1046
!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1047
292
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1048
string:s with:arg1 with:arg2 with:arg3
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1049
    "translate and expand args"
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1050
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1051
    ^ 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
  1052
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1053
    "Created: 9.12.1995 / 19:08:50 / cg"
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1054
!
62799b2ab9ae new method: string:with:with:with:
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
  1055
1042
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
  1056
string:s with:arg1 with:arg2 with:arg3 with:arg4
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
  1057
    "translate and expand args"
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
  1058
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
  1059
    ^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4)
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
  1060
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
  1061
    "Created: 9.9.1996 / 18:52:14 / cg"
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
  1062
!
ddb262303ccd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 998
diff changeset
  1063
3184
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
  1064
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
  1065
    "translate and expand args"
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
  1066
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
  1067
    ^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5)
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
  1068
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
  1069
!
b8f6c186fff5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3102
diff changeset
  1070
5652
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1071
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1072
    "translate and expand args"
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1073
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1074
    ^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6)
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1075
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1076
    "Created: / 13-11-2010 / 11:35:00 / cg"
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1077
!
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1078
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1079
string:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1080
    "translate and expand args"
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1081
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1082
    ^ self string:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7)
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1083
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1084
    "Created: / 13-11-2010 / 11:35:07 / cg"
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1085
!
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1086
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1087
string:s withArgs:argArray
4932
b19b928b0026 Allow (and insert) Texts as arguments in #string:with:
Stefan Vogel <sv@exept.de>
parents: 4848
diff changeset
  1088
    "translate and expand args - allow text as arguments"
123
9f8c7f20fdb2 *** empty log message ***
claus
parents: 118
diff changeset
  1089
5069
2b40d206ba7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  1090
    |template|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1091
2461
3c212ae910ec added #string:default:with* methods.
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  1092
    template := self at:s ifAbsent:s.
5069
2b40d206ba7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  1093
    ^ template expandPlaceholdersWith:argArray.
4932
b19b928b0026 Allow (and insert) Texts as arguments in #string:with:
Stefan Vogel <sv@exept.de>
parents: 4848
diff changeset
  1094
5069
2b40d206ba7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  1095
2b40d206ba7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  1096
2b40d206ba7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  1097
2b40d206ba7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  1098
2b40d206ba7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  1099
2b40d206ba7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  1100
2b40d206ba7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  1101
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1102
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1103
4402
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1104
stringWithCRs:s
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1105
    "translate (retrieve) a string - if not present, return s"
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1106
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1107
    ^ (self string:s) withCRs
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1108
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1109
    "
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1110
     NewLauncher classResources
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1111
	stringWithCRs:'LICENCEFILE'
4402
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1112
    "
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1113
!
1314cdc7b6ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4332
diff changeset
  1114
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1115
stringWithCRs:s with:arg
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1116
    "translate, replace \'s with CRs and finally expand arg.
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1117
     CR-replacement is donw before args are inserted
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1118
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1119
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1120
    ^ self stringWithCRs:s withArgs:(Array with:arg)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1121
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1122
    "Modified: / 21.3.2003 / 14:22:09 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1123
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1124
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1125
stringWithCRs:s with:arg1 with:arg2
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1126
    "translate, replace \'s with CRs and finally expand args.
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1127
     CR-replacement is donw before args are inserted
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1128
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1129
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1130
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1131
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1132
    "Modified: / 21.3.2003 / 14:22:06 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1133
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1134
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1135
stringWithCRs:s with:arg1 with:arg2 with:arg3
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1136
    "translate, replace \'s with CRs and finally expand args.
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1137
     CR-replacement is donw before args are inserted
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1138
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1139
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1140
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1141
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1142
    "Created: 9.12.1995 / 19:08:50 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1143
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1144
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1145
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1146
    "translate, replace \'s with CRs and finally expand args.
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1147
     CR-replacement is donw before args are inserted
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1148
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1149
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1150
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1151
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1152
    "Modified: / 21.3.2003 / 14:21:48 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1153
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1154
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1155
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1156
    "translate, replace \'s with CRs and finally expand args.
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1157
     CR-replacement is donw before args are inserted
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1158
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1159
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1160
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5)
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1161
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1162
    "Modified: / 21.3.2003 / 14:21:55 / cg"
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1163
!
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1164
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1165
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6
5652
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1166
    "translate, replace \'s with CRs and finally expand args.
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1167
     CR-replacement is donw before args are inserted
5652
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1168
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1169
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1170
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6)
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1171
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1172
    "Created: / 13-11-2010 / 11:35:30 / cg"
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1173
!
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1174
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1175
stringWithCRs:s with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1176
    "translate, replace \'s with CRs and finally expand args.
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1177
     CR-replacement is donw before args are inserted
5652
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1178
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1179
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1180
    ^ self stringWithCRs:s withArgs:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7)
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1181
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1182
    "Created: / 13-11-2010 / 11:35:20 / cg"
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1183
!
Claus Gittinger <cg@exept.de>
parents: 5642
diff changeset
  1184
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1185
stringWithCRs:s withArgs:argArray
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1186
    "translate, replace \'s with CRs and finally expand args.
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1187
     CR-replacement is done before args are inserted
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1188
     i.e. if any arg contains a backslash (DOS filenames), those are not translated."
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1189
5070
e0b85fdde61b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5069
diff changeset
  1190
    |template|
3823
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1191
e76715148cb3 +stringWithCRs
Claus Gittinger <cg@exept.de>
parents: 3817
diff changeset
  1192
    template := self at:s ifAbsent:s.
5070
e0b85fdde61b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5069
diff changeset
  1193
    ^ template withCRs expandPlaceholdersWith:argArray.
6174
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1194
!
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1195
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1196
whichPackIncludesKey:aKey
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1197
    "for debugging: return the pack (alogn the super-pack chain), which
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1198
     has a translation for a string"
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1199
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1200
    |val pack projectPack alreadySearched|
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1201
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1202
    aKey isNil ifTrue:[ ^ nil ].
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1203
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1204
    val := self localAt:aKey.
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1205
    val notNil ifTrue:[^ self].
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1206
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1207
    (projectPack := self projectPack) notNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1208
	val := projectPack localAt:aKey.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1209
	val notNil ifTrue:[^ projectPack].
6174
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1210
    ].
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1211
    alreadySearched := Set new.
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1212
    projectPack notNil ifTrue:[ alreadySearched add:projectPack ].
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1213
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1214
    pack := self superPack.
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1215
    [ pack notNil ] whileTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1216
	val := pack localAt:aKey.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1217
	val notNil ifTrue:[^ pack].
6174
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1218
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1219
	(projectPack := pack projectPack) notNil ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1220
	    (alreadySearched includes:projectPack) ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1221
		val := projectPack localAt:aKey.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1222
		val notNil ifTrue:[^ projectPack].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1223
		alreadySearched add:projectPack.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1224
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1225
	].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1226
	pack := pack superPack
6174
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1227
    ].
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1228
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1229
    alreadySearched copy do:[:projectPack |
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1230
	|p|
6174
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1231
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1232
	p := projectPack superPack.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1233
	[p notNil and:[(alreadySearched includes:p) not]] whileTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1234
	    val := p localAt:aKey.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1235
	    val notNil ifTrue:[^ p].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1236
	    alreadySearched add:p.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1237
	    p := p superPack.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1238
	].
6174
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1239
    ].
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1240
982b8576dfbe class: ResourcePack
Claus Gittinger <cg@exept.de>
parents: 6113
diff changeset
  1241
    ^ nil
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1242
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
  1243
3317
fbad8f950059 Spelling
Stefan Vogel <sv@exept.de>
parents: 3263
diff changeset
  1244
!ResourcePack methodsFor:'accessing-internals'!
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1245
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1246
name:aKey
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1247
    "translate a string"
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1248
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1249
    ^ self at:aKey ifAbsent:aKey
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1250
!
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1251
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1252
packsClassName
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1253
    ^ packsClassName
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1254
!
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1255
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1256
packsClassName:aString
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1257
    packsClassName := aString
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1258
!
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1259
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1260
packsClassOrFileName
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1261
    "old: should no longer be used to access the filename; see packsFileName"
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1262
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1263
    ^ packsClassName
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1264
!
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1265
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1266
packsClassOrFileName:aString
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1267
    "old: should no longer be used to access the filename; see packsFileName"
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1268
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1269
    packsClassName := aString
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1270
!
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1271
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1272
packsFileName
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1273
    ^ packsFileName
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1274
!
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1275
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1276
projectPack
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1277
    ^ projectPack
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1278
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1279
    "Created: / 18-09-2006 / 17:38:07 / cg"
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1280
!
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1281
4085
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1282
projectPack:anotherResourcePack
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1283
    projectPack := anotherResourcePack
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1284
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1285
    "Created: / 29.1.1998 / 22:43:09 / cg"
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1286
!
2a6903a7feff preps for projectPacks
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  1287
4617
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1288
superPack
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1289
    ^ superPack
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1290
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1291
    "Created: / 18-09-2006 / 17:38:12 / cg"
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1292
!
d212c3f53ffd packsResources
Claus Gittinger <cg@exept.de>
parents: 4616
diff changeset
  1293
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1294
superPack:anotherResourcePack
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1295
    superPack := anotherResourcePack
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1296
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1297
    "Created: / 29.1.1998 / 22:43:09 / cg"
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1298
! !
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1299
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1300
!ResourcePack methodsFor:'file reading'!
48194c26a46c Initial revision
claus
parents:
diff changeset
  1301
684
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1302
fileReadFailed
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1303
    "return true, if the pack does not really contain
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1304
     valid translations, since the fileRead failed.
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1305
     However, all inherited translations are still available
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1306
     through the receiver"
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1307
687
d2cf3cd18f65 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 686
diff changeset
  1308
    ^ fileReadFailed ~~ false
684
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1309
2033
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1310
    "Created: / 14.5.1996 / 10:19:26 / cg"
dad8f0ee02f4 do not merge superPacks data;
Claus Gittinger <cg@exept.de>
parents: 1956
diff changeset
  1311
    "Modified: / 29.1.1998 / 22:46:38 / cg"
684
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1312
!
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1313
1894
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1314
nonexistingFileRead
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1315
    "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
  1316
     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
  1317
     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
  1318
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1319
    ^ nil
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1320
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1321
    "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
  1322
!
9982e96dff75 better behavior if no stylesheet is present.
Claus Gittinger <cg@exept.de>
parents: 1803
diff changeset
  1323
4332
767357a4294d allow array as key
Claus Gittinger <cg@exept.de>
parents: 4198
diff changeset
  1324
processLine:lineString encoding:encodingSymbolOrEncoder file:fileName printErrorWith:printError
145
claus
parents: 144
diff changeset
  1325
    "process a single valid line (i.e. #ifdef & #include has already been processed)"
claus
parents: 144
diff changeset
  1326
4509
865b5e03615d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4506
diff changeset
  1327
    self class
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1328
	processResourceLine:lineString
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1329
	encoding:encodingSymbolOrEncoder
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1330
	file:fileName
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1331
	printErrorWith:printError
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1332
	for:self
144
claus
parents: 135
diff changeset
  1333
!
claus
parents: 135
diff changeset
  1334
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1335
readFromFile:fileName directory:dirName
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1336
    "read definitions from a file in a directory"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1337
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1338
    |triedFilename inStream ok|
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1339
686
152d8437af35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 685
diff changeset
  1340
    fileReadFailed := false.
5781
fc35ed4fd223 changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  1341
    "/ need to catch errors here, as the handler might itself need resources.
fc35ed4fd223 changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  1342
    "/ (happens when da.rs is not present in libbasic/resources.rs)
fc35ed4fd223 changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  1343
    ExternalStream openErrorSignal handle:[:ex |
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1344
	Transcript showCR:'ResourcePack: failed to open file: ',fileName asString,' in ',dirName asString.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1345
	inStream := nil.
5781
fc35ed4fd223 changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  1346
    ] do:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1347
	dirName = 'resources' ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1348
	    inStream := Smalltalk resourceFileStreamFor:fileName
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1349
	] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1350
	    inStream := Smalltalk systemFileStreamFor:
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1351
			    (dirName isNil
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1352
				ifTrue:[fileName]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1353
				ifFalse:[dirName asFilename construct:fileName]).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1354
	].
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1355
    ].
5781
fc35ed4fd223 changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  1356
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1357
    inStream isNil ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1358
	"
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1359
	 an empty pack
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1360
	"
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1361
	^ self nonexistingFileRead
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1362
    ].
2996
59278dabe9a6 catch errors when reading #if
Stefan Vogel <sv@exept.de>
parents: 2971
diff changeset
  1363
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1364
    triedFilename := inStream pathName.
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1365
    [
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1366
	ok := self readFromResourceStream:inStream in:(triedFilename asFilename directoryName).
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1367
    ] ensure:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1368
	inStream close.
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1369
    ].
686
152d8437af35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 685
diff changeset
  1370
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1371
    ok ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1372
	packsFileName := triedFilename
5951
61a41352ce81 remember the actual filename from which a pack was read
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  1373
    ] ifFalse:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1374
	fileReadFailed := true.
684
4c7efce60043 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
  1375
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1376
	('ResourcePack [warning]: "' , triedFilename , '" contains error(s) - data may be incomplete.') errorPrintCR.
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1377
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1378
5781
fc35ed4fd223 changed: #readFromFile:directory:
Claus Gittinger <cg@exept.de>
parents: 5653
diff changeset
  1379
    "Modified: / 20-08-2011 / 17:10:02 / cg"
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1380
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1381
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
  1382
readFromResourceStream:inStream in:dirName
4848
18a6274df5d1 changed #localAt:
Stefan Vogel <sv@exept.de>
parents: 4844
diff changeset
  1383
    "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
  1384
     specify where #include files are searched for.
0f942dafc85a gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
  1385
     Return true, if the style sheet could be read without errors, false otherwise."
145
claus
parents: 144
diff changeset
  1386
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1387
    |lineString l lineNumber rest value ifLevel skipping first ok encoding decoder pack errorHandler
4947
9ed5d3a0cebf nested if/else handling
Claus Gittinger <cg@exept.de>
parents: 4932
diff changeset
  1388
     printError fileName pushedSkipValues|
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1389
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1390
    fileName := (inStream isFileStream
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1391
		    ifTrue:[inStream pathName asFilename baseName]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1392
		    ifFalse:['---']).
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1393
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1394
    printError := [:message |
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1395
		    'ResourcePack [warning]: ' errorPrint.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1396
		    message errorPrint.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1397
		    ' in file:' errorPrint.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1398
		    fileName errorPrint.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1399
		    ' line: ' errorPrint.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1400
		    lineNumber errorPrintCR
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1401
		  ].
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1402
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1403
    printError := [:message | ].
462
423f8426fefc added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
  1404
423f8426fefc added #encoding directive (I am lazy)
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
  1405
    encoding := nil.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1406
210
0f942dafc85a gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
  1407
    ok := true.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1408
    ifLevel := 0.
48194c26a46c Initial revision
claus
parents:
diff changeset
  1409
    skipping := false.
4058
d57a236e56f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4037
diff changeset
  1410
    lineNumber := 0.
4947
9ed5d3a0cebf nested if/else handling
Claus Gittinger <cg@exept.de>
parents: 4932
diff changeset
  1411
    pushedSkipValues := OrderedCollection new.
3567
f85c170f14e8 allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  1412
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1413
    errorHandler := [:ex |
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1414
			|con|
4947
9ed5d3a0cebf nested if/else handling
Claus Gittinger <cg@exept.de>
parents: 4932
diff changeset
  1415
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1416
			Transcript showCR:('ResourcePack [warning]: ''' , ex description , '''') "errorPrintCR".
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1417
			Transcript showCR:('ResourcePack [info]: file: ' , inStream pathName printString , ' line: ' , lineNumber printString , ': ''' , lineString , '''') "errorPrintCR".
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1418
			con := ex suspendedContext.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1419
			Transcript showCR:('ResourcePack [info]: in: ' , con fullPrintString) "errorPrintCR".
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1420
			con := con sender.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1421
			Transcript showCR:('ResourcePack [info]:   : ' , con fullPrintString) "errorPrintCR".
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1422
			con := con sender.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1423
			Transcript showCR:('ResourcePack [info]:   : ' , con fullPrintString) "errorPrintCR".
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1424
			value := nil.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1425
			ok := false.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1426
		    ].
3567
f85c170f14e8 allow expression evaluation in styleSheet
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  1427
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1428
    [inStream atEnd] whileFalse:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1429
	lineString := inStream nextLine. lineNumber := lineNumber + 1.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1430
	[lineString notNil and:[lineString endsWith:$\]] whileTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1431
	    lineString := lineString copyButLast:1.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1432
	    l := inStream nextLine. lineNumber := lineNumber + 1.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1433
	    l notNil ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1434
		lineString := lineString , l.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1435
	    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1436
	].
177
claus
parents: 158
diff changeset
  1437
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1438
	(lineString size > 0) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1439
	    first := lineString at:1.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1440
	    "/
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1441
	    "/ for your convenience: treat both ';' AND '"/' as comment-line
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1442
	    "/
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1443
	    ((first == $;) or:[lineString startsWith:'"/']) ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1444
		((first == $#) and:[(lineString startsWith:'#(') not]) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1445
		    "/ a directive
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1446
		    lineString := (lineString copyFrom:2) withoutSpaces.
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
  1447
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1448
		    (lineString startsWith:'if') ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1449
			pushedSkipValues add:skipping.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1450
			skipping ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1451
			    rest := lineString copyFrom:3.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1452
			    Error, UserInformation
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1453
				handle:errorHandler
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1454
				do:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1455
				    value := Compiler evaluate:rest compile:false.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1456
				].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1457
			    (value == #Error) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1458
				printError value:('error in resource:' , lineString).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1459
			    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1460
			    (value == false) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1461
				skipping := true
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1462
			    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1463
			].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1464
			ifLevel := ifLevel + 1
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1465
		    ] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1466
			(lineString startsWith:'endif') ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1467
			    ifLevel == 0 ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1468
				printError value:('if/endif nesting error').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1469
			    ] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1470
				ifLevel := ifLevel - 1.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1471
				skipping := pushedSkipValues removeLast.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1472
			    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1473
			] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1474
			    (lineString startsWith:'else') ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1475
				(pushedSkipValues includes:true) ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1476
				    skipping := skipping not
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1477
				]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1478
			    ] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1479
				skipping ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1480
				    (lineString startsWith:'superpack') ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1481
					rest := lineString copyFrom:('superpack' size + 1).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1482
					value := Compiler evaluate:rest compile:false.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1483
					(value isKindOf:ResourcePack) ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1484
					    superPack := value
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1485
					]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1486
				    ] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1487
					(lineString startsWith:'include') ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1488
					    (lineString startsWith:'includeResourcesFor') ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1489
						"/ include those resources ...
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1490
						rest := lineString copyFrom:('includeResourcesFor' size + 1).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1491
						value := Compiler evaluate:rest compile:false.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1492
						value isBehavior ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1493
						    pack := self class for:value.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1494
						    pack notNil ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1495
							self addAll:pack.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1496
						    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1497
						]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1498
					    ] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1499
						rest := lineString copyFrom:('include' size + 1).
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1500
						value := Compiler evaluate:rest compile:false.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1501
						value isString ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1502
						    printError value:('bad include filename: ' , value printString, ' "',lineString,'"').
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1503
						] ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1504
						    self readFromFile:value directory:dirName
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1505
						]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1506
					    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1507
					] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1508
					    (lineString startsWith:'encoding') ifTrue:[
4848
18a6274df5d1 changed #localAt:
Stefan Vogel <sv@exept.de>
parents: 4844
diff changeset
  1509
"/decoder notNil ifTrue:[self halt:'oops - encoding change in file'].
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1510
						encoding := self class extractEncodingFromLine:lineString.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1511
						decoder := CharacterEncoder encoderFor:encoding ifAbsent:nil.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1512
					    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1513
					]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1514
				    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1515
				]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1516
			    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1517
			]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1518
		    ].
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1519
		] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1520
		    skipping ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1521
			Error, UserInformation
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1522
			    handle:errorHandler
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1523
			    do:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1524
				(lineString at:1) == $!! ifTrue:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1525
				    "/ evaluate the rest
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1526
				    Compiler evaluate:(lineString copyFrom:2)
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1527
						      receiver:self
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1528
						      notifying:nil
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1529
						      compile:false.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1530
				] ifFalse:[
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1531
				    "/ process as resource
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1532
				    self
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1533
					processLine:lineString
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1534
					encoding:decoder
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1535
					file:(inStream isFileStream
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1536
						ifTrue:[inStream pathName]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1537
						ifFalse:['---'])
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1538
					printErrorWith:printError
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1539
				]]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1540
		    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1541
		]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1542
	    ]
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1543
	]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1544
    ].
210
0f942dafc85a gracefully handle errors when reading resource files
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
  1545
    ^ ok
177
claus
parents: 158
diff changeset
  1546
4534
d71ca6ac7cbe handle unicode string-keys and values
Claus Gittinger <cg@exept.de>
parents: 4531
diff changeset
  1547
    "Modified: / 31-08-1995 / 02:33:45 / claus"
4619
f4fb56981bad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4618
diff changeset
  1548
    "Modified: / 18-09-2006 / 20:35:37 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1549
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
  1550
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1551
!ResourcePack methodsFor:'printing & storing'!
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1552
5603
0945abfddb9a Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 5593
diff changeset
  1553
displayOn:aGCOrStream
0945abfddb9a Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 5593
diff changeset
  1554
0945abfddb9a Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 5593
diff changeset
  1555
    "/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
0945abfddb9a Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 5593
diff changeset
  1556
    "/ ST/X (and some old ST80's) mean: draw-yourself on a GC.
6545
6092db44bf06 displayOn: cleanup
Claus Gittinger <cg@exept.de>
parents: 6250
diff changeset
  1557
    (aGCOrStream isStream) ifTrue:[
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1558
	aGCOrStream nextPutAll:'ResourcePack for: '.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1559
	packsClassName printOn:aGCOrStream.
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1560
	^ self.
5603
0945abfddb9a Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 5593
diff changeset
  1561
    ].
0945abfddb9a Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 5593
diff changeset
  1562
0945abfddb9a Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 5593
diff changeset
  1563
    ^ super displayOn:aGCOrStream
4093
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1564
! !
24b16c9d3d82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1565
1173
86a212598655 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
  1566
!ResourcePack class methodsFor:'documentation'!
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
  1567
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
  1568
version
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1569
    ^ '$Header$'
5357
8057d6e1da5f changed:
Claus Gittinger <cg@exept.de>
parents: 5189
diff changeset
  1570
!
8057d6e1da5f changed:
Claus Gittinger <cg@exept.de>
parents: 5189
diff changeset
  1571
8057d6e1da5f changed:
Claus Gittinger <cg@exept.de>
parents: 5189
diff changeset
  1572
version_CVS
6887
b10262d21ed1 linked index chain in WeakArray
Claus Gittinger <cg@exept.de>
parents: 6799
diff changeset
  1573
    ^ '$Header$'
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
  1574
! !
3769
4b0f188d7f5c ifNotNil eliminated
Claus Gittinger <cg@exept.de>
parents: 3762
diff changeset
  1575
6051
f01078ce8c2c Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 5951
diff changeset
  1576
0
48194c26a46c Initial revision
claus
parents:
diff changeset
  1577
ResourcePack initialize!